Application Development 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: 

Appending zeros in form of amount

Former Member
0 Kudos

Hi Experts,

I have a requirement in which i need to append zero's in front of amount field (type Curr ,length 15,decimal 2) if the value is not of specified length.

I want the negative sign also to be remain as it is while adding zeros.

Any Pointers will be helpful.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hello there,

You cant append zeros unless u move that quantity to char type variable.

so first declare char:

data: lv_num(15) type c.

now move curr to char.

lv_num = <value>

lv_len = strlen (lv_num)<<<lv_len stores the length of lv_num

while lv_len < 15.

concatenate '0' lv_num to lv_num.

lv_len = strlen (lv_num).

endwhile.

if it has minus(-) before the value

for eg : -1.2

lv_num = 1.2-

if lv_num ca '-'

lv_num = (-1) * lv_num <<<< lv_num = 1.2

concatenate '-' lv_num to lv_num. <<<lv_num = -1.2.

now lv_minus = lv_num + 0(1). <<<<<lv_minus = '-'.

lv_len = strlen (lv_num)<<<lv_len stores the length of lv_num

while lv_len < 15.

concatenate '0' lv_num to lv_num.

lv_len = strlen (lv_num).

endwhile.

finally concatenate lv_minus lv_num to lv_num.

reg

7 REPLIES 7

Former Member
0 Kudos

Hi,

Try this FM:

CONVERSION_EXIT_ALPHA_INPUT - Converts number to a string filled with zeros..

Regards.

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Why can't u use the Conversion Routine for that displaying field.

COVERSION_EXIT_ALPHA_INPUT. WHICH WILL gives the Matnr value from 1234567890 to 000000001234567890.

Regards,

Sreeram Kumar.Madisetty

Former Member

I355602
Advisor
Advisor
0 Kudos

Hi,

Use FM's:

CONVERSION_EXIT_ALPHA_INPUT -


It is used to add the 0(Zero) at the begining of the value. You dont require to add zero manually for any variable.

CONVERSION_EXIT_ALPHA_OUTPUT -


It is used to Remove 0(Zero) from the Begining of the value. You dont require to remove Zero manually for any variable. Just call this Function Module and it will automatically removes zero from the begining.

Hope this helps you.

Regards,

Tarun

Former Member
0 Kudos

use overlay statement.

take a charcter field of required lenght( gereally you should go to domain of the curreccy fileds and take output length of domain ).

l_char = wa_reguh-rbetr.

CONDENSE l_char NO-GAPS.

REPLACE ALL OCCURRENCES OF '.' IN l_char WITH `,`.

IF STRLEN( l_char ) < 12.

l_str_len = 12 - STRLEN( l_char ).

wa_final-rbetr = l_char.

SHIFT wa_final-rbetr BY l_str_len PLACES RIGHT.

OVERLAY wa_final-rbetr WITH c_12.

CLEAR: l_str_len,

l_char.

ELSE.

wa_final-rbetr = l_char.

ENDIF.

0 Kudos

in above code;

c_12 = '000000000000'.

Former Member
0 Kudos

hello there,

You cant append zeros unless u move that quantity to char type variable.

so first declare char:

data: lv_num(15) type c.

now move curr to char.

lv_num = <value>

lv_len = strlen (lv_num)<<<lv_len stores the length of lv_num

while lv_len < 15.

concatenate '0' lv_num to lv_num.

lv_len = strlen (lv_num).

endwhile.

if it has minus(-) before the value

for eg : -1.2

lv_num = 1.2-

if lv_num ca '-'

lv_num = (-1) * lv_num <<<< lv_num = 1.2

concatenate '-' lv_num to lv_num. <<<lv_num = -1.2.

now lv_minus = lv_num + 0(1). <<<<<lv_minus = '-'.

lv_len = strlen (lv_num)<<<lv_len stores the length of lv_num

while lv_len < 15.

concatenate '0' lv_num to lv_num.

lv_len = strlen (lv_num).

endwhile.

finally concatenate lv_minus lv_num to lv_num.

reg