‎2006 Nov 14 6:32 AM
hi,
i have a requirement as below
kunnr sale order
1175 12365
1175 13563
1175 45646
here i have to take first and last row separety and store it in a field....
o/p should be like
1175 12365
1175 45646
thanks
kumar
‎2006 Nov 14 6:50 AM
‎2006 Nov 14 6:34 AM
HI,
use the control level events 'AT FIRST' and 'AT LAST' during looping.
Regard,
‎2006 Nov 14 6:36 AM
HI,
you can use READ TABLE ITAB INTO WA index 1.
and
READ TABLE ITAB INTO WA index sy-tfill.
Regards,
Sesh
‎2006 Nov 14 6:40 AM
what the solution given is only if i have only one kunnr but ....i am having different kunnrs... if i use at last the second field is coming as *******
how to proceed
thanks
‎2006 Nov 14 6:36 AM
U can use the read statement using index option
describe table itab lines n.
read table itab index 1. <b>this gives u the frist record</b>
read table itab index n. <b>gives the last record</b>
Regards
- Gopi
‎2006 Nov 14 6:37 AM
Hi,
Assuming that your table might contain different sales order nos. you can get the no. of lines of the table using describe command and then read the table with index = 1 and index = no. of lines in the table.
‎2006 Nov 14 6:37 AM
Initially u need to have the data into internal table according to ur requirement. if you want to sort it then sort it first and then u can use below code.
data: n type i.
data: itab1 type table of itab.
describe table itab lines n.
Read table itab into wa index 1.
append wa into itab1.
Read table itab index n.
append wa into itab1.
‎2006 Nov 14 6:46 AM
Hi,
If you need the first and the last record of your internal table.
U can use
READ table itab index 1.
And for the last statement do as below:
Describe table itab lines cnt
READ table itab index cnt.
If you wnat to get the firts and the last record for each kunnr.
The use AT FIRST and AT LAST statements in the LOOP.
‎2006 Nov 14 6:49 AM
‎2006 Nov 14 6:50 AM
‎2006 Nov 14 6:55 AM
hi Vibha Deshmukh ,
i have many kunnrs the internal table is like
1175 545646
1175 456464
1175 456465
1145 654564
1145 546546
how to proceed with that
thnaks
‎2006 Nov 14 7:01 AM
sort itab by kunnr.
Loop at itab.
l_index = sy-tabix.
at first kunnr.
read table itab into wa_itab index l_index.
append wa_itab into itab1.
endat.
at end of kunnr.
read table itab into wa_itab index l_index.
append wa_itab into itab1.
endat.
endloop.
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers