Application Development and Automation 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: 
Read only

Validation on Material number

Former Member
0 Likes
3,489

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 .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,779

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

3 REPLIES 3
Read only

Former Member
0 Likes
1,780

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

Read only

Former Member
0 Likes
1,779

Hi,

Please use FM CONVERSION_EXIT_MATN1_INPUT to convert material number input screen then perform validation against table MARA.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,779

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