‎2007 Nov 19 12:55 PM
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
‎2007 Nov 19 1:13 PM
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
‎2007 Nov 19 1:03 PM
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
‎2007 Nov 19 1:09 PM
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.
‎2007 Nov 19 1:13 PM
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
‎2007 Nov 19 2:11 PM
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