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

Transferring data from one internal table to another

Former Member
0 Likes
685

Hi,

I have two internal tables it_acct and it_acct1 as below.

data: begin of it_acct occurs 0,

belnr like bkpf-belnr,

bldat like bkpf-bldat,

augcp like bseg-augcp,

vbeln like bseg-vbeln,

end of it_acct.

data: begin of it_acct1 occurs 0,

belnr like bkpf-belnr,

cpudt like bsad-cpudt,

vbeln like bseg-vbeln,

end of it_acct1.

select belnr cpudt vbeln into corresponding fields of table it_acct1

from bsad where cpudt in s_cpudt.

Now I want to move the data from it_acct1 to it_acct . I have no data in it_acct now.

i want to move it_acct1-belnr to it_acct-belnr,

move it_acct1-cpudt to it_acct-augcp,

move it_acct1-vbeln to it_acct-vbeln.

Can someone help me how to code to move the data from it_acct1 to it_acct.

Regards,

D

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
650

Hi,

Try this..

LOOP AT IT_ACCT1.

IT_ACCT-BELNR = IT_ACCT1-BELNR.

IT_ACCT-VBELN = IT_ACCT1-VBELN.

it_acct-augcp = it_acct1-cpudt.

APPEND IT_ACCT.

ENDLOOP.

Thanks,

Naren

Hi,

I have two internal tables it_acct and it_acct1 as below.

data: begin of it_acct occurs 0,

belnr like bkpf-belnr,

bldat like bkpf-bldat,

augcp like bseg-augcp,

vbeln like bseg-vbeln,

end of it_acct.

data: begin of it_acct1 occurs 0,

belnr like bkpf-belnr,

cpudt like bsad-cpudt,

vbeln like bseg-vbeln,

end of it_acct1.

select belnr cpudt vbeln into corresponding fields of table it_acct1

from bsad where cpudt in s_cpudt.

Now I want to move the data from it_acct1 to it_acct . I have no data in it_acct now.

i want to move it_acct1-belnr to it_acct-belnr,

move it_acct1-cpudt to it_acct-augcp,

move it_acct1-vbeln to it_acct-vbeln.

Can someone help me how to code to move the data from it_acct1 to it_acct.

Regards,

D

5 REPLIES 5
Read only

Former Member
0 Likes
651

Hi,

Try this..

LOOP AT IT_ACCT1.

IT_ACCT-BELNR = IT_ACCT1-BELNR.

IT_ACCT-VBELN = IT_ACCT1-VBELN.

it_acct-augcp = it_acct1-cpudt.

APPEND IT_ACCT.

ENDLOOP.

Thanks,

Naren

Read only

Former Member
0 Likes
650

Hi Dev Reddy,

Try with this code.

LOOP AT IT_ACCT1.

move it_acct1-belnr to it_acct-belnr.

move it_acct1-cpudt to it_acct-augcp.

move it_acct1-vbeln to it_acct-vbeln.

APPEND IT_ACCT.

ENDLOOP.

Thanks,

Vinay

Read only

0 Likes
650

Hi ,

Thanks Naren...it solved my problem!

Vinay, I already tried that and it didnt work.

it asks for index.

however thanks for replying.

Regards,

D

Read only

0 Likes
650

Hi Dev,

Just add an additional line in Naren's code to get proper results at any time.

LOOP AT IT_ACCT1.

IT_ACCT-BELNR = IT_ACCT1-BELNR.

IT_ACCT-VBELN = IT_ACCT1-VBELN.

it_acct-augcp = it_acct1-cpudt.

APPEND IT_ACCT.

<b>CLEAR IT_ACCT.</b>

ENDLOOP.

If you didnt include CLEAR statement, even if IT_ACCT1 doesnt have any values for all fields or few fields in the next record, it will take values of previous one and it may lead to improper results.So it is a good practise to have CLEAR statement after APPEND statement in LOOP...ENDLOOP.

Thanks,

Vinay

Read only

Former Member
0 Likes
650

TRY THIS:

LOOP AT IT_ACCT1.

IT_ACCT-BELNR = IT_ACCT1-BELNR.

IT_ACCT-AUGCP = IT_ACCT1-CPUDT.

IT_ACCT-VBELN = IT_ACCT1-VBELN.

APPEND IT_ACCT1.

ENDLOOP.

bUT HERE THE SIZE AND TYPE OF THE VARIABLES AUGCP AND CPUDT SHULD BE SAME. OTHERWISE WONT ACCEPT.

THANX.