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: 

how to group and sum?

Former Member
0 Kudos

Dear Gurus,

[http://www.picoodle.com/view.php?img=/4/4/29/f_BYAREAT1m_b564b70.jpg&srv=img28]

I have this report, like showing above, I wanna modify the report, at the same model, each area only display the sum.

for example iin the report,

only will display out

card reader - main area - (total amount)

card reader - other - (total amount)

card reader - p1 - (total amount)

card reader - p2 - (total amount)

how to sum out all main area and display as 1 in each model?

below is the coding for the report print out.

FORM PRINT_SPECIFY_MKS_DATA.
*----------------------------------------------------------------------*
  SORT SPEC BY BYFIELD AREA2 FLAG.
  FORMAT COLOR 5 INTENSIFIED OFF. WA_REC_CNT    = 0.
  LOOP AT SPEC.
    MOVE-CORRESPONDING SPEC TO TMP.
    WA_REC_CNT = WA_REC_CNT + 1.
    AT NEW BYFIELD.
       WRITE:/1   SY-VLINE,  2(5)   WA_REC_CNT.
*             7   sy-vline,  8(18)  tmp-byfield.
  IF SPEC-AREA2  = TMP-AREA2. SUM. ENDIF.
       ENDAT.
    WRITE:1   SY-VLINE,    2(5)    WA_REC_CNT,
          7   SY-VLINE,    8(18)   TMP-BYFIELD,
*         26  sy-vline,    27(18)  tmp-matnr,
*         26  sy-vline,    27(2)   tmp-spart,
*         29  sy-vline,    30(3)   tmp-cat,
          26  SY-VLINE,    27(8)   TMP-AREA2,
*         40  sy-vline,    41(6)   tmp-type,
          35  SY-VLINE,    36(15)  TMP-025,
          51  SY-VLINE,    52(15)  TMP-05,
          67  SY-VLINE,    68(15)  TMP-1,
          83  SY-VLINE,    84(15)  TMP-3,
          99  SY-VLINE,    100(15) TMP-6,
          115 SY-VLINE,    116(15) TMP-7,
          131 SY-VLINE.
     NEW-LINE.

     AT END OF BYFIELD.
        SUM.
        FORMAT COLOR OFF. FORMAT COLOR 3 INTENSIFIED OFF.
        WA_REC_CNT = WA_REC_CNT + 1.   
        WRITE:/1(131) SY-ULINE.
        WRITE:/1  SY-VLINE,     2(5)   WA_REC_CNT,
               7  SY-VLINE,     8(18)  TMP-BYFIELD,
               7  SY-VLINE,     8(18)  TMP-BYFIELD,
               26  SY-VLINE,    27(8) 'SubTotal',
               35  SY-VLINE,    36(15)  SPEC-025,
               51  SY-VLINE,    52(15)  SPEC-05,
               67  SY-VLINE,    68(15)  SPEC-1,
               83  SY-VLINE,    84(15)  SPEC-3,
               99  SY-VLINE,    100(15)  SPEC-6,
               115 SY-VLINE,    116(15) SPEC-7,
               131 SY-VLINE.
        WRITE:/1(131) SY-ULINE. FORMAT COLOR OFF.
        FORMAT COLOR OFF. FORMAT COLOR 5 INTENSIFIED OFF.
     ENDAT.
     AT LAST.
        SUM.
        FORMAT COLOR OFF. FORMAT COLOR 3.
        WRITE:/1  SY-VLINE,     2(24)  'Grand Total',
               26  SY-VLINE,
               35  SY-VLINE,    36(15)  SPEC-025,
               51  SY-VLINE,    52(15)  SPEC-05,
               67  SY-VLINE,    68(15)  SPEC-1,
               83  SY-VLINE,    84(15)  SPEC-3,
               99  SY-VLINE,    100(15)  SPEC-6,
               115 SY-VLINE,    116(15) SPEC-7,
               131 SY-VLINE.
        WRITE:/1(131) SY-ULINE. FORMAT COLOR OFF.
     ENDAT.
  ENDLOOP.
ENDFORM.

1 REPLY 1

Former Member
0 Kudos

Solved! TQ