Application Development 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: 

year wise totals

Former Member
0 Kudos

i am getting month wise totals from S001-UMMENGE for each customer.

year wise totals are directly not coming from the system.

i should calculate year wise totals based on month wise totals ..

suppose jan,feb, mar,...dec i am getting 100, 250 , 400, --- like so..

finally i want to sum up all the values from january to december it will give year wise total..

how i will save month wise totals..and sum up for the year..

in my selection screen i am giving period and sales group information.

for understanding i am sending code below.

REPORT ZSAMPLE NO STANDARD PAGE HEADING LINE-SIZE 250.

TABLES: KNVV, S001, MVKE, ZSALE.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_VKGRP FOR KNVV-VKGRP,

S_SPBUP FOR S001-SPBUP.

SELECTION-SCREEN END OF BLOCK B1.

DATA: BEGIN OF ITAB OCCURS 0,

KUNNR TYPE KNVV-KUNNR,

VKGRP TYPE KNVV-VKGRP,

END OF ITAB.

DATA: BEGIN OF KTAB OCCURS 0,

BONUS TYPE VBRP-BONUS,

MATNR TYPE VBRP-MATNR,

ARKTX TYPE VBRP-ARKTX,

END OF KTAB.

DATA: BEGIN OF STAB OCCURS 0,

KUNNR TYPE S001-KUNNR,

MATNR TYPE S001-MATNR,

UMMENGE TYPE S001-UMMENGE,

SPBUP TYPE S001-SPBUP,

PERIV TYPE S001-PERIV,

END OF STAB.

DATA: BEGIN OF SALE OCCURS 0,

KUNNR TYPE ZSALE-KUNNR,

NAME1 TYPE ZSALE-NAME1,

TGMONTHCORE TYPE ZSALE-TGMONTHCORE,

TGMONTHTOTAL TYPE ZSALE-TGMONTHTOTAL,

TGYEARCORE TYPE ZSALE-TGYEARCORE,

TGYEARTOTAL TYPE ZSALE-TGYEARTOTAL,

REBATE TYPE ZSALE-REBATE,

TRMONTH TYPE ZSALE-TRMONTH,

TRYEAR TYPE ZSALE-TRYEAR,

END OF SALE.

DATA: IV_RESULT LIKE ZSALE-TGMONTHTOTAL,

I_COMM LIKE ZSALE-TGMONTHTOTAL.

DATA:ZSUM LIKE S001-UMMENGE.

SELECT KUNNR VKGRP INTO CORRESPONDING FIELDS OF TABLE ITAB FROM KNVV WHERE VKGRP IN S_VKGRP.

IF NOT ITAB[] IS INITIAL.

SELECT KUNNR MATNR UMMENGE SPBUP PERIV INTO CORRESPONDING FIELDS OF TABLE STAB FROM S001 FOR ALL ENTRIES

IN ITAB WHERE KUNNR = ITAB-KUNNR AND SPBUP IN S_SPBUP.

ENDIF.

IF NOT STAB[] IS INITIAL.

SELECT BONUS MATNR ARKTX INTO CORRESPONDING FIELDS OF TABLE KTAB FROM VBRP FOR ALL ENTRIES IN STAB

WHERE MATNR = STAB-MATNR.

ENDIF.

SELECT * FROM ZSALE INTO CORRESPONDING FIELDS OF TABLE SALE.

SORT STAB BY KUNNR.

LOOP AT STAB.

LOOP AT KTAB WHERE MATNR = STAB-MATNR.

IF KTAB-BONUS = 'A0'.

A0 = A0 + STAB-UMMENGE.

ENDIF.

WRITE: /1 STAB-KUNNR, 12 KTAB-ARKTX, 40 KTAB-MATNR, 53 KTAB-BONUS, 80 A0.

LOOP AT SALE WHERE KUNNR = STAB-KUNNR.

WRITE: 62 SALE-TGMONTHCORE, 125 SALE-REBATE, 175 SALE-TGMONTHTOTAL, 195 SALE-TGYEARTOTAL.

IV_RESULT = A0 - SALE-TGMONTHCORE.

WRITE: 105 IV_RESULT.

IF KTAB-BONUS = 'A0'.

IF A0 > SALE-TGMONTHCORE AND STAB-UMMENGE > SALE-TGMONTHTOTAL.

I_COMM = SALE-REBATE * A0.

WRITE: 140 I_COMM.

ENDIF.

ENDIF.

ENDLOOP.

ENDLOOP.

AT END OF KUNNR.

SUM.

WRITE: 155 STAB-UMMENGE.

ENDAT.

ENDLOOP.

TOP-OF-PAGE.

WRITE: /1 'CUSTMERNO', 12 'MATERAIAL DESCRIPTION', 40 'MATERIALNO', 53 'BONUS', 63 'TGMONTHCORE', 80 'TGACTUALCORE',

105 'MONTHCOREDIFF', 125 'REBATE' , 140 'COMMISSION' , 155 'TGMONTHACTUAL', 175 'TGMONTHTOTAL', 195 'TGYEARTOTAL',

212 'TGYEARACTUAL'.

ULINE.

1 REPLY 1

Former Member
0 Kudos

Hi Venkat,

Follow the code.

loop at itab.

at end-of-kunnr.

g_ummenge = g_ummenge + S001-UMMENGE

endat.

endloop.

write: g_ummenge.

if it is usefull pls rewrd pts.

Regards

Srimanta