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: 

How to work with deep structure

Former Member
0 Kudos

Hi !

I wanted to ask how to loop, modify, append tables located in deep structures. Deep structures i mean, structures consist of columns which are tables ( usualy exists in user-exit). Please give examples and reference help to this subject.

Thanks

Moshe

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos
report ztest.

data: begin of itab1 occurs 0,
      uname like sy-uname,
      end of itab1.

data: begin of itab occurs 0,
      matnr like mara-matnr,
      user  like itab1 occurs 0,
      end of itab.
data: wa_user like itab1.
select matnr
       from mara
       up to 10 rows
       into corresponding fields of itab
     .
   endselect.

   loop at itab-user into wa_user.
   wa_user-uname = 'Test'.
   modify itab-user from wa_user index sy-tabix.

   endloop.

thanks

vijay

3 REPLIES 3

FredericGirod
Active Contributor
0 Kudos

Hi Moshe,

if you structure looks like :

IS_TOTO

with an internat table TUTU

you could simple do :

loop at IS_TOTO-TUTU.

write : /1 IS_TOTO-TUTU-FIELD1.

endloop.

What is your problem with that ?

Rgd

Frédéric

Former Member
0 Kudos

Hi

TYPES: T_TYBSEG TYPE STANDARD TABLE OF BSEG.

DATA: BEGIN OF T_DOCUMENTS,

HEADER LIKE BKPF,

ITEMS TYPE T_TYBSEG,

END OF T_DOCUMENTS.

DATA: T_BSEG TYPE T_TYBSEG,

T_BKPF TYPE STANDARD TABLE OF BKPF WITH HEADER LINE.

  • Append data:

SELECT * FROM BKPF INTO TABLE T_BKPF WHERE ....

LOOP AT T_BKPF.

MOVE-CORRESPONDING T_BKPF TO T_DOCUMENTS-HEADER.

SELECT * FROM BSEG INTO TABLE T_BSEG where ....

Here it uses the table t_bseg to append the items to T_DCOUMENTS-ITEMS: it's very import to clear this table before appending records.

If you don't clear the internal table you'll append several times the same records.

REFRESH T_DOCUMENTS-ITEMS.

APPEND LINES OF T_BSEG TO T_DOCUMENTS-ITEMS.

APPEND T_DOCUMENTS.

ENDLOOP.

  • Read DATA:

LOOP AT T_DOCUMENTS.

LOOP AT T_DOCUMENTS-ITEMS INTO BSEG.

ENDLOOP.

ENDLOOP.

OR

READ TABLE T_DOCUMENTS (WITH KEY ...) (INDEX <INDEX>).

IF SY-SUBRC = 0.

LOOP AT T_DOCUMENTS-ITEMS INTO BSEG.

ENDLOOP.

ENDIF.

Modify

LOOP AT T_DOCUMENTS.

LOOP AT T_DOCUMENTS-ITEMS INTO BSEG.

IF BSEG-GJAHR = '2005'.

BSEG-GJAHR = '2006'.

ENDIF.

...........

MODIFY T_DOCUMETS-ITEMS FROM BSEG.

ENDLOOP.

ENDLOOP.

So if you use this type of structure the table haven't an headerline, so you always use a workarea to read an update the data.

Max

Message was edited by: max bianchi

former_member188685
Active Contributor
0 Kudos
report ztest.

data: begin of itab1 occurs 0,
      uname like sy-uname,
      end of itab1.

data: begin of itab occurs 0,
      matnr like mara-matnr,
      user  like itab1 occurs 0,
      end of itab.
data: wa_user like itab1.
select matnr
       from mara
       up to 10 rows
       into corresponding fields of itab
     .
   endselect.

   loop at itab-user into wa_user.
   wa_user-uname = 'Test'.
   modify itab-user from wa_user index sy-tabix.

   endloop.

thanks

vijay