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

Parameter Value.

ramco1917
Participant
0 Likes
1,912

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

8 REPLIES 8
Read only

TobiH
Participant
0 Likes
1,739

hi,

check the following

shift matnr left deleting leading '0'.

kind regards,

tobias

Read only

matt
Active Contributor
1,739

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.

Read only

0 Likes
1,739

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

Read only

matt
Active Contributor
0 Likes
1,739

Use the INPUT function module just before you call your Z_ function module. Internally, leading zeros are used, yes.

Read only

former_member660513
Participant
0 Likes
1,739

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)

Read only

ramco1917
Participant
0 Likes
1,739

Hi Tobias

How i can use Shift in my code.

Thanks

Read only

matt
Active Contributor
1,739

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,739

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".