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

Internal table data manipulation

Former Member
0 Likes
546

Hi,

i have itab data as below:

<b>a

ab

abc

abcd----need to pass this line to another itab

efg

efgh----need to pass this line to another itab

ijk

ijkl----need to pass this line to another itab</b>

First i need to pass 4th line data to another itab and subsequest second line values need to pass to another itab.

How to do that?

1 ACCEPTED SOLUTION
Read only

former_member188827
Active Contributor
0 Likes
487

try da code ..its working

types:begin of it,

zch(4),

end of it.

data:itab TYPE TABLE OF it WITH HEADER LINE,itab1 TYPE TABLE OF it WITH HEADER LINE.

itab-zch = 'a'.

APPEND itab.

itab-zch = 'ab'.

APPEND itab.

itab-zch = 'abc'.

APPEND itab.

itab-zch = 'abcd'.

APPEND itab.

itab-zch = 'efg'.

APPEND itab.

itab-zch = 'efgh'.

APPEND itab.

itab-zch = 'ijk'.

APPEND itab.

itab-zch = 'ijkl'.

APPEND itab.

data count1 TYPE i.

loop at itab.

count1 = sy-tabix.

ENDLOOP.

data count type i.

count = 4.

LOOP at itab.

if sy-tabix = count and sy-tabix le count1.

move-CORRESPONDING itab to itab1.

APPEND itab1.

count = count + 2.

endif.

endloop.

loop at itab1.

WRITE / itab1-zch.

ENDLOOP.

3 REPLIES 3
Read only

former_member188827
Active Contributor
0 Likes
487

types:begin of it,

zch(4),

end of it.

data:itab TYPE TABLE OF it WITH HEADER LINE,itab1 TYPE TABLE OF it WITH HEADER LINE.

itab-zch = 'a'.

APPEND itab.

itab-zch = 'ab'.

APPEND itab.

itab-zch = 'abc'.

APPEND itab.

itab-zch = 'abcd'.

APPEND itab.

itab-zch = 'efg'.

APPEND itab.

itab-zch = 'efgh'.

APPEND itab.

itab-zch = 'ijk'.

APPEND itab.

itab-zch = 'ijkl'.

APPEND itab.

data count1 TYPE i.

loop at itab.

count1 = sy-tabix.

ENDLOOP.

data count type i.

count = 4.

LOOP at itab.

if sy-tabix = count and sy-tabix le count1.

move-CORRESPONDING itab to itab1.

APPEND itab1.

count = count + 2.

endif.

endloop.

loop at itab1.

WRITE / itab1-zch.

ENDLOOP.

Message was edited by:

abapuser

Read only

Former Member
0 Likes
487

Hi

If it is always a record which is having 4 char then

we can use the STRLEN fun and then move into another itab.

data v_len type i.

loop at ITAB.

v_len = STRLEN( itab-field )

if v_len = 4.

itab1-field = itab-field.

append itab1.

endif.

clear itab1.

endloop.

there should be some distinction for that record which has to be moved to other int table , based on that condition we can move it

Regards

Anji

Read only

former_member188827
Active Contributor
0 Likes
488

try da code ..its working

types:begin of it,

zch(4),

end of it.

data:itab TYPE TABLE OF it WITH HEADER LINE,itab1 TYPE TABLE OF it WITH HEADER LINE.

itab-zch = 'a'.

APPEND itab.

itab-zch = 'ab'.

APPEND itab.

itab-zch = 'abc'.

APPEND itab.

itab-zch = 'abcd'.

APPEND itab.

itab-zch = 'efg'.

APPEND itab.

itab-zch = 'efgh'.

APPEND itab.

itab-zch = 'ijk'.

APPEND itab.

itab-zch = 'ijkl'.

APPEND itab.

data count1 TYPE i.

loop at itab.

count1 = sy-tabix.

ENDLOOP.

data count type i.

count = 4.

LOOP at itab.

if sy-tabix = count and sy-tabix le count1.

move-CORRESPONDING itab to itab1.

APPEND itab1.

count = count + 2.

endif.

endloop.

loop at itab1.

WRITE / itab1-zch.

ENDLOOP.