Skip to Content

* IN AT END OF.....ENDAT

Dear all,

Could ne 1 plz tell me why does * come while using AT END OF syntax.

eg loop at it_table into wa_table.

some processing.....

at end of wa_table-field.

some code

endat.

Why does * come into work area? Also all numeric fields turn to 0.

This question is just out of Curiosity

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:59 AM

    If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:

    The components of the current control key remain unchanged.

    All components with a character-type, flat data type to the right of the current control key are set to character "*" in every position.

    All the other components to the right of the current control key are set to their initial value.

    When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:53 AM

    AT NEW , AT END work properly only if the field u are refreering s the first field in internal table.. all the numeric field will become 0 and characters * once inside AT new block.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:52 AM

    to avoid that u need to read table itab index sy-tabix.

    after at end of statement

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:55 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:55 AM

    Hai,

    loop at it_table into wa_table.

    AT END OF syntax.

    Read table it_table into wa_table with key sy-tabix.

    some processing.....

    end of wa_table-field.

    some code

    endat.

    now stars wil not com

    regards

    kish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 09:57 AM

    AT END OF & ENDAT has a characteristic where the field which is specified in this statement all the fields to the left of the fields in the table will turn in to its initial value (i.e **** for character fields and '0' for the numeric fields. Right fields will be printed with its value.

    Rewards if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 28, 2007 at 10:00 AM

    Dear all,

    Why does * and 0 come in the first place??There surely has to be some reason behin it

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 10:05 AM

    Rahul,

    No !dea why SAP has done like this, eevn i have wondered why.. i too watching this thread to know the reason.

    Add a comment
    10|10000 characters needed characters exceeded

    • Just going through i again,i guess it is coz of this:-

      Loop at int_table into wa_table.

      some processing.

      at end of field

      endat

      endloop

      so i guess what must be happening is that when we are looping ,an event is getting triggered .the moment at end of is triggerd ,while looping SAP understands that the previous data has to be processed with before moving on,,so the new data is converted to * .i guess there cant be any other reason....Does ne 1 know

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 10:19 AM

    Hi

    • 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

  • Posted on Nov 28, 2007 at 10:23 AM

    Just going through i again,i guess it is coz of this:-

    Loop at int_table into wa_table.

    some processing.

    at end of field

    endat

    endloop

    so i guess what must be happening is that when we are looping ,an event is getting triggered .the moment at end of is triggerd ,while looping SAP understands that the previous data has to be processed with before moving on,,so the new data is converted to * .i guess there cant be any other reason...(As xplained by Imtiyaz)

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      If you are working with a work area wa, it does not contain the current line in the AT-ENDATstatement block. All character fields to the right of the current group key are filled with asterisks (*). All other fields to the right of the current group key contain their initial value.

      Because in ENDAT you can use only SUM operations of the numeric fields...

      So other fields are filled with *.

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.