2014 Jan 23 6:57 AM
Dear Experts,
I have 2 tables..VBRP and ZDOX.
I fetch data from vbrp table like below....
SELECT VBELN FKIMG VGBEL VGPOS MATNR ARKTX WERKS ERDAT VSTEL
FROM VBRP
INTO TABLE IT_VBRP
WHERE MATNR IN S_MATNR
AND ERDAT IN S_ERDAT.
NOW AFTER EXECUTION DATA COMES TO IT_VBRP...
IF IT_VBRP IS NOT INITIAL.
SELECT WERKS MATNR CREATED_ON FINAL DOCTYP DOCNO FINALQTY
FROM ZDOX
INTO TABLE IT_ZDOX
WHERE WERKS = IT_VBRP-WERKS
AND MATNR = IT_VBRP-MATNR
AND CREATED_ON = IT_VBRP-ERDAT
AND DOCTYP = 'A'.
MY PROBLEM IS : WHEN I EXECUTE DATA IS NOT COME TO IT_ZDOX.
WERKS, MATNR, CREATED_ON, ARE NOT THE KEY FIELDS OF ZDOX.
SO HOW I CAN FETCH DATA FROM ZDOX TABLE PLEASE SUGGEST ME...
IS THERE ANY CHANGE TO MAKE IN SELECT STATEMENT PLEASE EXPLAIN.
KIND REGARDS,
AJIT
2014 Jan 23 7:18 AM
Hi Ajit,
if there is not having mandatory data in any of the field werks, matnr and created-on,
then you have to change your AND operation to OR operation,
First check that, the data is present in your ZDOCS, tables or not,
if it is present and any of the fields maynot have data then use as shown below.
SELECT WERKS MATNR CREATED_ON FINAL DOCTYP DOCNO FINALQTY
FROM ZDOX
INTO TABLE IT_ZDOX
WHERE WERKS = IT_VBRP-WERKS
OR MATNR = IT_VBRP-MATNR
OR CREATED_ON = IT_VBRP-ERDAT
AND DOCTYP = 'A'.
2014 Jan 23 7:01 AM
Make this change
SELECT WERKS MATNR CREATED_ON FINAL DOCTYP DOCNO FINALQTY
FROM ZDOX
INTO TABLE IT_ZDOX
FOR ALL ENTRIES IN IT_VBRP
WHERE WERKS = IT_VBRP-WERKS
AND MATNR = IT_VBRP-MATNR
AND CREATED_ON = IT_VBRP-ERDAT
AND DOCTYP = 'A'.
2014 Jan 23 7:06 AM
@NABNEET...
I USED FOR ALL ENTRIES STATEMENT BUT SORRY FOR GOT TO WRITE HERE.
STILL NO RESULT.
REGARDS,
AJIT
2014 Jan 23 7:09 AM
First of all dont use CAPITAL letters it does not look good. Secondly did you check in SE16 was their any data available for the data in IT_VBRP which you have given in where clause? If you say yes then please add the screen shot highlighting IT_VBRP contents for which data is available in Z table. Check carefully the leading zeros also
Nabheet
2014 Jan 23 7:12 AM
Hi Ajit,
Try for all entries in concept. It fetches the data from database table(ZDOX) based on each entry in driver table(IT_VBRP is driver table in your example).
NOTE: While using 'for all entries in' in your select statement, the driver table should not be empty.
Please go through the following code.
SELECT VBELN FKIMG VGBEL VGPOS MATNR ARKTX WERKS ERDAT VSTEL
FROM VBRP
INTO TABLE IT_VBRP
WHERE MATNR IN S_MATNR
AND ERDAT IN S_ERDAT.
IF IT_VBRP IS NOT INITIAL.
SELECT WERKS MATNR CREATED_ON FINAL DOCTYP DOCNO FINALQTY
FROM ZDOX
INTO TABLE IT_ZDOX
FOR ALL ENTRIES IN IT_VBRP
WHERE WERKS = IT_VBRP-WERKS
AND MATNR = IT_VBRP-MATNR
AND CREATED_ON = IT_VBRP-ERDAT
AND DOCTYP = 'A'.
ENDIF.
2014 Jan 23 7:18 AM
Hi Ajit,
if there is not having mandatory data in any of the field werks, matnr and created-on,
then you have to change your AND operation to OR operation,
First check that, the data is present in your ZDOCS, tables or not,
if it is present and any of the fields maynot have data then use as shown below.
SELECT WERKS MATNR CREATED_ON FINAL DOCTYP DOCNO FINALQTY
FROM ZDOX
INTO TABLE IT_ZDOX
WHERE WERKS = IT_VBRP-WERKS
OR MATNR = IT_VBRP-MATNR
OR CREATED_ON = IT_VBRP-ERDAT
AND DOCTYP = 'A'.
2014 Jan 23 7:22 AM
Hi Ajit ,
First to add For all entries in second query ,use sy-subrc and debug your program and check sy-subrc value .Hopefully you get it .
Regards
Vivek
2014 Jan 23 7:23 AM
Hi Ajit,
I think may be for your second select query there are no entries corresponding to your WHERE condition.
You can also try.......
First select a WERKS, MATNR and ERDAT for a particular entry from VBRP in SE11 or SE16n t-code and try putting those entries for table ZDOX in SE11 or SE16n just to make sure there are entries available for any document.
Then when you execute place a breakpoint after first SELECT statement and ensure it is not INITIAL atleast some data comes into IT_VBRK. Then for that data try in SE11 or SE16n.
Hope this helps!
Happy Coding,
Santhosh Yadav
2014 Jan 23 7:39 AM
Hi Ajit,
if there are entries against the selection fields in your ZDOX, this simply means your
select option is wrong, please put a breakpoint on it and see what is the value of sy-subrc,
if it is 0, and still you are not getting values , means there is no data for the specified
selection range.
Please debug your code, it will gives you the clear idea.
2014 Jan 23 7:44 AM
Dear ,
Thank you @sanjeev, as you said to change AND to OR, I did and now my data is coming to it_zdox itab.