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 populate internal table................

Former Member
0 Kudos
98

hii all,

my code is according this..................

the three KEY field which is commom in IT_CDPOS & IT_CDHDR are

1. objectclass = 'VBERCGH'

2. tabname = 'VBAP'

3.changind = 'U'.

loop at it_cdpos into wa_cdpos.

z_var = wa_cdpos-tabkey.

wa_cdhdr-vbeln = z_var+3(10).

wa_cdhdr-posnr = z_var+13(6).

modify it_cdhdr from wa_cdhdr transporting vbeln posnr.

endloop.

now the problem is that when i execute the code DUMP is come due to modify statement.

apart from that if i use in place of MODIFY......

APPEND.

Data will move but not in proper position.like it appends from the last position.

As IT_CDHDR has data before this code.

so according the data that IT_CDHDR contain i want to move vbeln and posnr value in IT_CDHDR at correct position.

Please provide me the suitable code for that......

thanks

Babbal.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
70

Hi there,

Try using

modify it_cdhdr from wa_cdhdr index sy-tabix transporting vbeln posnr.

Hope that will not give you short dump and update the appropriate records.

Let me know if you need further help.

Thanks-

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos
70

Add a READ TABLE before moving the data,

- READ TABLE it_cdhdr into wa_cdhdr WITH KEY objectclass = wa_cdpos-objectclass tabname = wa_cdpos-tabname changind = wa_cdpos-changind.

- saved_tabix = SY-TABIX. " store the SY-TABIX

- move fields (wa_cdhdr-vbeln = z_var+3(10). etc.)

- MODIFY it_cdhdr FROM wa_cdhdr INDEX saved_tabix ....

An internal table is not updated like a table via SQL

Regards

Former Member
0 Kudos
71

Hi there,

Try using

modify it_cdhdr from wa_cdhdr index sy-tabix transporting vbeln posnr.

Hope that will not give you short dump and update the appropriate records.

Let me know if you need further help.

Thanks-

Former Member
0 Kudos
70

Assuming that you have declared it_cdhdr with the correct data type, I would first read the table it_cdhdr and modify the read line after checking the sy-subrc.

Former Member
0 Kudos
70

Hi,

data l_idx type sy-tabix.
loop at it_cdpos into wa_cdpos.
*Read table it_cdhdr into wa_cdhdr with key objectclass = wa_cdpos-objectclass*
                                                              * tabname = wa_cdpos-tabname*
                                                               *changind = wa_cdpos-changind*
if sy-subrc = 0.
*l_idx = sy-tabix.*
z_var = wa_cdpos-tabkey.
wa_cdhdr-vbeln = z_var+3(10).
wa_cdhdr-posnr = z_var+13(6).
modify it_cdhdr from wa_cdhdr transporting vbeln posnr *index l_idx.*
clear l_idx.
endif.
endloop.

Edited by: Kamesh Bathla on Aug 14, 2008 4:24 PM