This topic is not related to a brand new technology, but provides a convenient, safe and transparent way to fill in BAPI extension structures. BAPIs are the functional APIs of SAP exposed to the outside world via RFC protocol. They are technically function modules marked as available remotely.
Extension structures are provided by SAP to be able to access customer fields via the BAPI added to SAP DDIC structures / tables previously.
CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE' EXPORTING notif_type = lv_notif_type notifheader = ls_notifheader IMPORTING notifheader_export = es_notifheader_e TABLES notitem = lt_notitem notifpartnr = lt_notifpartnr longtexts = lt_longtexts return = lt_return extensionin = lt_extensionin extensionout = lt_extensionout.
These extension structures are however “not typed“. Not typed means that
extensionin/extensionout are table types based on row types which is a long character sequence separated in 4 fields.
The customer fields from the customer include
BAPI_TE_QMEL can be filled into the
BAPIPAREX structure. Due external communication via RFC, only character type fields can be appended and moved in/out. Conversion from other data types like integer, decimal etc. are your task in advance.
To do the move properly, a utility method
cl_abap_container_utilities=>fill_container_c is available in ABAP.
DATA: ls_header_ext TYPE bapi_te_qmel, lv_container TYPE c length 960, ls_extension TYPE bapiparex. "Fill in fields into the customer include structure ls_header_ext here "Move typed structure to the BAPI extension structure cl_abap_container_utilities=>fill_container_c( EXPORTING im_value = ls_header_ext IMPORTING ex_container = lv_container ). ls_extension-structure = 'BAPI_TE_QMEL'. ls_extension+30 = lv_container. APPEND ls_extension TO rt_extension."of type TT_BAPIPAREX
What You see on the above snippet is that we use a helper variable of length 4×240 = 960 for the valueparts, which is filled in by the container utility from our typed DDIC structure. So far so good, we did a safe and easy operation using the utility class. What does then ls_extension+30 do ? Since the first field in BAPIPAREX structure is the field holding the type of the original content, it will occupy the first 30 characters. So we can start at character number 31 only. The + 30 is shifting the start position on the target of the move statement. You can do this with any character typed variables in ABAP.
The extraction is the reverse direction using
cl_abap_container_utilities=>read_container_c. Good luck programmer 🙂
Share this content: