2008 Dec 02 10:33 AM
Hi All,
I need to insert leading zeros for a currency and quantity field.
Eg: v_dig =7.00
v_dig = 00007.00
I searched in SDN but I could get only for char. I even converted to char and tried but the value is changing to 0000700. the decimal is not coming.
Please help me with this.
Regards,
Srik
2008 Dec 02 11:33 AM
HI,
Try this FM: HRPBSNO_FORMAT_ZERO
With input values:
Left = 4
Right = 2
In_separator = blank
Out_separator = dot( .)
Str value = 70.00
You will get output as 0070.00
Regards,
Bhaskar
HI,
Try this FM: HRPBSNO_FORMAT_ZERO
With input values:
Left = 4
Right = 2
In_separator = blank
Out_separator = dot( .)
Str value = 70.00
You will get output as 0070.00
Regards,
Bhaskar
2008 Dec 02 10:35 AM
how did you move the decimal value to char field? you have to do like this:
WRITE decimal TO char_field.after that you can fill up with leading zeros.
2008 Dec 02 10:36 AM
hi,
it is not posible to add leading zeroes to currency. u have to take the output field also as char.
Regards,
Ajay
2008 Dec 02 10:40 AM
lv_val = v_dig(1).
lv_len = strlen ( lv_val).
while (lv_len LT 4).
concatenate '0' lv_val into v_dig.
lv_len = strlen( lv_val).
endwhile.
Hope this helps.
regards
Edited by: BrightSide on Dec 2, 2008 10:40 AM
2008 Dec 02 10:41 AM
Use FM
BKK_AMOUNT_CONV_TO_EXTERNAL or
CURRENCY_AMOUNT_SAP_TO_IDOC
to properly convert you amount from internal to external format
you may define AMOUNT_EXTERNAL as character field.
This will properly convert your amount.
After that you can concatenate 0000 to your amount.
Regards,
Mohaiyuddin
2008 Dec 02 10:58 AM
hi,
you could try using TRANSLATE statement :
DATA : v_dig LIKE reguh-rwbtr
, v_dig_with_zero(8) .
v_dig = 7 .
MOVE v_dig TO v_dig_with_zero .
* move value to the right side of the final variable : v_dig_with_zero contains ' 7.00'
SHIFT v_dig_with_zero RIGHT DELETING TRAILING space .
* replace space in front of value with zeros : v_dig_with_zero contains '00007.00'
TRANSLATE v_dig_with_zero USING ' 0' .
peter.
2008 Dec 02 11:30 AM
do you want to show the content with leading zeroes in a script or smartform then use the fill character F
for example &V_DIG(F0)&.
when you want to show the content with leading zeroes in a write statement then use this:
WRITE v_dig TO v_dig_type_char.
OVERLAY v_dig_type_char with '000000000000000000'.
WRITE v_dig_type_char.
Regards,
Guido
2008 Dec 02 11:33 AM
HI,
Try this FM: HRPBSNO_FORMAT_ZERO
With input values:
Left = 4
Right = 2
In_separator = blank
Out_separator = dot( .)
Str value = 70.00
You will get output as 0070.00
Regards,
Bhaskar
2008 Dec 02 11:49 AM
Hi All,
I implemented all the above but still I am getting spaces but not zeros.
DATA: unhrs(8) type c.
DATA: amount(11) type c.
WRITE wa_tm-unhrs TO unhrs.
SHIFT amount RIGHT DELETING TRAILING space .
translate amount using '0'.
wa_items-unit = unhrs.
please help me with this.
Regards,
Srik
2008 Dec 02 12:28 PM
> translate amount using '0'.
Your partern is not correct. It should be : translate amount using ' 0' (there is a space before the zero).
When using translate, the first char of partern is replaced by the second (use F1 key on word TRANSLATE in your abap editor).
peter.
2008 Dec 02 11:54 AM
Hey,
You cannot get leading 0's in a quantity/currency field.
for displaying purpose, after all calculation are over
you can convert it into a character field
and then apply the MATN conversion exit.
Hope this helps,
Regards,
Raj
2008 Dec 02 12:00 PM
Hi Bhaskar,
How to give the dot(.) its not accepting. Throwing error.
Regards,
Srik
2008 Dec 02 12:03 PM
Hi
As eric said Move the data to character fields then to NUMC field u wil get leading zeros
2008 Dec 02 12:36 PM
Hi,
You can use the below code as well:
DATA: v_menge TYPE bstmg,
v_char(8) TYPE c,
v_char1(8) TYPE c.
v_menge = '7.00'.
v_char = v_menge.
UNPACK v_char TO v_char.
CONCATENATE v_char0(5) '.' v_char5(2) INTO v_char1.
WRITE: v_char1.
Regards,
Nitin.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |