09-11-2008 5:40 AM
Hi,
I had developed a code in which i had to retrieve data from QALS,QMEL and QMFE. There are 2 tables in which i am having data from QALS,QMEL in the table STIT and to take data from the QMFE in table STIT1 .
Data in the STIT is coming right as i had used left Outer join but when try to reterive the data for the STIT1 the data is not coming right..
here's the code which i am using for the SELECT query :-
SELECT AMATNR AWERK APRUEFLOS APAENDTERM ALOSMENGE BMAWERK BCHARG BLGORTCHARG BMGEIN BMGEIG BQMNUM CNTGEW CMEINS CGEWEI
FROM QALS AS A
LEFT OUTER JOIN QMEL AS B ON BMATNR = AMATNR AND BPRUEFLOS = APRUEFLOS
INNER JOIN MARA AS C ON CMATNR = AMATNR
INTO TABLE STIT WHERE AWERK = P_WERKS AND AMATNR IN P_MATNR AND APAENDTERM IN I_DATE AND ALAGORTCHRG IN P_LGORT AND A~CHARG IN P_CHARG.
SORT STIT BY MATNR.
SELECT QMNUM FEQKLAS FECOD FEGRP FMGEIG FROM QMFE INTO TABLE STIT1
FOR ALL ENTRIES IN STIT WHERE QMNUM = STIT-QMNUM.
SORT STIT1 BY QMNUM.
The data coming for STIT is correct but not the STIT1.
Edited by: ricx .s on Sep 11, 2008 6:40 AM
09-11-2008 5:44 AM
Rics,
Either you put the select query in loop stit --endloop or use for all entries in stit in the select query.
K.Kiran.
09-11-2008 5:53 AM
Hi Kiran,
Currently i am doing it in this way that the data from STIT and STIT1 are getting stored in the table ITAB.
The logic for it as follows:-
SELECT AMATNR AWERK APRUEFLOS APAENDTERM ALOSMENGE BMAWERK BCHARG BLGORTCHARG BMGEIN BMGEIG BQMNUM CNTGEW CMEINS CGEWEI
FROM QALS AS A LEFT OUTER JOIN QMEL AS B ON BMATNR = AMATNR AND BPRUEFLOS = APRUEFLOS
INNER JOIN MARA AS C ON CMATNR = AMATNR
INTO TABLE STIT WHERE AWERK = P_WERKS AND AMATNR IN P_MATNR
AND APAENDTERM IN I_DATE AND ALAGORTCHRG IN P_LGORT AND A~CHARG IN P_CHARG.
SORT STIT BY MATNR.
ELECT QMNUM FEQKLAS FECOD FEGRP FMGEIG FROM QMFE INTO TABLE STIT1
FOR ALL ENTRIES IN STIT WHERE QMNUM = STIT-QMNUM.
SORT STIT1 BY QMNUM.
LOOP AT STIT.
ITAB-MATNR = STIT-MATNR.
ITAB-PRUEFLOS = STIT-PRUEFLOS.
ITAB-PAENDTERM = STIT-PAENDTERM.
ITAB-LOSMENGE = STIT-LOSMENGE.
ITAB-CHARG = STIT-CHARG.
ITAB-LGORTCHARG = STIT-LGORTCHARG.
ITAB-MGEIN = STIT-MGEIN.
ITAB-MGEIG = STIT-MGEIG.
ITAB-NTGEW = STIT-NTGEW.
LOOP AT STIT1 WHERE QMNUM = STIT-QMNUM.
ITAB-QMNUM = STIT1-QMNUM.
ITAB-FEQKLAS = STIT1-FEQKLAS.
ITAB-FECOD = STIT1-FECOD.
ITAB-FEGRP = STIT1-FEGRP.
ITAB-FMGEIG = STIT1-FMGEIG.
ENDLOOP.
APPEND ITAB.
ENDLOOP.
09-11-2008 6:03 AM
Hi,
You told that data is not coming right, means some data is coming. What is the problem with the data?
Please specify what is the wrong with the data then only we can able to correct.
One more thing check the internal table for the sequence of fields you defined and the sequence of fields you are using in the select query. Both should be in the same sequence.
09-11-2008 6:47 AM
Hi Surya,
The problem is when i debug it for the STIT1 the data is coming but it is repeating the data or missing the information. The main problem lies in the STIT1 table as i am using for all entries in the STIT table so that only the data should be displayed for the those entries which are present in the STIT.
09-11-2008 7:24 AM
Hi,
The problem is with the database table which you are using for STIT1. Check whether you had provided all the primary keys required for that table. Otherwise you will get other entries also.
Check the sequence of fields you had defined for the internal table STIT1 and the sequence of fields you are fetching using the select query for the table STIT1.
If you are getting duplicates or unnecessay data, perform some validations on the internal table STIT1 for deleting that data from the internal table STIT1
09-11-2008 6:51 AM
hi,
you can use select for all entries for stt and stt1.and use modify for your internal table.
DATA: itab TYPE TABLE OF vbak WITH HEADER LINE,
itab2 TYPE TABLE OF vbap WITH HEADER LINE.
SELECT * INTO TABLE itab FROM vbak WHERE vbeln BETWEEN u20191000000000u2019 AND u20194999999999u2019.
IF NOT itab[] is initial.
SELECT * INTO TABLE itab2 FROM vbap FOR ALL ENTRIES IN itab WHERE vbeln = itab-vbeln AND matnr LIKE u2019F%u2019.ENDIF.
use this
link..
09-11-2008 6:51 AM
hi,
you can use select for all entries for stt and stt1.and use modify for your internal table.
DATA: itab TYPE TABLE OF vbak WITH HEADER LINE,
itab2 TYPE TABLE OF vbap WITH HEADER LINE.
SELECT * INTO TABLE itab FROM vbak WHERE vbeln BETWEEN u20191000000000u2019 AND u20194999999999u2019.
IF NOT itab[] is initial.
SELECT * INTO TABLE itab2 FROM vbap FOR ALL ENTRIES IN itab WHERE vbeln = itab-vbeln AND matnr LIKE u2019F%u2019.ENDIF.
use this
link..