12-20-2006 1:30 AM
Hi,all.
I want to deal with a itab,the form of the table like this:
FLAG NO. TEXT
a 001 my <-
b 001 you
c 002 he
a 003 she <-
s 001 hi
m 004 hello
g 008 he
a 007 mine <-
w 009 them
you see the field FLAG is a flag, i want to get some records, if the value of
FLAG = 'a',then get the follow records into another iternal table include these records which FLAG='a'. at last,it is:
ITAB 1:
a 001 my
b 001 you
c 002 he
ITAB 2:
a 003 she
s 001 hi
m 004 hello
g 008 he
ITAB 3:
a 007 mine
w 009 them
NEED YOUR HELP
12-20-2006 5:43 AM
DATA W_INDEX TYPE N.
DATA W_NAME TYPE STRING.
types: BEGIN OF ty_itab,
flag(1) type c,
no(3) type n,
text(10),
end OF ty_itab.
data: itab type table of ty_Itab with header line.
itab1 type table of ty_Itab with header line.
itab2 type table of ty_Itab with header line.
itab3 type table of ty_Itab with header line.
field-symbols <itab> type table.
ITAB-FLAG = 'A'. ITAB-TEXT = 'LINE1'. APPENd itab. "etc
loop at itab.
if itab-flag = 'A'.
add 1 to w_index.
concatenate 'ITAB' W_INDEX '[]' INTO W_NAME
ASSIGN (W_NAME) TO <itab>.
endif.
APPEND ITAB TO <ITAB>.
endloop.
loop at itab1.
write:/ itab1-flag.
endloop.
12-20-2006 2:36 AM
Hi,
The a records will it occur only thrice..meaning the a records that has the flag a can be in maximum of three rows..Otherwise we need to create dynamic internal table depends on the number of records that has flag as a..
Thanks,
Naren
12-20-2006 2:38 AM
12-20-2006 3:55 AM
you can do like this.
data : counter type i.
loop at itab.
if itab-flag = 'a'.
counter = counter + 1.
endif.
if counter = 1.
move-corresponding to itab1.
append itab1.
elseif counter = 2.
move-corresponding to itab2.
append itab2.
elseif counter = 3.
move-corresponding to itab3.
append itab3.
endif.
endloop.
regards
shiba dutta
12-20-2006 5:43 AM
DATA W_INDEX TYPE N.
DATA W_NAME TYPE STRING.
types: BEGIN OF ty_itab,
flag(1) type c,
no(3) type n,
text(10),
end OF ty_itab.
data: itab type table of ty_Itab with header line.
itab1 type table of ty_Itab with header line.
itab2 type table of ty_Itab with header line.
itab3 type table of ty_Itab with header line.
field-symbols <itab> type table.
ITAB-FLAG = 'A'. ITAB-TEXT = 'LINE1'. APPENd itab. "etc
loop at itab.
if itab-flag = 'A'.
add 1 to w_index.
concatenate 'ITAB' W_INDEX '[]' INTO W_NAME
ASSIGN (W_NAME) TO <itab>.
endif.
APPEND ITAB TO <ITAB>.
endloop.
loop at itab1.
write:/ itab1-flag.
endloop.