Converting cstring to xstring
What is cstring & Xstring ?
how to do the conversion ?
data: w_char type string, " Character String .Dynamic Length
w_hex type Xstring , " Hexadecimal String.DYnamic Length
w_int type i.
w_hex = 'ABC021343'.
w_char = w_hex. " Conversion From Hex to Char
w_int = w_hex. " Conversion From Hex to INT
write :/ w_int.
write : w_char.
[Check Conversion Rules|http://help.sap.com/saphelp_webas620/helpdata/en/fc/eb3434358411d1829f0000e829fbfe/content.htm]
Regards,
Gurpreet
Similar Messages
-
Convert PDF to XSTRING and dysplay in portal(html)
Hi experts :
I need your help once again. I've read all the post regarding this issue but can't find a solution for my problem.
Basically, I have to create a PDF from a spool, convert it to xstring and send it to the web via RFC.
What I do is :
Convert the spool to PDF using FM CONVERT_OTFSPOOLJOB_2_PDF.
Convert the PDF tline table into XSTRING using a field symbol and a table of tlines (as described in one of the SDN blogs).
Then, I send to the web the value reurned from the conversion of the PDF line to XSTRING.
But, when opening the xstring there is nor PDF file but and error. If I download the PDF tline table, it works and can create the PDF, but nothing from the XSTRING.
My questions are :
Do we have to do any conversion on the portal side to convert the XSTRING into PDF?
is there any possibility of downloading the xstring to my desktop in order to check if I could create the PDF file from it?.
Helpful answer will be rewarded.
Regards,
Carlos.For the last question, use this code:
FORM write_bin_file
USING
i_filename TYPE string
i_file_xstring TYPE xstring.
TYPES xx(50) TYPE x.
DATA lt_xstring TYPE TABLE OF xx.
DATA l_length TYPE i.
CALL METHOD cl_swf_utl_convert_xstring=>xstring_to_table
EXPORTING
i_stream = i_file_xstring
IMPORTING
e_table = lt_xstring
EXCEPTIONS
OTHERS = 3.
l_length = XSTRLEN( i_file_xstring ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_length
filename = i_filename
filetype = 'BIN'
CHANGING
data_tab = lt_xstring
EXCEPTIONS
OTHERS = 3.
ENDFORM. "write_bin_file -
How to convert if_ixml_istream to xstring?
hi guys,
would anyone give me some ideas about converting if_ixml_istream to xstring?
can I use the method like:
CREATE OBJECT l_xml.
rc = l_xml->CREATE_WITH_DATA( dataobject = istream ).
l_xml->render_2_xstring( EXPORTING pretty_print = 'X' IMPORTING stream = xstring size = size retcode = retcode ).
Thanks a lot
Regards,
Liying
Message was edited by:
Liying Wang/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
check this out i think this might help -
Converting PDF to XSTRING for Adobe in WD ABAP Application
I have a requirement to develop a WD abap application in the portal, where 300 PDF's would exist on our LAN all with the pernr number embedded in the name. When a user logs onto the portal, it would retrieve the correct PDF for their pernr and display in an adobe form. In the application, I know how I can use the username, to derive the pernr to get the PDF name.
Right now I can use the upload functionality to upload(with an upload UI element) a particular file and put in a PDF with adobe, However, If I want to point to a particular file (based on the pernr name) on a secure folder on our LAN, can I do that?
If I plug in a file name instead of using the upload UI element, I need to figure out how to convert the PDF to an XSTRING so that I can pass that xstring to the adobe form interface.
Also, is there even a way to assign a file name on a LAN to an upload element in a WD ABAP application or is it necessary to use the dropdown to retrieve the file name from the users desktop in order for it to convert ot a PDF correctly?
Thanks,
Pam Lavertyhi pam,
I think it's not possible to select the file automatically. use action must be there.
So use upload ui element, once you click on upload button and select the file, that file data will be in DATASOURCE ATTRIBUTE ( the attribute which is binded to data property of upload ui element ) OF UPLOAD UI element in XSTRING format.
From there you can pass it to pdf.
Regards
srinivas -
FM for converting PDF to XSTRING - display R/3 report in Portal as PDF
Hello SDNers,
Requirement:
I am trying to display an R/3 report in Portal as PDF. I am trying to do it with the following logic:
1. Call a RFC enabled FM from my Webdynpro Java appln.
2. The FM then submits the Print request for the R/3 report and then gets the spool.
3. Convert the ABAP spool to PDF (using FM CONVERT_ABAPSPOOLJOB_2_PDF).
4. Convert the PDF to XSTRING and send it back to the calling Webdynpro appln.
5. Using the XSTRING regenerate the PDF using some Webdynpro Java APIs.
The Problem / Question:
The output of the FM CONVERT_ABAPSPOOLJOB_2_PDF is a table of type "TLINE" which includes TDFORMAT and TDLINE.
To get the XSTRING I am using the FM "'SCMS_STRING_TO_XSTRING". This FM only uses the "TDLINE" and completely ignores the "TDFORMAT". When I import this XSTRING value into my Webdynpro for Java appln., and assign to the corresponding UI element, my PDF does not show up.
My FM code is like this:
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spono
no_dialog = 'X'
TABLES
pdf = t_pdf
IF sy-subrc 0.
ENDIF.
IF sy-subrc EQ 0.
LOOP AT t_pdf INTO w_pdf.
CONCATENATE
output
w_pdf-tdformat
w_pdf-tdline
INTO output.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output
IMPORTING
buffer = outputx.
I doubt if "'SCMS_STRING_TO_XSTRING'" is the right FM to use in my scenario.
If we had a smartform, we could have used the FM "CONVERT_OTF" , but in our case we do not have a smart form and I am not able to figure out which FM should be used.
Please suggest if I am doing any thing wrong.
Thanks for Reading.
Regards,
Raj KumarHi
check this thread
spool to pdf conversion
It looks like you are missing translate in you processing of the table t_pdf. Something like the following line is missing:
TRANSLATE gd_buffer USING '~ '.
Loo at the standard program RSTXPDFT4 as well. It converts spool to PDF and then you can download it to your desktop. -
Hi expert,
I want test some Function Module, and for do this i need to convert a generic file (pdf doc txt) into XSTRING... And after convert XSTRING into file, with use mimetype to read this...
I search into FM, and in SDN but i don't find anything, can someone help me to do this??
Thank you all...Hi,
Check if FM SCMS_FTEXT_TO_XSTRING can be of help.
Regards, Bert -
hallow
i have internal table (person_tab) and i wont convert it to
<b>xtring</b>
how can i do that?
best regards.
TYPES : BEGIN OF 1_itab,
werks TYPE persa,
persg TYPE persg,
persk TYPE persk,
orgeh TYPE orgeh,
stell TYPE stell,
lastname TYPE pad_nachn,
firstname TYPE pad_vorna,
stdaz TYPE enstd,
btrtl TYPE btrtl,
name1 TYPE pbtxt,
btext TYPE btrtx,
perid TYPE prdni,
END OF 1_itab.
DATA : person_tab TYPE TABLE OF 1_itab,
wa_person_tab LIKE LINE OF person_tab
<b>
i now this function but how i move person_tab to this function?</b>
<b>plz give example</b>
call function 'SOTR_SERV_TABLE_TO_STRING'
exporting
line_length = gl_linewidth
langu = p_langu
importing
text = l_text
tables
text_tab = l_text_tab.
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = l_text
importing
buffer = l_xstring_data
exceptions
failed = 1
others = 2Hello,
Please try this combination FM.
SOTR_SERV_TABLE_TO_STRING
SCMS_STRING_TO_XSTRING or SCMS_FTEXT_TO_XSTRING
Please try this.
data: l_text type string.
types: begin of text_table,
line type sotr_txt,
end of text_table.
data: l_text_tab type table of text_table.
data: l_xstring_data type string.
call function 'SOTR_SERV_TABLE_TO_STRING'
exporting
line_length = gl_linewidth
langu = p_langu
importing
text = l_text
tables
text_tab = l_text_tab.
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = l_text
importing
buffer = l_xstring_data
exceptions
failed = 1
others = 2
Regards,
Deepu.K -
Hi everyone,
I have a non-character like structure and i wanna print it by passing the vallues of it into an xstring. So can anyone tell me is there anyone class which can be helpful in this process. If anyone has used it please try sending me the code snippet.
please revert.
thanks n regards,
Bhargava.non-character like structure? i didnt get that .
anyhow to convert string to Xstring you can use the following FM
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output " variable type string
IMPORTING
buffer = outputx. " variable type xstring
Regards
Raja -
Hi Expert,
i found the employee photo from OOAD tcode in
UUID (in charter form ) is 4D1D826798AB3BDDE1000000AC10066F.
Now how can i convert this into Xstring (Hexadecimal) format for printing
emp photo on Adobe Form.
How this can be acheived?
Thanks...Hi,
Use FM SCMS_TEXT_TO_XSTRING to convert to Xstring.
Regards,
Srini. -
How to convert a STRING data to a XSTRING data?
Hi Expert,
In SAP, we need use a XSTING to convert a PDF document, but 3rd system send a STRING data to SAP. So I need to convert STRING to XSTRING, How to do it? Thanks in advance!
RegardsHi,
<li>Use the fm SCMS_STRING_TO_XSTRING.
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = text "type STRING
importing
buffer = content. "type XSTRING
Thanks
Venkat.O -
Xstring to string for ms_excel
Hi ALL,
I am using OFFICE CONTROL UI ELEMENT for displaying iternal table data into EXCEL OFFICE CONTROL UI .
i am displaying data into OFFICE CONTROL UI EXCEL, then i will update excel of office control and then i will save,when i save that updated data need to send one internal table .
DATA :OUT_STRING1 TYPE STRING,
CONTENTXMLSOURCE TYPE XSTRING.
WD_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = 'DATAS' IMPORTING VALUE = CONTENTXMLSOURCE ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
FROM_CODEPAGE = '8500'
IN_XSTRING = CONTENTXMLSOURCE
OUT_LEN =
IMPORTING
OUT_STRING = OUT_STRING1.
data lr_conv type ref to cl_abap_conv_in_ce.
lr_conv = cl_abap_conv_in_ce=>create( ).
lr_conv->convert( exporting input = xstring importing data = string ).
NOT FOR LIKE Excel file (like Tab Delimited, CVS, XML, etc). Only for ms_excel.
the above mention two concepts are not working to convert from xstring to string ,is there any concept ms_excel format xstring to string?
THANKS,
RAMA
Edited by: Ramakullay Challa on Sep 25, 2009 2:03 PM
Edited by: Ramakullay Challa on Sep 25, 2009 2:06 PMHi Lekha,
When i am activating one method , insede this method i am calling one c lass.
data: DATASOURCE type ref to CL_WD_OFFICE_CONTROL,
content type xstring.
TRY.
DATASOURCE = cl_wd_office_control=>GET_DATA_SOURCE( VALUE = CONTENT ).
CATCH CX_WD_ACF_EXCEPTION.
ENDTRY.
error .any idea lekha.
*you can use only use "class=>method" with static methos.*
data: DATASOURCE type ref to CL_WD_OFFICE_CONTROL,
content type xstring.
CONTENT = DATASOURCE->GET_DATA_SOURCE( ).
no error.
thanks.
thanks,
rama
Edited by: Ramakullay Challa on Sep 28, 2009 7:08 AM
Edited by: Ramakullay Challa on Sep 28, 2009 7:09 AM
Edited by: Ramakullay Challa on Sep 28, 2009 11:26 AM -
In smartform word document convert into pdf file
Hi Experts,
I have issue on smartform, i have done two page smartform in preview its coming properly but
when i give to print its not coming properly...output is not coming properly...so please sugest me
even how to covert smartform word document into PDF file...im waiting for your replay. Thanks in
Advance....
Regards
AshwiniHi,
I hope its printer problem check with u r basis, and for Smartform to PDF bewlow is my coding in which by using OTF data from Smartform it ill veiw in PDF.
*& Report ZSAP_PDF_VIEWER_DEMO_2
REPORT ZSAP_PDF_VIEWER.
DATA: LT_PDF TYPE TABLE OF TLINE,
LS_PDF LIKE LINE OF LT_PDF,
LV_URL TYPE CHAR255,
PDF_FSIZE TYPE I,
LV_CONTENT TYPE XSTRING,
LT_DATA TYPE STANDARD TABLE OF X255.
DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL.
DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP.
DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER.
DATA: LO_DIALOG_CONTAINER TYPE REF TO CL_GUI_DIALOGBOX_CONTAINER.
DATA: LO_DOCKING_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.
DATA : P_VBELN TYPE VBELN_VL.
FIELD-SYMBOLS <FS_X> TYPE X.
INITIALIZATION.
LS_CONTROL_PARAM-GETOTF = 'X'.
LS_CONTROL_PARAM-NO_DIALOG = 'X'.
START-OF-SELECTION.
CALL FUNCTION '/1BCDWB/SF00000034'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = LS_CONTROL_PARAM
P_VBELN = P_VBELN
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO = L_DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = L_JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = L_JOB_ OUTPUT_OPTIONS
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = PDF_FSIZE
TABLES
OTF = L_JOB_OUTPUT_INFO-OTFDATA
LINES = LT_PDF
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
convert pdf to xstring string
LOOP AT LT_PDF INTO LS_PDF.
ASSIGN LS_PDF TO <FS_X> CASTING.
CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE.
ENDLOOP.
CALL SCREEN 100.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
**CREATE OBJECT LO_DOCKING_CONTAINER
EXPORTING
REPID = SY-REPID
DYNNR = '100'"SY-DYNNR
SIDE = LO_DOCKING_CONTAINER->DOCK_AT_LEFT
EXTENSION = 1200.
CREATE OBJECT g_html_container
EXPORTING
container_name = 'HTML'.
*CREATE OBJECT G_HTML_CONTROL
EXPORTING
PARENT = LO_DOCKING_CONTAINER.
CREATE OBJECT G_HTML_CONTAINER
EXPORTING
CONTAINER_NAME = 'HTML'.
CREATE OBJECT G_HTML_CONTROL
EXPORTING
PARENT = G_HTML_CONTAINER.
Convert xstring to binary table to pass to the LOAD_DATA method
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = LV_CONTENT
TABLES
BINARY_TAB = LT_DATA.
*application/
Load the HTML
CALL METHOD G_HTML_CONTROL->LOAD_DATA(
EXPORTING
TYPE = 'application'
SUBTYPE = 'pdf' "
IMPORTING
ASSIGNED_URL = LV_URL
CHANGING
DATA_TABLE = LT_DATA
EXCEPTIONS
DP_INVALID_PARAMETER = 1
DP_ERROR_GENERAL = 2
CNTL_ERROR = 3
OTHERS = 4 ).
CALL METHOD G_HTML_CONTROL->show_url
EXPORTING url = lv_url
in_place = 'X'
EXCEPTIONS cntl_error = 1.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
DATA ok_code LIKE sy-ucomm.
MOVE sy-ucomm TO ok_code.
CASE ok_code.
WHEN 'BACK' OR 'EXIT'.
CALL METHOD LO_DOCKING_CONTAINER->free.
CALL METHOD g_html_control->free.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USE -
Can I call a dll with a C++ Class Cstring variable?
So,
we bought an optiphase interferometer, and it comes with a dll and with LabVIEW example code.
However, there is a big problem!
The dll is a C++ dll and requires the C++ Cstring class!
for example I can't get the function Boolean LoadDemodulatorDSPCore(Cstring arg1, U8Bit arg2) to work.
They did provide a GetDllVersionchar(Cstr arg1, long arg2) which does work, (offcourse, it uses a standard C string pointer)
but GetDllVersion(Cstring arg1) does not work. (offcourse not, it using the Cstring class)
Is there a way to get CString classes to work in LabVIEW? (with a struct, or an binary array or whatever?)
Or do I have to write a wrapper dll to convert CString classes to standard C string pointers?
Thanks.Nils Gokemeijer wrote:
So,
we bought an optiphase interferometer, and it comes with a dll and with LabVIEW example code.
However, there is a big problem!
The dll is a C++ dll and requires the C++ Cstring class!
for example I can't get the function Boolean LoadDemodulatorDSPCore(Cstring arg1, U8Bit arg2) to work.
They did provide a GetDllVersionchar(Cstr arg1, long arg2) which does work, (offcourse, it uses a standard C string pointer)
but GetDllVersion(Cstring arg1) does not work. (offcourse not, it using the Cstring class)
Is there a way to get CString classes to work in LabVIEW? (with a struct, or an binary array or whatever?)
Or do I have to write a wrapper dll to convert CString classes to standard C string pointers?
Thanks.
I'm afraid this won't really be
possible without a wrapper DLL. A CString is more like an object with
internal pointers and last time I checked into a DLL with a
disassembler it seemed that the actual layout of the internal structure
depends on the size of the string that is contained, with small strings
being entirely embedded and larger strings being a pointer to the
string. Trying to figure out these difficulties is something you should
leave to compiler developers and not try to do yourself.
One way that might be possible is to actually only create three or four
C functions that are exported by a helper DLL. These functions would
allocate a CString, copy a CStr into it and out of it and one to
deallocate it. As far as LabVIEW is concerned you would treat the
CString simply as a uInt32.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How to download a file from a server path?
Is it possible to attach files on the server to a web dynpro response with cl_wd_runtime_services=>attach_file_to_response? All the examples I have seen assume you have the file content as an XSTRING. But how can one just send a file from a known path?
Is it really necessary to first load the file (e.g. a 50Mb TIFF) as an XSTRING before downloading it? If so, how is this done?Hi Marc,
Try using this FM to convert String to Xstring.
SCMS_STRING_TO_XSTRING
HR_KR_STRING_TO_XSTRING
and also check this...Error document.getElementById(...) in function 'SCMS_STRING_TO_XSTRING'
Might Helps you.
Cheers,
Kris. -
How to attach an internal table as excel file in wf container.
Hi all, I have a task that is attaching an xml file in wf container, but I need to attach as excel file, how can I convert this xml to excel ?
my currento code is like this:
* Call Transformation to generate XSTRING of the generated data *
TRY .
CALL TRANSFORMATION ztr_wf_excel
SOURCE appl_stat = li_data2
RESULT XML pi_attach.
CATCH cx_st_error INTO lo_exception.
lv_text = lo_exception->get_text( ).
ENDTRY.
IF lv_text IS INITIAL.
pi_header-file_type = 'B'.
pi_header-file_name = 'Data'.
pi_header-file_extension = 'XLS'.
pi_header-language = 'E'.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = lw_worklist-wi_id
att_header = pi_header
att_bin = pi_attach
do_commit = 'X'
IMPORTING
att_id = lw_att_id.
this code is working fine, but I need to attach an excel file instead an xml file
How can I do that?
Regardshi ,
Follow this approach :
You can use following funcntions. First one to create internal table to string and second FM SCMS_STRING_TO_XSTRING to convert String to XSTRING. Then this XSTRING value you can pass to CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE.
data: tab_str type string.
data: begin of it_tab1,
name(20),
age(10) ,
end of it_tab1.
data : lv_name type xstring.
data it_tab like STANDARD TABLE OF it_tab1.
data: wa like line of it_tab.
wa-name = 'naresh'.
wa-age = '30'.
append wa to it_tab.
wa-name = 'naresh1'.
wa-age = '31'.
append wa to it_tab.
CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'
IMPORTING
TEXT = tab_str
TABLES
TEXT_TAB = it_tab
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = tab_str
IMPORTING
BUFFER = lv_name
CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
EXPORTING
I_FILENAME = 'c:\test.txt'
I_CONTENT = lv_name
I_MIME_TYPE = 'TXT'
Refer below links. This has been discussed many times :
Re: download a file
Maybe you are looking for
-
How to delete the Hierarchy data from Infoobjects.
How to delete the Hierarchy data from Infoobjects. In my case I had 300 records in the corresponding table of info object. When i was trying to delete the hierarchy data, I am getting error message. "Some master data not deleted". Can any one tell me
-
I've got a new ipod and i'm trying to get all my songs on it that I have in i-tunes from my old ipod, and when I look at it through i-tunes it shows that all the songs are on my new ipod but when I disconnect it - the ipod has no songs on it. What am
-
Problem: unable to view recordset in browser.
I have an ASP page and when testing the recordset, a record is returned. (except for one record within the row which is a text value/format). But when viewing in the browser only table headings are shown and no records are displayed. process; user lo
-
Strange MagSafe Issue-How can I fix this?
I have a MacBook Pro and out of nowhere started experiencing trouble charging my computer. Here is what is happening. -Charger turns green but never Amber (and won't charge) -I used my moms charger on my computer, and it works. She has an older MacBo
-
Inactive Memory leak in Safari 4.0.3
There is a memory leak in Safari 4.0.3. I haven't isolated it to a particular page since I usually have 15-20 tabs open when I notice the spinning ball, caused by VM paging. When this happens, according to Activity Monitor, Safari.app uses between 50