Converting char type to numeric
hi,
is there any Function Module that converts char type to numeric.
thanks.
hi,
data : w_num type i,
w_char type char10.
Use can asign character to numeric in PGM by using the statement try endtry.
try .
w_num = w_char.
endtry.
Regards,
Prabhudas
Similar Messages
-
Converting Char type structure to Hex type structure
Hello ,
In unicode system how to convert char type structure to hex type structure . I am having structures as follows :
DATA: BEGIN OF HEXBYTE,
X TYPE X,
END OF HEXBYTE.
DATA: BEGIN OF CHARBYTE,
C TYPE C,
END OF CHARBYTE.
HEXBYTE-X = CHARFIELD.
CHARBYTE = HEXBYTE.
But error coming is Charbyte and HexByte are not compatible . Plz suggest!!
Thanks ,
KeithHi,
These function modules are:
NLS_STRING_CONVERT_TO_SYS (hex to char)
NLS_SRING_CONVERT_FROM_SYS (char to hex)
Regards,
Nikhil -
Converting CHAR type to other data types
Dear SDN users,
would any of you know how to convert a CHAR data type to other data types for example hexadecimal etc., and convert them back? I suspect there must be some standard FMs available.
Thankyou for your responses.
Regards,
SmithaHello smitha ,
I suppose you are assigning some variable of char type to a variable of integer type it will automaticaly (implicitly ) convert the type .
in some case we need to change the type explicitly like the above mentiioned .
Thanks and regards ..
Priyank -
Error converting data type nvarchar to numeric 'witholding tax' (OWHT)
Hi Guys.
After I have upgraded my clients 2007 PL 30 database to 8.81 PL05, and running a repair to fix inconsistincies, I am receiveing some error when opening any sales documents.
It takes place when I open a sales document, or browse previous docs. When browsing previous docs, it onlly happens on some of them.
I also receive a different error when viewing sales orders: Error converting data type nvarchar to numeric (CRD2).
Any ideas how to fix it?
It does not limit me from processing and using the rest of the functionality. All calculations with queries in the docs are still working.
Thanks.Hi,
Please check Note No. : 1402855 and see if the same applied to the issue mentioned by you.
Kind Regards,
Jitin
SAP Business One Forum Team -
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Jni: converting char* to JNI type?
In my native C++ code I have to call a function through another dll. This function has an OUT parameter which is of type: char *.
I need to return this parameter to the calling Java method through the native C++ code using JNI ...is the corresponding JNI type that i should be returning jcharArray or jstring??
If so, how do I convert char * to the jcharArray/jstring type.Things may not be that simple. Beware that this function dos not expect any kind of char* . It expects UTF-8-encoded string.
it means that if your C string is all basic (i.e <127) chars, it is ok.
but if you have some special characters ( where ascii code > 128), it may not be interpreted the way you want.
see the end of http://java.sun.com/j2se/1.3/docs/guide/jni/spec/types.doc.html
for more details. -
Hi all,
How to convert decimal type length 3(e.g:25.0) to char type.......
Thanks in advancehi,
data : var_dec type p decimals 3,
var_char(10).
<b>move var_dec to var_char.</b>
else use FM
CALL FUNCTION <b>'CEVA_CONVERT_FLOAT_TO_CHAR'</b>
EXPORTING
FLOAT_IMP = P_ORIGEN
FORMAT_IMP = CAMPO_FLOAT
IMPORTING
CHAR_EXP = C_DESTINO.
Regards,
Santosh -
FM to convert character type to hexadecimal type
I have to make an object unicode compliant .
in the object the password is created using paskey and bcode.
Bcode contains all alphanumeric or alphabets.
and paskey is numeric.
to create password passkey and bcode are subtracted bit by bit.
now the problem is that i am not able to convert the Bcode to numeric type.
hence at the line where subtraction is starting.
its giving runtime error.
Can anyone help me to convert the alphnumeric chartcters to numeric...hexdecimal type.
Is there any FM or any code , plz tell me.
Its urgent.
Thanks and regards,
PrachiPrachi,
Check the below FM'S
NLS_STRING_CONVERT_TO_SYS( Hex to char)
and NLS_STRING_CONVERT_FROM_SYS (char to hex)
Amit. -
How to convert char to curr ?
Hi gurus.
Forgive me for the silly question.
I have a problem with data conversion from char to curr with 2 decimal places.
This is the scenario, I have a Z transaction which receives an excel file containing data from invoices and when the field contains a value such as 35,0 the program records the value 3.50 in the destination variable. But when the value is 35,45, it works.
Here is the piece of code:
WHEN '0007 '.
TRANSLATE USING ITAB-VALUE. " '.
ITAB-VALUE USING TRANSLATE',.'.
CONDENSE ITAB-VALUE NO-GAPS.
WA_OPER_MENORES-VL_BRUTO = ITAB-VALUE.
If I format the column in the excel file for numeric value with 2 decimal places also works, because when the value is formatted 35,0 change to 35,00. But I can not tell all the users hey formatt your files before upload to SAP.
To test I generate a simple report that reads the excel file and makes the conversion of the columns, like the code above, so I had no problems. I think there should be some configuration that has been changed in the transaction, but I'm new in ABAP, I come from "Java World" and I have no idea that could be.
I could just use a quick and dirty solution, adding a zero at the end of the column, when there is the 2 decimal places, but I prefer a clean solution.
Guys, is there any function module or class that does that kind of data conversion? If not, you could tell me what is the best practice to solve this problem?
thank you very much,
Ronaldo S. VieiraFollow this example to convert Char to Curr and Vice-Versa
DATA iamnt(17) TYPE c VALUE '243567.00'.
DATA eamnt TYPE p DECIMALS 2.
DATA oamnt(17) TYPE c.
MOVE iamnt TO eamnt.
WRITE eamnt TO oamnt.
WRITE oamnt. -
Hi all,
i searched alot but couldn't find solution.
i have l_value char(45) field value has 4560
I need to convert this into vbak-netwr field in sales order user exit MV45AFZZ
when i assign vbak-netwr = l_value.
I am getting 45.60 in vbak-netwr field.
when i try same login in report progam it is working fine but not in user exit.
any suggestions?
GiriSample program to convert Char to Curr.
data: curr type kna1-umsa1,
char(254) type c.
data: temp type p length 15 decimals 2.
char = '1,405.25'.
REPLACE ALL OCCURRENCES OF '.' IN char WITH space.
REPLACE ALL OCCURRENCES OF ',' IN char WITH space.
CONDENSE char NO-GAPS.
temp = char.
curr = temp / 100.
write: 'CHAR = '.
write :/ char.
write:/ 'CURR = '.
write: curr.
<< Removed by moderator >>
Regards,
Uttam Agrawal
<< Removed by moderator >>
Edited by: uttamagrawal on Feb 22, 2011 9:21 AM
Edited by: Neil Gardiner on Feb 22, 2011 9:01 PM -
hi
i have a char type var which contain value = ****12,1212.00
now i want to convert this char value in to numarical value like 12,1212.00 .
for that i have used the conversion_exit_alpha_input but i did not get proper out put .
plz a fm to solve this porblem .Well, you example dumps.........why? Because you need to get rid of the thousands seperator.
report zrich_0001.
data : v_char(20) value '121,212.00',
v_num type p decimals 2.
translate v_char using ', '.
condense v_char no-gaps.
v_num = v_char.
write : v_num.
Of couse, this only works if you user specific formating is like <b>123,456.00</b>
Where , is the thousands sepeator and '.' is the decimal separator.
Regards,
Rich Heilman -
Convert char to ascii code and vice versa
HI
Is there any function module to convert char to ascii code and vice versa.
Thanks in advanceHi,
be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.
Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:
[P]
convert p_form to ASCII (internal) representation
DATA:
l_ofs TYPE syfdpos,
l_len TYPE sy-linsz,
l_ascii TYPE i.
FIELD-SYMBOLS:
<x> TYPE x.
l_len = STRLEN( p_ascii ).
DO l_len TIMES.
l_ofs = sy-index - 1.
ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.
l_ascii = <x>.
WRITE: l_ascii.
ENDDO.
[/P]
Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.
Regards,
Clemens -
Dear all ,
I have to convert char to dec , my requirement is to covert 12344434 to 123444.34 .
note i don't want 12344434 to 12344434.00 .
Thanks in advance
DebeshYou can try like this.
DATA : v_tot_len TYPE i,
v_off_len TYPE i.
DATA : v_off_text(50) TYPE c,
v_dec_text(2) TYPE c,
v_fin_text(50) TYPE c.
PARAMETERS : p_input TYPE text20 OBLIGATORY.
START-OF-SELECTION.
v_tot_len = STRLEN( p_input ).
v_off_len = v_tot_len - 2.
v_off_text = p_input+0(v_off_len).
v_dec_text = p_input+v_off_len(2).
CONCATENATE v_off_text v_dec_text INTO v_fin_text SEPARATED BY '.'.
Here I am inputting the text to be converted. -
How to convert char(1) to int32 datatype in pl/sql
Hello,
I am trying to convert char(1) to an integer data type to be put into an int32 variable in C#. I tried several options such as TO_NUMBER ,CAST(.. AS INTEGER), and CAST(.. AS SMALLINT) but they all return int64.
Is there a way to ensure the casting into a datatype that is compatible with int32 ?
ThanksOracle's SQL Datatypes are limited to NUMBER, BINARY_FLOAT and BINARY_DOUBLE.
There's a few others through PL/SQL including BINARY_INTEGER.
If you look in USER_ARGUMENTS you can see it is defined slightly differently.
Don't know whether / how .Net infers datatypes, but it is worth a shot.
create or replace function v (p number) return binary_integer is
begin
return p;
end;
/ -
Converting char to decimal value format as defined in SU3(User profile)
Hi Techies,
Is there any FM to convert CHAR value into Decimal fomat as defined in SU3.
If we use, WRITE statement for printing the value in decimal format , it shows the value in decimal format correctly
in SU3 transaction , there are three different decimal format notations which can be user specific
I would appreciate your valuable inputs ....
Thanks
SanthoshThis is my code in a generic method to transform a table into a csvrow
when 'P'.
tmpstr = <p_field>.
len = strlen( tmpstr ) - 1.
tmpstr = tmpstr+0(len).
if <p_field> < 0.
sign = '-'.
else.
sign = ' '.
endif.
case decimalformat.
when 'X' or 'E'.
split tmpstr at '.' into int frac.
ptmp = int.
write ptmp to cp.
shift cp left deleting leading space.
replace all occurrences of '.' in cp with ','.
concatenate
s
sign
cp
frac
delimiter
into s in character mode.
when 'Y' or 'D'.
split tmpstr at '.' into int frac.
ptmp = int.
write ptmp to cp.
shift cp left deleting leading space.
replace all occurrences of ',' in cp with '.'.
concatenate
s
sign
cp
frac
delimiter
into s in character mode.
when ' '.
concatenate s sign tmpstr delimiter into s in character mode.
when others.
concatenate s '????????' delimiter into s in character mode.
endcase.
where pfield is a fieldsymbol type P. (honestly ist from type any, but determined by RTTI). I needed this cause i want to format the value from "outside" without taking the user settings in consideration as write...to.. is doing.
What i'm doing is to use the write... to... clause modifying the result (change decimal point, thousand separator and sign) according to the demanded decimal notation.
Edited by: Rainer Hübenthal on Oct 7, 2009 4:47 PM
Maybe you are looking for
-
PRTMessageListenerException: The listener does not exist
Hi All, We are running EP 7.0 NWO4s on Windows 2003. When the user log on to the portal with the valid qualified URL geting an " 500 Internal Server error with java.lang.null pointer exception message" Before the restart of the server every user abl
-
Trying to understand SSL sticky with CSS 11506 / ssl-l4-fallback behavior
Dear experts I have a CSS 11506 (v7.50) which is used to load balance several SSL-based sites. We use the following textbook content rule: content mysite-SSL vip address 10.0.0.1 add service s01 add service s02 add service s03 port 443 protocol tcp a
-
Hi ALL, I have a typical scenario. My main plant is supplying a material to other plants through STO. The main plant also has its own requirements. The requirements in other plants as wel as that of main plant are entered as planned independant requi
-
Problem using Gotham font in Adobe Muse
I am working on a web design project using Adobe Muse for my client who uses predominantly Gotham. They own most of the Gotham font family in .otf and they also have the Gotham SSm (Screen Smart Font) for web use. When trying to load the font to Adob
-
External links in MCM Newsletters
Good morning, I am trying to create a Newsletter customize to the cq page launching the process. For that I have a Template Alert that by code is copied to tmp folder and fill out some attributes with the value of the page. Then is called the buildNe