Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

AT NEW command in loop statement

former_member392866
Active Participant
0 Likes
28,749

Hi Experts,

Inrenal table data:

A    B     C

------------------

2p   01   x

2p   01    y

2p   01    z

Now i'm looping above internal table for displaying data using write statements

Expected Output:

--------------------------

2p   01  x

            y

            z

Rewards if helpful.

Thank you.

Regards,

BALAJI.

Moderator Message: Basic question. Please read the sap documentation.

Message was edited by: Kesavadas Thekkillath

4 REPLIES 4
Read only

former_member194152
Contributor
6,522

Try this code :

Report Ytest.





data : begin of itab OCCURS 0,

         a type char2,

         b type char2,

         c type char1,

       end of itab.



data : begin of itab1 OCCURS 0,

         a type char2,

         b type char2,

         c type char1,

       end of itab1.



       itab-a = '2p'. itab-b = '01'. itab-c = 'X'. append itab.

       itab-a = '2p'. itab-b = '01'. itab-c = 'Y'. append itab.

       itab-a = '2p'. itab-b = '01'. itab-c = 'Z'. append itab.



       sort itab by a b.



       loop at itab.

         at new b.

           itab1-a = itab-a.

           itab1-b = itab-b.

         endat.

          itab1-c = itab-c.

          append itab1.

          clear itab1.

       endloop.



       loop at itab1.

         write : / itab1-a,itab1-b,itab1-c.

       endloop.

Regards,

Gagan

Read only

0 Likes
6,522

Thank you Gagan....

Read only

sandeep_katoch
Contributor
0 Likes
6,522

Hi Balaji,

Try this out

Loop at internal_table  into work area

At New B

Write : /  A

Endat

Endloop

This is just a pseudo code.

For more detials you can refer to

http://wiki.sdn.sap.com/wiki/display/ABAP/Control+Level+Statements+in+ABAP

Here you can find many examples of at new inside loop.

Hope it helps

Rgds,

Sandeep Katoch

Read only

Former Member
6,522

Loop at it into wa.
           at new A.
           Write : wa-A , wa-B.
           endat.
           Write: wa-C.
           endloop.

Try like this.

I think U need to handel AT New * and formatiing also u need to do.

But this Logic Will Work For U