Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Validations

Former Member
0 Kudos
107

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

9 REPLIES 9

Former Member
0 Kudos
80

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

Former Member
0 Kudos
80

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

Former Member
0 Kudos
80

Hi

I couldn't understand the Second part. please tell again

For the first part here is the query to solve.

Former Member
0 Kudos
80

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.

0 Kudos
80

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

Former Member
0 Kudos
80

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

0 Kudos
80

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

0 Kudos
80

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.

0 Kudos
80

Hi all,

These answeres is very helpful to me.I will give rewards points to all.

Thanks & Regards,

sairam