Friday, November 23, 2007

sap abap conversion program for Print Number Value Without Thousand Separator

How can I print number value without thousand separator?

See Eg.
data mqty type p decimals 3 value '1234.45'.
write:/ mqty .

Result is : 1,234.45
And I want to print it like 1234.45

I usually using the REPLACE Command,

mqty = '1,234.45'.

REPLACE ',' WITH '' INTO mqty.

Or

REPLACE ',' WITH SPACE INTO mqty.

ABAP Tips by: Nurmansah

For thousand separator, you should write this program.

You can also write this program as function. You can call when it require.
ex:

DATA : x TYPE i,
chspec(10).

MOVE it_comm1-fobval TO chspec.
CONDENSE chspec.
x = STRLEN( chspec ) .

IF x LE 3.
chspec = ''.
ELSEIF x = 4.
chspec = '_,___'.
ELSEIF x = 5.
chspec = '__,___'.
ELSEIF x = 6.
chspec = '_,__,___'.
ELSEIF x = 7.
chspec = '_,__,___'.
ENDIF.

WRITE: 89(12) it_comm1-fobval RIGHT-JUSTIFIED USING EDIT MASK chspec.

it_comm1-fobval = '1234'
result
1,234

No comments:

Blog Archive