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: 

How to get the data

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

former_member186741
Active Contributor
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

HI,could you give me a Demo?

Former Member
0 Kudos

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

former_member186741
Active Contributor
0 Kudos

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.