How to use extension in and extension out structures in BAPI
SAP uses the BAPIPAREX structure in BAPIs to handle customer fields. BAPIPAREX contains name and value pair. For compatibility reason, value is a combination of 4 value fields each of length 240 characters.
structure contain name of type. This does impose a limit on how many custom fields you can have. Length of all custom fields should be less than 960 characters.
L_EXTENSION_IN is too short for WA_EXT
BAPI table extension cannot be processed for structure &1
values are put into 4 value fields
Encoding – From structured data to EXTENSIONIN
types: begin of value_parts,
valuepart1 type valuepart,
valuepart2 type valuepart,
valuepart3 type valuepart,
valuepart4 type valuepart,
end of value_parts .
data structured_data type bapi_te_qmfe .
data str_container type string .
data value_part type value_parts .
data extension_in type bapiparex .
"fill in structure data
structured_data-notif_no = '2000202' .
cl_abap_container_utilities=>fill_container_c(
exporting
im_value = structured_data
importing
ex_container = str_container
exceptions
illegal_parameter_type = 1
others = 1 ).
value_part = str_container .
extension_in-structure = 'BAPI_TE_QMFE' .
move-corresponding value_part to extension_in .
Decoding – EXTENSIONOUT to structured data
types: begin of value_parts,
valuepart1 type valuepart,
valuepart2 type valuepart,
valuepart3 type valuepart,
valuepart4 type valuepart,
end of value_parts .
data structured_data type bapi_te_qmfe .
data str_container type string .
data value_part type value_parts .
data extension_out type bapiparex .
move-corresponding extension_out to value_part .
str_container = value_part.
move-corresponding extension_out to value_part .
str_container = value_part.
cl_abap_container_utilities=>read_container_c(
exporting
im_container = str_container
importing
ex_value = structured_data
exceptions
illegal_parameter_type = 1
others = 2 ) .
Depending on the scenario you may have to implement additional BADIs to save these custom fields in the respective database tables and return values back in EXTENSIONOUT structures.