2007 Jul 23 3:52 PM
Hi,
Can you use the same key field more than once?
For example:
READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'
Werks = '1002'.
I get an error when trying this.
Is there an alternative?
Thanks,
John
2007 Jul 23 3:58 PM
Hi John,
I guess you are trying to use OR condition here which will not work with READ statment, you have to use loop for that
loop at itab where werks = '1004' or
werks = '1002'.
endloop.
2007 Jul 23 3:53 PM
2007 Jul 23 3:55 PM
2007 Jul 23 3:57 PM
Hi ,
In this requirement you can use loop at where condion ...Instead of read
Loop at Internal table where werks = '1002' and '1004'.
Thanks,
varma
2007 Jul 23 3:58 PM
Hi,
Use Loop with where condition.
loop at itab where werks eq 'A001' and werks eq 'A002'.
exit.
endloop.
if sy-subrc eq 0.
<<<<< >>>>>
endif.
aRs
Message was edited by:
a®
2007 Jul 23 3:58 PM
Hi John,
I guess you are trying to use OR condition here which will not work with READ statment, you have to use loop for that
loop at itab where werks = '1004' or
werks = '1002'.
endloop.
2007 Jul 23 4:01 PM
Hi John,
You can not use KEY FIELD in READ statement more than once by giving different values. You need to use LOOP AT with WHERE condition and specify the condition in the WHERE clause only.
LOOP AT I_TVKWZ <b>WHERE WERKS = '1004' OR WERKS = '1002'</b>.
<<DO AS PER REQUIREMENT>>
ENDLOOP.
Try as follows if you want only with READ statement
DATA V_SUBRC1 TYPE SY-SUBRC.
DATA V_SUBRC2 TYPE SY-SUBRC.
<b>READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'.
V_SUBRC1 = SY-SUBRC.
READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'.
V_SUBRC2 = SY-SUBRC.
IF V_SUBRC1 = 0 OR V_SUBRC2 = 0.
<<DO ACCORDINLGY>>
ENDIF.</b>
Thanks,
Vinay
2007 Jul 23 4:03 PM
Hi John,
try this:
DATA: begin of itab occurs 0,
werks like mseg-werks,
i type i,
end of itab.
itab-werks = '1000'. itab-i = itab-i + 1. append itab.
itab-werks = '1000'. itab-i = itab-i + 1. append itab.
itab-werks = '2000'. itab-i = itab-i + 1. append itab.
itab-werks = '3000'. itab-i = itab-i + 1. append itab.
itab-werks = '5000'. itab-i = itab-i + 1. append itab.
itab-werks = '5000'. itab-i = itab-i + 1. append itab.
itab-werks = '7000'. itab-i = itab-i + 1. append itab.
itab-werks = '7000'. itab-i = itab-i + 1. append itab.
itab-werks = '9000'. itab-i = itab-i + 1. append itab.
itab-werks = '9000'. itab-i = itab-i + 1. append itab.
itab-werks = '9000'. itab-i = itab-i + 1. append itab.
*
loop at itab where werks = '1000' or werks = '9000'.
write: / itab-werks, itab-i.
endloop.
Regards, Dieter
2007 Jul 23 4:12 PM
Hi,
Try this way.
read table itab with key wekrs = 'A001'
binary search.
if sy-subrc eq 0.
read table itab with key werks = 'A002'
binary search.
if sy-subrc eq 0.
* <<<<< do your coding >>>>>
endif.
endif.
aRs
2007 Jul 24 8:27 AM