2014 Jan 16 10:14 PM
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.
2014 Jan 16 10:22 PM
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?
2014 Jan 16 10:22 PM
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?
2014 Jan 17 6:56 AM
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
2014 Jan 17 7:46 AM
Hi Katan,
no worries, I already had the feeling you didn't do it on purpose.
Best,
Sander
2014 Jan 16 10:29 PM
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
2014 Jan 17 5:11 AM
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
2014 Jan 17 5:26 AM
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.
2014 Jan 17 6:33 AM
First sort your internal table on vbeln_or kdmat vgpos. Then use binary search.
Vivek