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

AT NEW

I have an internal table i_vbep which contains

VBEP		POSNR		ETENR		MBDAT
0000000001	000010	 0001		09/06/2007
0000000001	000020	0001		09/06/2007
0000000001	000020	0002		09/07/2007
0000000002	000020	0001		09/06/2007
0000000002	000020	0002		09/08/2007
0000000002	000030	0001		09/06/2007
0000000002	000030	0002		09/10/2007

I need to apply a MBDAT filter s_mbdat to this internal table and delete those rows that dont meet the criteria. If item has only one ETENR i.e. 0001 then apply s_mbdat to the MBDAT. If it has more than one ETENR i.e. 0001, 0002, then apply check for s_mbdat in both the MBDATs. Can someone help me with the code.

Message was edited by:

Megan Flores

Message was edited by:

Megan Flores

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 01:21 PM

    HI

    SEE MY PROGRAM USE IN THIS WAY

    I HAD TAKEN ONE EXMPLE

    * 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.

    REWARD IF USEFULL

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 01:22 PM

    Hi ..

    AT NEW command cannot be Nested... So change the code like this and write ur Logic..

    DATA: idx1 TYPE sy-tabix, idx2 TYPE sy-tabix.

    LOOP AT i_vbep INTO wa_vbep.

    MOVE i_vbep TO i_vbep_temp.

    idx1 = sy-tabix.

    idx2 = sy-tabix.

    WRITE:/ 'IDX1', idx1.

    AT NEW vbeln.

    ENDAT.

    AT NEW etenr.

    WRITE:/ 'IDX2', idx2.

    ENDAT.

    ENDLOOP.

    <b>reward if helpful</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 01:22 PM

    LOOP AT i_vbep INTO wa_vbep where MBDAT in s_mbdat.

    WRITE :/ wa_vbep-vbep,

    wa_vbep-posnr,

    wa_vbep-etenr,

    wa_vbep-mbdat.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 01:45 PM

    hi

    good

    go through it and use AT NEW accordingly.

    You can use control level statements to react to control breaks in internal tables instead of programming them yourself with logical expressions. Within the loop, you must order the AT-ENDAT statement blocks according to the hierarchy of the control levels. If the internal table has the columns <f1>, <f 2>, ...., and if it is sorted by these columns, you must program the loop as follows:

    LOOP AT <itab>.

    AT FIRST. ... ENDAT.

    AT NEW <f1>. ...... ENDAT.

    AT NEW <f2 >. ...... ENDAT.

    .......

    <single line processing>

    .......

    AT END OF <f2>. ... ENDAT.

    AT END OF <f1>. ... ENDAT.

    AT LAST. .... ENDAT.

    ENDLOOP.

    thanks

    mrutyun^

    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.