Application Development 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 THE PREVIOUS RECORD OF INTERNAL TABLE

tarangini_katta
Active Contributor
0 Kudos

Hi All,

I have an internal table with the following values in the internal table.

I am working on change document numbers.

I am getting al the values perfectly.

But my pblm is

In internal table i have valueschangenumber = 50000001

50000003

50000004

50000005.

when the chnage number is loop.

I want to get the previous value of internal table i.e.if wa has 500000003 i want read the record of change number 50000001.

How can i do this.

Can aynbody please explain how to dod this.

Thanks,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi bro....

you can do this thing in following way..

WORK_AREA AND WORK_AREA1 should have line type of t_table

data: w_num type i.

loop at T_TABLE INTO WORK_AREA.

if sy-tabix > 1.

w_num = sy-tabix.

w_num = w_num - 1 .

now read the table T_TABLE INTO WORKAREA2 WITH INDEX W_NUM.

endloop.

Edited by: Mohit Kumar on Feb 5, 2009 8:58 AM

5 REPLIES 5

Former Member
0 Kudos

Hi,

try this logic



LOOP AT it_revision INTO wa_rev.
*&.........
*& update statement is updating the field of discription and check box.
*&...............

      UPDATE t352r SET revtx = wa_rev-revtx
                       revab = wa_rev-revab
                       WHERE iwerk = wa_rev-iwerk   " in where check the existing data like id 3000
                        AND  revnr = wa_rev-revnr.
    ENDLOOP.
  ENDIF.

Thanks

Arun Kayal

Former Member
0 Kudos

hi bro....

you can do this thing in following way..

WORK_AREA AND WORK_AREA1 should have line type of t_table

data: w_num type i.

loop at T_TABLE INTO WORK_AREA.

if sy-tabix > 1.

w_num = sy-tabix.

w_num = w_num - 1 .

now read the table T_TABLE INTO WORKAREA2 WITH INDEX W_NUM.

endloop.

Edited by: Mohit Kumar on Feb 5, 2009 8:58 AM

Former Member
0 Kudos

Hi ,

When you loop at an internal table the index of the current record you are reading is stored in the system varaibale sy-tabix , you can move this value in another variable and substract 1 from it and use this new value as index and read the internal table.

the code will look some thing like this.

loop at it into wa.
var1 = sy-tabix - 1.
read table it into wa1 index var1.

endloop.

Regards

Arun

Former Member
0 Kudos

You will need to store the index of the current record of the internal table and read the previous record with help of that into a different work area.

data: temp_tabix like syindex.

data: itab_wa1 structure itab, itab_wa2 structure itab.

loop at itab into itab_wa1.

temp_tabix = sy-tabix.

....

---

temp_tabix= temp_tabix -1 .

read table itab into itab_wa2 index temp_tabix.

"[now itab_wa2 has previous record].

endloop.

tarangini_katta
Active Contributor
0 Kudos

Thank you,

All of you.

I have rewareded you pints.