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 Correction to the code

Former Member
0 Likes
779

Hi

Data : V1(10) type c value ' 123-',

sign_flag(1).

IF V1 < 0.

V1 = V1 * -1 .

sign_flag = 'X'.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V1

IMPORTING

OUTPUT = V1.

IF sign_flag = 'X'.

V1 = - ( V1 ).

ENDIF.

Write : V1.

<b>Above code is for Padding Leading Zeroes to Negative Number stored in field V1 with Data type C(10).</b>

Output of above code is = 123-

But I want it to be = 000000123-

How I can do that.

Do the correct modifications in the program.

Points will be given to the good ones.

Regards

Message was edited by:

Tulip Shah

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
759

IF sign_flag = 'X'.

V1 = '- 0000123'.

ENDIF.

Write : V1(10).

do this correction in ur code ..

bhanu

7 REPLIES 7
Read only

dev_parbutteea
Active Contributor
0 Likes
759

use

'CONVERSION_EXIT_ALPHA_OUTPUT'

Read only

Former Member
0 Likes
759

use this code/.....

Data : V1(10) type c value ' 123-',

v2(10) TYPE n,

v3(11) TYPE n,

sign_flag(1).

IF V1 < 0.

V1 = V1 * -1 .

sign_flag = 'X'.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V1

IMPORTING

OUTPUT = V1.

IF sign_flag = 'X'.

V1 = - ( V1 ).

ENDIF.

*v2 = v1.

move v1 to v2.

CONCATENATE v2 '-' into v3.

Write 😕 V1, / v3.

With Regards,

S.Barani

Read only

Former Member
0 Likes
760

IF sign_flag = 'X'.

V1 = '- 0000123'.

ENDIF.

Write : V1(10).

do this correction in ur code ..

bhanu

Read only

Former Member
0 Likes
759

Hi

No question of using the fun module

it is of no use

it won't accept signs.

use the following code.

it will work

Data : V1(10) type c value ' 123-',

n2(10) TYPE n,

n3(11) TYPE n,

sign_flag(1).

IF V1 < 0.

V1 = V1 * -1 .

sign_flag = 'X'.

ENDIF.

IF sign_flag = 'X'.

V1 = - ( V1 ).

ENDIF.

move v1 to n2.

CONCATENATE n2 '-' into n3.

Write 😕 n3.

Reward points if useful

Regards

Anji

Read only

0 Likes
759

Thanks for all your replys

All above answers are not meeting my requirement.

Regards

Read only

Former Member
0 Likes
759

Thanks

Read only

dev_parbutteea
Active Contributor
0 Likes
759

Hi,

try this out:

num = strlen(V1)

num2 = 10 - num.

do num2 times.

concatenate '0' V1 into V1.

enddo.

Reward if helpful,

Regards,

Sooness.