Skip to Content
0
Former Member
Apr 22, 2008 at 10:11 AM

Select-options

27 Views

Hi All,

I need to fetch the data based on selection criterial PLANT,MATERIAL,DATE,at present my coding working for MATERIAL only can any one give hit how to fetcah data from above two options,here it is my code:

TABLES:s031,s032,makt,marc.

DATA : BEGIN OF itab1 OCCURS 0,

matnr TYPE s031-matnr,

lgort TYPE s031-lgort,

werks TYPE s031-werks,

spmon TYPE s031-spmon,

magbb TYPE s031-magbb,

wagbb TYPE s031-wagbb,

azubb TYPE s031-azubb,

aagbb TYPE s031-aagbb,

END OF itab1.

DATA : BEGIN OF itab2 OCCURS 0,

matnr LIKE makt-matnr,

maktx LIKE makt-maktx,

END OF itab2.

DATA : BEGIN OF itab3 OCCURS 0,

matnr TYPE marc-matnr,

werks TYPE marc-werks,

ekgrp TYPE marc-ekgrp,

END OF itab3.

DATA : BEGIN OF itab4 OCCURS 0 ,

matnr TYPE s032-matnr,

lgort TYPE s032-lgort,

werks TYPE s032-werks,

mbwbest TYPE s032-mbwbest,

wbwbest TYPE s032-wbwbest,

END OF itab4.

DATA: BEGIN OF itab5 OCCURS 0,

matnr LIKE s031-matnr,

atinn LIKE cawn-atinn,

atwrt LIKE cawn-atwrt,

objek LIKE ausp-objek,

END OF itab5.

DATA : BEGIN OF itab_final1 OCCURS 0,

matnr TYPE s031-matnr,

lgort TYPE s031-lgort,

werks TYPE s031-werks,

  • spmon TYPE s031-spmon,

magbb TYPE s031-magbb,

wagbb TYPE s031-wagbb,

azubb TYPE s031-azubb,

aagbb TYPE s031-aagbb,

maktx TYPE makt-maktx,

ekgrp TYPE marc-ekgrp,

mbwbest TYPE s032-mbwbest,

wbwbest TYPE s032-wbwbest,

atwrt TYPE cawn-atwrt,

END OF itab_final1.

DATA : BEGIN OF itab_final OCCURS 0,

matnr TYPE s031-matnr,

lgort TYPE s031-lgort,

werks TYPE s031-werks,

  • spmon TYPE s031-spmon,

magbb TYPE s031-magbb,

wagbb TYPE s031-wagbb,

azubb TYPE s031-azubb,

aagbb TYPE s031-aagbb,

maktx TYPE makt-maktx,

ekgrp TYPE marc-ekgrp,

mbwbest TYPE s032-mbwbest,

wbwbest TYPE s032-wbwbest,

atwrt TYPE cawn-atwrt,

END OF itab_final.

DATA: wa_itab5 LIKE LINE OF itab5.

DATA : wa_itab_final LIKE LINE OF itab_final.

SELECT-OPTIONS:s_matnr FOR s031-matnr.

SELECT-OPTIONS:s_werks FOR s031-werks.

SELECT-OPTIONS : s_DATE FOR S031-SPMON.

*---- Validate Material/Plant.

SELECT *

FROM s031

WHERE matnr in s_matnr

AND werks in s_werks.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE E999(GW) WITH 'Check Material/Plant no.'.

ENDIF.

SELECT amatnr algort awerks aspmon amagbb awagbb aazubb aaagbb

bmaktx cekgrp dmbwbest dwbwbest

INTO CORRESPONDING FIELDS OF TABLE itab_final1

FROM ( ( ( s031 AS a

INNER JOIN makt AS b ON bmatnr = amatnr )

INNER JOIN marc AS c ON cmatnr = bmatnr )

INNER JOIN s032 AS d ON dwerks = cwerks ) WHERE a~matnr IN s_matnr

ORDER BY a~matnr

a~werks.

LOOP AT itab_final1 INTO wa_itab_final.

itab_final-matnr = wa_itab_final-matnr.

itab_final-lgort = wa_itab_final-lgort.

itab_final-werks = wa_itab_final-werks.

itab_final-magbb = wa_itab_final-magbb.

itab_final-wagbb = wa_itab_final-wagbb.

itab_final-azubb = wa_itab_final-azubb.

itab_final-aagbb = wa_itab_final-aagbb.

itab_final-maktx = wa_itab_final-maktx.

itab_final-mbwbest = wa_itab_final-mbwbest.

itab_final-wbwbest = wa_itab_final-wbwbest.

APPEND itab_final.

ENDLOOP.

SELECT eatinn eatwrt fatinn fobjek

INTO CORRESPONDING FIELDS OF TABLE itab5

FROM ( cawn AS e

INNER JOIN ausp AS f ON fatinn = eatinn ) WHERE f~objek IN s_matnr.

SORT itab_final BY matnr werks ekgrp .

DELETE ADJACENT DUPLICATES FROM itab_final COMPARING matnr werks ekgrp.

LOOP AT itab5 INTO wa_itab5 .

loop at itab_final where matnr = wa_itab5-objek.

itab_final-atwrt = wa_itab5-atwrt.

modify itab_final index sy-tabix transporting atwrt.

endloop.

ENDLOOP.

LOOP AT itab_final.

WRITE: / itab_final-matnr , itab_final-lgort , itab_final-werks, itab_final-magbb, itab_final-wagbb, itab_final-azubb, itab_final-aagbb,

itab_final-maktx, itab_final-ekgrp, itab_final-wbwbest, itab_final-mbwbest,itab_final-atwrt color 3.

ENDLOOP

Thanks&regds,

Sree.