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

regarding the AT END

hi,

i had written the following code as below

LOOP AT IT_WEMNG INTO WA_WEMNG WHERE EBELN = WA_EKPO-EBELN

AND EBELP = WA_EKPO-EBELP.

IF SY-TABIX = 1.

MOVE WA_WEMNG-EINDT TO WA_EKPO-EINDT.

ENDIF.

W_WEMNG = W_WEMNG + WA_WEMNG-WEMNG.

AT LAST.

MOVE W_WEMNG TO WA_EKPO-WEMNG.

ENDAT.

ENDLOOP.

but in the extended code check it is giving an error.

Please correct me.

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 06:22 AM

    see this sample program

    • 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 Apr 01, 2008 at 06:25 AM

    Hello,

    Can I know what is the error in extended chaeck? I don;t see anything wrong in your code

    Thanks,

    Anil

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 06:26 AM

    AT statements should not be used alongwith where clause in loop. This causes errors in execution of these statements.

    Also do not remove where clause and add it as IF condition inside the loop. Basically AT statements should not be conditionally executed.

    You can write IF conditions inside AT statements. Modify your code to use conditions inside AT statement and not before it.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 01, 2008 at 06:29 AM

    hi Surya,

    the problem is: WHERE conditions in your LOOP, that means probably not each line of the internal table will be processes. On the other hand the AT ... commands will be processed on the original internal table, which can lead to a situatio that AT ... won't run on any line (because that line was sorted out by the WHERE condition)

    hope this helps

    ec

    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.