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: 

raise error if material no. doesnot exist

Former Member
0 Kudos

Hi All,

Currently I am checking:

if wa_datatab-col1 is initial

or wa_datatab-col4 is initial

message A000(AR) with 'Error in the file in line,' sy-tabix.

So if my col1 and col4 is blank then it is throwing the error. My col1 is material no. Also I have to throw an error if my materianl no in col1 doesnot exist in mara.

Can anyone of you guys please tell me the code for it.

Regards,

Cheng

8 REPLIES 8

Former Member
0 Kudos
DATA:
  lv_subrc          TYPE sysubrc.

SELECT COUNT( * ) FROM mara WHERE matnr = wa_datatab-col1.
lv_subrc = sy-subrc.

IF wa_datatab-col1 IS INITIAL OR
   wa_datatab-col4 IS INITIAL OR
   lv_subrc IS NOT INITIAL.
  MESSAGE A000(AR) with 'Error in the file in line,' sy-tabix.
ENDIF.

Former Member
0 Kudos

hi,

if wa_datatab-col1 is not initial.

select count(*) from mara where matnr = wa_datatab-col.

if sy-subrc eq 0.

message 'Material doesn't exist' type 'E'.

endif.

endif.

<removed_by_moderator_together_with_some_points>

Edited by: Julius Bussche on Jun 24, 2008 10:21 PM

kesavadas_thekkillath
Active Contributor
0 Kudos

select matnr into mara-matnr from mara where matnr = wa_datatab-col1

and lvorm = space.

exit.

endselect.

check sy-subrc <> 0.

message 'Material doesnot Exists' TYPE 'E'.

Former Member
0 Kudos

Hi,

Please refer the code below :




if wa_datatab-col1 is initial
or wa_datatab-col4 is initial
message A000(AR) with 'Error in the file in line,' sy-tabix.
endif.

"New code for material number validation.

if not wa_datatab-col is initial.
 select matnr from mara into v_matnr where matnr = wa_datatab-col.

if sy-subrc <> 0.
message 'Mat not found' type 'E'.
endif.

Thanks,

Sriram POnna.

Former Member
0 Kudos

Hi,

You Can Try Like This Way

Loop at wa_datatab.

if wa-datab-col1 in not initial.

select matnr from mara where matnr eq wa-data-col1.

If sy-subrc ne 0.

message 'Material Not found' Type 'I'.

Endif.

Endif,

Endloop.

Thanks

Sujit

Former Member
0 Kudos

Hai Cheng,

Try this:

This is to check for the availability of atleast one record in MARA for a given Material No.

Select single *

From mara

Into wa

Where matnr in <sel-options name>.

If sy-subrc ne 0.

Message e000(AR) with 'No Records Foundu2019.

Endif.

This is to check whether a particular material exist or not

Select *

From mara

Into table <datatab name>

Where matnr in <sel-options name>.

If sy-subrc ne 0.

Message e000(AR) with 'Material No. does not existu2019.

Endif.

Plzz reward points if useful.

Regards,

Swapna.

Former Member
0 Kudos

hi

u can try this.

select matnr
into     wa_mara
from    mara
up to 1 rows.

if sy-subrc <> 0.
Error <Message>. Mat Not present
endif.

endselect.

hope this will work.

reward if useful.

Sumit Agarwal

Former Member
0 Kudos

Hi Cheng,

You can go by any of the above mentioned ways, but make sure that you use SELECT SINGLE....... as follows.

SELECT SINGLE MATNR

INTO W_MATNR

FROM MARA

WHERE <CONDITION>.

IF W_MATNR IS INITIAL

MESSAGE 'MATERIAL DOES NOT EXISTS' TYPE I.

ENDIF.

Hope this helps you.

Regards,

Chandra Sekhar

Edited by: Chandrasekhar Gandla on Jun 25, 2008 7:47 AM