02-02-2008 7:18 AM
Hi friends,
I want to make one report in that i want to take sum of actual product quantity,sum of sales order quantity and sum of target order quantity according to machinewise.
I hav one ZPPLAN table in that (act_prod,quaty,plan_qty) is table field related to above description.
In selection screen I take SHFTIN(shift incharge)as mendotry field so the data must be fielter as per shift incharge.
Target quantity calculate by using formula like
Taget qut. = ( plan_qty / 3 ).
so how can I take loop to sum of quantity for perticular one machine?
Plz gv me rep its urgent so.
Thnaks in advance.
Prashant.
02-02-2008 8:14 AM
I send one example for item wise total so using this example u can set your own report.
*************************************************************
REPORT ZTOTAL_ITEMWISE .
DATA: BEGIN OF line,
t1(4) TYPE c,
t2 TYPE i,
END OF line.
DATA : tot TYPE I,
GRTOT TYPE I.
*DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY t1.
DATA : ITAB LIKE TABLE OF LINE .
line-t1 = 'aaaa'.
line-t2 = 1.
INSERT line INTO TABLE itab.
line-t1 = 'aaaa'.
line-t2 = 1.
INSERT line INTO TABLE itab.
line-t1 = 'aaaa'.
line-t2 = 1.
INSERT line INTO TABLE itab.
line-t1 = 'bbbb'.
line-t2 = 2.
INSERT line INTO TABLE itab.
line-t1 = 'bbbb'.
line-t2 = 2.
INSERT line INTO TABLE itab.
line-t1 = 'bbbb'.
line-t2 = 2.
INSERT line INTO TABLE itab.
line-t1 = 'cccc'.
line-t2 = 3.
INSERT line INTO TABLE itab.
line-t1 = 'cccc'.
line-t2 = 3.
INSERT line INTO TABLE itab.
line-t1 = 'cccc'.
line-t2 = 3.
INSERT line INTO TABLE itab.
line-t1 = 'aaaa'.
line-t2 = 1.
INSERT line INTO TABLE itab.
SORT itab.
PERFORM loop_at_itab.
FORM loop_at_itab.
SORT itab by t1.
LOOP AT itab INTO line.
On change of line-t1.
if sy-tabix = 1.
else.
ULINE.
WRITE: /'Sum:', 10 tot.
GRTOT = GRTOT + TOT.
clear tot.
ULINE.
endif.
endon.
WRITE 😕 line-t1,line-t2.
tot = tot + line-t2.
ENDLOOP.
ULINE.
WRITE:/ 'Sum:', 10 tot.
ULINE.
ULINE.
GRTOT = GRTOT + TOT.
WRITE:/ 'GR.TOT:', 10 GRtot.
ULINE.
SKIP.
ENDFORM.
02-02-2008 8:31 AM
I think you internal table should have the field for machine,thentry the following code.
Sort itab by <Machine>.
loop at itab into wa.
at end of <machine>.
SUM.
wa-plan_qty = wa-plan_qty/3.
write: wa-plan_qty-act_prod, wa-plan_qty-quaty,wa-plan_qty-plan_qty.
endloop.
Edited by: Rengith Skariah on Feb 2, 2008 9:31 AM
02-02-2008 10:35 AM
Hi
I tried using your code in my programe but o/p not come after using this code
see i select my all data in itab internal table
then after i add your written code bt data is not come so please write your code in brief.
at end of <machine>.
SUM.
wat this line do please write me.
thanks.
02-02-2008 10:50 AM
Hi,
Say ur int-table itab has 5 flds A,B,C,D,E
and ur table is like dis..
A B C D E
a f c d e
a b h d e
a k c c e
1 b c d e
1 j c d e
.
loop at itab.
.....
.....
at end of A.
<this part of code ll be executed only twice for our table
1) after the third row....bcoz the value of field A is ending(ie changing from a to 1.
2) after the fifth row.>
endat.
endloop.
Cheers,
Will.