Convert XString to String and String to IWDResource
Hi everybody,
we want to open a PDF-Document from Backend in Web Dynpro. For the communication we use a Web Service.
In Backend we have a PDF-Document with data type XSTRING.
1. In Backend we convert the PDF-Document from XSTRING to STRING in order to send it via Web Service
2. Then we call the Web Service and pass by the STRING param
3. In Web Dynpro we convert the value from STRING to Bytes, like below:
IWDResource resource = WDResourceFactory.createResource( myPDFStringFromWS.getBytes(), "Doc1", WDWebResourceType.PDF);
4. We bind the Resource to a FileDownload-UI.
Unfortunately we get the error message: Document is not a valid PDF
How can we convert a String to IWDResource? Could the problem be in our first step, where we convert the XSTRING into STRING?
regards,
Sid
Hello Sid,
IWDResource resource = WDResourceFactory.createCachedResource(new ByteArrayInputStream(wdContext.currentFileElement().getString()),"PDF",WDWebResourceType.PDF,true);
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.toString(),"PDF");
window.show();
Can you try this and let us know.
Regards
Nizamudeen SM
Similar Messages
-
ByteArray to String and String to ByteArray error at readUTF from datainpu
hi everybody this is my first post I hope I can find the help I need I have been doing some research and couldnt find the solution thanks in advanced
The Objective:
im building a client server application with java and I need to send a response from the server to the client via Socket
so the response is like this : <Signal : ByteArray> where Signal is a String so the client can Identify the Type of response
and the ByteArray is an Array of bytes containing the Information I need
The Problem:
I have an Array of bytes containing the info to send and I need to pass this byte[] to a String add some String that let me Identify the data in the client side then remove the identifier in the client side and convert the resulting String back to an array of bytes this doesnt work
The Code:
Server Side (Creating the Byte Array):
public byte[] createData(){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(requestedFile.getName());
dos.flush();
byte[] data = baos.toByteArray();
return data;
}Server Side (Converting the byte[] to String and Add some Identifier)
byte[] data= createData(); //Obtain the data in a byte[]
String response = new String(data); //Convert the Data to String
String Identifier= "14"; // to identify in the client side the data received this will be removed later
response = Identifier+response; // add the identifier to the String
sendToClient( response.getBytes() ); //obtain bytes from the complete Response and send them to clientClient Side ( Receive the response that is a byte array containing the identifier plus the info <Identifier : info> )
int index=response.indexOf(":")+1; //find the index of the : so i can delete the identifier
response=response.substring(index); // delete the identifier
byte[] data = response.getBytes(); // obtains the bytes for the info ONLY cause the string no longer has identif
receiveData ( data ); // send the data to be read by this method Client Side (Receive the Info sent from the server and read it)
public void receiveData ( byte[] data ) {
ByteArrayInputStream bais = new ByteArrayInputStream ( data );
DataInputStream dis= new DataInputStream ( bais );
setTotalSize ( dis.readUTF( ) ); // here is the error it catches an EndOfFileException without read the info
}im tried sending other values like long and int and i was able to read them but the problem is with the Strings at the ReadUTF()
Im tried to be the most clear as possible please help me this is driving me nuts
and I would really appreciatte all your comments thankslemaniak wrote:
The Objective:
im building a client server application with java and I need to send a response from the server to the client via Socket
so the response is like this : <Signal : ByteArray> where Signal is a String so the client can Identify the Type of response
and the ByteArray is an Array of bytes containing the Information I need
The Problem:
I have an Array of bytes containing the info to send and I need to pass this byte[] to a String add some String that let me Identify the data in the client side then remove the identifier in the client side and convert the resulting String back to an array of bytes this doesnt workFirst of all, well done: a nicely explained problem. I wish more people were as clear as you.
Second: I'm no expert on this stuff, so I may well be wrong, but I did note the following:
1. I can't see anywhere where you're putting out the ":" to separate your signal.
2. You seem to be doing an awful lot of conversions from Strings to bytes and vice-versa, but only your filename is specified as a UTF-8 conversion. Could you not do something like:
dos.writeUTF("14:" + requestedFile.getName());or indeed, more generically
dos.writeUTF(signal + ":" + messageBody);from inside a createMessage() method.
3. You haven't included the sendToClient() code, but your createData() looks suspiciously like what I would put in a method like that.
From what I understand, you usually want mirror-images of your streams at your sending and receiving ends, so if your client is expecting an DataInputStream wrapping a ByteArrayInputStream to be read via readUTF(), your server better be sending a ByteArrayOutputStream wrapped in a DataOutputStream created, in its entirety, by writeUTF().
But after your UTF conversion, you're adding your signal and then using String.getBytes(), which uses the default character set, not UTF.
HIH (and hope I'm right :-))
Winston -
Difference between String=""; and String =null
I want to know the difference especially the ADVANTAGE between the following-
1. String s="";
String s="ABC"
and
String s;
String s="ABC";
or String s=null;
String s="ABC";
2. Object anyObject;
anyObject-new Object();
and
Object anyObject=null;
anyObject=new Object();Tanvir007 wrote:
I want to know the difference especially the ADVANTAGE between the following-
1. String s="";s points to the empty string--the String object containing no characters.
String s="ABC"s points to the String object containing the characters "ABC"
String s; Declares String reference varialbe s. Doesn't not assign it any value. If it's a local variable, it won't have a value until you explicitly assign it. If it's a member variable, it will be given the value null when the enclosing object is created.
String s="ABC";Already covered above.
or String s=null;s does not point to any object.
String s="ABC";???
You've already asked this twice.
Are you talking about doing
String s = null;
String s = "ABC";right after each other?
You can't do that. You can only declare a variable once.
If you mean
String s = null;
s = "ABC";It just does what I described above, one after the other.
2. Object anyObject;
anyObject-new Object();
and
Object anyObject=null;
anyObject=new Object();As above: In the first case, its value is undefined until the new Object line if it's a local, or it's null if it's a member.
As for which is better, it depends what you're doing. -
Compare string and string from db
I successfully queried a field from mysql into a jcombobox.
What I can't figure out is why:
String fromDB = comboBox.getSelectedItem().trim();
AND
String newString = "sameStringFromMySQL";are not equal. I already trimmed the text from the combo box but they are still not considered equal.
WHY???just like how i described above.
(fromDB.equals(newString)) returns false.
Then they are not equal.
Most likely reasons:
-fromDB: This is starting with the text you think.
-fromDB: You aren't getting it from the right place.
-fromDB: You are modifying it before it gets to the comparison.
-NewString: Doesn't have the value you think.
-The comparison above isn't really the problem.
You can always print the bytes in any string by using the getBytes() method on String and printing out both strings just before the above comparison (not elsewhere.) -
Selection of Localizable.strings and .strings file naming?
Hi Apple Developer Folks,
In the process of embedding Internalization for strings in my project, I referred to the "InternationalMountains" sample code project.
In that project there are three languages supported, English, French and Chinese.
What I do not understand is why all three Localizable.strings files have been checked in Localization section of the File Inspector.
This is the case for the other two such files, as well.
(See the full sized image at http://www.drake.org/images/AllThreeBoxes.jpg )
Also, I have one other question: "What is the suggested mechanism for controlling the NAMING of the Localizable.strings files?"
If I wanted to name the files something like "StandardApp.strings" or "ProApp.strings" - where and how would that be accomplished?
As it is, if the files are not named "Localizable.strings" - the NSLocalizedString(key, comment); calls do not work as intended.
Thanks very much!I'm guessing that most use the default naming of the localization strings files, which are packaged with related localized files in the appropriate resource folder - your screenshot is just showing that there are three localizations for that name.
You can use any name you want when creating a strings file - Foundation's NSLocalizedString just uses the default Localizable.string file name by calling NSBundle's localizedStringForKey:value:table: method with a nil value for the table. You can use other names by calling that method or by using Foundation's NSLocalizedStringFromTable, passing the desired table name (the file to use). -
URL to String and String to URL
Hello,
I'm fairly new to Java and I have made my way through most of the things I've tried...except for the following:
I'm trying to load an image from the following path:
http://JOHNB1:8082/classpath/StickShooter/
The code I'm using is:
aImages[ 0 ] = this.getImage( this.getDocumentBase(),"P0.gif" ) ;
I found that getDocumentBase() returns the following:
http://JOHNB1:8082/classpath/StickShooter/StickShooter.html
The other thing is I tried to do this:
sScratch = this.getDocumentBase().toString() ;
URL u = new URL( sScratch ) ;
but I keep getting a MalformedURLException error.
Any comments/feedback/help is much appreciated.
Thanks,
JohnHi,
Well, I'm not 100% sure on how to answer that question, but its an applet that I want to load a series of pictures/images (.GIF) that are in a sub folder of my project directory.
Thanks. -
Fm to convert XSTRING TO STRING in SRM 7.0
HI All ,
i have created a web dynpro application for Uploading excel . Now i am not getting any workaround to convert X STRING to STRING . In SAP there is a FM HR_KR_XSTRING_TO_STRING but its not there in SRM so when i tried to copy the same in SRM and try to convert its getting converted in Junk characters . Please help me out in this .
Regards
ShankarHI Nilema ,
I have tried ur code also but still the same result .
METHOD onactionon_upload .
TYPES :
BEGIN OF str_itab,
name(10) TYPE c,
age(10) TYPE c,
END OF str_itab.
DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
i_data TYPE STANDARD TABLE OF string,
lo_nd_sflight TYPE REF TO if_wd_context_node,
lo_el_sflight TYPE REF TO if_wd_context_element,
l_string TYPE string,
fs_table TYPE str_itab,
l_xstring TYPE xstring,
fields TYPE string_table,
lv_field TYPE string,
lv_codepage TYPE CPCODEPAGE.
DATA : t_table TYPE if_main=>element_datatab,
data_table TYPE if_main=>element_datatab.
get single attribute
break akedia.
wd_context->get_attribute(
EXPORTING
name = `DATASOURCE`
IMPORTING
value = l_xstring ).
CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
EXPORTING
external_name = 'ISO-8859-1'
KIND = 'H'
IMPORTING
SAP_CODEPAGE = lv_codepage
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
IF sy-subrc <> 0.
lv_codepage = '1100'.
ENDIF.
CALL FUNCTION 'LXE_COMMON_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IN_CODEPAGE = lv_codepage
EX_CODEPAGE = '0000'
UNMASK_CRLF = ''
IMPORTING
EX_STRING = l_string
EXCEPTIONS
ERROR = 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.
SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
Bind With table Element.
LOOP AT i_data INTO l_string.
SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
READ TABLE fields INTO lv_field INDEX 1.
fs_table-name = lv_field.
READ TABLE fields INTO lv_field INDEX 2.
fs_table-age = lv_field.
APPEND fs_table TO t_table1.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( 'DATATAB' ).
lo_nd_sflight->bind_table( t_table1 ).
ENDMETHOD. -
Hi All,
I need to convert the XSTRING to STRING and i need a FM or method which converts all the special characters like Å, ö, ä, å, ü as it is.
Im getting the xstring value from excel sheet using file upload in WEB UI.
The class used is CL_HTMLB_FILEUPLOAD and the attribute is FILE_CONTENT which is of type XSTRING.
I have few special characters in the excel sheet which i need as string.
I have modified this FM CRM_IC_XML_XSTRING2STRING to convert the Xstrin gto string... but stilll the replacement is not working.
Can anyone suggest me...Any different solution i can use to get the file upload in string. Or get the characters from Xstring
Useful answers are much apprieciated.
Thanx in advance
Siva.Hey,
Why dont you check this method
ECATT_CONV_STRING_TO_XSTRING. Not sure whether it supports special characters or not
Regards,
Vinay -
Need a function module to convert xstring to string in web dynpro applicati
hi,
need a function module to convert xstring to string in web dynpro application other than HR_KR_XSTRING_TO_STRING.
Moderator message: please (re)search yourself first.
Edited by: Thomas Zloch on Nov 17, 2010 5:31 PMHi,
Check the following link:
FM to convert XString to String
Regards,
Bhaskar -
FM to convert XString to String
I am developing an simple application to upload an excel file and display its contents in a table in Solution manager using Web dynpro.
But 'HR_KR_XSTRING_TO_STRING' is not avaiable in DS1.
Can you help me find a replacement for this function module.
TYPES :
BEGIN OF str_itab,
name(10) TYPE c,
age(10) TYPE c,
END OF str_itab.
DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
i_data TYPE STANDARD TABLE OF string,
lo_nd_sflight TYPE REF TO if_wd_context_node,
lo_el_sflight TYPE REF TO if_wd_context_element,
l_string TYPE char200,
fs_table TYPE str_itab,
l_xstring TYPE char200,
fields TYPE string_table,
lv_field TYPE string.
DATA : t_table TYPE if_main=>elements_data_tab,
data_table TYPE if_main=>elements_data_tab.
get single attribute
wd_context->get_attribute(
EXPORTING name = `DATASOURCE`
IMPORTING value = l_xstring ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IMPORTING
out_string = l_string.
SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
Bind With table Element.
LOOP AT i_data INTO l_string.
SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields. READ TABLE fields INTO lv_field INDEX 1.
fs_table-name = lv_field. READ TABLE fields INTO lv_field INDEX 2.
fs_table-age = lv_field. APPEND fs_table TO t_table1.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
lo_nd_sflight->bind_table( t_table1 ).
Thanks in advance
AkshathaIt is not appropriate to ask general ABAP questions such as this in the Web Dynpro ABAP Forum. As your punishment I will help with your question.
In this sample buffer is the XSTRING, text_buffer is the string. You have to supply an encoding to tell the system what codepage/unicode type the XSTRING is.
data: convin type ref to cl_abap_conv_in_ce,
call method cl_abap_conv_in_ce=>create
exporting
encoding = encoding
input = buffer
receiving
conv = convin.
call method convin->read
importing
data = text_buffer. -
Strange problem in converting between XML to string and vice versa
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument();How do you get the XML document? Do you use XSU? You can use:
String str = qry.getXMLString();
to get the result XML document in String.
XSU will escape all of the < and >. Or the the XML document in
one of the column will make the result XML doc not well-formed.
Not quite understand your problem. You can send me your test
case.
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument(); -
XML document convert into String and Insert into Database
Hello all,
In the FIle to File Scenario I want to send the data to the Reciever System in xml Document and convert into String and insert into Database.
Please can you tell me exact way how to send it.
Thanks & Regards,
RajHI,
As per my understanding your scenario is File to file where you will get output fiel in XML format.
Now that XMl payload need to be passed as single string in the database via XI.
You cauld do this but you need to imply some manipulations such as
With the help of standard API you need to concatenate the XML tags and create the structre along with the data.
For e.g. in your outpuf file the XML structre contain data as
<field1>ABCD</field1>
Then in mapping
The source field will be mappeda s concat(<field1>) + value of Source field "ABCD" + concat(</field1>) to the target field.
This is the way that you could achive the requirments else there is no direct way avaialble for it.
thanks
Swarup -
Convert Double to String and Specify Precision
Hi.....
Can anyone tell me what class/method I would use if I want to convert a double to a string and need the ability to specify the precision?
Thanks,
ChristineDecimalFormat
-
I have two image file in bmp file format. How to convert them into string and to check if they are differnt or same. If different how to mention or find that where the difference exists. This idea have to be extented with video application as well.
Hi,
if you have vision, you could use the functin IMAQ Image to Array to have a 2D array of the pixel values.
You can then compare pixel by pixel; if your images come from a camera, I would recommend to set a treshold of acceptance.
This is a time consuming solution anyway.
Alternative methods:
1) Make a subtraction of the two images, the resulting image will be the difference of them
2 ) Use IMAQ LogDiff function (operators palette)
3) Calculate the histogram of both image and compare the histogram reports
Good luck,
Alberto -
How to convert XML doc to string and vice versa?
Assume I have a XML doc and I want to convert it into a string (and put it into a string variable).
How can I do this?
How can I do the opposite: Convert a string content into a XML doc?
PeterUse:
ParseEscapedXML() and ora:getContentAsString()
See
http://www.codeguru.com/cpp/sample_chapter/article.php/c10789__7/
Marc
Maybe you are looking for
-
How to put in subscript and superscript characters
Hi: Does anyone know how to insert subscript and superscript characters into Dreamweaver. I am doing a site for an engineering/manufacturing firm and I am trying to create a subscript 2 like one would see in H2O. The "2" should be small and lower tha
-
Date variable in a column formula
Hi I am having trouble using date-values from a Dashboard Prompt in a column formula in Answers. The situation: I use a dashboard prompt to select a date, the selected date stored in a presentation variable ('production_end'). In an answers request,
-
How to mount USB & CDROM drives from single user mode - Solaris boot disk?
Hi All, I need to carry out ufsrestore on a single newly replaced system disk (no redundancy / mirroring) from either USB or CDROM drives from the following steps: ( i ) GRUB => e, e, cdrom –s, Enter, b (boot from Solaris 10 x86 media). ( ii ) Choose
-
Hi, We have a requirement in Italy to have the document journal output created in XML format. As we all know, SAP does not have such option in this report. Is there anything that we could do to get the outputs in either XML or PDF formats and save th
-
Simple question...*bmp in a JPanel
How do I load a *.bmp file and draw it on the JPanel? I was going to JPanel.getGraphics() and Graphics.drawImage() which needs an Image, but there is no constructor for an image to load any kind of *.bmp or *.jpg, *.gif for that matter either. Lookin