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

Adding Leading Zero's to a variable

Former Member
6,743

Hi friends ,

<b>1.</b> I want to add leading zero's to a field .

Wxample - LIFNR , if its value in a variable is 16987 then i want to convert it to standard format (0000016987).

<b>2.</b> I want to convert date format to system's format. In Dev server and quality server it is in different format and i'm facing problem while uploading data using BDC.Also how i'll identify that in which format it is in production.

How to get it

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,144

YOu can use the fm CONVERT_DATE_TO_INTERNAL for your 2nd problem.

YOu can use the fm CONVERSION_EXIT_ALPHA_INPUT

for your 1st problem

Regards,

ravi

17 REPLIES 17
Read only

Former Member
0 Likes
5,144

Hi to add leading zeroes

then please use FM

CONVERSION_EXIT_ALPHA_INPUT

Read only

Former Member
0 Likes
5,145

YOu can use the fm CONVERT_DATE_TO_INTERNAL for your 2nd problem.

YOu can use the fm CONVERSION_EXIT_ALPHA_INPUT

for your 1st problem

Regards,

ravi

Read only

0 Likes
5,144

data: k1(4) type c value '4567'.

data: k2(10) type n .

k2 = k1.

write: k2.

Read only

0 Likes
5,144

Hi sonal,

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = rp50m-pernr

IMPORTING

output = rp50m-pernr+0(8).

Reward points if it helps

Regards

Gunjan

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
5,144

Hi,

Use these function Modules for ur problems..

(1)For adding leading zeroes or in sap format internal..

<b>CONVERSION_EXIT_ALPHA_INPUT</b>

(2)For changing date into systems internal format..

<b>CONVERT_DATE_TO_INTERNAL</b>

Cheers,

Simha.

Read only

Former Member
0 Likes
5,144

To add leading zeroes, use FM CONVERSION_EXIT_ALPHA_INPUT if passing values from user screen to SAP), and CONVERSION_EXIT_ALPHA_OUTPUT (if passing values from SAP to user screen - this will delete leading zeroes and return only the value).

Standard date format in all SAP systems is sy-datum. It is stored in the system as YYYYMMDD. When writing on the screen, it will come up as per the user's specification.

If you declare your field as type sy-datum or pass it in the above format, you should be ok.

Hope this helps.

Sudha

Read only

Former Member
0 Likes
5,144

hi sonal,

1) Use the FM Conversion_exit_alpha_input.

2) use FM CONVERT_DATE_TO_INTERN_FORMAT or CONVERT_DATE_TO_INTERNAL

Read only

Former Member
0 Likes
5,144

Hi Sonal,

data : l_val type lifnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = l_val

IMPORTING

OUTPUT = l_val.

write : l_val

Read only

Former Member
0 Likes
5,144

Hi,

Use conversion exit function module to add zeros

CONVERSION_EXIT_ALPHA_INPUT

2. declare your variables as SY-DATUM.

regards,

Shashank

Read only

Former Member
0 Likes
5,144

1. Use Functional module

'CONVERSION_EXIT_ALPHA_INPUT'

export

input = wa_lifnr

import

output = wa_lifnr

->wa_lifnr will converts.

2. system will take date format yyyymmdd

so convert ur(what ever ur date format) date to yyyymmdd.

*take a variable like d_date using 'WRITE X(what ever ur date format) TO d_date yyyymmdd.

Regards,

Ramesh.

Read only

Former Member
0 Likes
5,144

Hi,

need to call the FM <b>CONVERSION_EXIT_ALPHA_INPUT</b>

Regards

Vijay

Read only

Former Member
0 Likes
5,144

<b>data: v_lifnr(10) type c.</b>

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = Wxample - LIFNR

IMPORTING

OUTPUT = v_lifnr

.

If Wxample - LIFNR = '16987'.

O/p:

v_lifnr = '0000016987'

Read only

Former Member
0 Likes
5,144

If i want to change the format of all the records present in my internal table at once then how can i ?

Sonal

Read only

0 Likes
5,144

loop at itab.

call to FM ....CONVERSION_EXIT_ALPHA_INPUT..

in the import parameter pass the itab-fieldname1 and pass the export parameter to itab-fielname1 (overwrite) and do the same for all the fields in ur itab.

endloop.

Reward points if it helps

Regards

Gunjan

Read only

0 Likes
5,144

don't change anything in the Internal Table. Whenever u r going to change to 10 characters(0000016987) before that u can use this FM.

Ex:

Loop at it.

. some process

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = it-lifnr

importing

output = v_lifnr.

u can use v_lifnr ......

Endloop.

Read only

0 Likes
5,144

Hi,

u can declare the field as type N.

Read only

Former Member
0 Likes
5,144

Hi,

<u>Use these function Modules for ur problems..</u>

(1)For adding leading zeroes or in sap format internal..

CONVERSION_EXIT_XXXXX_INPUT

(2)For changing date into systems internal format..

CONVERSION_EXIT_XXXXX_INPUT.

u can find out conversion routines for each corresponding domain of that field in given below procedure.

Domain->Defintion->Output Characteristics-> Conversion routine.

Double click on that, it will show corresponding conversion routines.

Please add ur rewards.

With regards,

Rajesh