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

AT new , At End of

Hi,

For At End Of , Suppose I have an internal table with fields MATNR, MAKTX,POSNR,and suppose I want to do some calculations "At End Of " POSNR then the internal table should have First field as POSNR.

Is it applicable to "At New" also???

regards

Avi......

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2007 at 10:31 AM

    Hi,

    Yes, You have to keep the POSNR as first field and to sort the Int table :

    SORT itab by posnr matnr maktx.

    Then only you can do totals using AT END OF POSNR>

    Same is applicable to AT NEW also.

    Regards,

    Anji

    Message was edited by:

    Anji Reddy Vangala

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 21, 2007 at 10:31 AM

    Yes. If it is not, then it will consider the concatenation of matnr+ vbeln +posnr as one field, and will trigger on change of any of those fields.

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2007 at 10:32 AM

    I believe so. If you do at end of posnr, where matnr, maktx and posnr are the table fields in that order, the routine will be entered when there is a change to matnr, maktx or posnr.

    Cheers Stephen

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2007 at 10:34 AM

    ur internal table should have posnr as the first field....if this is so, then At NEW or AT END will work properly.....if this is not first field, it works but sometimes gives wrong data.....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 07:22 AM

    hi Avi,

    Better to use another primary field at AT END OF.Even though i can understand ur problem.Thats why i develop a small code for ur problem.I think that is very much helpful for u.

    If u satisfy with the code plz give me the REWARD POINTS.

    plz copy the below code and execute it ok.

    code:

    ----


    • Tables

    ----


    tables:vbap.

    ----


    • Internal Table

    ----


    DATA: BEGIN OF itab OCCURS 0,

    vbeln LIKE vbap-vbeln, " Sales Doc No

    matnr LIKE vbap-matnr, " Material Number

    posnr LIKE vbap-posnr, " Sales Doc Item

    END OF itab.

    data: total type i. " Toatal value is hold.

    ----


    • Selection Screen

    ----


    SELECTION-SCREEN: BEGIN OF BLOCK b1 with frame TITLE text-001.

    SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.

    selection-screen: END OF BLOCK b1.

    initialization.

    perform initial.

    ----


    • Fetch data

    ----


    START-OF-SELECTION.

    PERFORM fetch_data.

    ----


    • Fetch data

    ----


    END-OF-SELECTION.

    perform diplay_data.

    &----


    *& Form fetch_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fetch_data .

    SELECT vbeln

    matnr

    posnr

    FROM vbap

    INTO TABLE itab

    WHERE vbeln IN s_vbeln.

    ENDFORM. " fetch_data

    &----


    *& Form diplay_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form diplay_data .

    sort itab by vbeln posnr.

    loop at itab.

    at first.

    write:/ 'VBELN', 20 'MATNR', 40 'POSNR'.

    uline.

    endat.

    at new vbeln.

    write: / itab-vbeln.

    endat.

    write: /20 itab-matnr,

    40 itab-posnr.

    total = total + itab-posnr.

    at end of vbeln.

    write:/20 'TOTAL = ',total.

    clear total.

    endat.

    at last.

    write:/40 'TOTAL = ',total.

    endat.

    endloop.

    endform. " diplay_data

    &----


    *& Form initial

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form initial .

    s_vbeln-sign = 'I'.

    s_vbeln-option = 'BT'.

    s_vbeln-low = '4969'.

    s_vbeln-high = '5000'.

    append s_vbeln.

    endform. " initial

    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.