Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Read Table..

Former Member
0 Likes
1,031

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,006

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.

6 REPLIES 6
Read only

Former Member
0 Likes
1,006

Hi,

how can i help you?

regards

Stefan Seeburger

Read only

0 Likes
1,006

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.

Read only

Former Member
0 Likes
1,007

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.

Read only

former_member188219
Participant
0 Likes
1,006

Parallel cursoring will be helpful in these case i guess

Read only

meghomallar_das
Participant
0 Likes
1,006

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

Read only

vamsilakshman_pendurti
Active Participant
0 Likes
1,006

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.