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

Problem in AT LAST COMMAND

Hello Friends,

I have the following code

Data : Begin of itab occurs 0,

sumso (18),

valut(15),

sumha(18),

end of itab.

DATA :TOTAL.

LOOP AT ITAB INTO WA_ITAB.

AT LAST.

SUM.

TOTAL =

WA_ITAB-SUMSO.

ENDAT.

ENDLOOP.

While executing ,'*****'

is getting in filled in wa_itab-sumso and throwing dump error.

How to resolve this ?

Hari

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:24 AM

    sample program

    see this

    • Using AT FIRST , AT NEW, AT THE END OF , AT LAST.

    DATA: BEGIN OF ITAB OCCURS 0,

    F1 TYPE I,

    F2(6) TYPE C,

    F3(10) TYPE N,

    F4(16) TYPE P DECIMALS 2,

    END OF ITAB.

    DATA: SUB_TOT(10) TYPE P DECIMALS 3.

    **--1

    ITAB-F1 = 1.

    ITAB-F2 = 'ONE'.

    ITAB-F3 = 10.

    ITAB-F4 = '1000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-F1 = 1.

    ITAB-F2 = 'ONE'.

    ITAB-F3 = 20.

    ITAB-F4 = '2000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-F1 = 1.

    ITAB-F2 = 'ONE'.

    ITAB-F3 = 30.

    ITAB-F4 = '3000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    *--2

    ITAB-F1 = 2.

    ITAB-F2 = 'TWO'.

    ITAB-F3 = 10.

    ITAB-F4 = '1000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-F1 = 2.

    ITAB-F2 = 'TWO'.

    ITAB-F3 = 20.

    ITAB-F4 = '2000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    *-- 3

    ITAB-F1 = 3.

    ITAB-F2 = 'THREE'.

    ITAB-F3 = 10.

    ITAB-F4 = '1000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    ITAB-F1 = 3.

    ITAB-F2 = 'THREE'.

    ITAB-F3 = 20.

    ITAB-F4 = '2000.00'.

    APPEND ITAB.

    CLEAR ITAB.

    SORT ITAB BY F1.

    LOOP AT ITAB.

    AT FIRST.

    WRITE: /35 ' MATERIAL DETAILS:'.

    ULINE.

    ENDAT.

    AT NEW F1.

    WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.

    ULINE.

    ENDAT.

    WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.

    SUB_TOT = SUB_TOT + ITAB-F4.

    AT END OF F1.

    ULINE.

    WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.

    CLEAR SUB_TOT.

    ENDAT.

    AT LAST.

    SUM.

    ULINE.

    WRITE: 'SUM:', ITAB-F4.

    ULINE.

    ENDAT.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:28 AM

    Data : Begin of itab occurs 0,

    sumso (18),

    valut(15),

    sumha(18),

    end of itab.

    DATA :TOTAL.

    sort itab by sumso valut sumha. <--- write this statement

    LOOP AT ITAB INTO WA_ITAB.

    AT LAST.

    read table ITAB index sy-tabix. <--- write this statement

    SUM.

    TOTAL =

    WA_ITAB-SUMSO.

    ENDAT.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:29 AM

    Hi

    DATA :TOTAL type p decimals 2.

    data : lwa_tab type itab.

    LOOP AT ITAB INTO WA_ITAB.

    lwa_tab = wa_tab.

    AT LAST.

    SUM.

    TOTAL =

    l_WA_ITAB-SUMSO.

    ENDAT.

    ENDLOOP.

    regards

    Shiva

    regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:32 AM

    HI, use this code

    Data : Begin of itab occurs 0,

    sumso (18),

    valut(15),

    sumha(18),

    end of itab.

    DATA :TOTAL.

    LOOP AT ITAB INTO WA_ITAB.

    AT LAST.

    SUM.

    write: itab-sumso.

    ENDAT.

    ENDLOOP.

    Regards,

    S.Nehru.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:37 AM

    declare variables of type i.

    TYPES : BEGIN OF itab,

    sumso type i,

    valut type i,

    sumha type i,

    END OF itab.

    DATA : t_itab TYPE STANDARD TABLE OF itab,

    wa_itab TYPE itab,

    total type i.

    wa_itab-sumso = 2.

    wa_itab-sumha = 3.

    append wa_itab to t_itab.

    wa_itab-sumso = 2.

    wa_itab-sumha = 3.

    append wa_itab to t_itab.

    LOOP AT t_itab INTO wa_itab.

    AT LAST.

    SUM.

    total = wa_itab-sumso.

    ENDAT.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:41 AM

    try using the above code and give a write statement.. then only u ll b able to check the answer.

    Hope this ll help u!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 09:42 AM

    Hi,

    Use the foloowing code.

    DATA : BEGIN OF ITAB OCCURS 0,

    SUMSO(18),

    VALUT(15),

    SUMHA(18),

    END OF ITAB.

    DATA :TOTAL LIKE ITAB-SUMSO,

    WA_ITAB LIKE ITAB.

    ITAB-SUMSO = '247385'.

    ITAB-VALUT = '437965'.

    ITAB-SUMHA = '365376'.

    APPEND ITAB. CLEAR ITAB.

    ITAB-SUMSO = '247384'.

    ITAB-VALUT = '437966'.

    ITAB-SUMHA = '3653767'.

    APPEND ITAB. CLEAR ITAB.

    LOOP AT ITAB INTO WA_ITAB.

    TOTAL = TOTAL + WA_ITAB-SUMSO.

    AT LAST.

    WRITE :/1 TOTAL.

    ENDAT.

    ENDLOOP.

    Regards,

    Sankar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 10:05 AM

    Using the the Statement 'SUM' you can only get the sum of numeric fields not character fields. So try to change the type of sumso to integer(numeric).

    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.