Calling transactions from WebDynpro applications via Launchpad configuration is a simple task once you know how it works. The key elements to this are:
- LPD_CUST Configuration
- Analyzing the Receiver Transaction
- Preparing Business Parameters for Receiver Transaction
- Triggering LPD_CUST Navigation from WebDynpro
LPD_CUST Configuration
- Go to transaction LPD_CUST, create a new launchpad (skip next step if you already have a launchpad to edit)
- Enter a Role, Instance, Description and use ‘Z’ or ‘Y’ as Namespace
- Once you are inside the launchpad, create a new application
- Enter Link Text, Transaction Code, System Alias and Application Type as ‘TRA’ or Transaction (see Figure 1)
- You can leave the rest of the fields with their default values
- You can change the Entries Once Started field to Skip Initial Screen if Possible if your program sets the values on initial screen
Tip: Fill Application Alias with a unique value withing the launchpad to identify it within your program.
Analyzing Receiver Transaction
All types of transaction except OO transaction work well with LPD_CUST. If you have an OO transaction you will not be able to set parameters on the initial screen which makes it impossible to use Skip Initial Screen if Possible option. However, you will still be able to navigate to the transaction itself even for OO transaction.
Sample Receiver Transaction
REPORT ycodex_tra_demo.
TABLES vicncn.
SELECT-OPTIONS: s_bukrs FOR vicncn-bukrs,
s_recnnr FOR vicncn-recnnr.
START-OF-SELECTION.
WRITE: s_bukrs, s_recnnr.
Preparing Business Parameters
The proper way to pass business parameters to a transaction might sound a bit unconventional to most ABAPers. The secret is to use the Data Element name as Key instead of the screen field name (see Figure 3 & Figure 4). The reason behind this is, the launchpad program gets the report screen fields and match field with data elements rather than field names.
Tip: In case of SELECT-OPTIONS field you can pass multiple entries with the same key and different values and the program automatically assigns all the values to the same selection field.
Tip: You can use global sets by appending _SET to the key field in business parameters internal table.
Trigger Receiver Transaction
- Get reference of WebDynpro Component API
- Get reference of POWL Runtime Services
- Use the above two references get a reference to LPD_CUST for the Role & Instance you’ve created at the beginning
- GET_CONTENT method returns all the applications under the launchpad and APPLICATION_ALIAS field can be used to uniquely identify your application
- From the content structure you retrieve above, you may have some default entries in APPLICATION_PARAMETER and BUSINESS_PARAMETER based on your configuration
- Add your screen field key-value pair to BUSINESS_PARAMETER and launch the application using LAUNCH_APPLICATION method
DATA: lr_provider TYPE REF TO if_apb_lpd_provider,
lr_wd_component TYPE REF TO if_wd_component,
lv_role TYPE apb_lpd_role VALUE 'ZAM_DASH',
lv_instance TYPE apb_lpd_instance VALUE 'TASKS',
lr_launchpad TYPE REF TO cl_apb_launchpad_api,
lt_content TYPE apb_lpd_t_content,
ls_content TYPE apb_lpd_s_content.
lr_wd_component = wd_this->wd_get_api( ).
CREATE OBJECT lr_provider TYPE cl_powl_runtime_services.
cl_apb_launchpad_api=>read_for_display(
EXPORTING
id_role = lv_role
id_instance = lv_instance
ir_provider = lr_provider
ir_wd_component = lr_wd_component
RECEIVING
er_launchpad = lr_launchpad
EXCEPTIONS
parameter_missing = 1
not_found = 2
OTHERS = 3 ).
lt_content = lr_launchpad->get_content( ).
READ TABLE lt_content WITH KEY application_alias = 'CONTRACT_DEMO' INTO ls_content.
IF sy-subrc EQ 0.
APPEND VALUE #( key = 'BUKRS' value = '3000' ) TO ls_content-business_parameter.
APPEND VALUE #( key = 'RECNNUMBER' value = '1000892' ) TO ls_content-business_parameter.
lr_launchpad->launch_application( it_application_parameters = ls_content-application_parameter
it_business_parameters = ls_content-business_parameter ).
ENDIF.