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

please correct this coding

Former Member
0 Likes
584

Hi All,

can any body please correct this code according to my requirement

i have calculated for material wise sum.

but i want month wise .

eg: 1000 100 02/2001

1000 200 02/2001

1000 100 03/2001

1000 200 03/2001

opt sholud be 1000 300 02/2001

1000 300 03/2001

like this for all material.

REPORT ZPRODUCT_ROLL .

TableS: S507.

DATA: BEGIN OF T_DATA OCCURS 0,

matnr LIKE S507-matnr,

SPMON LIKE S507-SPMON,

ZZDPFC LIKE S507-ZZDPFC,

ZZMARKET LIKE S507-ZZMARKET,

END OF T_DATA.

DATA: BEGIN OF itab1 OCCURS 0,

  • SPMON LIKE S507-SPMON,

matnr LIKE S507-matnr,

ZZDPFC LIKE S507-ZZDPFC,

  • ZZMARKET LIKE S507-ZZMARKET,

END OF itab1.

DATA:WA_DEMPLAN(10) TYPE C.

Select mATNR SPMON ZZDPFC ZZMARKET

From S507

into corresponding fields of table t_DATA WHERE

VRSIO = '000' AND BEDAE = 'KSV' AND ZZDMTYP = '001'

AND ZZDPFC GT '0' AND ZZMARKET IN ('001','002') AND SPMON >= 200705.

SORT T_DATA BY MATNR ZZMARKET SPMON.

write:/04 'Material',25 'Demand Plant'. "45 'Market',70 'Period'.

LOOP AT T_DATA.

**

WRITE:/02 t_data-MATNR ,25 t_data-ZZDPFC,45 t_data-ZZMARKET,

70 t_data-SPMON.

at end of matnr.

sum.

write : /02 t_Data-matnr,25 t_data-zzdpfc COLOR 5 .

endat.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
541

hi arun,

instead of matnr use datefield for at end of event as

LOOP AT T_DATA.

**

WRITE:/02 t_data-MATNR ,25 t_data-ZZDPFC,45 t_data-ZZMARKET,

70 t_data-SPMON.

at end of datefield [matnr].

sum.

write : /02 t_Data-matnr,25 t_data-zzdpfc COLOR 5 .

endat.

endloop.

if helpful reward some points.

with regards,

suresh babu aluri.

4 REPLIES 4
Read only

Former Member
0 Likes
541

hi Arun,

do this way take the month field to the second position and take another internal table.

LOOP AT T_DATA.


at end of datefield .
SUM.
it_final-field1.
it_final-date field.
it_final-field3.
append it_final.
clear it_final.
endat.
endloop.

Read only

Former Member
0 Likes
541

Hi Arun,

U have to split the date and store the month in a seperate field in you itab.

then use AT NEW or AT END with the month field and SUM.You can meet the requirement.

regards

Sarath

Read only

Former Member
0 Likes
541

into loop statement do the sum for the peroid ... dont worry about the month it consist of both month and year so .... the sum will be proper ....

if you don't want total about Matreil then comment the at end of matnr ... end at part .


SORT T_DATA BY MATNR SPMON.
LOOP AT T_DATA.
**
WRITE:/02 t_data-MATNR ,25 t_data-ZZDPFC,45 t_data-ZZMARKET,
70 t_data-SPMON.
at end of matnr.
sum.
write : /02 t_Data-matnr,25 t_data-zzdpfc COLOR 5 .
endat.

at end of SPMON.
sum.
write : /02 t_Data-matnr,25 t_data-zzdpfc COLOR 5 .
endat.

endloop. 

Girish

Read only

Former Member
0 Likes
542

hi arun,

instead of matnr use datefield for at end of event as

LOOP AT T_DATA.

**

WRITE:/02 t_data-MATNR ,25 t_data-ZZDPFC,45 t_data-ZZMARKET,

70 t_data-SPMON.

at end of datefield [matnr].

sum.

write : /02 t_Data-matnr,25 t_data-zzdpfc COLOR 5 .

endat.

endloop.

if helpful reward some points.

with regards,

suresh babu aluri.