Application Development and Automation 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: 
Read only

Populating an internal table.

Former Member
0 Likes
340

I know the conditions for this select are acceptable because when I select archiveykey and archiveofs into plain variable varKEY and varOFS, they get values. [the problem with this is that when there are more than one key and offset for the condition, varKEY and varOFS only retrieve the last record's info.]

For some reason, I cannot populate this internal table even though it's fields correspond directly to the fields from which I am trying to copy data.

DATA: BEGIN OF ITAB2 OCCURS 0,
      KEY LIKE ZARIXFI3-ARCHIVEKEY,
      OFS LIKE ZARIXFI3-ARCHIVEOFS.
DATA: END OF ITAB2.
*
*
*
SELECT: archivekey archiveofs INTO CORRESPONDING FIELDS OF TABLE ITAB2
            FROM (tablename)
            WHERE (lt_cond).

Any suggestions?

N L

2 REPLIES 2
Read only

Former Member
0 Likes
290

Natasha,

For the command INTO CORRESPONDING FIELDS OF TABLE ITAB2 to work the fields in teh ITAB2 have to be declared with the same name and datatype as the one you are selecting So your ITAB2 should be declared as

DATA: BEGIN OF ITAB2 OCCURS 0,      
      ARCHIVEKEY LIKE ZARIXFI3-ARCHIVEKEY,      
      ARCHIVEOFS LIKE ZARIXFI3-ARCHIVEOFS,
      END OF ITAB2.

or if that is not possible you can modify your select to read

SELECT ARCHIVEKEY ARCHIVEOFS INTO (ITAB2-key, itab2-ofs)
       FROM (tablename)
       WHERE (lt_cond).
  if sy-subrc = 0 .
    append itab2 .
  endif.
ENDSELECT .

Either should work and populate the internal table.

Thanks,

Anu

Read only

Former Member
0 Likes
290

When using cooresponding fields, the internal table fields names should be the same as the table itself. Your data statement should be like this.

DATA: BEGIN OF ITAB2 OCCURS 0,

ARCHIVEKEY LIKE ZARIXFI3-ARCHIVEKEY,

ARCHIVEOFS LIKE ZARIXFI3-ARCHIVEOFS.

DATA: END OF ITAB2.

*