CONVERSION_EXIT_ALPHA_INPUT / OUTPUT¶
Add or remove leading zeros — the standard conversion routines for material, vendor, customer, and account numbers.
Purpose¶
SAP stores many key fields (material numbers, vendor numbers, customer numbers, G/L accounts) in internal format: right-justified, padded with leading zeros to the field's full length. User-visible external format omits leading zeros. These two function modules convert between the two representations.
| Function module | Direction | Example |
|---|---|---|
CONVERSION_EXIT_ALPHA_INPUT |
External → Internal | '100' → '0000000100' |
CONVERSION_EXIT_ALPHA_OUTPUT |
Internal → External | '0000000100' → '100' |
When to use¶
Call CONVERSION_EXIT_ALPHA_INPUT before:
- Passing a user-entered number to a BAPI (VENDOR, MATERIAL, CUSTOMER, ACCOUNT fields)
- Using a short number in a SELECT WHERE clause on LIFNR, MATNR, KUNNR, HKONT
- Calling CONVERSION_EXIT_ALPHA_OUTPUT before displaying a stored number back to the user
Signature¶
Both routines share the same interface:
| Parameter | Direction | Description |
|---|---|---|
INPUT |
Importing | Number to convert |
OUTPUT |
Exporting | Converted result |
No EXCEPTIONS clause — these routines do not raise exceptions.
Example — convert before BAPI call¶
DATA: lv_vendor_ext TYPE char10 VALUE '100001',
lv_vendor_int TYPE lifnr.
" User input '100001' → internal '0000100001'
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_vendor_ext
IMPORTING
output = lv_vendor_int.
" Now safe to pass to BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = VALUE bapimepoheader(
vendor = lv_vendor_int " '0000100001'
... ).
Example — convert after reading from database¶
SELECT SINGLE lifnr FROM lfa1
INTO @DATA(lv_lifnr)
WHERE lifnr = @lv_vendor_int.
DATA lv_display TYPE char10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lv_lifnr
IMPORTING
output = lv_display.
WRITE: / 'Vendor:', lv_display. " prints '100001' not '0000100001'
Inline shorthand with ABAP 7.40+¶
For simple conversions inside expressions, use the ALPHA conversion exit directly:
" Input conversion inline
DATA(lv_matnr) = CONV matnr( |{ lv_input ALPHA = IN WIDTH = 18 }| ).
" Output conversion inline
WRITE: / |{ lv_matnr ALPHA = OUT }|.
The ALPHA = IN / ALPHA = OUT format options replicate the FM behavior without a function call.
Common pitfalls¶
Always convert before database access
Searching MATNR, LIFNR, or KUNNR with a short number (no leading zeros) returns no results. The WHERE clause must use the full internal format.
Field-specific conversion exits
ALPHA is the most common exit, but some fields use different routines:
- CONVERSION_EXIT_MATN1_INPUT — material number with special handling
- CONVERSION_EXIT_ISOLA_INPUT — ISO language codes
- CONVERSION_EXIT_GJAHR_INPUT — fiscal year
Check the field's domain in SE11 (Conversion Routine column) to find the correct exit for non-standard fields.
See also¶
BAPI_PO_CREATE1— vendor and material numbers need conversion before useBAPI_SALESORDER_CREATEFROMDAT2— partner numbers need conversion- Transaction SE11 — check a field's domain and its conversion routine