‎2007 Oct 05 5:42 AM
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?
‎2007 Oct 05 5:58 AM
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.
‎2007 Oct 05 5:46 AM
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
‎2007 Oct 05 5:51 AM
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
‎2007 Oct 05 5:58 AM
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.