‎2012 Feb 15 2:06 PM
Hi,
I have a problem. I would like to import a document and save the content on the server (AL11) in the PDF format.
First I convert the content into a xstring and then I put the content into a binary table. After that I write the binary table to the server.
To test the functionality I have the opportunity to save the data manually onthe desktop from the AL11. If I do that I get not a PDF, but always the type of original document.
Can anybody help me?
Regards,
Nik
CODE:
#############################################################
DATA: lr_cmdocument TYPE REF TO if_bol_bo_property_access,
lr_mixed_mode TYPE REF TO cl_bsp_wd_mixed_node,
lr_marked_item TYPE REF TO cl_crm_bol_entity,
lv_xpath TYPE crmt_ic_ac_identify_path,
ls_doc_attr TYPE zssc_epa_doc_att_struc,
lv_filename TYPE string,
lv_filesize TYPE n,
lv_content_type TYPE char128,
lv_xstring TYPE xstring,
l_tab_file TYPE tsfixml,
l_length_file TYPE i,
u2026
lr_cmdocument ?= er_cmdocument.
CHECK lr_cmdocument IS BOUND.
lr_mixed_mode ?= lr_cmdocument.
lr_marked_item ?= lr_mixed_mode-> if_bsp_wd_ext_property_access~get_model_node( ).
...
CALL METHOD cl_crm_ic_content_management=>get_doc_content
EXPORTING
iv_doc = lr_marked_item
RECEIVING
rv_result = lv_xstring.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
IMPORTING
output_length = l_length_file
TABLES
binary_tab = l_tab_file.
IF lv_filename is not INITIAL.
concatenate '/tmp/' lv_filename into lv_filename.
ENDIF.
pfad_sap = lv_filename.
OPEN DATASET pfad_sap FOR OUTPUT in BINARY MODE.
LOOP AT l_tab_file INTO wa_tab.
TRANSFER wa_tab TO pfad_sap.
ENDLOOP.
CLOSE DATASET pfad_sap.
CLEAR pfad_sap. CLEAR wa_tab.
‎2012 Feb 15 8:18 PM
Hi Nik,
Adobe forms or PDF files are always stored in XSTRING format. So converting that to binary you will get binary file only, better get the data from APP Server then convert it to XSTRING. And store it at appserver. But anyways you can not see the file data in PDF format via this option also, you need to have a different program which checkes those data and gives you output in XSTRING.
Application server folders are not like spool so it will not give output in PDF.
Best Regards,
Tapodipta Khan.
‎2012 Feb 15 8:35 PM
Hello Nik,
Not sure what you are trying to do here and the purpose behind it.
Do you want to upload the file in PDF format in AL11 and want to view it ins PDF format in AL11? If this is the requirement then you can't view a file in PDF format in AL11. Try using SAP standard transaction CG3Z (for upload to application server) and you will see that the PDF can be uploaded in application server but it will not be visible in that format in AL11. Over there it is in binary format.
If however your idea is to upload the content of the PDF to application server and then be able to download it at a later stage - for viewing, email or whatever purpose - then what you can do is to use FM CONVERT_OTF to convert the content to OTF and then save it AL11.
Whenever you want it view or read it then you can read it from AL11 and then use FM CONVERT_OTF_2_PDF to convert to PDF.
Let me know if you took this approach and it worked for you.
Good Luck,
Neeraj
‎2012 Feb 15 9:59 PM
Hello,
thanks for your quick response.
What I try to do: I want to save a file (e.g. an image, an PDF or an text file, etc) in the AL11 in PDF format. A job should be save (maybe once a day) the files in an file archive in PDF format.
My problem is that I not have only files in PDF. The input files can be any type of document. So far I have not found a method which can get the file content and converts the content into OTF.
Do you have any idea?
Many regards,
Nik
‎2012 Feb 16 9:39 AM
Hi Nik,
Use GUI_upload to upload the document into sap in binary format and then use the CREATE_DOCUMENT of class CL_DOCUMENT_BCS to create the document of any format.
Hope this is helpful.
Regards,
Aravind
‎2015 Sep 03 1:31 PM
after generating the xstring you should follow these steps:
*2. convert xstring to binary : pass the XSTRING received from UI Upload element
*call function 'SCMS_XSTRING_TO_BINARY'
*exporting
*buffer = l_xstring " this is the XSTRING of the file u want to upload
*importing
*output_length = filele
*tables
*binary_tab = lt_solix_tab.
*
** 3. write the file
*if not lt_solix_tab is initial.
*open dataset lv_filename for output in binary mode.
*loop at lt_solix_tab into ls_solix.
*transfer ls_solix to lv_filename.
*endloop.
*close dataset lv_filename.
*endif.