‎2007 Oct 16 6:46 PM
Hi , I am retrieving material numbers from a excel sheet into an internal table. Now I want to check this internal table against MARA table to see if the entered material numbers are valid or not. How to achieve this ? I mean what is the most efficient way.
Also , if I enter a value in a screen input field how can I check its validity with material number sin MARA
Thank you .
‎2007 Oct 16 6:48 PM
You need to first use Conversion exit routine to get the material no. Then you can write SELECT on MARA to validate material no.
For eg -
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = ITAB-MATNR
IMPORTING
OUTPUT = ITAB-MATNR
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
SELECT SINGLE MATNR INTO L_MATNR
FROM MARA
WHERE MATNR = ITAB-MATNR.
IF SY-SUBRC EQ 0.
"VALID MATERIAL"
ELSE
"INVALID MATERIAL".
ENDIF,
ENDIF.
Hope this helps.
ashish
‎2007 Oct 16 6:48 PM
You need to first use Conversion exit routine to get the material no. Then you can write SELECT on MARA to validate material no.
For eg -
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = ITAB-MATNR
IMPORTING
OUTPUT = ITAB-MATNR
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
SELECT SINGLE MATNR INTO L_MATNR
FROM MARA
WHERE MATNR = ITAB-MATNR.
IF SY-SUBRC EQ 0.
"VALID MATERIAL"
ELSE
"INVALID MATERIAL".
ENDIF,
ENDIF.
Hope this helps.
ashish
‎2007 Oct 16 6:49 PM
Hi,
Please use FM CONVERSION_EXIT_MATN1_INPUT to convert material number input screen then perform validation against table MARA.
Regards,
Ferry Lianto
‎2007 Oct 16 7:11 PM
Hello Krish,
How you know which material number is wrong one unless if you use error log table.
See the below logic :
You can write simple logic :
Assume that your internal table is itab.
error log internal table
data : begin of itab1 occurs 0,
matnr(18) type c,
text(50) type c,
end of itab1.
loop at itab.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = ITAB-MATNR
IMPORTING
OUTPUT = ITAB-MATNR
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2.
select single * from mara into mara
where matnr = itab-matnr.
if sy-subrc ne 0.
itab1-matnr = itab-matnr.
itab1-text = 'Material does not exits'.
append itab1
clear itab1.
endif.
endloop.
Thanks
Seshu