‎2007 Jul 03 2:50 PM
hello friends,
i am not getting the output for my program. my task is :
1.to display selected data by joining 6 tables. qmfe, qmsm, vbap, makt, ekpo and eket.
2. Conditions : in mncod if for same material there are both 3050 and 3100 exist then we should not display it and if there is only 3050 then it should be displayed in the output.
im pasting my code below. i hope ther is a problem in my select statement
REPORT Z_SPRING_DELIVERY .
tables : qmfe, makt, qmsm, vbap, vbup, ekpo, eket.
select-options : plant for qmfe-werks,
baugroup for qmfe-bautl,
material for qmfe-matnr.
data : begin of itab occurs 0,
mngrp like qmsm-mngrp,
bautl like qmfe-bautl,
maktx like makt-maktx,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
ebeln like eket-ebeln,
ebelp like eket-ebelp,
menge like eket-menge,
wemng 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 amngrp bbautl cmaktx dvbeln dposnr eebeln eebelp emenge ewemng eeindt
into corresponding fields of table stab from
( qmsm as a inner join qmfe as b on aqmnum = bqmnum
inner join makt as c on bmatnr = cmatnr
inner join vbap as d on cmatnr = dmatnr
inner join ekpo as f on cmatnr = fmatnr
inner join eket as e on febeln = eebeln )
where a~mncod eq '3050'
and a~mncod ne '3100'
and c~spras eq 'D'
and b~werks in plant
and b~bautl in baugroup.
call screen 0001.
&----
*& Module STATUS_0001 OUTPUT
&----
text
----
module STATUS_0001 output.
SET PF-STATUS 'MENU'.
SET TITLEBAR 'MENU'.
CREATE OBJECT container
EXPORTING
container_name = 'CONT'. "Layout Grid name as CONT"
CREATE OBJECT grid
EXPORTING
i_parent = container.
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZSC_ALVSTUC' Structure of Itab created in Data Dictionary"
CHANGING
it_outtab = stab
IT_FIELDCATALOG = gt_fieldcat.
endmodule. " STATUS_0001 OUTPUT
FORM prepare_field_catalog CHANGING pt_fieldcat type lvc_t_fcat.
DATA ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'MNGRP' .
ls_fcat-tabname = 'QMSM'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '8' .
ls_fcat-coltext = 'Codegroup' .
ls_fcat-seltext = 'CODEGRUPPE' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'BAUTL' .
ls_fcat-tabname = 'qmfe'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '18' .
ls_fcat-coltext = 'Baugruppe' .
ls_fcat-seltext = 'BAUGRUPPE' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'MAKTX' .
ls_fcat-tabname = 'MAKT'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '40' .
ls_fcat-coltext = 'Material Description' .
ls_fcat-seltext = 'MATERIAL DESCRIPTION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'VBELN' .
ls_fcat-tabname = 'VBAP'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Sales Document' .
ls_fcat-seltext = 'SALES DOCUMENT' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'POSNR' .
ls_fcat-tabname = 'VBAP'.
ls_fcat-inttype = 'N' .
ls_fcat-outputlen = '6' .
ls_fcat-coltext = 'Position' .
ls_fcat-seltext = 'POSITION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EBELN' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Purchase Document' .
ls_fcat-seltext = 'PURCHASE DOCUMENT' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EBELP' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'N' .
ls_fcat-outputlen = '5' .
ls_fcat-coltext = 'Psoition' .
ls_fcat-seltext = 'POSITION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'MENGE' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'Q' .
ls_fcat-outputlen = '13' .
ls_fcat-coltext = 'Schudeld Quantity' .
ls_fcat-seltext = 'SCHUDELED QUANTITY' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'WEMNG' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'Q' .
ls_fcat-outputlen = '13' .
ls_fcat-coltext = 'Quantity Issued' .
ls_fcat-seltext = 'QUANTITY ISSUED' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EINDT' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'D' .
ls_fcat-outputlen = '8' .
ls_fcat-coltext = 'Delivery Date' .
ls_fcat-seltext = 'DELIVERY DATE' .
APPEND ls_fcat to pt_fieldcat .
ENDFORM.
thanx in advance
abhilash
‎2007 Jul 03 6:37 PM
Hello,
Change the code like this and check.
data: ra_mncod type range of mncod.
ra_mncod-sign = 'I'.
ra_mncod-option = 'EQ'.
ra_mncod-sign = '3050'.
append ra_mncod.
ra_mncod-sign = 'E'.
ra_mncod-option = 'EQ'.
ra_mncod-sign = '3100'.
append ra_mncod.
select a~mngrp b~bautl c~maktx d~vbeln d~posnr e~ebeln e~ebelp e~menge e~wemng e~eindt
into corresponding fields of table stab from
( qmsm as a inner join qmfe as b on a~qmnum = b~qmnum
inner join makt as c on b~matnr = c~matnr
inner join vbap as d on c~matnr = d~matnr
inner join ekpo as f on c~matnr = f~matnr
inner join eket as e on f~ebeln = e~ebeln )
where a~mncod in RA_MNCOD " Check here
and c~spras eq 'D'
and b~werks in plant
and b~bautl in baugroup.
Try this.
Vasanth
‎2007 Jul 03 6:32 PM
Hi Abhilash,
i think because you are using joins, it is giving you the problem, i suggest instead of using joins, if you use different Internal tables and append them into one final table, it may work.i.e, instead of using qmfe, makt, qmsm, vbap, vbup, ekpo, eket in inner join, create internal tables for above tables, with required fields in the structure and append in final output table which contains the fields from diff tables which you want to output.
i think it should work.
Reward points if useful
Thanks & Regards
Sujay
‎2007 Jul 04 10:27 AM
hi sujay,
i am also trying to do as u said but iam not getting that, after 3 tables for 4th table its giving an error while appending
so could u xplain me how to do that program?
thanx in advance
abhilash.
‎2007 Jul 03 6:37 PM
Hello,
Change the code like this and check.
data: ra_mncod type range of mncod.
ra_mncod-sign = 'I'.
ra_mncod-option = 'EQ'.
ra_mncod-sign = '3050'.
append ra_mncod.
ra_mncod-sign = 'E'.
ra_mncod-option = 'EQ'.
ra_mncod-sign = '3100'.
append ra_mncod.
select a~mngrp b~bautl c~maktx d~vbeln d~posnr e~ebeln e~ebelp e~menge e~wemng e~eindt
into corresponding fields of table stab from
( qmsm as a inner join qmfe as b on a~qmnum = b~qmnum
inner join makt as c on b~matnr = c~matnr
inner join vbap as d on c~matnr = d~matnr
inner join ekpo as f on c~matnr = f~matnr
inner join eket as e on f~ebeln = e~ebeln )
where a~mncod in RA_MNCOD " Check here
and c~spras eq 'D'
and b~werks in plant
and b~bautl in baugroup.
Try this.
Vasanth
‎2007 Jul 03 8:58 PM
thank you vasanth ,
i'll try this and if i get any issue again i would come again
‎2007 Jul 04 4:42 AM
Hi abhi ,,,,
i did changes on your query .... cut and paste .... i just comeented the screen 001 ... if you want you can uncomment it .
REPORT Z_SPRING_DELIVERY .
tables : qmfe, makt, qmsm, vbap, vbup, ekpo, eket.
types : begin of itab ,
mngrp like qmsm-mngrp,
bautl like qmfe-bautl,
maktx like makt-maktx,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
ebeln like eket-ebeln,
ebelp like eket-ebelp,
menge like eket-menge,
wemng like eket-wemng,
eindt like eket-eindt,
end of itab.
data : stab TYPE STANDARD TABLE OF itab INITIAL SIZE 0.
DATA : CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GRID TYPE REF TO CL_GUI_ALV_GRID,
GT_FIELDCAT TYPE LVC_T_FCAT.
select-options : plant for qmfe-werks,
baugroup for qmfe-bautl.
parameters : material like qmfe-matnr.
start-of-selection.
select a~mngrp
b~bautl
c~maktx
d~vbeln
d~posnr
e~ebeln e~ebelp e~menge e~wemng e~eindt
into corresponding fields of table stab from
(
( ( ( ( qmsm as a join qmfe as b on b~qmnum = a~qmnum )
join makt as c on c~matnr = b~matnr )
*
join vbap as d on d~matnr = c~matnr )
*
join ekpo as f on f~matnr = d~matnr )
*
join eket as e on e~ebeln = f~ebeln )
where ( a~mncod eq '3050'
*
and a~mncod ne '3100' )
*
and c~spras eq 'D'
*
and b~werks in plant
*
and b~bautl in baugroup.
*call screen 0001.
*&---------------------------------------------------------------------*
*& Module STATUS_0001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*module STATUS_0001 output.
*SET PF-STATUS 'MENU'.
*SET TITLEBAR 'MENU'.
*
CREATE OBJECT container
EXPORTING
container_name = 'CONT'. "Layout Grid name as CONT"
CREATE OBJECT grid
EXPORTING
i_parent = container.
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
CALL METHOD grid->set_table_for_first_display
* EXPORTING
* i_structure_name = 'ZSC_ALVSTUC' Structure of Itab created in Data Dictionary"
CHANGING
it_outtab = stab
IT_FIELDCATALOG = gt_fieldcat.
*endmodule. " STATUS_0001 OUTPUT
FORM prepare_field_catalog CHANGING pt_fieldcat type lvc_t_fcat.
DATA ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'MNGRP' .
ls_fcat-tabname = 'QMSM'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '8' .
ls_fcat-coltext = 'Codegroup' .
ls_fcat-seltext = 'CODEGRUPPE' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'BAUTL' .
ls_fcat-tabname = 'qmfe'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '18' .
ls_fcat-coltext = 'Baugruppe' .
ls_fcat-seltext = 'BAUGRUPPE' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'MAKTX' .
ls_fcat-tabname = 'MAKT'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '40' .
ls_fcat-coltext = 'Material Description' .
ls_fcat-seltext = 'MATERIAL DESCRIPTION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'VBELN' .
ls_fcat-tabname = 'VBAP'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Sales Document' .
ls_fcat-seltext = 'SALES DOCUMENT' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'POSNR' .
ls_fcat-tabname = 'VBAP'.
ls_fcat-inttype = 'N' .
ls_fcat-outputlen = '6' .
ls_fcat-coltext = 'Position' .
ls_fcat-seltext = 'POSITION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EBELN' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Purchase Document' .
ls_fcat-seltext = 'PURCHASE DOCUMENT' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EBELP' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'N' .
ls_fcat-outputlen = '5' .
ls_fcat-coltext = 'Psoition' .
ls_fcat-seltext = 'POSITION' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'MENGE' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'Q' .
ls_fcat-outputlen = '13' .
ls_fcat-coltext = 'Schudeld Quantity' .
ls_fcat-seltext = 'SCHUDELED QUANTITY' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'WEMNG' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'Q' .
ls_fcat-outputlen = '13' .
ls_fcat-coltext = 'Quantity Issued' .
ls_fcat-seltext = 'QUANTITY ISSUED' .
APPEND ls_fcat to pt_fieldcat .
ls_fcat-fieldname = 'EINDT' .
ls_fcat-tabname = 'EKET'.
ls_fcat-inttype = 'D' .
ls_fcat-outputlen = '8' .
ls_fcat-coltext = 'Delivery Date' .
ls_fcat-seltext = 'DELIVERY DATE' .
APPEND ls_fcat to pt_fieldcat .
ENDFORM .reward points if it is usefull ...
Girish
‎2007 Jul 04 8:33 AM
hi Girish,
thank you for ur work but still im facing the same problem. The program is running for a long time and its giving an error like time exceeded. Reason: endless looping.....
‎2007 Jul 04 5:54 AM
Hi,
Yes there in a bit problem in ur where condition its easy u can spot it easily once u check the dependency of one table with each other on the basis of their primary key relationship.
Pls reward points if u get some help frm it.
Regards,
Ameet
‎2007 Jul 04 10:23 AM
hi ameet,
i had a question that can we join 6 tables as i have given in the code?
if so is it correct way?
thank you
abhilash