Skip to Content
author's profile photo Former Member
Former Member

Reports

Hi,

Any one please send me one exxample using control break statments like AT LAST,AT END OF ...etc...

using the SUM in the report...

Thanks & regards,

Shaheen.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 08:02 AM

    REPORT zinternaltable.

    TYPES:BEGIN OF itab,

    num TYPE i,

    name(10) TYPE c,

    amt type i,

    END OF itab.

    DATA : wa_itab TYPE itab,

    it_itab TYPE STANDARD TABLE OF itab.

    DATA : v_lines TYPE i.

    wa_itab-num = 1.

    wa_itab-name = 'nag'.

    wa_itab-amt = 1000.

    append wa_itab TO it_itab.

    wa_itab-num = 1.

    wa_itab-name = 'nag'.

    wa_itab-amt = 2000.

    append wa_itab TO it_itab.

    wa_itab-num = 1.

    wa_itab-name = 'nag'.

    wa_itab-amt = 1500.

    append wa_itab TO it_itab.

    wa_itab-num = 2.

    wa_itab-name = 'sri'.

    wa_itab-amt = 500.

    append wa_itab tO it_itab.

    wa_itab-num = 2.

    wa_itab-name = 'sri'.

    wa_itab-amt = 600.

    append wa_itab TO it_itab.

    wa_itab-num = 2.

    wa_itab-name = 'sri'.

    wa_itab-amt = 700.

    append wa_itab TO it_itab.

    wa_itab-num = 3.

    wa_itab-name = 'ganesh'.

    wa_itab-amt = 1200.

    append wa_itab TO it_itab.

    wa_itab-num = 3.

    wa_itab-name = 'ganesh'.

    wa_itab-amt = 1300.

    append wa_itab TO it_itab.

    wa_itab-num = 3.

    wa_itab-name = 'ganesh'.

    wa_itab-amt = 1400.

    append wa_itab TO it_itab.

    wa_itab-num = 4.

    wa_itab-name = 'suresh'.

    wa_itab-amt = 900.

    append wa_itab TO it_itab.

    wa_itab-num = 4.

    wa_itab-name = 'suresh'.

    wa_itab-amt = 300.

    append wa_itab TO it_itab.

    sort it_itab.

    LOOP AT it_itab INTO wa_itab.

    at first.

    write :/ 'details of sales order:'.

    uline.

    endat.

    at new num.

    write :/ 'serial num:', wa_itab-num.

    uline.

    endat.

    WRITE :/ wa_itab-num , wa_itab-name , wa_itab-amt.

    at end of num.

    uline.

    sum.

    write :/ 'total amount:',wa_itab-amt.

    uline.

    endat.

    *

    at last.

    sum.

    uline.

    write:/ 'grand total:',wa_itab-amt.

    endat.

    ENDLOOP.

    describe table it_itab lines v_lines.

    WRITE:/'no of records :', v_lines.

    reward if u find useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 08:02 AM

    Hi Shaheen MS,

    DATA: BEGIN OF LINE,

    COL1 TYPE C,

    COL2 TYPE I,

    COL3 TYPE I,

    END OF LINE.

    DATA ITAB LIKE HASHED TABLE OF LINE

    WITH UNIQUE KEY COL1 COL2.

    LINE-COL1 = 'A'.

    DO 3 TIMES.

    LINE-COL2 = SY-INDEX.

    LINE-COL3 = SY-INDEX ** 2.

    INSERT LINE INTO TABLE ITAB.

    ENDDO.

    LINE-COL1 = 'B'.

    DO 3 TIMES.

    LINE-COL2 = 2 * SY-INDEX.

    LINE-COL3 = ( 2 * SY-INDEX ) ** 2.

    INSERT LINE INTO TABLE ITAB.

    ENDDO.

    SORT ITAB.

    LOOP AT ITAB INTO LINE.

    WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.

    AT END OF COL1.

    SUM.

    ULINE.

    WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.

    SKIP.

    ENDAT.

    AT LAST.

    SUM.

    ULINE.

    WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.

    ENDAT.

    ENDLOOP.

    Plzz reward if it is useful,

    Mahi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 08:02 AM

    Hi,

    data: begin of itab,

    werks type werks,

    matnr type matnr,

    qty type i,

    end of itab.

    data: begin of itab1,

    werks type werks,

    matnr type matnr,

    qty type i,

    end of itab1.

    Sort itab by werks matnr.

    Loop at itab.

    AT END OF matnr.

    SUM.

    itab1-werks = itab-werks.

    itab1-matnr = itab-matnr.

    itab1-qty = itab-qty. (qty will be automatically summed up as SUM is used in at end of matnr.)

    APPEND itab1.

    ENDAT.

    Endloop.

    loop at itab1.

    write : / itab1.

    endloop.

    (output : qty will be summed based on plant and material. for each plant, total material quantity will be displayed.)

    AT LAST is used to do operation at the end of the loop.

    Edited by: Ramesh Hirial on Jan 28, 2008 5:03 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 08:12 AM

    types : begin of itab,

    x type i,

    y type i,

    z type i ,

    end of itab.

    data : itab1 type table of itab,

    wa_itab1 type itab.

    data : itab2 type table of itab.

    wa_itab1-x = 101.

    wa_itab1-y = 1001.

    wa_itab1-z = 1.

    append wa_itab1 to itab1.

    wa_itab1-x = 101.

    wa_itab1-y = 1001.

    wa_itab1-z = 2.

    append wa_itab1 to itab1.

    wa_itab1-x = 102.

    wa_itab1-y = 1002.

    wa_itab1-z = 2.

    append wa_itab1 to itab1.

    wa_itab1-x = 102.

    wa_itab1-y = 1002.

    wa_itab1-z = 3.

    append wa_itab1 to itab1.

    loop at itab1 into wa_itab1.

    write : /(20) wa_itab1-x ,wa_itab1-y ,wa_itab1-z .

    at end of x.

    sum.

    write :/ 'sum of y and z',wa_itab1-y,wa_itab1-z.

    endat.

    at last.

    write: / 'job over'.

    endat.

    endloop.

    reward with points if useful.

    thanks and regards

    vennila

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 28, 2008 at 08:25 AM

    data: begin of itab occurs o,

    name(20),

    amt like vbak-netwr,

    end of itab.

    do 10 times.

    itab-amt = itab-amt + 100.

    itab-name = 'ABC'.

    itab-amt = '100.25'.

    if sy-index gt 5.

    itab-name = 'ZYX'.

    endif.

    append itab.

    clear itab.

    enddo.

    loop at itab.

    write: /itab-name, itab-amt.

    at end of name.

    sum.

    write:/ 'The subtotal of', itab-name, 'is', itab-amt.

    endat.

    at last.

    sum.

    write:/ 'The total is', itab-amt.

    endat.

    endloop.

    Regards

    Praveen

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.