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
Similar Messages
-
Character format to currency format conversion?
Hai,
I have a field (char16) with value in the form 9800.50. How do I convert it into standard SAP currency type ( of the format 9.800,50 ) Is there any function module available ?
I have tried the FM "CHAR_FLTP_CONVERSION". But it can't convert decimals (like 9800.50)
Kindly help me. Thanks in advance..
Deepak.Hi,
Try this.
Call function 'BAPI_CURRENCY_CONV_TO_INTERNAL '
Exporting
currency = 'USD'
Amount External = V_Amount
Importing
Amount External = V_Amt
Reward if helpful.
Regards,
ramya -
Unicode - "DMBTR" must be a character-type field (data type C,N,D or T)
Greetings Experts!
I am trying to convert legacy code to Unicode for a current ERP6.0 reinstallation and have encountered the syntax error "DMBTR" must be a character-type field (data type C,N,D or T)
The field is part of a structure and the fields attributes are as follows:
COMPONENT = DMBTR
COMPONENT TYPE = DMBTR
DATA TYPE = CURR
LENGTH = 13
DECIMALS = 2
DESCRIPTION = Amount in Local Currency
The code in question is as follows:-
macro Move_Zoned.
Converts a numeric variable to zoned format and moves it to a
target variable.
DEFINE move_zoned.
&1 - source variable
&2 - Number of Decimal Places
&3 - 'To'
&4 - Target Variable.
write &1 to w_zoned no-grouping decimals &2.
condense w_zoned.
Remove the Decimal Points.
search w_zoned for '...'.
while sy-subrc = 0.
move sy-fdpos to w_to_point.
if w_to_point = 0.
w_to_point = 1.
endif.
compute w_from_point = sy-fdpos + 1.
concatenate w_zoned+0(w_to_point)
w_zoned+w_from_point
into w_zoned.
search w_zoned for '...'.
endwhile.
shift w_zoned right deleting trailing space.
translate w_zoned using ' 0'.
call function 'Z_TRANSLATE_ZONED_DECIMALS'
exporting
i_input = w_zoned
importing
i_output = w_zoned
exceptions
x_invalid_zoned_char = c_invalid_zoned_char
x_numeric_info_lost = c_numeric_info_lost
others = c_other_zoned_error.
Get the length of the recipient field so we don't truncate the
numbers....
describe field &4 length w_flength in character mode.
describe field &4 type w_type.
describe field w_zoned length w_zoned_len in character mode.
if w_zoned_len <= w_flength.
move w_zoned to &4.
shift &4 right deleting trailing space.
translate &4 using ' 0'.
else.
Get the start position....
If it's a packed field allow for values up to 6 figures
compute w_zoned_len = w_zoned_len - w_flength.
if w_type = 'P'.
subtract 2 from w_zoned_len.
clear w_type.
endif.
move w_zoned+w_zoned_len &3 &4.
endif.
END-OF-DEFINITION. "Move_zoned
LOOP AT t_single_kunnr.
move_zoned t_single_kunnr-postamt 2
to t_single_kunnr-dmbtr.
DIVIDE t_single_kunnr-dmbtr BY 100.
MODIFY t_single_kunnr.
ENDLOOP.
Is there a solution to get past this syntax error as I would rather not change the datatype of the field in the structure.
Much Obliged
Elphick.Type X is not allowed in Unicode. When a field is declared as Type X with Value u201809u2019 or any other value, it can be resolved by using classes.
Before Unicode
CONSTANTS: c_hex TYPE x VALUE '09'.
Resolution:
Itu2019s work for any value of x.
First a temporary field of Type c should declare. Following class will convert Type x variable into type c.
Example:
CONSTANTS: c_hex TYPE x VALUE '09'.
DATA: LV_TEMP TYPE STRING.
DATA: LV_TMP TYPE C.
TRY.
CALL METHOD CL_ABAP_CONV_IN_CE=>UCCP
EXPORTING
UCCP = c_hex
RECEIVING
CHAR = LV_TMP .
CATCH CX_SY_CONVERSION_CODEPAGE.
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
ENDTRY.
CONCATENATE I_OUTPUT-BKTXT I_OUTPUT-BVORG
I_OUTPUT-BUDAT I_OUTPUT-MESSAGE INTO
SEPARATED BY LV_TMP.
I_BUFFER = LV_TEMP.
CLEAR LV_TEMP.
CLEAR LV_TMP.
OR
Note: It works only for type x value 09.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: c_hex TYPE c VALUE
abap_char_utilities=>HORIZONTAL_TAB. -
Function module to convert character type to required data type
Hi,
Is there a function module which can convert data in character type to any other required data type?
Like i have a date 12.2.2008 and it is stored as character now i want to convert it into type d.
so that when i use
Describe field <field_name> type <type>.
statement afterwards then it gives me D not C as its data type.
The requirement does'nt stick to conversion of just one data type.I need an FM which can convert data in character type to any data type.
Hope you understood the problem.
Thanks for your time.Hi,
Use the code.
data : date like sy-datum.
call function 'CONVERT_DATE_TO_INTERNAL'
exporting
date_external = '01.01.2008'
IMPORTING
DATE_INTERNAL = date
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Regards,
Morris Bond.
Reward Points if Helpful. -
Passing regexp_replace backreference to a function; type conversion problem
I am trying to convert some text within my CLOB field to HTML links.
The format of the (part of the link I am having problems with) is:
<link 12>
which I wish to convert to
url_dest
I am trying to pass the backreference \1 (being the number 12 in this case) in regexp_replace to a simple function I have made and when I run it I receive the error:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
I have tested the function on its own with passing a string and it works fine.
I have passed the string from the backreference to the function and back out as the return value and it works fine.
However, when I try to pass the string back reference (a set of digits) to use as the NUMBER ID in my where clause, it always returns this error. I have tried CASTing / TO_NUMBER in every way possible I can think of, using temporary variables etc. and still the same error.
=====
CREATE OR REPLACE
FUNCTION GETLINK (linkid IN CLOB)
RETURN VARCHAR2 AS
linkstring VARCHAR2(4000);
linkchar VARCHAR(4000);
linkint NUMBER;
BEGIN
linkchar := TO_CHAR(linkid);
linkint := TO_NUMBER(linkchar);
SELECT url_dest INTO linkstring FROM TABLE WHERE ID = linkint;
RETURN linkstring;
END;
=====
Offending calling code:
tempcontent := regexp_replace(myClobField, '<link ([[:digit:]]*)>', GETLINK('\1'));
=====
I have tried implicit and explicit type conversions that vary the above function; in parameters as VARCHAR2; etc.; no joy.
Is this a bug within the database, is it by design, or is it just me making a hash of things? I really don't want to have to pull the XML into PHP then run the PHP regex functions with Oracle DB queries to do this!
Many thanks for your assistance.
IngramMany thanks for the reply, but I'm not sure how that would work. I wish to do a global regexp_replace on all instances of '<link> ([[:digit:]]*)>' within my XML document, with the return value from the GETLINK function.
So for instance.
The return value of GETLINK could be in format:
<a href="\1">
so an XML document of:
=====
<doc>
<link 12>Test Link</link>
some content
<link 783>A second Test Link</link>
</doc>
=====
would return as:
=====
<doc>
<a href="12">Test Link</link>
some content
<a href="783">A second Test Link</link>
</doc>
=====
Obviously I would then do the other replacements to fix broken XML with the non matching end tags etc.
TIA -
How to avoid oracle implicit data type conversion
Hello,
i have a query like below..
SELECT EMP_NUM
FROM EMPLOYEE
WHERE EMP_NUM=SOURCE_EMP_NUM;
1. My SOURCE_EMP_NUM data type is varchar2.
2. My table EMP_NUM data type is number.
3. In one case my SOURCE_EMP_NUM value '00000123'
4. I have an entry in table for EMP_NUM as 123.
5. In this case my query is success and giving me row for 123, which i don't want it should compare with leading zeros. But due to oracle implicit conversion the comparision getting passed.
6. I have an index for this column, so i can't use "like" operator...
Can somebody help me.....
Thanks in adv....HI,
Just see this :---
SQL> select * from emp where deptno=00020;---------deptno is number, 00020 is number and its true
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
SQL> select * from emp where to_char(deptno)=00020;=-------------deptno is character type and 00020 is number so still it is leaving 0000 from 20 as it number and has no impact,
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
SQL> select * from emp where to_char(deptno)='00020';---now both are character and no row is selected.
no rows selected
So you can avoid the implicit conversion according to the requirements and in this case we are usin to_char function to avoid this.
Regards,
Navneet -
Implicit and explicit Type conversion using Type object in heap
Hi,
I am surprised how Implicit and explicit Type conversion works using Type object in heap. for example when implicit type conversion occur what pointer it returns to object and similarly with explicit type conversion.Hello,
>> I am surprised how Implicit and explicit Type conversion works using Type object in heap.
For Implicit conversions: Typical examples are conversions from smaller to larger integral types, and conversions from derived classes to base classes. For the first one, the reference would be different which means it would return a different pointer to
a new object. For the reference type, it actually points to the same memory location, you could use the object.ReferenceEquals() to check it.
For Explicit conversions (casts):Typical examples include numeric conversion to a type that has less precision or a smaller range, and conversion of a base-class instance to a derived class. For first one, it would perform the same with implicit conversions.
While for the conversion of conversion of a base-class instance to a derived class, actually, there's no built-in way to do this conversion.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
The priority of different data type conversion
Hi All,
I want to know the priority of data type conversion rule. if in an expression, I have several kind of data type( I, P, F,N..).
Then finaly, all the data object will convert to which data type?
I don't know the priority of data conversion.
E.g. data a type i. data b type p. data c type f.
a = b + c.
or data d type p, data e type f.
if ( d > f ).
Then who will convert to who's type?
Thanks and Regards.
AaronFor expressions, the right term in SAP is "calculation type", it's explained here : [abap help - determining the calculation type|http://help.sap.com/abapdocu_70/en/ABENARITH_TYPE.htm]. SAP takes the "biggest" type of all variables in the expression. It can be I, P or F (smallest is I, biggest is F).
Conditions are handled differently, just using data type conversion (see link given above by Abhishek), SAP converts from smallest to biggest type (in your case, it converts P to F and compares the two F variables). -
Need Help with data type conversion
Hello People,
I am new to java, i need some help with data type conversion:
I have variable(string) storing IP Address
IPAddr="10.10.103.10"
I have to call a library function which passes IP Address and does something and returns me a value.
The problem I have is that external function call in this library excepts IP Address in form of a byte array.
Here is the syntax for the function I am calling through my program
int createDevice (byte[] ipAddress).
now my problem is I don't know how to convert the string IPAddr variable into a byte[] ipAddress to pass it through method.Class InetAddress has a method
byte[] getAddress() You can create an instance using the static method getByName() providing the IP address string as argument. -
Hi All,
following piece of code was working fine in 4.6 C but in ECC 6.0 I get the following error:
" "END_OF_RECORD" must be a character-type data object (data type C, N,D, T or STRING) . "
I tried type-casting with field symbols but still not able to remove the error. Cannot convert end_of_record directly to type C as it may hamper the functionality. Plz advice how to remove the error without converting type x to type C
In the following code :
DATA: DELIMITER TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
end_of_record TYPE x.
SPLIT data_file_i AT delimiter INTO it_ekko-rtype
it_ekko-ebeln
it_ekko-bsart
it_ekko-lifnr
it_ekko-bedat
it_ekko-ekorg
it_ekko-ekgrp
it_ekko-bukrs
it_ekko-zterm
it_ekko-zbd1t
it_ekko-zbd1p
it_ekko-zbd2t
it_ekko-zbd2p
it_ekko-zbd3t
it_ekko-inco1
it_ekko-inco2
it_ekko-waers
it_ekko-wkurs
it_ekko-kufix
it_ekko-verkf
it_ekko-telf1
it_ekko-ihrez
it_ekko-unsez
it_ekko-angnr
it_ekko-ihran
it_ekko-submi
it_ekko-loekz
end_of_record.
where all these fields except " end_of_record " are of character type and "data_file_i " is a character type structure as defined below:
DATA :
BEGIN OF data_file_i OCCURS 0,
record(1000),
END OF data_file_i,Type X is not allowed in Unicode. When a field is declared as Type X with Value u201809u2019 or any other value, it can be resolved by using classes.
Before Unicode
CONSTANTS: c_hex TYPE x VALUE '09'.
Resolution:
Itu2019s work for any value of x.
First a temporary field of Type c should declare. Following class will convert Type x variable into type c.
Example:
CONSTANTS: c_hex TYPE x VALUE '09'.
DATA: LV_TEMP TYPE STRING.
DATA: LV_TMP TYPE C.
TRY.
CALL METHOD CL_ABAP_CONV_IN_CE=>UCCP
EXPORTING
UCCP = c_hex
RECEIVING
CHAR = LV_TMP .
CATCH CX_SY_CONVERSION_CODEPAGE.
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
ENDTRY.
CONCATENATE I_OUTPUT-BKTXT I_OUTPUT-BVORG
I_OUTPUT-BUDAT I_OUTPUT-MESSAGE INTO
SEPARATED BY LV_TMP.
I_BUFFER = LV_TEMP.
CLEAR LV_TEMP.
CLEAR LV_TMP.
OR
Note: It works only for type x value 09.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: c_hex TYPE c VALUE
abap_char_utilities=>HORIZONTAL_TAB. -
Non-character-type structure need to be written in ASCI File in Unicode sys
Hi Gurus,
I am trying to write a structure into a ASCI file iapplication server.
My code is as follows.
data : ls_header type BBP_PDS_CTR_HEADER_D ,
lv_filename TYPE rlgrap-filename VALUE '/interface/AEE/IN/kalandi'.
CALL FUNCTION 'BBP_PD_CTR_GETDETAIL'
EXPORTING
I_OBJECT_ID = '4000000196'
IMPORTING
E_HEADER = ls_header.
open dataset lv_filename for output in text mode encoding default .
if sy-subrc = 0.
transfer ls_header to lv_filename.
close dataset lv_filename.
endif.
but it ives a dump .
Error is :
"TRANSFER f TO ..."
only character-type data objects are supported at the argument position
"f".
In this case. the operand "f" has the non-character-type
"BBP_PDS_CTR_HEADER_D". The
current program is a Unicode program. In the Unicode context, the type
'X' or structures containing not only character-type components are
regarded as non-character-type.
Thanks a lot in advance.
Points will be awared for appropriate Answers.
Regards
kalandiHi,
I think here ls_header and lv_filename are not compatible to transfer the data.
Regards,
Satish -
what are the invalid data type conversions in ABAP ???
Moderator message: please search for available information/documentation.
Edited by: Thomas Zloch on Mar 10, 2012 6:01 PMNo Amanda,
The values that I see in message monitor are also those that comes to XSLT programs as input.
I investigated our problem a little further myself:
1) XI always converts messages into XML format - this everybody knows.
2) In XI documentation it is declared that XI uses ISO 8601 for DATE type formatting. That's why you see dates in format YYYY-MM-DD in XML data in message monitoring.
3) The appearance of those decimal values are not that obvious for me. If XI uses ABAP transformation for message content then applies the rules for converting ABAP data types into XML. For this there is a SAP document 'ABAP - XML mapping' from TechEd2004. This document seems to describe how ABAP data types are handled by XML transformation.
Anyway, we currently need to play with decimal values in XSLT mapping programs inside XI:
a) add leading 0 integer if source value < 1
RFC returns 0.123 -> XI converts to XML '.123' -> XSLT mapper should return '0.123' ->SOAP response returns '0.123'
b) add decimal point and trailing zeros
RFC returns 0.000 -> XI converts to XML '0' -> XSLT mapper should return '0.000' ->SOAP response return '0.000'
With dates, the problem is actually on documenting mapping rules when writing interface specifications. If you would write an EAI-solution-independent conversion rule (RFC/date->SOAP/char) for date field it could sound like: YYYYMMDD -> dd.mm.yyyy. This works semantically between these systems but would not work for XI-developer, because he get YYYY-MM-DD from the RFC.
Additionally the decimal type conversion requirements in XSLT mapping programs probably only applies XI and are therefore not reusable in other EAI environments.
I would be glad if somebody would still have further comments for this data type conversion issue.
br: Kimmo -
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. -
my grandsons were using my computer, now my pound character types as a # sign, how to I get my pound sign back
If you have a british keyboard then they might have changed it to a US keyboard in System Preferences > Language & Text > Input sources tab > check "british" and uncheck US
-
WebDynpro call Returns an exception: Type conversion error
Hi,
I'm trying to start some of the standard SAP web dynpro .
most of then work fine.
some don't and i get the following error message.
Root Cause
The initial exception that caused the request to fail, was:
+com.sap.aii.proxy.framework.core.DataAccessException: Type conversion error, field TAX_PER_DIEMTAX, complex type class com.sap.xss.tra.tre.model.expenses.Ptrv_Web_General_Data_Int+
+at com.sap.aii.proxy.framework.core.JcoBaseTypeData.propagateJcoException(JcoBaseTypeData.java:130)+
+at com.sap.aii.proxy.framework.core.JcoBaseTypeData.setElementValue(JcoBaseTypeData.java:751)+
+at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setAttributeValue(DynamicRFCModelClass.java:482)+
+at com.sap.tc.webdynpro.progmodel.context.GenericModelClassCopyHelper.setAttributeValue(GenericModelClassCopyHelper.java:69)+
+at com.sap.tc.webdynpro.progmodel.context.CopyService.copyCorresponding(CopyService.java:55)+
+... 66 more+
See full exception chain for details.
could anyone give me an hint.
jco connetion are made and testet for:
sap_r3_humanresources
sap_r3_finacials
sap_r3_selfservicegenerics
sap_r3_travel
analog the *_MetaData
Thank in advance
MaximilianHello
did you solve this problem? I have the same error
Regards
Maybe you are looking for
-
Issue in Pricing Report Creation - V/LA
Dear All, I have created a new pricing report in V/LA. Details: 3 condition tables in the pricing configuration. 1-SO / DC / Customer / Sales district / Material 2-SO / DC / Customer / Material 3-SO / DC / Material During report creation I select onl
-
How can I make my Mac read email aloud?
I cannot find that function. I was looking at voiceover thread but all the posts are about problem using it not how to use it.
-
Best way to put 90 min. movie on DVD
I have a new movie that runs an hour and a half and is presently 17.7 gigs. I want to put it on DVD. iMovie compress it down to 2.8 gigs before burning a DVD but I want best quality possible which I believe is 4.2 gigs for a 4.7 gig DVD (one side).
-
Why do my app close when I play on them. Help
My apps keep closing when I open it to play. Wh
-
How do I create ringtones from purchased songs
exactly what the title says.