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

Simple Report

Former Member
0 Likes
1,084

hi friends, i want to print a report like this.

cust no:________ totalsalesdocuments_______ totalsales quantity__________

salesdocument quantity

salesdocument quantity

salesdocument quantity

............ .......

........... .......

cust no:________ totalsalesdocuments_______ totalsales quantity__________

salesdocument quantity

salesdocument quantity

salesdocument quantity

............ .......

........... .......

cust no:________ totalsalesdocuments_______ totalsales quantity__________

salesdocument quantity

salesdocument quantity

salesdocument quantity

............ .......

........... .......

i am getting the total sales quantity by using the SUM controlbreak event AT NEW.

but how to calculate the total sales documents of a customer before printing those documents. because it is not a numeric field SUM is not work.

plz tell me how to do this problem.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,006

Hi prashanth,

1. I don't prefer to use Control-Break logic.

Its not much reliable.

2. Instead i use COLLECT logic.

3. In your same program,

i have made one EXTRA FORM,

which will do all the work

in a better way (WITH COUNT)

              1. MODI

4. Just copy paste in new program.

5.

REPORT abc.

TABLES:vbak.

***********************data types**********

TYPES: BEGIN OF ty_orders,

kunnr TYPE vbak-kunnr,

vbeln TYPE vbak-vbeln,

kwmeng TYPE vbap-kwmeng,

sdoc1 TYPE i,

END OF ty_orders.

                        1. MODIFY

DATA : BEGIN OF summary OCCURS 0,

kunnr TYPE vbak-kunnr,

kwmeng TYPE vbap-kwmeng,

cnt TYPE i,

END OF summary.

DATA : doctotal TYPE i.

DATA: w_orders TYPE ty_orders.

DATA: t_orders TYPE STANDARD TABLE OF ty_orders INITIAL SIZE 1.

********************selection-screen************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: cno FOR vbak-kunnr.

SELECTION-SCREEN END OF BLOCK b1.

********************initialization event*********

INITIALIZATION.

cno-low = 1000.

cno-high = 2000.

APPEND cno.

*******************start-of-selectionevent********

START-OF-SELECTION.

*data sdoc1 type i.

SELECT vbak~kunnr

vbak~vbeln

vbap~kwmeng INTO TABLE t_orders

FROM vbak

INNER JOIN

vbap ON

vbakvbeln = vbapvbeln

WHERE vbak~kunnr IN cno.

SORT t_orders BY kunnr.

                        1. MODIFY

PERFORM doprint.

EXIT.

LOOP AT t_orders INTO w_orders.

  • at new sdoc1.

  • w_orders-sdoc1.

  • endat.

w_orders-sdoc1 = w_orders-vbeln.

  • on change of w_orders-vbeln.

    • sdoc = sdoc + 1.

  • endon.

AT NEW kunnr.

SUM.

WRITE: /5 'cust no:', w_orders-kunnr,

20 'no.of.sales documents:', w_orders-sdoc1,

45 'total sales orders quantity:' , w_orders-kwmeng.

ULINE.

WRITE: /15 'sales document no',

45 'order quantity'.

ULINE.

ENDAT.

WRITE: /20 w_orders-vbeln,

35 w_orders-kwmeng.

AT END OF kunnr.

ULINE.

SKIP.

ENDAT.

ENDLOOP.

*********************top-of-page************

TOP-OF-PAGE.

WRITE: /25 'customer wise sales document details'.

ULINE.

*----


                        1. MODIFY

*----


  • FORM

*----


FORM doprint.

*----


Get Statistics

SORT t_orders BY kunnr.

LOOP AT t_orders INTO w_orders.

MOVE-CORRESPONDING w_orders TO summary.

summary-cnt = 1.

COLLECT summary.

ENDLOOP.

BREAK-POINT.

*----


For Printing

LOOP AT summary.

WRITE 😕 '----


'.

WRITE 😕 summary-kunnr , summary-kwmeng , summary-cnt.

WRITE 😕 '----


'.

LOOP AT t_orders INTO w_orders WHERE kunnr = summary-kunnr.

WRITE 😕 w_orders-kunnr , w_orders-vbeln , w_orders-kwmeng.

ENDLOOP.

ENDLOOP.

ENDFORM. "doprint

regards,

amit m.

9 REPLIES 9
Read only

Former Member
0 Likes
1,006

Hi prashant,

Create another internal table with Customer No & add the sales documents quantity & append for each customer by looping at this internal table.

While writing just read that table with the cust no. & write the value.

Read only

Former Member
0 Likes
1,006

Hi,

Create another internal table with Customer No total Qty.

You have to call this loop before your current loop.

Loop at Itab (Your table).

L_intdex = Sy-tabix.

Counter = Counter + 1.

At end of Customer.

Read itab index l_tabix.

Move Itab-customet to itab_new-customer.

Move counter to itab_new-Total_lines.

append Itab_new.

Clear Counter.

Endat.

endloop.

In your loop read this Itab_new by using:

Read itab_new with key Customer = Itab-customer.

Hope this will help.

Lanka

Read only

Former Member
0 Likes
1,006

Hi,

Check the sequence of fields in internal table you are using, sort them by order and issue AT END event and SUM up the values in AT END event.

I think you should get desired results.

Read only

Former Member
0 Likes
1,006

Hi Prashanth,

data : pack type p,

sumdoc type p.

.....

loop at itab.

pack = itab-salesdoc.

sumdoc = sumdoc + pack.

at new salesdoc.

write : sumdoc."which is the actual sum

clear sumdoc.

endat.

....

endloop.

hope this works fine...

reward points in case its helpful

regards,

Read only

Former Member
0 Likes
1,006

hi friends,thanks for u answers. still my problem is not solved. i am giving my code.

i am not getting total sales documents for a particular customer.

plz modify my program.

tables:vbak.

***********************data types**********

types: begin of ty_orders,

kunnr type vbak-kunnr,

vbeln type vbak-vbeln,

kwmeng type vbap-kwmeng,

sdoc1 type i,

end of ty_orders.

data: w_orders type ty_orders.

data: t_orders type standard table of ty_orders initial size 1.

********************selection-screen************

selection-screen begin of block b1 with frame title text-001.

select-options: cno for vbak-kunnr.

selection-screen end of block b1.

********************initialization event*********

initialization.

cno-low = 1000.

cno-high = 2000.

append cno.

*******************start-of-selectionevent********

start-of-selection.

*data sdoc1 type i.

select vbak~kunnr

vbak~vbeln

vbap~kwmeng into table t_orders

from vbak

inner join

vbap on

vbakvbeln = vbapvbeln

where vbak~kunnr in cno.

sort t_orders by kunnr.

loop at t_orders into w_orders.

  • at new sdoc1.

  • w_orders-sdoc1.

  • endat.

w_orders-sdoc1 = w_orders-vbeln.

  • on change of w_orders-vbeln.

    • sdoc = sdoc + 1.

  • endon.

at new kunnr.

sum.

write: /5 'cust no:', w_orders-kunnr,

20 'no.of.sales documents:', w_orders-sdoc1,

45 'total sales orders quantity:' , w_orders-kwmeng.

uline.

write: /15 'sales document no',

45 'order quantity'.

uline.

endat.

write: /20 w_orders-vbeln,

35 w_orders-kwmeng.

at end of kunnr.

uline.

skip.

endat.

endloop.

*********************top-of-page************

top-of-page.

write: /25 'customer wise sales document details'.

uline.

Read only

0 Likes
1,006

Hi

there is small change you will get the sum in the footer of the endat

tables:vbak.

***********************data types**********

types: begin of ty_orders,

kunnr type vbak-kunnr,

vbeln type vbak-vbeln,

kwmeng type vbap-kwmeng,

sdoc1 type i,

end of ty_orders.

data: w_orders type ty_orders.d

data: count type i.

data: t_orders type standard table of ty_orders initial size 1.

********************selection-screen************

selection-screen begin of block b1 with frame title text-001.

select-options: cno for vbak-kunnr.

selection-screen end of block b1.

********************initialization event*********

initialization.

cno-low = 1000.

cno-high = 2000.

count = 0.

append cno.

*******************start-of-selectionevent********

start-of-selection.

*data sdoc1 type i.

select vbak~kunnr

vbak~vbeln

vbap~kwmeng into table t_orders

from vbak

inner join

vbap on

vbakvbeln = vbapvbeln

where vbak~kunnr in cno.

sort t_orders by kunnr.

loop at t_orders into w_orders.

  • at new sdoc1.

  • w_orders-sdoc1.

  • endat.

w_orders-sdoc1 = w_orders-vbeln.

  • on change of w_orders-kunnr.

  • sdoc = sdoc + 1.

  • endon.

at new kunnr.

count = 0.

write: /5 'cust no:', w_orders-kunnr,

uline.

endat

count = count + 1.

write: /20 w_orders-vbeln,

35 w_orders-kwmeng.

at end of kunnr.

sum.

write:/ 20 'no.of.sales documents:', count,

45 'total sales orders quantity:' , w_orders-kwmeng.

uline.

skip.

endat.

endloop.

*********************top-of-page************

top-of-page.

write: /25 'customer wise sales document details'.

uline.

Message was edited by: Harikishore Sreenivasulu

Read only

0 Likes
1,006

Hi

if you want the no.of sales and total quantity in the header then

use another internal table which stores the header details using a separate loop. Before the used loop.

Regards

Read only

Former Member
0 Likes
1,007

Hi prashanth,

1. I don't prefer to use Control-Break logic.

Its not much reliable.

2. Instead i use COLLECT logic.

3. In your same program,

i have made one EXTRA FORM,

which will do all the work

in a better way (WITH COUNT)

              1. MODI

4. Just copy paste in new program.

5.

REPORT abc.

TABLES:vbak.

***********************data types**********

TYPES: BEGIN OF ty_orders,

kunnr TYPE vbak-kunnr,

vbeln TYPE vbak-vbeln,

kwmeng TYPE vbap-kwmeng,

sdoc1 TYPE i,

END OF ty_orders.

                        1. MODIFY

DATA : BEGIN OF summary OCCURS 0,

kunnr TYPE vbak-kunnr,

kwmeng TYPE vbap-kwmeng,

cnt TYPE i,

END OF summary.

DATA : doctotal TYPE i.

DATA: w_orders TYPE ty_orders.

DATA: t_orders TYPE STANDARD TABLE OF ty_orders INITIAL SIZE 1.

********************selection-screen************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: cno FOR vbak-kunnr.

SELECTION-SCREEN END OF BLOCK b1.

********************initialization event*********

INITIALIZATION.

cno-low = 1000.

cno-high = 2000.

APPEND cno.

*******************start-of-selectionevent********

START-OF-SELECTION.

*data sdoc1 type i.

SELECT vbak~kunnr

vbak~vbeln

vbap~kwmeng INTO TABLE t_orders

FROM vbak

INNER JOIN

vbap ON

vbakvbeln = vbapvbeln

WHERE vbak~kunnr IN cno.

SORT t_orders BY kunnr.

                        1. MODIFY

PERFORM doprint.

EXIT.

LOOP AT t_orders INTO w_orders.

  • at new sdoc1.

  • w_orders-sdoc1.

  • endat.

w_orders-sdoc1 = w_orders-vbeln.

  • on change of w_orders-vbeln.

    • sdoc = sdoc + 1.

  • endon.

AT NEW kunnr.

SUM.

WRITE: /5 'cust no:', w_orders-kunnr,

20 'no.of.sales documents:', w_orders-sdoc1,

45 'total sales orders quantity:' , w_orders-kwmeng.

ULINE.

WRITE: /15 'sales document no',

45 'order quantity'.

ULINE.

ENDAT.

WRITE: /20 w_orders-vbeln,

35 w_orders-kwmeng.

AT END OF kunnr.

ULINE.

SKIP.

ENDAT.

ENDLOOP.

*********************top-of-page************

TOP-OF-PAGE.

WRITE: /25 'customer wise sales document details'.

ULINE.

*----


                        1. MODIFY

*----


  • FORM

*----


FORM doprint.

*----


Get Statistics

SORT t_orders BY kunnr.

LOOP AT t_orders INTO w_orders.

MOVE-CORRESPONDING w_orders TO summary.

summary-cnt = 1.

COLLECT summary.

ENDLOOP.

BREAK-POINT.

*----


For Printing

LOOP AT summary.

WRITE 😕 '----


'.

WRITE 😕 summary-kunnr , summary-kwmeng , summary-cnt.

WRITE 😕 '----


'.

LOOP AT t_orders INTO w_orders WHERE kunnr = summary-kunnr.

WRITE 😕 w_orders-kunnr , w_orders-vbeln , w_orders-kwmeng.

ENDLOOP.

ENDLOOP.

ENDFORM. "doprint

regards,

amit m.

Read only

Former Member
0 Likes
1,006

thanks amit ur code working perfectly.

full points to u.