‎2007 Jul 02 10:08 AM
i used inner join for joining 4 tables in my program. but i m not sure that the select statement is correct. but its showing syntactically correct in my program.
the problem is im not getting the output.
could any body help me in my code
REPORT Z_DELIVERY_DETAILS.
TABLES : QMFE, QMSM, MAKT, VBAP, EKPO, EKET.
SELECT-OPTIONS : PLANT FOR VBAP-WERKS,
CODGRUP FOR QMFE-OTGRP,
MATERIAL FOR MAKT-MATNR.
DATA : BEGIN OF ITAB OCCURS 0,
MNCOD LIKE QMSM-MNCOD,
OTGRP LIKE QMFE-OTGRP,
BAUGRUPPE LIKE QMFE-BAUTL,
MATEXT LIKE MAKT-MAKTX,
SALESORDR LIKE VBAP-VBELN,
SALESPOS LIKE VBAP-POSNR,
PURORDER LIKE EKET-EBELN,
PURPOS LIKE EKET-EBELP,
SHDQTY LIKE EKET-MENGE,
QTYREC LIKE EKET-WEMNG,
EINDT LIKE EKET-EINDT,
END OF ITAB.
DATA : STAB LIKE TABLE OF ITAB.
DATA : CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GRID TYPE REF TO CL_GUI_ALV_GRID,
gt_fieldcat TYPE lvc_t_fcat.
SELECT AOTGRP ABAUTL BMAKTX CVBELN CPOSNR EEBELN EEBELP EMENGE EWEMNG EEINDT
INTO CORRESPONDING FIELDS OF TABLE STAB FROM
( QMSM AS F INNER JOIN QMFE AS A ON FQMNUM = AQMNUM
INNER JOIN MAKT AS B ON AMATNR = BMATNR
INNER JOIN VBAP AS C ON BMATNR = CMATNR
INNER JOIN EKPO AS D ON BMATNR = DMATNR
INNER JOIN EKET AS E ON DEBELN = EEBELN )
WHERE C~WERKS IN PLANT
AND A~OTGRP IN CODGRUP
AND F~MNCOD = '3050'.
CALL SCREEN 0001.
‎2007 Jul 02 10:10 AM
Hi,
Try to debug the code and check, you will know whether data is coming or not.
Paste your code here.
Thanks,
Anitha
‎2007 Jul 02 10:13 AM
Hi,
Refer these links it will give You the syntax for Inner joins,
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm.
Regards,
Sudha S.
‎2007 Jul 02 10:15 AM
Hi,
hope there is no data present in db for Criteria u r giving.
Jogdand M B
‎2007 Jul 02 10:19 AM
Hi abhilash venkata,
Try to debug your "select" by commenting a "join line" then test it.
perform a step by step debug like this.
Hope this helps,
Erwan
‎2007 Jul 05 12:29 PM
hi erwan,
i have divided this program and made the first two tables seperately and the rest of ther tables seperately as different programs. then iam able to get the results, but when i gave everything in one program im not getting .
my seperate codes :
first two tables are joined as follows:
SELECT TMNGRP SBAUTL INTO CORRESPONDING FIELDS OF TABLE ITAB1
FROM QMSM AS T LEFT OUTER JOIN QMFE AS S ON SQMNUM = TQMNUM
WHERE ( T~MNCOD EQ '3050'
AND T~MNCOD NE '3100' )
AND T~MNGRP IN CODGROUP.
CALL SCREEN 0001.
rest of the tables joined as follows :
SELECT AMAKTX BVBELN BPOSNR CEBELN CEBELP CMENGE CWEMNG CEINDT
INTO CORRESPONDING FIELDS OF TABLE STAB FROM
( MAKT AS A INNER JOIN VBAP AS B ON AMATNR = BMATNR
INNER JOIN EKPO AS D ON AMATNR = DMATNR
INNER JOIN EKET AS C ON DEBELN = CEBELN )
WHERE B~WERKS IN PLANT
AND B~MATNR IN MATERIAL
AND A~SPRAS = 'D'.
CALL SCREEN 0001.
the above two codes were given in two different programs. then i got the result
but when i gave together as follows:
SELECT
A~OTGRP
A~BAUTL
B~MAKTX
C~VBELN
C~POSNR
E~EBELN
E~EBELP
E~MENGE
E~WEMNG
E~EINDT
INTO CORRESPONDING FIELDS OF TABLE STAB FROM
( QMSM AS F INNER JOIN QMFE AS A ON AQMNUM = FQMNUM
LEFT OUTER JOIN MAKT AS B ON AMATNR = BMATNR
INNER JOIN VBAP AS C ON BMATNR = CMATNR
INNER JOIN EKPO AS D ON BMATNR = DMATNR
INNER JOIN EKET AS E ON DEBELN = EEBELN )
WHERE C~WERKS IN PLANT
AND C~MATNR IN MATERIAL
AND B~SPRAS = 'D'
AND A~OTGRP IN CODGRUP
AND F~MNCOD = '3050'.
CALL SCREEN 0001.
so could anybody help me in this aspect????????