Reputation: 611
I want to create dynamically the ITAB's name e.g. itab_name = |it_itab{ time }|. where time is 1 or 2 or .... The itab will be type standard table of BAPIACGL09.
What I want to do is to run the BAPI 'BAPI_ACC_BILLING_POST' more than once and I want to fill the structures and tables more than once, namely I want to have GIT_ACCOUNTGL, GIT_ACCOUNTGL01, GIT_ACCOUNTGL02 etc and run the BAPI as many times as the times of the ITABs & Structures I have.
Can someone tell me how to do?
Thanks
Upvotes: 0
Views: 723
Reputation: 13628
It depends what you call "dynamic", but one possibility based on the proposal of Florian (using a table, a "table of complex structure" in my case) is this one:
TYPES : BEGIN OF ty_bapiarglist,
" arguments passed to the BAPI
accountgl TYPE STANDARD TABLE OF bapiacgl01 WITH EMPTY KEY,
" ...
" arguments returned by the BAPI
return TYPE STANDARD TABLE OF bapiret2 WITH EMPTY KEY,
" ...
END OF ty_bapiarglist.
DATA: bapiarglist TYPE ty_bapiarglist,
bapiarglists TYPE TABLE OF ty_bapiarglist.
"++++++++++++++
" Call BAPI
" Fill lists of arguments
"++++++++++++++
LOOP AT someitab...
" fill arguments to transmit
" bapiarglist-accountgl = ...
CALL FUNCTION 'BAPI_ACC_BILLING_POST'
...
TABLES
accountgl = bapiarglist-accountgl
return = bapiarglist-return
...
APPEND bapiarglist TO bapiarglists.
ENDLOOP.
"++++++++++++++
" Later usage
"++++++++++++++
LOOP AT bapiarglists INTO bapiarglist.
...
ENDLOOP.
Upvotes: 0
Reputation: 5051
Use a table of tables. Each line represents one of the itabs you describe. Address the tables by their index, not by some name.
TYPES table_type TYPE STANDARD TABLE OF bapiacgl09 WITH EMPTY KEY.
TYPES collection_type TYPE STANDARD TABLE OF table_type WITH EMPTY KEY.
DATA all_results TYPE collection_type.
" collect the results
DO 100 TIMES.
DATA(single_result) = " call bapi
INSERT single_result INTO TABLE all_results.
ENDDO.
" access a specific result by index
DATA(forty_second_result) = all_results[ 42 ].
" iterate all results
LOOP AT all_results INTO single_result.
ENDLOOP.
Upvotes: 4