‎2014 Nov 11 11:14 AM
Hi ,
I am having a doubt in this condition .
This is my read statement .
Read table t_final into w_final with key contract_i = l_contarct_item
event_date = 'BD'.
Shall write the read statement in this form
Read table t_final into w_final with key contract_i = l_contarct_item
event_date = 'BD' and '11'.
Because the condition need to print 11 also.
‎2014 Nov 11 11:22 AM
Hi Bharani G,
You can not add AND in READ TABLE conditions. READ TABLE returns only single valye.
If you have multiple values in your ITAB for event_date 'BD' then go for LOOP AT ..
loop at t_final into w_final where contract_i = l_contarct_item
and ( event_date = 'BD' or event_date = '11' ).
-
-
-
-
end loop.
‎2014 Nov 11 11:18 AM
‎2014 Nov 11 11:20 AM
You can only read one row of the table with READ TABLE.
Do this:
DATA: t_final_aux type...
READ TABLE t_final INTO w_final WITH KEY contract_i = l_contarct_item
event_date = 'BD'.
append w_final TO t_final_aux.
READ TABLE t_final INTO w_final WITH KEY contract_i = l_contarct_item
event_date = '11'.
append w_final TP t_final_aux.
If you need only two rows. If you need all rows:
SORT t_final BY contract_i.
READ TABLE t_final INTO w_final WITH KEY contract_i = l_contarct_item binary search.
if sy-subrc.
LOOP AT t_final FROM sy-tabix INTO w_final where contract_i = l_contarct_item
AND .... .
APPEND w_final TO t_final_aux.
ENDLOOP.
endif.
OR:
t_final_aux = t_final.
DELETE t_final_aux WHERE contract_i <> l_contarct_item AND event_date <> 'DB' AND event_date <> '11'.
OR:
DELETE t_final_aux WHERE contract_i <> l_contarct_item.
Regards,
Alberto.
‎2014 Nov 11 11:22 AM
Hi Bharani G,
You can not add AND in READ TABLE conditions. READ TABLE returns only single valye.
If you have multiple values in your ITAB for event_date 'BD' then go for LOOP AT ..
loop at t_final into w_final where contract_i = l_contarct_item
and ( event_date = 'BD' or event_date = '11' ).
-
-
-
-
end loop.
‎2014 Nov 11 11:26 AM
‎2014 Nov 11 11:26 AM
Hello Bharani,
Incase of read statement you will only get a single record , so if you want to read the table with multiple values of a key field then you have to read it twice, once of 'BD' and another time for '11'.
Sample.
Read table t_final into w_final with key contract_i = l_contarct_item
event_date = 'BD' .
if sy-subrc eq 0.
endif.
Read table t_final into w_final with key contract_i = l_contarct_item
event_date = '11' .
if sy-subrc eq 0.
endif.
I hope this will solve your problem.
Cheers !!
Megh
‎2014 Nov 11 11:35 AM
Hi bharani,
Read statement is not allow for logical operators like OR / AND.
It is not supporting a table with two keys on same field...
Better to go for Loop the table....
Regards ,
Vamsi.