Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Populating partially filled internal table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

1 REPLY 1

Former Member
0 Kudos

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