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: 

Sales Order Report

Former Member
0 Kudos

Hi everybody,

i have been given to develop a report that is sales person wise sales order report and output should come month wise. this part is working fine what i want to know is that if any sales order document is getting extended where the old data will get stored.

eg: In January i created one sales order with 1 line item, In May again i am extending the same sales order by adding more material in the same line item then price will also get changed, here i need to develop a report which shows the amount that got incresed in may and need to show in May month(incremented amount) and amount that was there in January(Actual amount) in January month.

Help will be highly appreciated..

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sukesh,

when you extract sales orders created for a specific time period, if you use VBAP-ERDAT as the criteria then you would automatically get the list of order line items created for the period. Or you could use the sales information system (SIS structures) which also has a standard report on sales performance of employee.

the report would become complex if you also have the scenario where order line items are changed (That is, the item quantity is incremented). then in that case you also need to look at changed order line items through (VBAP-AEDAT) and further see what has been changed between months through change documents (CDHDR/CDPOS).

Regards,

Prabhu

2 REPLIES 2

Former Member
0 Kudos

<b>See this report it is an sales order report for an Customer ....

</b>

REPORT ZVRDOC0 no standard page heading
line-size 300
line-count 50(5).


*******************TABLES***********************************************

TABLES : vbak, "Sales Document Header Level
vbap, "Sales Document Header Level
kna1. "General Data in customer Master

*******************INTERNAL TABELS DECLARATION**************************

*INTERNAL TABLE T_VBAP

DATA : Begin of t_vbap occurs 0,
       vbeln like vbap-vbeln,
       matnr like vbap-matnr,
       posnr like vbap-posnr,
       arktx like vbap-arktx,
       kwmeng like vbap-kwmeng,
       cmkua like vbap-cmkua,
       end of t_vbap.

*INTERNAL TABLE T_TAB.

DATA : Begin of t_tab occurs 0,
        vbeln like vbak-vbeln,
        kunnr like vbak-kunnr,
        audat like vbak-audat,
        netwr like vbak-netwr,
        vkorg like vbak-vkorg,
        name1 like kna1-name1,
        land1 like kna1-land1,
        end of t_tab.

*INTERNAL TABLE T_FINAL.

DATA : Begin of t_final occurs 0,
        vbeln like vbap-vbeln,
        kunnr like vbak-kunnr,
        matnr like vbap-matnr,
        posnr like vbap-posnr,
        arktx like vbap-arktx,
        kwmeng like vbap-kwmeng,
        cmkua like vbap-cmkua,
        audat like vbak-audat,
        netwr like vbak-netwr,
        vkorg like vbak-vkorg,
        name1 like kna1-name1,
        land1 like kna1-land1,
        end of t_final.

*****************************SELECTION SCREEN***********************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-bO3.

parameters : P_kunnr like vbak-kunnr.

select-options : S_vbeln for vbak-vbeln,
                 S_audat for vbak-audat.

SELECTION-SCREEN END OF BLOCK B1.

*********************START-OF-SELECTION****************************

start-of-selection.

select vbeln  matnr posnr arktx kwmeng cmkua  from vbap
into corresponding fields  of table  t_vbap  where vbeln in S_vbeln .
IF sy-subrc EQ 0.

select  vbak~kunnr vbak~vbeln vbak~audat vbak~netwr vbak~vkorg
        kna1~name1 kna1~land1  into  table   t_Tab   from
        vbak   join  kna1   on kna1~kunnr  = vbak~kunnr
        FOR ALL ENTRIES IN t_vbap
        where vbak~vbeln = t_vbap-Vbeln and
        vbak~kunnr = p_kunnr and
        vbak~audat  in  S_audat .

ENDIF.


*end-of-selection.


loop at t_vbap.

read table t_tab with key vbeln = t_vbap-vbeln.


move :
t_vbap-vbeln to t_final-vbeln,
t_vbap-matnr to t_final-matnr,
t_vbap-posnr to t_final-posnr,
t_vbap-arktx to t_final-arktx,
t_vbap-kwmeng to t_final-kwmeng,
t_vbap-cmkua to t_final-cmkua,
t_tab-kunnr to t_final-kunnr,
t_tab-audat to t_final-audat,
t_tab-netwr to t_final-netwr,
t_tab-vkorg to t_final-vkorg,
t_tab-name1 to t_final-name1,
t_tab-land1 to t_final-land1.

append t_final.
clear t_Final.

endloop.

***************************loop at t_final****************************
sort t_Final by vbeln   Kunnr    matnr posnr  .

loop at t_final.

at new vbeln.
write : /1 SY-VLINE, 2 t_final-vbeln color 5 inverse.
ULINE /1(250).

endat.

write : /1 SY-VLINE, 2 t_final-vbeln color 5 inverse,
20 SY-VLINE, 21 t_final-posnr color 5 inverse,
40 SY-VLINE, 41 t_final-matnr color 5 inverse,
60 SY-VLINE, 61 t_final-arktx color 4 inverse,
80 SY-VLINE, 81 t_final-kwmeng color 4 inverse,
100 SY-VLINE, 101 t_final-cmkua color 4 inverse,
120 SY-VLINE, 121 t_final-kunnr color 3 inverse,
140 SY-VLINE, 141 t_final-audat color 3 inverse,
160 SY-VLINE, 161 t_final-netwr color 2 inverse,
180 SY-VLINE, 181 t_final-vkorg color 2 inverse,
210 SY-VLINE, 211 t_final-name1 color 1 inverse,
230 SY-VLINE, 231 t_final-land1 color 1 inverse,
250 SY-VLINE.

at end of vbeln.
sum.
ULINE /1(250).
write: /60 SY-VLINE, 'Total' ,
81 t_final-kwmeng color 4 inverse ,100 SY-VLINE,
101 t_final-cmkua color 4 inverse,120 SY-VLINE.
ULINE /1(250).
endat.

at last.
SKIP 2.
sum.
ULINE /1(250).
write: /1 SY-VLINE, 60 SY-VLINE, 'Grand Total' ,
81 t_final-kwmeng color 4 inverse , 100 SY-VLINE ,
101 t_final-cmkua color 4 inverse,120 SY-VLINE.
ULINE /1(250).
endat.

endloop.

***********************TOP-OF-PAGE*********************************
TOP-OF-PAGE.

ULINE /50(24).
WRITE : /50 SY-VLINE , 52 'SALES ORDER DETAILS' COLOR 5,
73 SY-VLINE.

ULINE /50(24).

ULINE .

WRITE: /10 'CURRENT DATE :', 25 SY-DATUM COLOR 1 INVERSE,
100 'CURRENT TIME :', 115 SY-UZEIT color 5 INVERSE.

WRITE: /10 'USERNAME :', 25 SY-UNAME COLOR 1 INVERSE,
100 'PAGE NO :', 113 SY-PAGNO COLOR 5 INVERSE.

WRITE: /10 'LOGON CLIENT :', 25 SY-MANDT COLOR 1 INVERSE,
100 'COLON N0 :', 114 SY-COLNO COLOR 5 INVERSE.

WRITE: /10 'CURRENT REPROT:', 25 SY-REPID COLOR 1 INVERSE,
100 'LANGUAGE :', 116 SY-LANGU COLOR 5 INVERSE.


ULINE.

ULINE /1(250).

write : /1 SY-VLINE, 2 'SALES DOC NO' color 6 inverse,
20 SY-VLINE, 21 'SALES DOC ITEM' color 6 inverse,
40 SY-VLINE,41 'MATERIAL NO' color 6 inverse,
60 SY-VLINE, 61 'SHORT SALES TEXT' color 6 inverse,
80 SY-VLINE, 81 'CUMM ORDER SALES' color 6 inverse,
100 SY-VLINE, 101 'CREDIT DATA' color 6 inverse,
120 SY-VLINE, 121 'CUSTOMER NO' color 6 inverse,
140 SY-VLINE, 141 'DOC DATE' color 6 inverse,
160 SY-VLINE, 161 'NET VALUE SALES' color 6 inverse,
180 SY-VLINE, 181 'SALES ORG' color 6 inverse,
210 SY-VLINE, 211 'CUSTOMER NAME' color 6 inverse,
230 SY-VLINE, 231 'CUSTOMER CONTY' color 6 inverse,
250 SY-VLINE.


ULINE /1(250).



**************************END-OF-PAGE********************************

END-OF-PAGE.


ULINE.

WRITE: /45 ' THIS IS END OF PAGE FOR SALES DOCUMENT DETAILS'
COLOR 6 .

reward points if it is usefull ....

Girish

Former Member
0 Kudos

Hi Sukesh,

when you extract sales orders created for a specific time period, if you use VBAP-ERDAT as the criteria then you would automatically get the list of order line items created for the period. Or you could use the sales information system (SIS structures) which also has a standard report on sales performance of employee.

the report would become complex if you also have the scenario where order line items are changed (That is, the item quantity is incremented). then in that case you also need to look at changed order line items through (VBAP-AEDAT) and further see what has been changed between months through change documents (CDHDR/CDPOS).

Regards,

Prabhu