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 statement keeps failing

former_member295881
Contributor
0 Kudos

Hello Experts,

I'm having a tough time to do a simple READ TABLE statement on two tables. My two tables are (  pi_git_zrerate_dtl ) and ( lt_zrerate_output_vf ) and both have same data and fields as well which I want to compare but when READ TABLE statement always fails when in pi_git_zrerate_dtl table VBELN is same on multiple rows. I even try to pass other fields (KDMAT and POSNR) which are not same and should make a unique records but still READ fails (as shown in below screen shots).

Can anybody see what mistake I'm making in the above code and please tell me how to rectify it?

Many thanks in advance.

1 ACCEPTED SOLUTION

former_member192854
Active Participant
0 Kudos

can't make much of the screen shot, but you're using BINARY SEARCH. Is the table sorted based on the fields you're searching for?

7 REPLIES 7

former_member192854
Active Participant
0 Kudos

can't make much of the screen shot, but you're using BINARY SEARCH. Is the table sorted based on the fields you're searching for?

0 Kudos

Hi Sander,

Just to let you know.  I had no intention of copying what you wrote.  When I initially hit reply, there were no responses and only after I submit my response did I see you had also replied with the same approach. 

Cheers,

Katan

0 Kudos

Hi Katan,

no worries, I already had the feeling you didn't do it on purpose.

Best,

Sander

Katan
Active Participant
0 Kudos

Hi There,

I can see you are using the addtion "BINARY SEARCH" in your read statement.  To use this however you need to ensure that you apply a sort on your table based on the key fields you are searching.  I can't see if you are doing this from your screenshot, but it looks like a good place to start.

You can quickly test if this is the cause by removing this addition from your read statement and retesting.  If it works, then you should add the statement back in and perform the sort on the table before reading from it. 

As a side point you should also consider:

- tables of type sorted (performance gains on read and "BINARY SEARCH"is implied, cost increase on insert statements)

- if the table is usually small, have you considered removing the binary search and not sorting it (quick for small tables, cost of read is that the whole table is read to find the record)

Depending on the most likely production scenario is for you requirement is what you should aim to code for to get the best performance gains. 

Cheers,

Katan

Former Member
0 Kudos

Hi,

Remove binary search from the statement and then try.

Check whether the length of the equating fields for target(LWA) and source(GWA) is same.

confirm that there is no space in the end of GWA,

try using conversion exits for the source variables.

Thanks & Regards,

Akshay Ruia

former_member187748
Active Contributor
0 Kudos

Hi,

whenever you use BINARY SEARCH, make sure that your table is SORTED.

So please do it accordingly, first sort your internal table based on your main

field (say ebeln)  and then use binary search.

This will makes your output as you wants.

Former Member
0 Kudos

First sort your internal table on vbeln_or kdmat vgpos. Then use binary search.

Vivek