Application Development 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: 

At new

abdulazeez12
Active Contributor
0 Kudos

Hi

I have itab with fld1 fld2 fld3 fld4 fields..sorted in same order..

i want to print this way:

-


fld1 fld2 fld3 fld4

fld4

fld4

fld4

if any of fld1 fld2 fld3 changes, again all three fields shud be displayed along with fld4..

pls help

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try this..........

sort itab by fld1 fld2 fld3 fld4.
loop at itab.
at new fld3.
write : /2itab-fld1,12itab-fld2,22itab-fld3,32itab-fld4.
exit.
endat.
write : /32itab-fld4.
endloop.

Cheers,

jose.

Edited by: jose on Feb 8, 2008 10:59 AM

6 REPLIES 6

Former Member
0 Kudos

you will have to take these three fields in separate variables before at new and then print them after at new .

this is becoz after at new only field left side to field in at new statement are recognized and fields at right side are not.

this will surely help u

plz reward if useful

vivek

Former Member
0 Kudos

try this..........

sort itab by fld1 fld2 fld3 fld4.
loop at itab.
at new fld3.
write : /2itab-fld1,12itab-fld2,22itab-fld3,32itab-fld4.
exit.
endat.
write : /32itab-fld4.
endloop.

Cheers,

jose.

Edited by: jose on Feb 8, 2008 10:59 AM

former_member386202
Active Contributor
0 Kudos

Hi,

declare 2 work area.

data wa1 type itab.

data : wa2 type itab.

Sort itab by Field1 Field2 Field3 Field4.

Loop at itab into wa1.

wa2 = wa1.

at new field3.

write : w2-field4.

like this.

endat.

endloop.

Regards,

Prashant

Former Member
0 Kudos

hi,

Move the values of the four fields to 4 variables, v1,v2,v3,v4.

now write this code

loop at itab.

write : ( write for the first time)

If v1 NE fld1 or v2 NE fld2 or v3 NE fld3 or v4 NE fld4.

write: ( print the values as you wish )

endif.

endloop.

The if statement will be executed only if there is a change in the values.

reward if helpful.

Former Member
0 Kudos

I think this will work in a much better way.

write : ( write for the first time)

loop at itab.

If v1 NE fld1 or v2 NE fld2 or v3 NE fld3 or v4 NE fld4.

write: ( print the values as you wish )

endif.

endloop.

NE stands for not equalto

Former Member
0 Kudos

Hi,

Try this...

LOOP.

AT NEW fld3.

write:fld1,fld2,fld3,fld4.

ENDAT.

write:fld4.

ENDLOOP.

Reward points if useful.

Regards,

Sowmya.