‎2010 Dec 04 6:15 AM
hi everybody.....!
I 'm new to abap programming. My question is, if we declare a variable of 10 character size and if we pass a number of four digits, the output should display like this 0000001234. for getting this as the output, which functional module has to be used. Actually how to know abt the different functional modules which are allready predefined?
Moderator message: please search for available information/documentation before asking, these forums are not a replacement for ABAP training, use meaningful subject lines when posting, please read the rules of engagement.
Edited by: Thomas Zloch on Dec 4, 2010 9:52 PM
‎2010 Dec 04 1:38 PM
There are several methods to add leading zeroes.
1. Function Module CONVERSION_EXIT_ALPHA_INPUT
2. OVERLAY command
3. UNPACK
DATA: v_char TYPE char10.
v_char = '1234'
" Using UNPACK command which unpacks the field by adding leading zeroes
UNPACK v_char TO v_char.
" Using Function Module
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = v_char
IMPORTING
OUTPUT = v_char.
"Using OVERLAY
SHIFT v_char RIGHT DELETING TRAILING SPACE. "adds six preceeding space characters
OVERLAY v_char WITH '0000000000'. "replace space characters with zero
‎2010 Dec 04 3:55 PM
Hi praveen8470,
no function module required.
You can declare the variable as TYPE N. This is Numerical Character.
The best thing is to use an existing data element.
If you are not coming from stone age, you will use SE80 object explorer for all your development. You have a big button on the left "Repository info system". Push ist, expand the tree for dictionary, choose data elements, enter 10 for the length and NUMC for the datatype.
Press F8 and choose what fits your need.
Declare variable as
DATA lv_numchar type NUMC10.The data type NUMC uses an implicit Input/Output conversion: For Input, leading zeros are added. For output, they are removed.
Regards,
Clemens
Regards,
Clemens