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

Simple string operation

Former Member
0 Likes
963

Hi there,

I hav a really simple question but the ideas I have for implementing it, aren't really good in my opinion, so I ask you. I hope you can help me

I have a character field, that should be converted into another character field with a fixed size (of three characters). No I want to have the folowwing conversion:

Input: '1'

Output: '001'

Input: '15'

Output: '015'

Input: ''777'

Output: ''777'

So I want to fill the character fields with leading zeros... The field is not in the data dictionary so that I think that I can't use the ALPHA-function modules for conversion.

Can you help me? Thanks a lot

Kind regards

Markus

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 1:31 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

Hi,

try this code

data : v_num(3) type c value '1'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = v_num

IMPORTING

OUTPUT = v_num.

write : v_num.

Regards,

kavitha.

8 REPLIES 8
Read only

Former Member
0 Likes
944

hi,

declare it as N type and pass it ..


data : v_char(2) type c value '11',
         v_numc(3) type n.

 v_numc = v_char.

write : v_numc. 

Read only

Former Member
0 Likes
944

use this function module CONVERSION_EXIT_ALPHA_INPUT

Read only

Former Member
0 Likes
944

Hi,

USe FM CONVERSION_EXIT_MATN1_OUTPUT.

Regards

Raju Chitale

Read only

Former Member
0 Likes
944

Hi,

USe FM CONVERSION_EXIT_MATN1_OUTPUT.

Regards

Raju Chitale

Read only

prasanth_kasturi
Active Contributor
0 Likes
944

use numeric type it helps.

pass the character variable to numeric

reagerds

prasanth

Read only

former_member194669
Active Contributor
0 Likes
944

Try with

UNPACK source_variable TO target_variable

Read only

Former Member
0 Likes
944

Hi,

1.Calculate string length and store in seperate variable(var1).

2.if var1 = 1.

concatenate '00' '1' into var2.

elseif var1 = 2.

concatenate '0' '15' into var2.

else.

var2 = '777'.

<REMOVED BY MODERATOR>

Thanks,

Chandu

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 1:32 PM

Read only

Former Member
0 Likes
945

Hi,

try this code

data : v_num(3) type c value '1'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = v_num

IMPORTING

OUTPUT = v_num.

write : v_num.

Regards,

kavitha.