I'm trying to select the latest date of a material movement from MSEG, but the material needs to be in stock and that is sourced from a bespoke table which uses unconverted Material names.
I've tried using the CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
(and INPUT
) but I'm not sure how to properly utilize it in a select statement.
IF MSEG-BWART = '101'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = ZBJSTOCK-ZMAT10
IMPORTING
OUTPUT = WA2-MATNR.
SELECT MAX( BUDAT_MKPF )
FROM MSEG
INTO GRDT
WHERE MATNR = WA2-MATNR.
ENDIF.
Currently, WA2-MATNR
seems to come out as blank and therefore is not pulling the data from MSEG.
You shouldn't use conversion exit here. Material number in SAP tables lays in internal (INPUT) format and you are converting it into readable format (OUTPUT) in order to query table. It is obvious you will not find anything.
Sample:
MATNR internal format (for OUT exits)
MATNR external format (for IN exits)
Conversions cases:
000000000000025567 ->
CONVERSION_EXIT_MATN1_OUTPUT
-> 25567 ✔️25567 ->
CONVERSION_EXIT_MATN1_OUTPUT
-> 25567 ❌ nothing changes25567 ->
CONVERSION_EXIT_MATN1_INPUT
-> 000000000000025567 ✔️000000000000025567 ->
CONVERSION_EXIT_MATN1_INPUT
-> 000000000000025567 ❌ nng changesMost likely, your bespoke table contains faulty material number so exit doesn't return anything. Or material number in format that exit doesn't expect, e.g. 19 characters instead of 18 and so on.
P.S.
Just for you info, you can use templates for conversion. It is the same as calling conversion FMs
In the above sample SELECT will not return anything, but if you comment out the template line it will.