Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Tips and Tricks arrow User Exits arrow Conversion Exits
Conversion Exits PDF Print E-mail
User Rating: / 3
PoorBest 
Written by Rich   
Saturday, 19 May 2007
What are conversion exits ?? Conversion exits are the method by which SAP uses to normalise the data held in the various tables. As a good example, have a look at material numbers.

If the material number contains all numeric characters (ie the characters 0-9), then SAP prepends leading zeroes onto the string so that 12345 becomes 000000000000012345.

The reason for this is so that the numbers are sorted correctly by the database. If for example you had the numbers 1,2,3,4,5, 10, 200, 1000 as material numbers and asked SAP to sort them by material number you would end up with the sequence: 1,10,1000, 2, 200, 3, 4 and 5. However by prepending zeroes to the material number to bring it to some standard length, then the material numbers will sort in the order that you think they should be.

This also explains why, when you search for a material number, even though the user says it's '1234' and you search the database for '1234' you will not find it. Stick a bunch of zeroes on the front and you will find it!!

As another quick example, have a look at WBS elements. I'll defy you to find a WBS element in the database which has a name the same as you type in to access them. SAP converts these names into six (or is it 8 ??) digit numbers prefixed by zeroes. This is then what is used in the tables to identify each WBS element or project:

So what is a conversion exit ?
A conversion exit consists of two function modules. One module converts incoming data into the representation that will be used internally. The second is a module that converts internally represented data to that which is displayable and user friendly.

Conversion exits are called automatically whenever a variable (who'se domain has a conversion exit defined) is either input via a selection screen or output via a write statement.

How do I find a conversion exit.

Conversion exits are defined at a domain level and therefore apply to all data elements and fields that belong to that domain.

Taking the second example above, a data element for a WBS element is PS_POSNR. If we look at the data element screen for PS_POSNR we can see that the domain is PS_POSNR. Displaying the details for that domain shows us the following screen:



In the field titled 'Convers. Routine', we can see the text 'ABPSP'. The conversion exits for this type of data then are : CONVERSION_EXIT_ABPSP_INPUT (called by Parameter statements etc) and CONVERSION_EXIT_ABPSP_OUTPUT which is for output statements.

Now I've Found It How Do I Use It ?

Conversion exits are used in exactly the same way as functions (well... They are functions). You provide the input parameters and the function then provides the answers:

Code:
*
* Valid settlement profile ?
*
Call Function 'CONVERSION_EXIT_ABPSP_INPUT'
Exporting
Input = w_pspnr_out
Importing
Output = w_pspnr.
Read Table t_elements with key pspnr = w_pspnr.
Select single aprof
into w_aprof
from cobra
where objnr = t_elements-objnr.
For input parameters, as long as you define the parameter as a member to the same domain, the conversion exit input function will be called automatically so that the variable then contains the internal representation of the value.

Likewise, using the WRITE command will also use the correct conversion exit output function if the variable is defined with the correct domain.

How Do I Create my Own Conversion Exits ?

Write your two conversion exits in the same manner that SAP does - with an input and output parameter only.

Make sure that they conform to the naming convention CONVERSION_EXIT_XXXXX_INPUT and CONVERSION_EXIT_XXXXX_OUTPUT.

Activate and test them.

Then, create a domain that reflects the characteristics of the data you are processing, and in the Conversion exit field enter XXXXX.

You then need to define a data type to be able to use this.

Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 332
Sample Code: 164
Total Contributions: 548

Member Activity
Members: 6125 since 2/1/2007!
New: 7 since yesterday!
Visitors: 985320

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor