HEX to CHAR conversion in ECC 6.0
Hi All,
We have upgraded the client system from 4.6C to ECC 6.0. In one of the program the code was as below:
c_code1(1) TYPE x VALUE '23',
c_code2(1) TYPE x VALUE 'E1'.
i_uml-uml = c_code1.
APPEND i_uml.
i_uml-uml = c_code2.
APPEND i_uml.
LOOP AT i_uml INTO w_char.
SEARCH i_rab_tab FOR w_char.
IF sy-subrc = 0.
MOVE 'X' TO w_found.
EXIT.
ENDIF.
ENDLOOP.
Here c_code1 and c_code2 are declared as hex and assigned 23 and E1. These codes are moved to itab i_umi. These valuse are assigned to w_char.
When assigned to w_char, the hex value of 23 is converted to '#' and E1 is converted to 'ä'.
Above logic is working in 4.6 but not working in ECC 6.0. The conversion of HEX to char is not working in 6.0. In ECC 6.0, when hex number 23 is assigned to w_char, it takes value as '2'.
Please suggest me how can I make it work in ECC.
Thanks in advance.
regards,
Gaurav
Hi,
Try with the below Z report by Changing the values for VALUE in the below report and execute it you can get the hexadecimal conversion,
data : i1 type xstring,
i2 type string,
i3 type x.
parameters: value like i3.
i1 = value.
CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
EXPORTING
lang_used = sy-langu
source = i1
FROM_FE = 'MS '
IMPORTING
RESULT = i2
SUBSTED =
EXCEPTIONS
ILLEGAL_SYST_CODEPAGE = 1
NO_FE_CODEPAGE_FOUND = 2
COULD_NOT_CONVERT = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write: i2.
Thank U,
Jay....
Similar Messages
-
Hi Experts,
I am trying to convert hexa decimal value 1D to char value GS. I tried using the FMs <b>NLS_STRING_CONVERT_TO_SYS</b> and <b>stpu1_hex_to_char</b> but I did not get GS as output instead it was ##.Please suggest me the solution for this.
Points will be rewarded.
Thanks,
NageshHi Nagesh,
You can use the following code to get the char value of the hex value.
TRY.
CALL METHOD CL_ABAP_CODEPAGE=>CONVERT_FROM
EXPORTING
SOURCE = xstr
CODEPAGE = `UTF-8`
ENDIAN =
REPLACEMENT = '#'
IGNORE_CERR = ABAP_FALSE
RECEIVING
RESULT = char
CATCH CX_PARAMETER_INVALID_RANGE .
CATCH CX_SY_CODEPAGE_CONVERTER_INIT .
CATCH CX_SY_CONVERSION_CODEPAGE .
CATCH CX_PARAMETER_INVALID_TYPE .
ENDTRY.
This will work for normal characters. But GS (Group Separator) is a special character, it will return "#" only..
We were also facing this issue. So we decided to take a decision depending on the Hex value itself.
If you find any mechanism to solve this problem, do let me know.
~ ramanath. -
Numeric or value error: hex to raw conversion error , pls help
I am having problem with a sproc which accepts a Raw parameter.
I have a table called Profile:
CREATE TABLE PROFILES
PROFILEID INTEGER NOT NULL,
USERID INTEGER NOT NULL,
PROFILE RAW(255)
and a sproc named addprofile
CREATE OR REPLACE PROCEDURE addprofile
profile IN RAW,
userName IN VARCHAR2
AS
userId INT;
BEGIN
GetUserIdByName( userName, userId);
INSERT INTO Profiles
( ProfileID,userId , profile )
VALUES ( Profiles_ProfileID_SEQ.NEXTVAL,AddProfile.userId ,
AddProfile.profile );
END;
I am calling the Ent Library's Insert profile method which is part of DbProfileProvider.cs (Security App block). It is trying to persist a serialized profile object into the database.
private void InsertProfile(string userName, byte[] serializedProfile,
Data.Database securityDb, IDbTransaction transaction)
DBCommandWrapper cmd = securityDb.GetStoredProcCommandWrapper
(SPAddProfile);
cmd.AddInParameter("userName", DbType.String, userName);
cmd.AddInParameter("profile", DbType.Binary, serializedProfile);
securityDb.ExecuteNonQuery(cmd, transaction);
I get the following error:
Any suggestion on what needs to be changed to get this working? thanks!
Exception Details: Oracle.DataAccess.Client.OracleException: ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error ORA-06512: at line 1
Stack trace:
[OracleException: ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
ORA-06512: at line 1]
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DBCommandWrapper command)
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DBCommandWrapper command, IDbTransaction transaction)
Microsoft.Practices.EnterpriseLibrary.Security.Database.DbProfileProvider.InsertProfile(String userName, Byte[] serializedProfile, Database securityDb, IDbTransaction transaction)
Microsoft.Practices.EnterpriseLibrary.Security.Database.DbProfileProvider.SetProfile(IIdentity identity, Object profile)
[InvalidOperationException: Error saving the profile for the following user 'test'.]
Microsoft.Practices.EnterpriseLibrary.Security.Database.DbProfileProvider.SetProfile(IIdentity identity, Object profile)
EntLibSecuritySample.DFO.Security.SecurityHelper.SetUserProfile(IIdentity identity, Object Profile) in C:\DFO\Sample\Security\EntLibSecuritySample\SecurityHelper.vb:285
[ApplicationException: An error has occurred saving profile object to Datastore. See stack trace for further information]
EntLibSecuritySample.DFO.Security.SecurityHelper.SetUserProfile(IIdentity identity, Object Profile) in C:\DFO\Sample\Security\EntLibSecuritySample\SecurityHelper.vb:287
EntLibSecuritySample.ProfilePage.cmdSaveProfile_Click(Object sender, EventArgs e) in C:\DFO\Sample\Security\EntLibSecuritySample\profile.aspx.vb:59
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1292Harsh,
I am not a user of the Enterprise Library so I can not speak to the specifics of that. However, here is a short sample that is based on the information you've provided. Perhaps it will be useful.
Database:
create table profiles
profileid integer not null,
userid integer not null,
profile raw(255)
create or replace procedure addprofile
p_profileid in integer,
p_userid in integer,
p_profile in raw
as
begin
insert into
profiles (profileid, userid, profile)
values (p_profileid, p_userid, p_profile);
end;
/C# code:
using System;
using System.Data;
using System.Text;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace HarshTest
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
// connect to local db using o/s authentication
OracleConnection con = new OracleConnection("User ID=/; Pooling=False");
con.Open();
// create command object and set properties
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "ADDPROFILE";
cmd.CommandType = CommandType.StoredProcedure;
// parameter object for profileid
OracleParameter p_profileid = new OracleParameter();
p_profileid.OracleDbType = OracleDbType.Int32;
p_profileid.Value = 1;
p_profileid.Direction = ParameterDirection.Input;
// parameter object for userid
OracleParameter p_userid = new OracleParameter();
p_userid.OracleDbType = OracleDbType.Int32;
p_userid.Value = 1;
p_userid.Direction = ParameterDirection.Input;
// create a byte array for the raw value
ASCIIEncoding encoder = new ASCIIEncoding();
byte[] byteArray = encoder.GetBytes("TestProfile");
// parameter object for profile
OracleParameter p_profile = new OracleParameter();
p_profile.OracleDbType = OracleDbType.Raw;
p_profile.Value = byteArray;
p_profile.Direction = ParameterDirection.Input;
// add parameters to collection
cmd.Parameters.Add(p_profileid);
cmd.Parameters.Add(p_userid);
cmd.Parameters.Add(p_profile);
// execute the stored procedure
try
cmd.ExecuteNonQuery();
catch (OracleException ex)
Console.WriteLine(ex.Message);
// clean up objects
p_profile.Dispose();
p_userid.Dispose();
p_profileid.Dispose();
cmd.Dispose();
con.Dispose();
}Maybe the part about creating the byte array is what you are missing...
- Mark -
Web service call on hosted env fails with hex to raw conversion error
Hi,
I use Enciva to run some hosted Apex applications, and I've had a call open with them for a few days re: setting up a web service call to an e-mail checker, provided by a company called Rolosoft. The e-mail checker runs fine from outside the hosted environment, but I get the following error trying to call from the Apex application:
ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
Has anyone hit this error before with web services, I've tried manual and RESTful but get the same error message.
Thanks,
MikeHello,
We encounter the same issue using manual WebService !
Environnement Settings :
Oracle 11g R2 - Windows W2K3 - NLS_CHARACTERSET : AL32UTF8
Apex 4.1
Any suggestions, helps ?
Thanks,
G. -
Non-unicode to Unicode conversion in ECC 6.0
hello friends,
WE have ECC 6.0 at our location , it was upgraded from 4.7 to Ecc 6.0, but it is in non-unicode format , just we have to convert that thing to unicode , for that we have seen that we can export the data from current non-unicode system by SAPINST and import that data to another ECC 6.0 unicode system by using SAPINST .
i bit confuised that which oprn from SAPINST i have to select to export the data and which option to be select from SAPINST to import the data so pls can anybody help me regarding the same.
Regards
Anil> Go for the exact document which u need. Code page
> 4100 is common for Unicode conversion....
4100? No - 4102 or 4103 are the correct ones - depending on processor and operating system (endianess). See
Note 552464 - What is Big Endian / Little Endian? What Endian do I have?
Markus -
Hi all
in the following query:
select to_date('31-JUL-12', 'dd-MON-yy') res from dual;we have error:
ORA-01843: not a valid month
01843. 00000 - "not a valid month"
*Cause:
*Action:...this is the first strange error/for me :) /...
After this conversion - i want to convert it to char.
Expected output:
2012/07/31 00:00:00Any ideas?
Version: 11g
Thanks in advance,
Bahchevanov.bahchevanov wrote:
Hi all
in the following query:
select to_date('31-JUL-12', 'dd-MON-yy') res from dual;we have error:
ORA-01843: not a valid month
01843. 00000 - "not a valid month"
*Cause:
*Action:...this is the first strange error/for me :) /...
After this conversion - i want to convert it to char.
Expected output:
2012/07/31 00:00:00Any ideas?
Version: 11g
Thanks in advance,
Bahchevanov.post results from following SQL
select to_char(sysdate-1,'YYYY-MON-DD') FROM DUAL; -
Hi there,
I have an hex variable that I want to move to a Char variable.
DATA: x_var(255) type X,
c_var(255).
MOVE x_var to c_var.
I normally used the command MOVE, but my application needs to be unicode compliant and I receive a warning saying that those "variables are not mutually convertible in a Unicode program".
I have tried the STPU1_HEX_TO_CHAR but it expects a C type variable as input so it does not work
Actually, my c_var variable is the header of a table I have declared as RAW, in case it may give some additional hints
Thanks for your supportHi,
It depends on how you use the type X variable in your Program.
The FM mentioned by RAVI are perfect.
But before using them you need to take two variables of type STRING and XSTRING and proceed because the specifed FM do not accept field types of X and C as parameters.
Example: DATA: x_var1 type xstring,
c_var1 type string.
x_var1 = x_var.
call function module pass x_var1 and store result in c_var1.
c_var = c_var1.
Thanks.
Hope this helps you. -
hi guys,
i am trying to convert an hex to an char using the folloing code but its giving me short dumb with the message "When converting the base entry of the field symbol "<FS>" (number in base table: 13), it was found that the target type requests a memory
alignment of 2."
but the same code is working in some other system i am suing BI 7.0 can anyone tell me what is the reason....
data : v_hex(4) type x,
v_char(10) type c value 'ABCDA0A0',
V_CHAR(10) TYPE C VALUE 'A0A0A0A0'.
v_hex = 'A0A0A0A0'.
FIELD-SYMBOLS <FS> TYPE ANY.
v_hex = '20202020'.
ASSIGN V_HEX TO <FS> CASTING TYPE C.
CONCATENATE <FS> V_CHAR INTO V_CHAR.
pls reply me
raviHello Ravi,
Check the below program:
data : v_hex(4) type x,
v_char(10) type c value 'ABCDA0A0',
V_CHAR1 TYPE string.
v_hex = 'A0A0A0A0'.
FIELD-SYMBOLS <FS> TYPE ANY.
v_hex = '20202020'.
ASSIGN V_HEX TO <FS> ."CASTING TYPE C.
move <FS> to v_char1.
CONCATENATE v_char1 V_CHAR INTO V_CHAR.
write:/ v_char.
In Unicode env ,do not use casting after assign statement
I don't have idea about your functionality.
Check the below program :
field-symbols <fs> type any .
data : w_hex(1) type x value 31.
assign w_hex to <fs> ."casting.
write <fs>.
hex value is 31 ,when you convert into ASCII character then it becomes 1F.
Thanks
Seshu -
Convert Access Module to SQL Function - Hex To Dec conversion
I need to convert an Access Module to a SQL Function but not sure how to successfully accomplish this.
The module has several different functions to convert hexadecimal numbers to decimal and vice versa. I am not sure if I needed to break out each module function into a seperate function in SQL or not. Any help would be appreciated.
Here is the actual module that needs to be converted:
Public Function MEID_DecToHex(mMEIDDec As String) As String
'Dim mMEIDDec As String
Dim mManNum As Double
Dim mSerialNum As Double
Dim mMEIDHex As String
Dim mManHex As String
Dim mSerialHex As String
'mMEIDDec = "268435457304109828"
'*** Check MEID digits, make sure it is 18 digits else return invalid
If Len(mMEIDDec) = 18 Then
'*** 18 digit decimal code: 1st 10 digits is for the Manufacturer and last 8 digits is for the Serial Number
mManNum = Left(mMEIDDec, 10)
mSerialNum = Right(mMEIDDec, 8)
'*** Convert MEID Dec to Hex
mManHex = DecToHex(mManNum)
mManHex = fntPad(mManHex, "0", 8)
mSerialHex = DecToHex(mSerialNum)
mSerialHex = fntPad(mSerialHex, "0", 6)
MEID_DecToHex = mManHex & mSerialHex
ElseIf Len(mMEIDDec) = 11 Then
'*** 11 digit decimal code: 1st 3 digits is for the Manufacturer and last 8 digits is for the Serial Number
mManNum = Left(mMEIDDec, 3)
mSerialNum = Right(mMEIDDec, 8)
'*** Convert MEID Dec to Hex
mManHex = DecToHex(mManNum)
mManHex = fntPad(mManHex, "0", 2)
mSerialHex = DecToHex(mSerialNum)
mSerialHex = fntPad(mSerialHex, "0", 6)
MEID_DecToHex = mManHex & mSerialHex
Else
MEID_DecToHex = "Invalid"
End If
End Function
Public Function MEID_HexToDec(mMEIDHex As String) As String
'Dim mMEIDDec As String
Dim mManNum As String
Dim mSerialNum As String
'Dim mMEIDHex As String
Dim mManDec As String
Dim mSerialDec As String
'mMEIDHex = "a000001937b27a"
' Remove any spaces befor or after the string
mMEIDHex = Trim(mMEIDHex)
'*** Check MEID digits, make sure it is 14 digits else return invalid
If Len(mMEIDHex) = 14 Then
'*** 14 hexadecimal digits: 1st 8 digits is for the Manufacturer and last 6 digits is for the Serial Number
mManNum = Left(mMEIDHex, 8)
mSerialNum = Right(mMEIDHex, 6)
'*** Convert MEID Hex to Dec
mManDec = HexToDec(mManNum)
mManDec = fntPad(mManDec, "0", 10)
mSerialDec = HexToDec(mSerialNum)
mSerialDec = fntPad(mSerialDec, "0", 8)
MEID_HexToDec = mManDec & mSerialDec
ElseIf Len(mMEIDHex) = 8 Then
'*** 8 digit Hex code: 1st 2 digits is for the Manufacturer and last 6 digits is for the Serial Number
mManNum = Left(mMEIDHex, 2)
mSerialNum = Right(mMEIDHex, 6)
'*** Convert MEID Dec to Hex
mManDec = HexToDec(mManNum)
mManDec = fntPad(mManDec, "0", 3)
mSerialDec = HexToDec(mSerialNum)
mSerialDec = fntPad(mSerialDec, "0", 8)
MEID_HexToDec = mManDec & mSerialDec
Else
MEID_HexToDec = "Invalid"
End If
End FunctionTry link
you can create & use CLR function
or you can simply convert on fly refer below link
http://blog.sqlauthority.com/2010/02/01/sql-server-question-how-to-convert-hex-to-decimal/
http://blog.sqlauthority.com/2012/07/26/sql-server-answer-how-to-convert-hex-to-decimal-or-int/
decimal to hex
http://stackoverflow.com/questions/13643729/decimal-to-hex-conversion-in-sql-server-2008 -
Imagine that I have a raw format variable t raw(10); and it represents a character string in binary format. Now, I want to convert it from hexadecimal RAW format to VARCHAR2. How to do that? You would say:"It's simple, just use DUMP function and cut the information header.", but the main problem is, that the variable t is a representation of string in an actual charset. So I will ask again. How to convert HEX raw representation of a string to VARCHAR2 string with a charset I like? My problem was, that some of the central european characters were damaged and split into 2 ascii characters.
What charactersets does your database use?
-
How do I convert a string I have (I am sure its one character) in to char?
you must mean char foo, instaead of String!
char foo = "bar".toCharArray()[0]; -
Very simple Char* conversion operator not working
This should be simple, but it's not working. The code below gives me a compiler error:
Error 2 error C2440: 'initializing' : cannot convert from 'Foo' to 'char *'
class Foo
char * _data;
public:
operator const char * () { return _data; }
Foo f;
char * bar = f;
char*_data;
public
operatorconstchar*(){return_data;}
Eric Jorgensen http://www.ericjorgensen.comOn 3/5/2015 12:26 AM, "Eric Jorgensen" wrote:
This should be simple, but it's not working. The code below gives me a compiler error:
Error 2 error C2440: 'initializing' : cannot convert from 'Foo' to 'char *'
Foo can be converted to const char*, but not to char*
Igor Tandetnik -
Please sent me immediately when u get this mssg;;;;;
Is there any methods like Integer.parseInt() for converting a String to charecter?
Or plz send me a way to read charecter as commandline argument so that it can be used in Switch().You could use method from String class toCharArray().
String s = "my string";
char [] charray = s.toCharArray(); -
Hai all,
I have a colmn called Kilometers in table of datatype varchar and has got morethan 20,000 numeric records in it.. only numbers are getting stored in that column.. now am creating one more table with column called kiometres with datatype number..
I want to insert the records of table A.Kilometres to B.Kilometres.. I tried the follwoing :
insert into project_mileage (kilometres) select (to_number(kilometres,'9999999')) from project
am getttin the error :
ora-01722. invalid number.
how can I get the records inserted..
Thanks
KaiIf your data doesn't include other characters but numbers, you could rely on the implicit datatype conversion:
SQL> create table a(a varchar2(3));
Table created.
SQL> create table b(b number(3));
Table created.
SQL> insert into a values ('1');
1 row created.
SQL> insert into a values ('2');
1 row created.
SQL> insert into a values ('3');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into b select * from a;
3 rows created.
SQL> commit;
Commit complete.
SQL> select * from b;
B
1
2
3
SQL>~ Madrid -
CHAR conversion to NUM.
dear all,
in BI7, how can i convert my CHAR into NUM datatype? data from external source is coming in as CHAR and i want to change it to type NUM. how can i do that in the update rule? thanks.Hi,
Do Type casting to convert the CHAR into NUM datatype.
Let's say,
l_var1 --> Source variable in CHAR
l_var2 --> Target variable in NUM
Create a temporary variable variable l_temp as Type NUM.
Make sure that l_var1 does not have any non-numeric values. Do a check for that.
IF l_var1 CONTAINS ( 0,1,2,3,4,5,6,7,8,9 )
l_temp = l_var1 (Type Casting)
l_var2 = l_temp.
ENDIF.
This will work out.
Regards,
Balaji V
Maybe you are looking for
-
Master Detail : Default value to '0' in Detail
Hi All, I am new to Apex. I need some assistance with a Master-Detail form I created in Oracle APEX. The detail table has few columns and during ADD ROW (@ detail level), I have been trying to default the values in the detail table to '0'. But, I hav
-
Advice wanted: Should I upgrade to iLife '11 on my iMac that has Aperture?
David Pogue just mentioned that iLife '11 supposedly has some kind of incredible slide show feature that turns your slides into some kind of movie trailer. Now I don't normally do slide shows so haven't used them much in either iPhoto or Aperture. So
-
Also Transfer Problem with ZEN X
Finally i decided it to buy a zen xtra. The player works fine, also the firmware update was no problem. But then i wanted to transfer my mp3 files to the zen, i used just the nomad explorer for that(Because although i read the readme, i didn?t manage
-
Read the file on application server and Z table as Link in ALV report.
Hi , I need some suggession on following requirement. I need to develop an ALV report where, I have to display 6 column. Four rows are kind of data which i am getting from some tables. But other two column are link to Excel files. So following are th
-
I have the new Mountain Lion OS X installed, with the Apple Server app as my webserver - however I can't get Coldfusion 10 to install. The issue arises because the installer can't find the Apache config file. Normally the file would be called "httpd.