Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Every time you use a BAPI to create a SAP Object there are several structures and tables that need to be filled in with the data requiered to complete the document. Most of the times these structures are acompanied by other structures that contains the flags that tells the BAPI what fields are going to be used or updated. Those structures are always identified by an 'X' at the end of the name.

How many times have you spent time and time wondering why a BAPI is not working just to realised that you forgot to fill the corresponding field in the 'X' structure? I can tell you that i have spent quite a lot.

For that reason i have developed a method that makes that work for you. You fill a new field in the data structure and this method automatically put the 'X' in the corresponding strucutre.

All you need is to create a method in your tools class with the following importing parameters

Importing Parameters

where "DATA_STRUCT" is the structure with the data used in the BAPI and "FLAG_STRUCTURE_NAME" is the name of the 'X' structure that acompanies the data structure in the BAPI.

Of course the result of this method will be an exporting structure with the following characteristics

Exporting Parameters


The code of the method is as follows
cl_reca_ddic_tabl=>get_field_list( EXPORTING id_name = flag_struct_name
IMPORTING et_field_list = DATA(table_data) ).

IF sy-subrc = 0.

LOOP AT table_data ASSIGNING FIELD-SYMBOL(<fs_field>).

ASSIGN COMPONENT <fs_field>-fieldname OF STRUCTURE data_struct TO FIELD-SYMBOL(<fs_data>).
IF sy-subrc <> 0.
ASSIGN COMPONENT <fs_field>-fieldname OF STRUCTURE filled_flag_struct TO FIELD-SYMBOL(<fs_datax>).

IF <fs_data> IS NOT INITIAL.
CASE <fs_field>-rollname.
<fs_datax> = abap_true.
<fs_datax> = <fs_data>.



There are some fields that are not flags inside the 'X' structure so in that case the value of the data structure is replicated in the 'X' structure.

With this method you do not have to worry anymore about forgetting to fill the 'X' structure correctly.

1 Comment
Labels in this area