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

splitting qty in internal table

paruchuri_nagesh
Active Contributor
0 Likes
1,020

my internal table out put is like this

crd date crd qty cpd date cpd qty

01/02/2008 1000 03/01/2008 500

15/02/2008 300 05/01/2008 500

17/01/2008 700 06/01/2008 600

06/01/2008 400

In this eg... whenever crd qty> cpd qty

1000 of crd qty is splitted into 500,500

and 600 of cpd qty is splitted into 300,300

and 700 of crd qty is splitted into 300,400(not 350,350).

The output should appear as follows:

CRD Date CRD Qty CPD Date CPD Qty

01/02/08 500 03/01/08 500

01/02/08 500 05/01/08 500

15/02/08 300 06/01/08 300

17/01/08 300 06/01/08 300

17/01/08 400 06/01/08 400

points will be reward

my internal table out put is like this

crd date crd qty cpd date cpd qty

01/02/2008 1000 03/01/2008 500

15/02/2008 300 05/01/2008 500

17/01/2008 700 06/01/2008 600

06/01/2008 400

In this eg... whenever crd qty> cpd qty

1000 of crd qty is splitted into 500,500

and 600 of cpd qty is splitted into 300,300

and 700 of crd qty is splitted into 300,400(not 350,350).

The output should appear as follows:

CRD Date CRD Qty CPD Date CPD Qty

01/02/08 500 03/01/08 500

01/02/08 500 05/01/08 500

15/02/08 300 06/01/08 300

17/01/08 300 06/01/08 300

17/01/08 400 06/01/08 400

points will be reward

6 REPLIES 6
Read only

Former Member
0 Likes
919

hi ,

Try following code.

loop at itab where crdqty > cpdqty.

itab-cpdqty = itab-crdqty / 2.

itab-crdqty = itab-cpdqty.

modify itab.

endloop.

use workarea if it is need.

L.Velu

Read only

0 Likes
919

hi

velu

here i have to split cpdqty only that too not in equal parts say

if cpdqty is 700 it should be divides into 300 & 400.

Regards

Nagesh.Paruchuri

Read only

Former Member
0 Likes
919

Hi,

i missed last condition.

loop at itab where crdqty > cpdqty.

wa_tmp1 = itab-crdqty / 2.

wa_tmp2 = wa_tmp1 mod 100.

if wa_tmp2 eq 0.

itab-cpdqty = itab-crdqty / 2.

itab-crdqty = itab-cpdqty.

else.

itab-cpdqty = wa_tmp1 + wa_tmp2.

itab-crdqty = itab-crdqty - itab-cpdqty.

endif.

modify itab.

endloop.

reward me if useful.

L.Velu

Read only

Former Member
0 Likes
919

Try Modulus Operation on the Quantity with 100.

If there is remainder apply ROUND Operation.

Then Subtract from Original Qty.

awrd points if useful

Bhupal

Read only

Former Member
0 Likes
919

Hi,

Your explanation differs from the result.

your output shows that , divide CRD_QTY and assigning the same value to CPD_QTY.

Check the below:

Input recs:

15/02/2008 300 05/01/2008 500

17/01/2008 700 06/01/2008 600

Output recs for the above:

15/02/08 300 06/01/08 300 (even crdqty < cpdqty in input, result has been changed)

17/01/08 300 06/01/08 300

17/01/08 400 06/01/08 400 (cpdqty is same as crdqty)

What is the logic of dividing 700 into 300 & 400?

Read only

Former Member
0 Likes
919

Hi,

Loop at itab in to wa_itab.

if wa_itab-crd_qty > wa_itab-cpd_qty.

wa_itab-crd_qty = wa_itab-crd_qty / 2.

l_diff = wa_itab-crd_qty MOD 100.

if l_diff <> 0.

l_crd_qty1 = wa_itab-crd_qty + 100 - l_diff.

l_crd_qty2 = wa_itab-crd_qty - l_diff.

else.

l_crd_qty1 = l_crd_qty2 = wa_itab-crd_qty.

endif.

wa_itab-crd_qty = l_crd_qty1.

append wa_itab to itab1.

wa_itab-crd_qty = l_crd_qty2.

append wa_itab to itab1.

else.

append wa_itab to itab1.

endif.

endloop.

Check if it can help you,

Thanks

ANUPAM