Conversion of character field to currency format
Hi All
I am reading an excel file witch has a netwr amount fiels as character type , but when I try to update the field table netwr which is CURR data type the program dumps sayin it can not do that becuase of the format .
is there any way of converting the character or string field into CURR and vice versa
any help woul do
Thanks.
Hi
Write this FM
FUNCTION Z_CONV_CHAR_TO_DECIM.
""Local Interface:
*" IMPORTING
*" REFERENCE(I_NUMBER) TYPE STRING
*" REFERENCE(I_CURRENCY) TYPE WAERS_ISO
*" EXPORTING
*" VALUE(E_AMOUNT) TYPE DEC_16_02_S
*" REFERENCE(E_AMOUNT_DISPLAY) TYPE CHAR20
*" REFERENCE(E_NO_OF_DECIMALS) TYPE INT_1
*" REFERENCE(E_MAX_NO_OF_DECIMALS) TYPE INT_1
*" EXCEPTIONS
*" ERROR_IN_CONTENT
*" ERROR_IN_DECIMALS
data: l_amt_1_s type string.
data: l_amt_2_s type string.
data: l_amt_1(30) type c.
data: l_amt_2(20) type c.
data: l_amt_3(20) type c.
data: l_amt_4(20) type c.
data: l_amt_1N(20) type n.
data: l_amt_2N(2) type n.
data: l_amount type dmbtr.
data: l_no_of_decimals type i.
e_max_no_of_decimals = 2.
clear e_amount.
split i_number
at ','
into l_amt_1 l_amt_2.
l_no_of_decimals = strlen( l_amt_2 ).
e_no_of_decimals = l_no_of_decimals.
REPLACE ' ' WITH '0' INTO l_amt_2.
do.
split l_amt_1 at '.'
into l_amt_3
l_amt_4.
if l_amt_4 = space.
exit.
endif.
concatenate l_amt_3 l_amt_4 into l_amt_1.
enddo.
if l_amt_1 co '-0123456789 '.
else.
raise error_in_content.
endif.
if l_amt_2 co '-0123456789 '.
else.
raise error_in_content.
endif.
if l_amt_1 = '-'.
l_amt_1 = '-0'.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = l_amt_1
IMPORTING
OUTPUT = l_amt_1n.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = l_amt_2(2)
IMPORTING
OUTPUT = l_amt_2n.
e_amount = l_amt_1n.
do l_no_of_decimals times.
e_amount = e_amount * 10.
enddo.
if l_amt_1 cs '-'.
e_amount = e_amount - l_amt_2n.
else.
e_amount = e_amount + l_amt_2n.
endif.
e_amount = e_amount / 100 .
write e_amount to e_amount_display
decimals l_no_of_decimals.
ENDFUNCTION.
REGARDS.
Similar Messages
-
Help needed to display character vaiable in currency format
Hi Friends
In a SAP Script I am passing a currency field to the subroutine as an i/p parameter and since it gets converted to character format in subroutine because of 'itcsy' , ihave deleted the trailing zeroes and decimal points from the field and performed calculations on the field, now i need to pass this char field back to SAP script but i need to display that field in currency format with commas and decimal points in the script...how do i do that???
Thanks
Vishal.Hi Vishal,
When you pass the currency amount into the perform, no need to remove the trailing zeros and the decimal point.
Only thing you need to remove is the comma seperator as it gives a runtime error during calculation.
To convert it back to the format with comma, write the below command:
WRITE v_Item_total currency '2' to v_item_char.
CONDENSE v_item_char.
Here v_item_total is a number which is converted to comma seperated number and passed to char variable.
This char variable is then passed to the SCRIPT.
regards,
Gaurav. -
Character field with date format alike & character entered
Hi all,
I got one character field created ( varchar2 ) for the purposed to let user the enter the date and also any character since it is a character field.
Hence, my field may contain the following data :-
Ship_date
01/10/2010
07/02/2011
15/01/2011
25/01/2011
31/01/2011
TBA
STOP
11/01/2011
TBA
Hence when come to sorting, I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
ship_date
01/10/2011
11/01/2011
15/01/2011
25/01/2011
31/01/2011
07/02/2011
STOP
TBA
Trying to do the normal sorting, it does not exactly sort on the date format, as it only sort on the first two character on the date hence I am not getting the correct sorting on this.
01/10/2011
07/02/2011
11/01/2011
15/01/2011
25/01/2011
31/01/2011
STOP
TBA
Could someone help me on this. Thanks.
LimHi, Lim,
sm**** wrote:
Hi all,
I got one character field created ( varchar2 ) for the purposed to let user the enter the date and also any character since it is a character field.That's a very bad idea. Use a DATE column for storing dates. Have another, separate column for VARCHAR2 data.
Hence when come to sorting, I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
If you must deal with the table as it is:
ORDER BY CASE
WHEN TRANSLATE ( ship_date
, '012345678'
, '999999999'
) = '99/99/9999'
THEN SUBSTR (ship_date, 7)
|| SUBSTR (ship_date, 4, 2)
END
, ship_dateThe CASE expressionj sorts anything the looks like a date ('99/99/9999' where '9' stands for any digit) first, in order by the last 4 digits, then the middle 2 digits. The first 2 digits are sorted by the second ORDER BY expression.
I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
ship_date
01/10/2011
11/01/2011
15/01/2011
25/01/2011
31/01/2011
07/02/2011That must be a mistake. I don't believe you want January to come after October and before February, but if you do, you can change what comes after THEN in the CASE expression. -
How to get a currency format for a character field
for some specifix reason, we have a requirement to show character field (which results in value 633948) in the format $633,948
how do i do this?
if i do SELECT to_char(:c_1,'$999,999')) from dual;
it gives me ora: 01722: invalid number error
c_1 is a user parameter of data type characterTry using TO_NUMBER first, as in something like:
SQL> VARIABLE c_1 VARCHAR2(6)
SQL> EXECUTE :c_1 := '633948';
PL/SQL procedure successfully completed.
SQL> SELECT TO_CHAR(TO_NUMBER(:c_1), '$999,999') FROM DUAL;
TO_CHAR(T
$633,948Hope this helps. -
How to set Character field's Format Mask?
dear all,
how to set Character field's Format Mask?
i searched the forum and found the following, where can i use this code and how to change and set its format mask.
SRW.SET_FORMAT_MASK('mask');
Thanks
Muhammad NadeemNadeem,
If you have database 10g, look into function REGEXP_REPLACE. Otherwise you can also try this (you might already know).
SELECT SUBSTR('CHHOCMIPO07020001', 1,2)||'-'||SUBSTR('CHHOCMIPO07020001' ,3,2)||'-'||
SUBSTR('CHHOCMIPO07020001' , 5,2)||'-'||SUBSTR('CHHOCMIPO07020001' , 7,3)||'-'||
SUBSTR('CHHOCMIPO07020001' , 10,2)||'-'||SUBSTR('CHHOCMIPO07020001' , 12,2)||'-'||
SUBSTR('CHHOCMIPO07020001' , 14,4)
FROM dual
CH-HO-CM-IPO-07-02-0001
If you have to use this at many places, create a function, pass the raw value, manipulate the string and return.
FS -
Hello,
I'm creating a calculated field with a set currency for a business rule. I'm planning to use it as a deficiency criteria. I want the values to come from the currency conversion of another field. Can someone provide me the step by step procedure on how to do it?
Some documents would be great.
I've been trying to do it on my own but I've gotten lost.
Thank you.Thank you for all your help above.
Just to confirm your advice, am I right with the following conclusions? :
1. The script (function) to fill the text field with the modification date of a different PDF file needs to be stored in a folder level .js file.
2. The document containing the text field needs to call the .js function either within the document script or within the custom script property of the text field itself.
Further to that can you just advise on the syntax for accessing the modification date of the other document.
Do I need to assign a variable to the address of the file to be used, and then use this variable in the text form filling script (as below) or can I use a direct file reference at the .modDate command.
var LastSync = "C:\sync\bin\lastsync.pdf";
var strMsg = util.printd("h:MM tt",LastSync.modDate) + " on ";
strMsg += util.printd("dddd, d mmmm, yyyy",LastSync.modDate);
this.getField("LastSyncDate").value = strMsg;
If the syntax is totally different to the above I would be very grateful for some guidance in the right direction.
I much appreciate your time to help me ... I'm almost there.
Kind Regards,
Nifty -
Character type to currency type conversion
hi all,
i need to transfer the character type data to the currency type data.
my requirement is when i am trying to transfer the data from excel i need to store it as a character. again i need to change the same as currency. any pointers will be highly appriciated.
thanks.Hi use the belwo function module and first move the currecy field to character..and inthe out put table decclare field as character 20 ..and download the field..
hope will works..
Amount to string:
CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
EXPORTING
betrg = w_curerency "currency field
WAERS = 'DKK'
IMPORTING
STRING = slam . "Output table field type char20
String to amount:
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = slam2 "character field
DECIMAL_SEPARATOR = '.'
THOUSANDS_SEPARATOR =
WAERS = 'HUF'
IMPORTING
BETRG = b2 . "converting into currency field
Prabhudas -
Hi All,
Is there any way that one can format a field as currency.
ie Aligned to the right with decimals - eg 1.00 NOT 1
Thanks
AlanHi,
Thanks for answer.
I can't even find those options.
I'm editing a form. Take options Edit | Edit Fields | Show Field Properties | that brings up a tabbed window with following tabs: General Appearance Position Options Actions.
Where do I find the options you mentioned?
Regards
Alan -
Conversion from CHARacter to CURRENCY ???
Hi Experts,
Pls. let me know that, How to convert a CHAR acter field to CURRENCY field?
Is there any FM? or How to get it done?
thanqHi Srini,
check this.
DATA: P_DBMTR TYPE DMBTR.
DATA: C_VALUE(20).
c_value = '123,456.78'.
Convert to amount
replace all OCCURENCES of ',' in c_value with ' '.
condense c_value.
move c_value to P_DBMTR.
kindly reward if found helpful.
cheers,
Hema. -
Currency format problem while exporting as excel
Hi
I have to create a report for which the currency format should be $#,##0.00 and -$#,##0.00 for negative numbers.
In the text form field of rtf template, I have selected number format and removed the portion ;($#,##0.00) from $#,##0.00;($#,##0.00).When I view the report as HTML the numbers are showing in proper format.($#,##0.00 or -$#,##0.00).But when the report is exported as excel ,the negative number format changes to ($#,##0.00) in red color.
Can anyone tell me how avoid this problem?
Thanks in advance
NaveenI think this is an Excel issue - you can right mouse click in Excel the column header and "Format Cells>Text"
You could also append a ' character to your numbers in BI Answers ie: '6035784010491980 which should give you the correct format in Excel.
eg. CONCAT( '''', CAST ( '6035784010491980 AS CHAR) )
There is also an MS Office plug in available for OBIEE this may give you further options. -
Hi
Good day experts,
I've problem with Currency formate. In my client 101 i've 1,234,567.89 in Owndata.
But Functional side they've 1,234,567.89 in 103 client.
My problem is when the functional guys is entered data in currency field. if they double click in the currency field, they r getting extraa zeros and if they entered end of the position which is right then the digits are not allowing .
I've taken the data element which is 14 lenght of char. in this i've written the conversions for curr.
This is my conversions:
CONVERSION_EXIT_YMXAM_OUTPUT
DATA LV_16(16).
IF INPUT EQ SPACE.
LV_16 = '0.00'.
SHIFT LV_16 RIGHT DELETING TRAILING SPACE.
OUTPUT = LV_16.
ELSE.
OUTPUT = INPUT.
ENDIF.
CONVERSION_EXIT_YMXAM_INPUT:
DATA LV_AMNT TYPE YBET00.
PERFORM TEXT_TO_NUM
CHANGING
INPUT.
SHIFT input LEFT DELETING LEADING space.
CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 1
CONVT_OVERFLOW = 2
BCD_FIELD_OVERFLOW = 3.
LV_AMNT = INPUT.
ENDCATCH.
IF SY-SUBRC = 1.
MESSAGE 'Invalid Format' TYPE 'E'.
ELSEIF SY-SUBRC = 2 OR SY-SUBRC = 3.
MESSAGE 'Number contains too many digits' TYPE 'E'.
ENDIF.
WRITE lv_amnt TO output(17).
OUTPUT(14) = LV_AMNT .
MESSAGE output TYPE 'E'.
SHIFT output(18) RIGHT DELETING TRAILING space.
ENDFUNCTION.
*& Form text_to_num
FORM TEXT_TO_NUM CHANGING VALUE(IV_FLD) TYPE C.
DATA LV_DCPFM TYPE XUDCPFM.
SELECT SINGLE DCPFM INTO LV_DCPFM FROM USR01 WHERE BNAME = SY-UNAME.
CASE LV_DCPFM.
WHEN ' '.
TRANSLATE IV_FLD USING '. '.
WHEN 'X'.
TRANSLATE IV_FLD USING ', '.
WHEN 'Y'.
TRANSLATE IV_FLD USING '. '.
ENDCASE.
CONDENSE IV_FLD NO-GAPS.
Plz give me solution.
regards,
kkHi,
Thank for ur reply. Caa2 t.code, i've created the finance subscree. in the subcreen, i'vecurrency field which is Char(14).it extras the data from CI_FKKVKP stracture.
Wht i've to do for this problem.
regards
kk -
Hello All, an urgent issue:- Currency Format
Hello All,
I created one program which download & printed the report after selecting the correspondence Radio button.
While I am downloading the file on local system it will download as .txt file format & while I select the radio button printed report it will do it for correspondence invoice number.
My issue is.
In output I have few currency values in diff field. Now User want those value should come in this format (1.000.000,00) every time.
So is there any function module which can convert the currency value format which user want? Or do I have to do some coding, if yes then what it should be.
Because here user want whatever system format should be but value come in that format only in both condition either downloading the file or printed one.Sonu,
Try with below example.
Currency Conversion:
Use the function module
CONVERT_TO_LOCAL_CURRENCY
Writing currency amount to string without thousands seperator
This is usefull e.g. i connection with batch input/call transaction.
GI_OUTPUT-WRBTR: Field type Currency with amount
L_AMOUNT_STRING: Field type c with amount
PERFORM AMOUNT_TO_STRING USING GI_OUTPUT-WRBTR
CHANGING L_AMOUNT_STRING.
FORM AMOUNT_TO_STRING USING P_AMOUNT
CHANGING P_AMOUNT_STRING.
DATA L_SEP(1) TYPE C.
PERFORM GET_THOUSAND_SEPERATOR USING L_SEP.
WRITE P_AMOUNT TO P_AMOUNT_STRING.
REPLACE L_SEP WITH ' ' INTO P_AMOUNT_STRING.
CONDENSE P_AMOUNT_STRING NO-GAPS.
WRITE P_AMOUNT_STRING TO P_AMOUNT_STRING RIGHT-JUSTIFIED.
ENDFORM.
FORM GET_THOUSAND_SEPERATOR USING P_SEP.
DATA: L_AMOUNT LIKE BSEG-DMBTR,
L_AMOUNT_STRING(15) TYPE C.
Find 1000 seperator. If decimal seperator = . then
1000 seperator = , else 1000 seperator = .
L_AMOUNT = '1.00'.
WRITE L_AMOUNT TO L_AMOUNT_STRING.
IF L_AMOUNT_STRING CS ','.
P_SEP = '.'.
ELSE.
P_SEP = ','.
ENDIF.
ENDFORM.
Convert amount to/from string
CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
EXPORTING
betrg = 3000
WAERS = 'DKK'
NEW_DECIMAL_SEPARATOR =
NEW_THOUSANDS_SEPARATOR =
IMPORTING
STRING = slam
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = slam2
DECIMAL_SEPARATOR = '.'
THOUSANDS_SEPARATOR =
WAERS = 'HUF'
IMPORTING
BETRG = b2
EXCEPTIONS
CONVERT_ERROR = 1
OTHERS = 2
Language depending formatting
To format a currency amount with decimals according to the currency use
WRITE and the CURRENCY option.
Currency keys an d numbers of decimals are defined in table TCURX Decimal
Places in Currencies.
E.G.
Formatting an amount in Kuwatian Dinars:
Dmbtr = 123456.
Write dmbtr currency 'KUD'
123.456
Write dmbtr currency 'USD'
1234.56
Note that the formatting does not depend on the number of decimals in the
number in the program.
Dmbtr = '12.3456'.
Write dmbtr currency 'USD'
1234.56
To format the decimal and thousand sepearators according to the settings for
a specific country,
use the statement SET COUNTRY <country key>
Settings for countries are defined in table T005 Countries.
The country key used in the statement is field LAND1
E.g.
set country 'US'
Don't forget to reward if useful.... -
Currencies Formating and Validations
hi All,
I'm using ADF BC, JDev11g, Window XP, IE7.
My use case:
I'm having a table which has details in first facet, in the second facet there is a form which displays the contents of selected row in a form. In this form there are few fields like Currency and Local Currency. Once i enter the currency and tab out it should format into the form like US format or Indian Format. Also display the equivalent of the number in the local currency field.
Here my Currency is USD and Local Currency is Indian Rupee. How can i achieve this condition?
Also what are the supported formats for currency in ADF BC.
All inputs are useful and would be appreciated,
Thanks In Advance,
-JyothiPlease give some suggestion. Its very important to make that validation and conversion.
-Jyothi -
In Scripts how to print the values in currence format
Dear abap guru's,
I am working on Purchase Order Script, copy from the standard script, after that wrote a one perform , in that added one new field to script, but value is printed like this formate : 1000.00, but i want to print 1,000.00 like this currence format. let me know the any solution
thanks to all
raj.Hi ,
When you are populating the value in perform instead of assigning the value (using = ) pass it using WRITE TO.
Like : WRITE lw_total TO output-value.
Declare lw_total as currency field.
Regards,
Rajitha. -
BInput Data mismatch with currency format
i am working with fs10 transaction
I want to sum up the balance amount with respect to all
companycode and post SUM to the bseg table using Batch input.
i defined sum variable as below and coded.
data : sum like glt0-hsl01. (currency format)
After all SUM operation.
I have done like this to diplay SUM in report first(to check SUM output)
SUM = SUM * 100.
write : sum decimals 0.
>>>>Now in report output i get value '17,222-'
if u see in fs10 screen we are getting same value.
but when i try to post in Batch input.
i have done like this below.(before posting i have checked
for negative value )
if sum < 0.
sum = sum *100.
compute sum = abs( sum )
now...
perform open_group................
perform bdc_field using 'bseg-wrbtr' (currency format)
sum.
when i execute this BI i get error in Amount(Sum)value
display screen. (saying something differs in length )
how to match the field.
ambichan.Hello,
Go to the Domain of the Field BSEG-WRBTR, which is WERT7. There you see the Output length as 16. So you decalre a local variable in BDC which is of CHAR16 in length to hold the value of WRBTR.
Hope this helps you.
Regds, Murugesh AS
Maybe you are looking for
-
Hi All, I have one doubt regarding Report Painter Reports like is it possible to create Report painter Reports in two currencies(one is company code currency and another one is USD). And how we can maintain User Settings using transaction RPC0 for Z-
-
Contacts and calendar items disappear when exchange server is off
Hi All I've been having this problem for a few weeks now and it's most frustrating. My iphone is setup to sync over the air to our corporate exchange server. It seems that when the server is down for repair/patching ALL my contacts and calendar items
-
L455D-S5976 wont work whith BCD 3000 dj mixer
i have a behringer BCD 3000 Dj mixer that uses traktor 3 le bdc 3000 edition that works fine in my pc and another laptop i have, the bcd has an internal souncard that let you conect to it headphones for cue monitor and to master output audio to a amp
-
Hi Guys , I anstalled portal,but i am trying to launch url "https://inld50054767a:53000/irj/portal" i m getting "500 Internal Server Error Application error occurred during request processing. Details: java.lang.NullPointerException: null Ex
-
HT1918 how to use email to find out what u recently downloaded
i used to get emails saying what i recently bought and downloaded and now i don't anymore. Is there any way i can change that?