‎2008 Jun 24 11:14 PM
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
‎2008 Jun 24 11:17 PM
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.
‎2008 Jun 24 11:19 PM
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
‎2008 Jun 25 4:33 AM
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'.
‎2008 Jun 25 5:05 AM
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.
‎2008 Jun 25 5:47 AM
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
‎2008 Jun 25 6:09 AM
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.
‎2008 Jun 25 6:10 AM
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
‎2008 Jun 25 6:46 AM
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