Skip to Content
0
Former Member
Feb 25, 2010 at 12:07 PM

At New Field and At End of Field not working

30 Views

Dear Experts,

Please have a look on the below code and advice me what wen wrong as

at new and at end of statement not working, please advice.

LOOP AT I_FINAL INTO S_FINAL.

    AT NEW KUNRG.
      SELECT NAME1 FROM KNA1 INTO S_NAME WHERE KUNNR = S_FINAL-KUNRG.
      ENDSELECT.
      SKIP.
 WRITE :/10 'Customer Name :', S_NAME,
            'Code :         ', S_FINAL-KUNRG.
      WRITE :/10 'For the period from ', S_DATE-LOW,
                ' To ', S_DATE-HIGH.
      SKIP.
      WRITE AT 5(95) SY-ULINE.
      SKIP.
      WRITE :/10 'Serial',
              20 'Billing',
              32 'Invoice',
              46 'Invoice',
              66 'Invoice'.
      WRITE :/10 '  No. ',
              20 '  No.  ',
              32 'Number',
              46 ' Date  ',
              66 'Amount '.
      SKIP.
      WRITE AT 5(95) SY-ULINE.
      G_SI_NUM = 0.
    ENDAT.


    G_SI_NUM = G_SI_NUM + 1.

    WRITE: /05 G_SI_NUM,
            17 S_FINAL-VBELN,
            29 S_FINAL-EXNUM NO-ZERO,
            43 S_FINAL-FKDAT,
            55 S_FINAL-NETWR RIGHT-JUSTIFIED.

    SKIP.
    AT END OF KUNRG.
      SUM.
      WRITE AT 5(95) SY-ULINE.
      WRITE :/17 'Total',
              55 S_FINAL-NETWR  RIGHT-JUSTIFIED.
      SKIP.
      WRITE AT 5(95) SY-ULINE.
    ENDAT.

  ENDLOOP.

Its calculating every single vbeln as new field and taking the total for each vbeln

but I need total for each ( Kunrg ) Customer.

Please advice

Karthik