‎2007 Sep 14 2:26 PM
I would like to have this in my report in ABAP 7:
READ TABLE ti_prococolos WITH KEY
protocol = lc_protocol
status = 'abc'
status = 'ced'.
But I receive the following error, when verifying the syntax:
Key field "STATUS" has been used more than once. This is not allowed .
How can I solve this?
Thanks!
‎2007 Sep 14 2:29 PM
The READ statement is used to read a specific row of the internal table, in this case it appears that you are saying that you want a record if the STATUS is either abc or def. You can't do that with the READ. You would need to use the LOOP.
Loop at ti_prococolos where protocol = lc_protocal
and ( status = 'abc' or status = 'ced' ).
* do what ever here, and EXIT after since you only want one row.
EXIT.
endloop.Regards,
RIch Heilman
‎2007 Sep 14 2:31 PM
When you read with KEY, the field can have only one value for the FIELD.
In your case, you've to open a loop or use two separate READ statements ie one for each value..
Arya
‎2007 Sep 14 2:32 PM
Hi,
Please try this.
ranges: r_status for ti_prococolos-status.
r_status-sign = 'I'.
r_status-option ='EQ'.
r_status-low = 'abc'.
append r_status.
r_status-sign = 'I'.
r_status-option ='EQ'.
r_status-low = 'ced'.
append r_status.
READ TABLE ti_prococolos WITH KEY
protocol = lc_protocol
status in r_status.
Regards,
Ferry Lianto
‎2007 Sep 14 3:24 PM
Try:
sort ti_prococolos by protocol status.
READ TABLE ti_prococolos WITH KEY
protocol = lc_protocol
status = 'abc'
BINARY SEARCH.
IF sy-subrc <> 0.
READ TABLE ti_prococolos WITH KEY
protocol = lc_protocol
status = 'ced'
binary search.
ENDIF.
Rob
‎2007 Oct 02 1:58 PM