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

Duplicate record with Do n time

Former Member
0 Likes
309

Hi good morning to everybody

I'm not able to duplicate record according to anzpk.

Thanks a lot for your support

This is itab

vbeln | anzpk | anzpk_tmp

800001 0001

800002 0003

800003 0002

800004 0001

This is as it sould be

vbeln | anzpk | anzpk_tmp

800001 0001 0001

800002 0003 0001

800002 0003 0002

800002 0003 0003

800003 0002 0001

800003 0002 0002

800004 0001 0001

I tried with this cod

SORT lt_likp BY vbeln.

*

LOOP AT lt_likp WHERE anzpk GT 1.

DO lt_likp-anzpk TIMES.

lt_likp-anzpk_tmp = lt_likp-anzpk_tmp + 1.

ON CHANGE OF lt_likp-vbeln.

APPEND lt_likp.

lt_likp-anzpk_tmp = 1.

EXIT.

*

ENDON.

ENDDO.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
284

Hi

Loop at itab.

itab1-vbeln = itab-vbeln.

itab1-anzpk = itab-anzpk.

clear gv_ind.

Do itab1-anzpk times.

if gv_ind is initial.

itab1-anzpk_tmp = '0001'.

append itab1.

gv_ind = 'X'.

else.

itab1-anzpk_tmp = itab1-anzpk_tmp + 0001.

append itab1.

endif.

ENDdo.

clear: itab1,itab.

ENDIF.

Use the above logic in itab1 u will get the duplicate records as u required.

Regard,

Raghu.

1 REPLY 1
Read only

Former Member
0 Likes
285

Hi

Loop at itab.

itab1-vbeln = itab-vbeln.

itab1-anzpk = itab-anzpk.

clear gv_ind.

Do itab1-anzpk times.

if gv_ind is initial.

itab1-anzpk_tmp = '0001'.

append itab1.

gv_ind = 'X'.

else.

itab1-anzpk_tmp = itab1-anzpk_tmp + 0001.

append itab1.

endif.

ENDdo.

clear: itab1,itab.

ENDIF.

Use the above logic in itab1 u will get the duplicate records as u required.

Regard,

Raghu.