Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Populating partially filled internal table

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

Tags:
replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question