Application Development 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 table does not corresponds to the row that is mentioned in the condition

tk_gerald
Participant
0 Kudos

Hi together,

I need to solve an issue regarding read table statement. The code is as follows:

IF rab_sot IS NOT INITIAL.

    READ TABLE tkomvd[] WITH KEY kschl = rab_sot ASSIGNING FIELD-SYMBOL(<ls_tkmovd>).
IF sy-subrc = 0. script-bruttowert = script-kbetr_basis + <ls_tkomvd>-kwert. ENDIF. ENDIF.

The issue is that the variable rab_sot saves a condition value of YPWE. And in the read table, it should read the record in the table tkomvd for the kschl = YPWE. Now the issue is that on the part of the code <ls_tkomvd>-kwert, it takes a value from the table tkomvd that is not corresponding to the kschl of YPWE. Thus, the value of kwert is 150, while for the row in the table tkomvd where the kschl is YPWE the value should be 60.

May anyone now how can I fetch the corresponding row in the table tkomvd?

Please do tell me if you need some additional information.

Many thanks,

R

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

The programming languages don't do random things. If it takes 150, it means it's 150. You probably don't look at the right place.

venkateswaran_k
Active Contributor
0 Kudos

Hi

Is that table tkomvd[] is sorted on KSCHL.

Please sort the table on KSCHL before it is being used for Read.

Hi,

The highlighted two structures are not same. Use the same structure which is being filled in with read condtion.

Excellent Rama, You found it..

0 Kudos

venkateswaran.k Thank you sir.