2013 Aug 23 8:16 AM
Hello All,
This the the table structure
field A ,B,C,D,E,F are part of primary key and there are other fields also such as G,J,I,J.
data has maintained in table.
Now field B,E,F are having some data in table(A,C,D = null) and I want to get those data using Read table statement but its getting failed
Read Table IT_XYZ into WA_XYZ with key A = wa-a
B = wa-b
C = wa-c
D = wa-d
E = wa-e
F = wa-f
What i am doing wrong. Please suggest.
Best Regards,
Jitendra
2013 Aug 23 8:24 AM
From your query, the table fields A,C and D are blank in the table. So if wa-a, wa-c, wa-d are having any values, your read statement wont work as it would be searching for that values in the table.
2013 Aug 23 8:25 AM
Hi Jitendra,
Statement seems to be correct. Check wa-a, wa-b, etc... conditions might not be getting fulfilled.
Regards,
Shahir Mirza
2013 Aug 23 8:30 AM
Can you provide the sample data for fields A, B,..I,J and at the same time Workarea data also then we can figure it out the problem.
Thanks in advance,
Krishna
2013 Aug 23 8:35 AM
what is the error you are facing.
I don't thing so there is anyerror in the code given by you..
Please read the following link..
http://help.sap.com/SAPHELP_470/Helpdata/EN/fc/eb35f8358411d1829f0000e829fbfe/content.htm
hope it will help you..
BR
2013 Aug 23 8:40 AM
one more thing..
Read Table IT_XYZ into WA_XYZ with key A = wa-a
B = wa-b
C = wa-c
D = wa-d
E = wa-e
F = wa-f.
in this A = wa-a <and> B = wa-b <and> ...
it works like this means each condition get appended with and statement so this can be the reason you are not getting correct data.
So you should create a dynamic query to give in the condition..
BR
Chandra..
2013 Aug 23 8:44 AM
Hi Jitendra,
Basic point
Before going to read any internal table, make sure that Intenal table should be sorted.
So as per your requirement sort the internal table with fields B,E and F.
READ TABLE IT_XYZ into WA_XYZ with key B = wa-b
E = wa-e
F = wa-f
Binary search.
If SY-SUBRC = 0.
* write your logic........................
endif.
Regards,
Krishna.
2013 Aug 23 8:46 AM
Hi Jitendra,
Are you using another READ operation to fill the workarea "WA" (mentioned in the above scenario)?
Thanks,
Shahanaz Hussain,
Applexus Technologies.
2013 Aug 23 8:59 AM
@All,
There is data exits in internal table which match criteria with wa data but still it is not working
2013 Aug 23 9:02 AM
This can not be possible.
Read Table IT_XYZ into WA_XYZ with key A = wa-a
B = wa-b
C = wa-c
D = wa-d
E = wa-e
F = wa-f.
in this A = wa-a <and> B = wa-b <and> ...
it works like this means each condition get appended with and statement so this can be the reason you are not getting correct data.
something must coming wrong..
So you should create a dynamic query to give in the condition..
2013 Aug 23 9:05 AM
Hi Jitendra,
If you are filling work area WA using a READ statement, then before ENDLOOP statement of the main LOOP, CLEAR workarea WA.
Thanks,
Shahanaz Hussain,
Applexus Technologies.
2013 Aug 23 9:11 AM
data: BEGIN OF xyz,
a type string,
b type string,
c type string,
d type string,
e type string,
f type string,
END OF xyz,
it_xyz like TABLE OF xyz,
wa_xyx like xyz.
wa_xyx-a = 'a'.
wa_xyx-b = 'b'.
wa_xyx-c = 'c'.
APPEND wa_xyx to it_xyz.
CLEAR wa_xyx.
wa_xyx-b = 'b'.
wa_xyx-c = 'c'.
wa_xyx-d = 'd'.
APPEND wa_xyx to it_xyz.
CLEAR wa_xyx.
READ TABLE it_xyz INTO wa_xyx with KEY a = 'a' b = 'b' c = 'c'.
if sy-subrc = 0.
write: wa_xyx-a , wa_xyx-b , wa_xyx-c.
ENDIF.
READ TABLE it_xyz INTO wa_xyx with KEY a = 'a' b = 'b'.
if sy-subrc = 0.
write: wa_xyx-a , wa_xyx-b , wa_xyx-c.
ENDIF.
see the code...
Its working fine.
2013 Aug 23 8:59 AM
Hi Jitendra,
Query is ok as per structure. But as per your coding, it will search the table for those record, that matches the selection criteria. Now if you want to read the records from table those are having A,C & D as null, then you need to pass null value in your selection criteria for those field. Or else you can remove those or some other fields from selection criteria to get data from table. READ TABLE won't return any data, until unless it matches all the selection criteria. That is the reason, your query is failing. Hope I made myself clear.
Regards,
Anubhab
2013 Aug 23 9:50 AM
Hello Jitendra ,
syntax point of view your read statement is ok, and also you say data is in the internal table , if for some field the value is null better remove from query . again if you thing you condition is right just put a break point before read statement and do a check in debug mode that acc to condition is their any record in internal table if record is in internal table and not fetched that means the condition needed to fetch record are not still provided.
Hope This will Solve Your Problem.
2013 Aug 23 11:41 AM