09-30-2008 1:28 PM
Hi SDN,
While writing a user exit you generally inherit a structure/internal table. Suppose I have one such structure/internal table (called data package in BI) and a couple of its fields need to be populated with corresponding fields from a table.
What would be the shortest or the most direct form of the SELECT or LOOP to extract from the table and populate those fields into the internal table?
Thanks.
SM
09-30-2008 2:40 PM
Hi,
It really depends on the nature of your table and internal table. The following generic pseudo code will assume that there is some sort of primary key or secondary index field(s) to link the table and internal table.
* Select the data from the table
SELECT field1 field2 FROM dbtab INTO TABLE itab2
WHERE {enter your where condition here}...
IF SY-SUBRC = 0.
* Use loop with assign to get the additional values into itab1
LOOP AT itab1 ASSIGNING <fs_itab1>.
* Read the second itab to get the values previously selected from dbtab into the <fs_itab1> fields
READ TABLE itab2...
ENDOOP.
ELSE.
* {message or other error handling here}
ENDIF.
Regards,
Jamie
09-30-2008 2:40 PM
Hi,
It really depends on the nature of your table and internal table. The following generic pseudo code will assume that there is some sort of primary key or secondary index field(s) to link the table and internal table.
* Select the data from the table
SELECT field1 field2 FROM dbtab INTO TABLE itab2
WHERE {enter your where condition here}...
IF SY-SUBRC = 0.
* Use loop with assign to get the additional values into itab1
LOOP AT itab1 ASSIGNING <fs_itab1>.
* Read the second itab to get the values previously selected from dbtab into the <fs_itab1> fields
READ TABLE itab2...
ENDOOP.
ELSE.
* {message or other error handling here}
ENDIF.
Regards,
Jamie