‎2008 Jul 03 4:53 PM
Hello,
I want to reading internal table as follows:
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME1.
I want to read the same table with or condition in key like
domvalue = it_kna1-name1 or domvalue = it_kna1-name2.
How can I do or condition for Keys ?
Regards,
Rajesh
‎2008 Jul 03 4:54 PM
You can only use READ TABLE statement with equality condition.
You can achieve the desired result in the following way:
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME1.
if sy-subrc ne 0.
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME2.
if sy-subrc = 0.
PERFORM subroutine1.
endif.
else.
PERFORM subroutine1.
endif.
‎2008 Jul 03 4:54 PM
You can only use READ TABLE statement with equality condition.
You can achieve the desired result in the following way:
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME1.
if sy-subrc ne 0.
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME2.
if sy-subrc = 0.
PERFORM subroutine1.
endif.
else.
PERFORM subroutine1.
endif.
‎2008 Jul 03 4:58 PM
In my case I will have value in either of fields, so I want to read the table with that key which has the value..
‎2008 Jul 03 5:00 PM
You can achieve the desired result in the following way:
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME1.
if sy-subrc ne 0.
READ TABLE i_cust WITH KEY domvalue = it_kna1-NAME2.
if sy-subrc = 0.
PERFORM subroutine1.
endif.
else.
PERFORM subroutine1.
endif.
‎2008 Jul 03 5:14 PM
Ok, then you could use a field symbol.
field-symbols: <fs_name> type any.
if it_kna1-NAME1 is not initial.
assign it_kna1-NAME1 to <fs_name>.
elseif it_kna1-NAME2 is not initial.
assign it_kna1-NAME2 to <fs_name>.
endif.
READ TABLE i_cust WITH KEY domvalue = <fs_name>.
if sy-subrc = 0.
endif.Regards,
Rich Heilman
‎2008 Jul 03 4:56 PM