2007 Jan 22 10:04 AM
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.
2007 Jan 22 10:12 AM
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...
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.
2007 Jan 22 10:06 AM
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
2007 Jan 22 10:06 AM
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
2007 Jan 22 10:12 AM
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...
2007 Jan 22 10:39 AM
if you want to write the data
loop at itab.
write : / sy-tabix, itab-colmna.
endloop.
regards
shiba dutta
2007 Jan 22 10:44 AM
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
2007 Jan 23 4:46 AM
I trying this code but getting an error say that -
>
the internal table has no header line.
please help.
2007 Jan 23 4:51 AM
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
2007 Jan 23 4:58 AM
2007 Jan 23 5:04 AM
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
2007 Jan 23 5:08 AM
Hi Shaheen
Can you post your code, maybe that can help us to identify the error and rectify the same.
Regards
Eswar
2007 Jan 23 5:09 AM
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
2007 Jan 23 5:13 AM
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
2007 Jan 23 6:48 AM
2007 Jan 23 7:27 AM
I tried it .... this one also not working .any suggestions plaese
2007 Jan 23 7:31 AM
Your code would help for better advices as i said earlier... Post the same...
Regards
Eswar
2007 Jan 23 7:34 AM
2007 Jan 23 7:41 AM
2007 Jan 23 7:46 AM
*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
2007 Jan 23 7:52 AM
2007 Jan 23 5:01 AM
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
2007 Jan 23 5:16 AM
2007 Jan 23 8:03 AM
try dis...
LOOP AT iTAB.
WRITE:/ sy-tabix, iTAB-F1 , iTAB-F2, iTAB-F3.
ENDLOOP.