02-08-2008 9:49 AM
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
02-08-2008 9:54 AM
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
02-08-2008 9:52 AM
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
02-08-2008 9:54 AM
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
02-08-2008 9:54 AM
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
02-08-2008 9:54 AM
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.
02-08-2008 9:57 AM
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
02-08-2008 10:01 AM
Hi,
Try this...
LOOP.
AT NEW fld3.
write:fld1,fld2,fld3,fld4.
ENDAT.
write:fld4.
ENDLOOP.
Reward points if useful.
Regards,
Sowmya.