‎2021 May 14 12:27 PM
Hi
I have below code . In Parameter i have to enter value - 000000000000000038.
I want that i should enter only 38 . Since Value in Matnr is stored as 38.
REPORT ZABAP_GETMATERIALDETAILS.
data : wa_mara type mara.
PARAMETERS : p_matnr type mara-matnr.
CALL FUNCTION 'ZABAP_GETMATERIALDETAILS'
EXPORTING
IM_MATNR = p_matnr
IMPORTING
EX_MARA = wa_mara
.
Write : SY-SUBRC.
*WRITE : WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MEINS, WA_MARA-MBRSH .
IF SY-SUBRC = 0.
* Implement suitable error handling here
WRITE : WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MEINS, WA_MARA-MBRSH .
ENDIF.
Thanks
‎2021 May 14 12:49 PM
hi,
check the following
shift matnr left deleting leading '0'.kind regards,
tobias
‎2021 May 14 12:56 PM
Do not use SHIFT.
Go to SE11, look at the domain for the data element MATNR. You'll see it has a conversion exit called MATN1. This means there are function modules to convert from the external (your parameter) to the internal (how it's held on the database). These are:
CONVERSION_EXIT_MATN1_INPUT and
CONVERSION_EXIT_MATN1_OUTPUT
Use these function modules.
‎2021 May 14 2:37 PM
Hi Matthew
Yes. Can u pls help me with my scenario where i should write to access this function in my code.
Internally i think Matnr is saved as 000000000000000045 (with leading Zeros) or i am wrong
Thanks
‎2021 May 14 3:22 PM
Use the INPUT function module just before you call your Z_ function module. Internally, leading zeros are used, yes.
‎2021 May 14 1:47 PM
Other alternative is to use the keyword WRITE TO, maybe have a look here regarding the syntax
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapwrite_to.htm
it should execute the conversion(routines)
‎2021 May 14 2:39 PM
‎2021 May 14 3:33 PM
Don't use the solution. First of all, Tobias is converting from 000000000000000038 to 38 and I think you want form 38 to 000000000000000038, so using the conversion FM is easiest (or WRITE... USING EDIT MASK '==MATN1' )
Secondly, it won't help you if you encounter conversion functions of a different kind somewhere else.
‎2021 May 14 6:51 PM
Your question and the comments are a lot confusing.
With this line of code:
PARAMETERS : p_matnr type mara-matnr.if you type "38" in P_MATNR screen field, the variable P_MATNR will automatically contain the value "000000000000000038" because of the conversion exit defined by MARA-MATNR.
Why do you need to convert it?
NB: ZABAP_GETMATERIALDETAILS should work with value "000000000000000038", not with value "38". That would probably be a bad design if it works only with "38".