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

Picking a record from internal table

Former Member
0 Likes
1,139

Hi Friends,

I want to pick the second record from the internal table and modify it,

I have used the following code to do that but it is not working pls tell me what to do.,

LOOP AT lt_check INTO lw_check.

  • read table lt_check into lw_check with key xblnr where sy-tabix = 2.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MOVE 'CL' TO itab_temp-clear.

endloop.

Thank in advance,

Line

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,106

i am not enough clear that which table you want to modify? as per your code it seems you want to modify(or append) the itab_temp table. if it is so then...

LOOP AT lt_check INTO lw_check.

  • read table lt_check into lw_check with key xblnr where sy-tabix = 2.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MOVE 'CL' TO itab_temp-clear.

append itab_temp

" if data is not there in itab_temp or use modify itab_temp index 2 if the there

"are at least 2 rows in your itab_temp.

endif.

endloop.

please let us know what is your exact requirement... and with some sample data in both the int table...

regards

shiba dutta

i am not enough clear that which table you want to modify? as per your code it seems you want to modify(or append) the itab_temp table. if it is so then...

LOOP AT lt_check INTO lw_check.

  • read table lt_check into lw_check with key xblnr where sy-tabix = 2.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MOVE 'CL' TO itab_temp-clear.

append itab_temp

" if data is not there in itab_temp or use modify itab_temp index 2 if the there

"are at least 2 rows in your itab_temp.

endif.

endloop.

please let us know what is your exact requirement... and with some sample data in both the int table...

regards

shiba dutta

7 REPLIES 7
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,106

Hi,

LOOP AT lt_check INTO lw_check.

  • read table lt_check into lw_check with key xblnr where sy-tabix = 2.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MOVE 'CL' TO itab_temp-clear.

modify itab_temp index 2 transporting trans lifnr xblnr bukrs usnam procese appdate status .

endif.

endloop.

Message was edited by:

Jayanthi Jayaraman

Read only

0 Likes
1,106

hi Jayanthi,

In my loop sy-tabix value is not becoming to 2, what to do ?

Regards,

Line

Read only

0 Likes
1,106

Hi,

If you want to modify only the second record, read statement is enough with modify.One more thing which table you want to modify lt_check or itab_temp?If itab_temp which record you want to modify?

read table lt_check into lw_check index 2.

IF sy-subrc eq 0.

....

endif.

Read only

0 Likes
1,106

Hi Line,

As said by Jayanthi use READ only, but before that just see if the LT_CHECK has more than 2 entries, if there are less than 2 entries then you will get a ABAP dump.

So use

<b>DESCRIBE TABLE lt_check LINES lv_lines.

IF lv_ines > 1.</b>

read table lt_check into lw_check index 2.

IF sy-subrc eq 0.

....

endif.

<b>ENDIF.</b>

Regards,

Atish

Read only

Former Member
0 Likes
1,107

i am not enough clear that which table you want to modify? as per your code it seems you want to modify(or append) the itab_temp table. if it is so then...

LOOP AT lt_check INTO lw_check.

  • read table lt_check into lw_check with key xblnr where sy-tabix = 2.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MOVE 'CL' TO itab_temp-clear.

append itab_temp

" if data is not there in itab_temp or use modify itab_temp index 2 if the there

"are at least 2 rows in your itab_temp.

endif.

endloop.

please let us know what is your exact requirement... and with some sample data in both the int table...

regards

shiba dutta

Read only

Former Member
0 Likes
1,106

LOOP AT ITAB.

IF sy-tabix = 2.

itab_temp-trans = lw_check-trans.

itab_temp-lifnr = lw_check-lifnr.

itab_temp-xblnr = lw_check-xblnr.

itab_temp-bukrs = lw_check-bukrs.

itab_temp-usnam = lw_check-usnam.

itab_temp-procese = lw_check-procese.

itab_temp-appdate = lw_check-appdate.

itab_temp-status = lw_check-status.

MODIFY ITAB.

ENDIF.

ENDLOOP.

IF USEFULL REWARD

Read only

Former Member
0 Likes
1,106

DESCRIBE TABLE lt_check LINES lv_lines.

IF lv_ines > 1.

read table lt_check into lw_check index 2.

IF sy-subrc eq 0.

loop at lw_check.

move lw_check into it_temp.

modify it_temp.

endloop.

endif.

endif.

reward if useful.