‎2010 May 06 11:13 AM
Hi guys,
I have created a web service in abap based on a FM that creates a smartform and saves the form in pdf format on my pc.
If i execute the FM everything goes fine and the pdf is created and saved but when i call the WS through soapUI i the file is not created but everything is executed fine.
Any idea?
Thanks!!
Jon
‎2010 May 06 11:20 AM
Hi,
I'm guessing you are using cl_gui_frontend_services or GUI_DOWNLOAD to download the file? This will work in when running the FM in SAP GUI but the web service will call the FM via RFC and this will fail
‎2010 May 06 11:20 AM
Hi,
I'm guessing you are using cl_gui_frontend_services or GUI_DOWNLOAD to download the file? This will work in when running the FM in SAP GUI but the web service will call the FM via RFC and this will fail
‎2010 May 06 11:22 AM
Yes you are right, i'm using gui_download.
Do you you how can i download a file into the application server?
‎2010 May 06 12:48 PM
Jon,
You can use the OPEN DATASET command to write the file to the application server.
Check out this page for code samples: [https://wiki.sdn.sap.com/wiki/display/ABAP/Workingwithfiles|https://wiki.sdn.sap.com/wiki/display/ABAP/Workingwithfiles]
‎2010 May 06 1:54 PM
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = w_bin_filesize
TABLES
otf = t_otfdata-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
OPEN DATASET 'C:\TEST.PDF' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
* here wf_filename has to be a unique path in app server.
LOOP AT it_lines into wa_line.
TRANSFER wa_line-tdformat TO 'C:\TEST.PDF'.
TRANSFER wa_line-tdline TO 'C:\TEST.PDF'.
ENDLOOP.
so after this i have to call command open dataset ?
‎2010 May 06 2:27 PM
Jon,
As this is a PDF I would use binary mode.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = w_bin_filesize
TABLES
otf = t_otfdata-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
OPEN DATASET 'FILE' FOR OUTPUT IN BINARY MODE.
LOOP AT it_lines into wa_line.
TRANSFER wa_line-tdline TO 'C:\TEST.PDF'.
ENDLOOP.
CLOSE DATASET 'FILE'.
‎2010 May 06 2:33 PM
Gregor,
I have debugged it and it trhows an exception on transfer.
Any idea?
‎2010 May 06 2:49 PM
You can catch the exception to determine what's being thrown, but it's highly unlikely that you have access to the directory root of the application server file system. Check AL11 for a suitable location.
‎2010 May 06 3:52 PM
Ya, this sounds like a permissions issue. BASIS might be able to create a directory specifically for your process.
A trick I have used is to create a share on your PC with full permissions and then create the file on
IP_ADDRESS\MYSHARE where IP_ADDRESS is your IP and MYSHARE is the name of the share you created. You'll need to have windows file sharing enabled but can save time if you don't have file access on the app server.
Gregor