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

functional module

Former Member
0 Likes
353

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

2 REPLIES 2
Read only

Former Member
0 Likes
311

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

Read only

Clemenss
Active Contributor
0 Likes
311

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