06-29-2006 7:43 PM
I want to read the unit of measure from marc table.
The whole program was hard coded for one plant ,now they added few more materials under different plant.
My orginal statement was like this
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and werks = 'ABC'.
NOW IAM CHANGING IT TO.
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and werks = 'ABC'
OR WERKS = 'DEF'.
can anybody tell me how does it work
I thought it would first check plant ABC ,IF ITS NOT FOUND IN PLANT ABC THEN IT WOULD CHECK pLANT DEF.
lET ME KNOW WHETHER IAM RIGHT OR NOT?
06-29-2006 7:47 PM
No, because you are not using parenthesis
Make sure to use parenthesis. In your statement you are saying that I want record where MATNR = the_material and where plant is = 'ABC' OR forget about the material and where the plant = 'DEF'. Adding parenthesis, will help out your AND/OR logic.
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and ( werks = 'ABC'
OR WERKS = 'DEF' ).
Regards,
Rich Heilman
06-29-2006 7:47 PM
No, because you are not using parenthesis
Make sure to use parenthesis. In your statement you are saying that I want record where MATNR = the_material and where plant is = 'ABC' OR forget about the material and where the plant = 'DEF'. Adding parenthesis, will help out your AND/OR logic.
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and ( werks = 'ABC'
OR WERKS = 'DEF' ).
Regards,
Rich Heilman
06-29-2006 7:47 PM
Change it this way.
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and ( werks = 'ABC'OR
WERKS = 'DEF' ).
06-29-2006 8:08 PM
The best way would be to put it into a select-option and default it at the initialization event. That way, if (when) they want to add more plants, the user just changes the selection screen.
Rob
06-29-2006 8:11 PM
or use,
select single ausme into itab-ausme
from marc
where matnr = itab-matnr
and werks in ( 'ABC' OR 'DEF' ).
but how you will know the retrieved AUSME value is for what plant ??? so its better to use PLANT(WERKS) also in the select condition.
select single werks
ausme
into (itab-werks,
itab-ausme)
from marc
where matnr = itab-matnr
and werks in ( 'ABC' OR 'DEF' ).
YOu also hardcoding the PLANT values in the selection screen.instead you can use a Select-option displayed on the selection-screen & use that select options in the where clause like
where WERKS IN S_WERKS.
regards
srikanth
Message was edited by: Srikanth Kidambi
06-29-2006 8:14 PM
MARC might have entrys for one plant or both plants.
Select statement does not check for entry in plant DEF if not found for ABC, but selection stops after selecting first record. it might be ABC or DEF.
If primary key exists in the database (Usually do), it'll be sorted and you get ABC if both plants have records in the table.
Regards
Sridhar
06-29-2006 8:50 PM