‎2006 Jun 29 3:30 PM
i need to find line in itab.
when i find it i need to take the line before and the line after how i can do it?
PLS
‎2006 Jun 29 3:38 PM
Hi,
Consider this ,
DATA : ind1 TYPE sy-tabix,
ind2 TYPE sy-tabix.
READ TABLE it_test INTO wa_test WITH TABLE KEY k1 = v1
kn = v2.
IF sy-subrc EQ 0.
ind1 = sy-tabix + 1.
ind2 = sy-tabix - 1.
READ TABLE it_test INTO wa_after INDEX ind1.
READ TABLE it_test INTO wa_before INDEX ind2.
ENDIF.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi
Message was edited by: Arun Sambargi
‎2006 Jun 29 3:33 PM
‎2006 Jun 29 3:36 PM
i have loop on mardh and before i have mard.
LOOP AT imardh ASSIGNING <ls_mardh>.
IF <ls_mardh>-lfmon = z_period+0(2) AND
<ls_mardh>-lfgja = z_period+2(4).
<b>here i found the line and end stock now i need to find the start and it's the line before
and if i didnt find i need to take the line before and after</b>
<ls_mard>-e_stock = <ls_mardh>-labst.
ENDIF.
ENDLOOP.
‎2006 Jun 29 3:36 PM
‎2006 Jun 29 3:34 PM
Hi,
Use SY-Tabix.
Sy-tabix will point to current line.
lv_next_line type I.
lv_next_line = sytabix + 1.
take temp work area.
wa_temp
read table itab into wa_temp index lv_next_line.
update current line with wa_temp.
update next line with previous data
‎2006 Jun 29 3:34 PM
hi rani,
use read stmt.
im not sure but try this..
read table itab index sy-tabix.
to read before the line
data: v_tabix type sy-tabix.
v_tabix = sy-tabix - 1.
read table itab index v_tabix.
to read after the line
data: v_tabix1 type sy-tabix.
v_tabix1 = sy-tabix + 1.
read table itab index v_tabix1.
‎2006 Jun 29 3:34 PM
READ table something with key = sometning
temp = sy-tabix + 1.
temp2= sy-tabix - 1.
READ table something index temp.
read table something index temp2.
Something like that.
BR, JAcek
‎2006 Jun 29 3:37 PM
Hi rani,
u can find it thru sy-tabix.
example.
loop at itab.
l_tabix = sy-tabix." current line no.
.....
For line before
read table itab index l_tabix -1.
For line after
read table itab index l_tabix +1.
endloop.
Regards,
kiran B
‎2006 Jun 29 3:37 PM
Hi Rani,
The line you find in the itab will have a specific index. So you can do index + 1 and index - 1 to get the next and the before line.
Ex: your internal table has 5 records. you are taking the the 3rd record, your tabix will be 3.
Then do this.
lws_index = sy-tabix + 1.
lws_ind = sy-tabix - 1.
read table index lws_index. (next record)
read table index lws_ind. (before record)
‎2006 Jun 29 3:37 PM
Hi,
loop at itab where 'condition'.
itab_index = sy-tabix.
itab_prev_index = itab_index - 1.
read itab index itab_prev_index .
itab_next_index = itab_index + 1.
read itab index itab_next_index .
endloop.
‎2006 Jun 29 3:38 PM
Hi,
Consider this ,
DATA : ind1 TYPE sy-tabix,
ind2 TYPE sy-tabix.
READ TABLE it_test INTO wa_test WITH TABLE KEY k1 = v1
kn = v2.
IF sy-subrc EQ 0.
ind1 = sy-tabix + 1.
ind2 = sy-tabix - 1.
READ TABLE it_test INTO wa_after INDEX ind1.
READ TABLE it_test INTO wa_before INDEX ind2.
ENDIF.
Regards,
Arun Sambargi.
Message was edited by: Arun Sambargi
Message was edited by: Arun Sambargi
‎2006 Jun 29 3:44 PM
hello,
here is the pseudo-code for your reqmt.
*-
data: l_tabix1 like sy-tabix.
data: l_tabix2 like sy-tabix.
*-
data: g_s_itab1 like line of g_t_itab.
data: g_s_itab2 like line of g_t_itab.
READ TABLE g_t_itab
TRANSPORTING NO FIELDS WITH KEY
key = 'KEY'
BINARY SEARCH.
*-
if sy-subrc = 0.
clear: l_tabix1, l_tabix2,g_s_itab1, g_s_itab2.
l_tabix1 = sy-tabix - 1.
l_tabix2 = sy-tabix + 1.
read table g_t_itab into g_s_itab1 index l_tabix1.
*- check SY-SUBRC
read table g_t_itab into g_s_itab2 index l_tabix2.
*- check SY-SUBRC
endif.hope this helps
best regards, Murugesh AS