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

Convert input into an output

Former Member
0 Likes
1,357

Hi,

i get an external value in this format:

1.4651 and will convert it to this 0001.4651000

or

551.46 and will convert it to this 0551.4600000

which means 4 digits befor '.' with leading '0'

and 7 digits behind '.' with ending '0'

Any idea?

Regards, Dieter

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,150

Hi,

As I understand you've got (internal) value like 1.4651 and you'd like to display it in external format 0001.4651000.

In such case you should use the coversion routines (function modules). Have a look the at domain KUNR (transaction SE11). It uses routine ALPHA which contains function modules: CONVERSION_EXIT_ALPHA_INPUT and

<b>CONVERSION_EXIT_ALPHA_OUTPUT</b>.

You can implement the similiar procedure which adds 7 digits after.

Best Regards

Adam

4 REPLIES 4
Read only

Former Member
0 Likes
1,150

Hi,

try this.

Split the varaible at '.' into 2 local variables.

now find the length of the first variable.

if its is less than 4, then keep concatenating 0 in front of the variable.

Pusedo code.

split l_org_value at '.' into l_num1 l_num2.

l_size = strlen(l_num1).

l_size = 4-l_size.

while l_size LT 4 and l_size GT 0.

concatenate '0' l_num1 into l_num1.

l_size = l_size - 1.

end while.

concatenate l_num1 '.' l_num2 into l_org_val.

Reward points if useful,

Regars,

Niyaz

Message was edited by:

Niyaz Ahamed

Read only

Former Member
0 Likes
1,150

Hi,

try this code..


DATA : var TYPE char20 VALUE '551.46',
       var2 TYPE char20,
       var3 TYPE char20,
       len TYPE i.



SPLIT var AT '.' INTO var2 var3.
len = 4 - STRLEN( var2 ).
DO len TIMES.
  CONCATENATE '0' var2 INTO var2.
ENDDO.
len = 7 - STRLEN( var3 ).
DO len TIMES.
  CONCATENATE  var3 '0' INTO var3.
ENDDO.
CLEAR var.

CONCATENATE var2 var3 INTO var SEPARATED BY '.'.
WRITE :/ var.

Read only

Former Member
0 Likes
1,151

Hi,

As I understand you've got (internal) value like 1.4651 and you'd like to display it in external format 0001.4651000.

In such case you should use the coversion routines (function modules). Have a look the at domain KUNR (transaction SE11). It uses routine ALPHA which contains function modules: CONVERSION_EXIT_ALPHA_INPUT and

<b>CONVERSION_EXIT_ALPHA_OUTPUT</b>.

You can implement the similiar procedure which adds 7 digits after.

Best Regards

Adam

Read only

Former Member
0 Likes
1,150

Hi,

thanks for your answers.

I have solved it in this way:

DATA: C01(12) VALUE '12.56'.

DATA: C04(04).

DATA: C07(07).

DATA: C12(12).

*

DATA: POS TYPE I.

DATA: LEN TYPE I.

*

C01 = '12.56'.

SPLIT C01 AT '.' INTO C04 C07.

*

C12 = '0000.0000000'.

LEN = STRLEN( C04 ).

POS = 4 - LEN.

C12+POS(LEN) = C04(LEN).

LEN = STRLEN( C07 ).

C12+5(LEN) = C07(LEN).

WRITE: / C01, C12.

*

C01 = '5512.567'.

SPLIT C01 AT '.' INTO C04 C07.

*

C12 = '0000.0000000'.

LEN = STRLEN( C04 ).

POS = 4 - LEN.

C12+POS(LEN) = C04(LEN).

LEN = STRLEN( C07 ).

C12+5(LEN) = C07(LEN).

WRITE: / C01, C12.

regards, Dieter