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

how to do this

Former Member
0 Likes
1,037

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
972

Have u tried with the code that I have given

11 REPLIES 11
Read only

dani_mn
Active Contributor
0 Likes
972

HI,

use the control level events 'AT FIRST' and 'AT LAST' during looping.

Regard,

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
972

HI,

you can use READ TABLE ITAB INTO WA index 1.

and

READ TABLE ITAB INTO WA index sy-tfill.

Regards,

Sesh

Read only

0 Likes
972

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

Read only

gopi_narendra
Active Contributor
0 Likes
972

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

Read only

former_member283648
Participant
0 Likes
972

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.

Read only

Former Member
0 Likes
972

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.

Read only

Former Member
0 Likes
972

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.

Read only

0 Likes
972

i intented to say at end of.......... not at last

thanks

Read only

Former Member
0 Likes
973

Have u tried with the code that I have given

Read only

0 Likes
972

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

Read only

0 Likes
972

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