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

number the items

Former Member
0 Likes
2,083

I'd like to have the items in the internal table numbered as follows:

column a column b column c

1. he 12345 fgd012

2. wa 44465 fgs768

3. aa 33321 gdge9

****************************

count type i.

loop at itab.

count = count + 1.

endloop.

write: count1 , column a.

****************************

this code is not working! thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,055

u have the internal table as....

column a column b column c

he 12345 fgd012

wa 44465 fgs768

aa 33321 gdge9

so u need numbers to the rows of the internal table....

data: count type i value 0.

<b>loop at itab.

itab-column1 = count + 1.

modify itab index sy-tabix.

clear: itab.

endloop.</b>

so ur internal table will have data as

column1 column a column b column c

1 he 12345 fgd012

2 wa 44465 fgs768

3 aa 33321 gdge9

Award Points...

22 REPLIES 22
Read only

Former Member
0 Likes
2,054

Hello,

Change the code like this:

count type i.

loop at itab.

count = count + 1.

new-line.

<b>write: count1 ,itab-column a.</b>

endloop.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
2,054

Hi Shaheen

Try DESCRIBE Statement if you need to know the number of records.

or

loop at itab.
  write:/ sy-index,
       10 itab-a,
       20 itab-b.
   ....
endloop.

Regards

Eswar

Read only

Former Member
0 Likes
2,056

u have the internal table as....

column a column b column c

he 12345 fgd012

wa 44465 fgs768

aa 33321 gdge9

so u need numbers to the rows of the internal table....

data: count type i value 0.

<b>loop at itab.

itab-column1 = count + 1.

modify itab index sy-tabix.

clear: itab.

endloop.</b>

so ur internal table will have data as

column1 column a column b column c

1 he 12345 fgd012

2 wa 44465 fgs768

3 aa 33321 gdge9

Award Points...

Read only

Former Member
0 Likes
2,054

if you want to write the data

loop at itab.

write : / sy-tabix, itab-colmna.

endloop.

regards

shiba dutta

Read only

Former Member
0 Likes
2,054

add a field to internal table for count

data: begin of itab occurs 0,

<b> count type i,</b>

col1--

--

end of itab.

declare another variable of type integer to use in the loop

data c type i.

then

loop at itab.

c = c + 1.

read table itab index c.

if sy-subrc eq 0.

itab-count = c.

modify itab index c transporting count .

endif.

endloop.

now display and see the itab contents. it meets ur requirement

Read only

0 Likes
2,054

I trying this code but getting an error say that -


>

the internal table has no header line.

please help.

Read only

Former Member
0 Likes
2,054

Hi,

Try this..

LOOP AT ITAB.

WRITE:/ SY-TABIX, " Row no

ITAB-A, " column a

ITAB-B, " column b

ITAB-C. " column c

ENDLOOP.

Thanks,

Naren

Read only

0 Likes
2,054

same error again

Read only

0 Likes
2,054

your itab is without header line so you have to do it by assigning it to a work area.

data : wa like itab.

loop at itab into wa.

write : / sy-tabix,

wa-colmna.

endloop.

regards

shiba dutta

Read only

0 Likes
2,054

Hi Shaheen

Can you post your code, maybe that can help us to identify the error and rectify the same.

Regards

Eswar

Read only

0 Likes
2,054

yes I did as you suggest and this time I'm not getting the error thanks alot, but it is still not working.... I'm still having the rows not numbered..... any suggestions plaese

Read only

0 Likes
2,054

i think you ant to modify your itab.

then

loop at itab into wa.

wa-slno = sy-tabix.

modify itab from wa.

endloop.

here specify slno as type i in your itab.

regards

shiba dutta

Read only

0 Likes
2,054

still .... I guess I need a write stat.

Read only

0 Likes
2,054

I tried it .... this one also not working .any suggestions plaese

Read only

0 Likes
2,054

Your code would help for better advices as i said earlier... Post the same...

Regards

Eswar

Read only

0 Likes
2,054

I already gave the code in my question

Read only

0 Likes
2,054

That doesnt help to get any picture...

Read only

0 Likes
2,054
*1. he 12345 fgd012
*2. wa 44465 fgs768
*3. aa 33321 gdge9

data : begin of itab occurs 0,
       f1(4) type c,
       f2(8) type c,
       f3(8) type c,
       end of itab.

       itab-f1 = 'HE'.
       itab-f2 = '12345'.
       itab-f3 = 'FGD012'.
       APPEND ITAB.

       itab-f1 = 'WA'.
       itab-f2 = '44465'.
       itab-f3 = 'FGS768'.
       APPEND ITAB.

       itab-f1 = 'AA'.
       itab-f2 = '33321'.
       itab-f3 = 'GDGE9'.
       APPEND ITAB.



       LOOP AT ITAB.
       WRITE:/ SY-TABIX, ITAB-F1 , ITAB-F2, ITAB-F3.
       ENDLOOP.

Execute the code and make use of the field sy-tabix for cnt instead of handling with logic.

regards,

vijay.

Please close the thread

Read only

0 Likes
2,054

Thanks everyone.

Read only

Former Member
0 Likes
2,054

Hi,

Move the row to a work area.

Example

-


DATA: WA LIKE LINE OF ITAB.

LOOP AT ITAB INTO WA.

WRITE:/ SY-TABIX, " Row no

WA-A, " column a

WA-B, " column b

WA-C. " column c

ENDLOOP.

Thanks,

Naren

Read only

SantoshKallem
Active Contributor
0 Likes
2,054

write: count. (in ur code it is count1)

Read only

former_member188827
Active Contributor
0 Likes
2,054

try dis...

LOOP AT iTAB.

WRITE:/ sy-tabix, iTAB-F1 , iTAB-F2, iTAB-F3.

ENDLOOP.