03-12-2009 10:15 AM
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.
03-12-2009 10:29 AM
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
03-12-2009 10:18 AM
Hi,
Try this FM:
CONVERSION_EXIT_ALPHA_INPUT - Converts number to a string filled with zeros..
Regards.
03-12-2009 10:19 AM
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
03-12-2009 10:21 AM
https://forums.sdn.sap.com/click.jspa?searchID=23425663&messageID=6896506
check this for leading zeroes
03-12-2009 10:21 AM
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
03-12-2009 10:23 AM
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.
03-12-2009 10:24 AM
03-12-2009 10:29 AM
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