2007 Mar 14 9:28 AM
Hi,
Iam doing some validations.fileds is plant(WERKS)mateial(MATNR), ZDATBA(date from date),ZDATBI(Date to date),Zmessage.
My requirement is
1)check whether a material is selected for the given plant.if it doesn't belongs to the selected plant,display error message" Material does not
exist for this plant"
2) Check whether the message entered already exist for the plant,material,Date
Combination(Note: All fields in ZMSG table).If it exists display message " A message already exists for the material,plant,date combination"
How to write the select quires for my requirement.Please help me.It is very urgent.
Thanks & Regards,
Sairam
2007 Mar 14 9:35 AM
Hi
for the first part:
tables: marc, Zmsg.
select single matnr werks into (v_matnr , v_werks) from MARC
where matnr in s_matnr and
werks in s_werks.
(s_werks, and S_matnr are selection screen fields)
if sy-subrc <> 0.
give the given error message.
endif.
similary write a selecrt statement for table ZMSG and give error message.
Regards,
Anji
2007 Mar 14 9:40 AM
Solution for first query ..
Tables : Marc .
parameters : p_werks type werks ,
p_matnr type matnr.
At-selection-screen.
Select single * from marc where werks = p_werks and matnr = p_matnr.
if sy-subrc <> 0.
message "Material does not exist for this plant" type 'E'.
endif.
Thanks
JK
2007 Mar 14 9:40 AM
Hi
I couldn't understand the Second part. please tell again
For the first part here is the query to solve.
2007 Mar 14 9:45 AM
Tables: MARC
" s_matnr and s_werks are the select options placed on the screen.
data: v_matnr like marc-matnr,
v_werks like marc-werks.
Select Single matnr
werks
into v_matnr ,
v_werks
from MARC
where matnr in s_matnr and
werks in s_werks.
if sy-subrc ne 0.
<Error Message> " Your error messge Type 'E'
endif.
2007 Mar 14 10:39 AM
Hi,
Thanks for all replies.This answers is very help full to me.
This requirement is doing for table validations not for report.(ZMSG table).
My second problem is I was maintaing the table entries (ZMSG) through
transaction code.Suppose in the table entries i entered Plant,material and date combination one message.Again i have enter the same message for the These 3 fields combination i will get the error message " These message already enetered the these 3 fields combinitions".This is my requirement.Please give me query.
Thanks & Regards,
sairam
2007 Mar 14 11:02 AM
For Validating table while maintenance
1)To check whether material belongs to the plant,use check table with marc.
2)To get error message for same entries,
define the fields Plant,material and date as primary key fields.
Hope it solves ur query.
Regars,
Viji
2007 Mar 14 11:38 AM
Hi,
I defiend primary keys.But i want for validations.How to write the query
for second problem.Because iam displaying the custom message.
Thanks & Regards,
sairam
2007 Mar 14 11:55 AM
Hi ,
Then in that case, in ur query,
data: v_matnr like msg-matnr,
1)To chk material belong to plant
loop at it_msg.
Select Single matnr
into v_matnr ,
from Msg
where matnr eq it_msg-matnr and
werks eq it_msg-werks .
if sy-subrc ne 0.
<Error Message> " Your error messge Type 'E'
endif.
endloop.
2) To check for duplications
loop at it_msg.
Select Single matnr
into v_matnr ,
from Msg
where matnr eq it_msg-matnr and
werks eq it_msg-werks and date eq it_mseg-werks.
if sy-subrc eq 0.
<Error Message> " Your error messge Type 'E'
endif.
2007 Mar 15 5:45 AM
Hi all,
These answeres is very helpful to me.I will give rewards points to all.
Thanks & Regards,
sairam