‎2011 Jul 06 11:52 AM
Hi Experts,
I have the following requirement.
Based on a country code say "A" , "B", "C" and based on this i have to read different internal tables lt_tabA, lt_tabB and lt_tabC.
The table key can be given dynamically, but how can i use the internal table name dynamically without using if statements.
Please help.
Thanks!
Best Regards,
Gayathri
‎2011 Jul 06 11:53 AM
‎2011 Jul 06 11:53 AM
‎2011 Jul 06 11:54 AM
Hi,
if you have just 3 internal tables, what is teh issue in using if/case statements?
‎2011 Jul 06 11:58 AM
There is no issue. It is just that a similar piece of code has to repeated and i want the code to be better.
‎2011 Jul 06 11:59 AM
‎2011 Jul 07 4:29 AM
‎2011 Jul 06 1:21 PM
Hello,
it is possible with a little dynamic programming. Here is how:
FIELD-SYBMOLS:
<lv_tab> TYPE STANDARD TABLE.
DATA:
lt_tab1 TYPE TABLE OF....
lt_tab2 TYPE TABLE OF...
ASSIGN lt_tab1 TO <lv_tab>.
READ TABLE <lv_tab> " read from the first table
...
ASSIGN lt_tab2 TO <lv_tab>.
READ TABLE <lv_tab> " read from the second table
...
‎2011 Jul 06 1:37 PM
Hi,
you can use the concept of field symbols .
ASSIGN COMPONENT lv_data OF STRUCTURE <dyn_wa> TO <fs1>.
<fs1> = p_wa_out-comp_code.
some thing like this.
‎2011 Jul 06 5:17 PM
Hi Gayathri,
something like
DATA:
lt_t100 TYPE TABLE OF t100,
lt_t000 TYPE TABLE OF t000.
FIELD-SYMBOLS:
<table> TYPE table,
<rec> TYPE ANY,
<field> TYPE ANY.
SELECT:
* INTO CORRESPONDING FIELDS OF TABLE lt_t100 FROM t100 UP TO 10 ROWS,
* INTO CORRESPONDING FIELDS OF TABLE lt_t000 FROM t000 UP TO 10 ROWS.
CASE abap_true.
WHEN space.
ASSIGN lt_t100 TO <table>.
WHEN OTHERS.
ASSIGN lt_t000 TO <table>.
ENDCASE.
READ TABLE <table> with key ('MANDT') = sy-mandt ASSIGNING <rec>.Regards,
Clemens