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

Convert in right data element

Former Member
0 Likes
2,496

hi all

i have import materialnumber from a textfile, now i want to convert this materialnumber from string in matnr type. For this, i need a class or functionmodul...

Thx abap_begin....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,455

Hi,

Use conversion exits, like CONVERSION_EXIT_ALPHA_INPUT function module

Regards,

Raghava Channooru

3 REPLIES 3
Read only

Former Member
0 Likes
1,456

Hi,

Use conversion exits, like CONVERSION_EXIT_ALPHA_INPUT function module

Regards,

Raghava Channooru

Read only

Former Member
0 Likes
1,455

Hi,

You can directly pass the imported value to any variable of type MATNR.

It will automatically handle the conversion routines.

Please search on SDN before posting.

Thanks,

Daya.

Read only

Former Member
0 Likes
1,455

Sigh, this really is a basic question that should have been answered plenty of times. However, I feel obliged to comment, because I don't like wrong answers (because if people actually do search, they will pick up wrong suggestions)...

SAP uses so called [conversion exits|http://help.sap.com/abapdocu_70/en/ABENCONVERSION_EXITS.htm] for converting values for certain domains. E.g. for the data element MATNR, which you can find in the data dictionary (transaction SE11), you'll see that a domain with the same name MATNR is used. If you drill down into the domain, you'll find a field labeled conversion routine and there you see MATN1. This means that input data is converted to internal format via CONVERSION_EXIT_MATN1_INPUT and the internal format is converted to external format via CONVERSION_EXIT_MATN1_OUTPUT. In your specific case you'll have to use the first function, if you have an external material number that needs to be converted to the format how it's used internally on the database.

That much for the do's, now to the don'ts:

<ul style="list-style:square!important;">

<li>Don't use CONVERSION_EXIT_ALPHA_INPUT, because this is simply incorrect. Depending on your customizing for material numbers it might lead to wrong results as it's simply not the right conversion routine (as you can see clearly in the data dictionary). There is for example a customer exit for material number input, which would not be applied at all if you use this wrong function module.</li>

<li>Don't assume that conversions are always automatically applied. I.e. if I have a variable of type STRING and MOVE the contents to another variable of type MATNR, the contents will simply be copied one-to-one (with possible truncation though, since material number has maximal 18 characters). The statement that the conversion exits are automatically applied when you use the right datatype is true if we talk about screen fields where users enter data.</li>

</ul>

Cheers, harald