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

ITAB

Former Member
0 Likes
862

Hi Experts,

I have a itab like this.

data: begin of itab occurs 0,

finaltext(1000),

end of itab.

and when i exicute my pgm the above itab contains data like this:

1

ITEM1

THIS IS ITEM1

2

ITEM2

THIS IS ITEM2

3

ITEM3

THIS IS ITEM3

4

ITEM4

THIS IS ITEM4

5

ITEM5

THIS IS ITEM5

6

ITEM6

THIS IS ITEM6

7

ITEM7

THIS IS ITEM7

So i have one more jtab like this:

data: begin of jtab occurs 0,

pnumber(10),

pname(20),

pdes(50),

end of jtab.

So i want to append data from itab to Jtab.

output shold come in jtab like this:

1 ITEM1 THIS IS ITEM1

2 ITEM2 THIS IS ITEM2

3 ITEM3 THIS IS ITEM3

4 ITEM4 THIS IS ITEM4

5 ITEM5 THIS IS ITEM5

6 ITEM6 THIS IS ITEM6

7 ITEM7 THIS IS ITEM7

Can any body tell me how to do that?

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
805

DATA : V_TABIX TYPE SY-TABIX.

LOOP AT ITAB.

jtab-pnumber = ITAB-FINALTEXT.

V_TABIX = SY-TABIX + 1.

READ TABLE ITAB INDEX V_TABIX.

jtab-pname = ITAB-FINALTEXT.

V_TABIX = SY-TABIX + 2.

READ TABLE ITAB INDEX V_TABIX.

jtab-pdes = ITAB-FINALTEXT.

APPEND JTAB.

ENDLOOP.

Regards,

Srikanth

small correct in the second V_tabix its replaced with 2.

not 1.

Message was edited by: Srikanth Kidambi

8 REPLIES 8
Read only

Former Member
0 Likes
805

have u tried my answer which i had posted yesterday

check the last 2 answers

Read only

Former Member
0 Likes
806

DATA : V_TABIX TYPE SY-TABIX.

LOOP AT ITAB.

jtab-pnumber = ITAB-FINALTEXT.

V_TABIX = SY-TABIX + 1.

READ TABLE ITAB INDEX V_TABIX.

jtab-pname = ITAB-FINALTEXT.

V_TABIX = SY-TABIX + 2.

READ TABLE ITAB INDEX V_TABIX.

jtab-pdes = ITAB-FINALTEXT.

APPEND JTAB.

ENDLOOP.

Regards,

Srikanth

small correct in the second V_tabix its replaced with 2.

not 1.

Message was edited by: Srikanth Kidambi

Read only

0 Likes
805

Hi Srikanth,

I think you are wrong..

Pls test ur code.

Read only

0 Likes
805

hi,

just i changed code little bit

for the second V_TABIX = sy-tabix + 1 is wrong.

use SY-TABIX + 2.

i hope that will work.

regards

srikanth.

Read only

Former Member
0 Likes
805

Hi ,

try this.

count = 0.

loop at itab.

if count eq 0.

jtab-pnumber = itab-finaltext.

count = count + 1

else if count eq 1.

jtab-pname = itab-finaltext.

count = count + 1.

else if count eq 2.

jtab-pdes = itab-finaltext.

count = 0.

append jtab.

endif.

regards,

Sumit.

Read only

Former Member
0 Likes
805

Hi ravi,

1. I have written the code.

2. It will get what u want.

3. just copy paste.

4.

report abc.

*----


data: begin of itab occurs 0,

finaltext(1000),

end of itab.

data: begin of jtab occurs 0,

pnumber(10),

pname(20),

pdes(50),

end of jtab.

DATA : NUM TYPE I.

DATA : HOWMANY TYPE I.

DATA : CTR TYPE I.

DATA : MYIND TYPE SY-INDEX.

*----


START-OF-SELECTION.

itab-finaltext = '1'.

append itab.

itab-finaltext = 'ITEM1'.

append itab.

itab-finaltext = 'THIS IS ITEM1 '.

append itab.

itab-finaltext = '2'.

append itab.

itab-finaltext = 'ITEM2'.

append itab.

itab-finaltext = 'THIS IS ITEM2 '.

append itab.

*----


DESCRIBE TABLE ITAB.

NUM = SY-TFILL.

HOWMANY = NUM / 3.

DO HOWMANY TIMES.

MYIND = ( SY-INDEX - 1 ) * 3 + 1.

CLEAR JTAB.

READ TABLE ITAB INDEX MYIND.

CONDENSE ITAB-FINALTEXT.

JTAB-PNUMBER = ITAB-FINALTEXT.

MYIND = MYIND + 1.

READ TABLE ITAB INDEX MYIND.

CONDENSE ITAB-FINALTEXT.

JTAB-PNAME = ITAB-FINALTEXT.

MYIND = MYIND + 1.

READ TABLE ITAB INDEX MYIND.

CONDENSE ITAB-FINALTEXT.

JTAB-PDES = ITAB-FINALTEXT.

APPEND JTAB.

ENDDO.

BREAK-POINT.

regards,

amit m.

Read only

0 Likes
805

Hi All,

Thanks ..It works

Read only

Former Member
0 Likes
805

Hi Ravi,

Check the last two replies this query is already answered there, when you post a query try to follow it.

Regards,

Arun Sambargi.