Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Web service

Former Member
0 Likes
1,118

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,086

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

8 REPLIES 8
Read only

Former Member
0 Likes
1,087

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

Read only

0 Likes
1,086

Yes you are right, i'm using gui_download.

Do you you how can i download a file into the application server?

Read only

0 Likes
1,086

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]

Read only

0 Likes
1,086

 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 ?

Read only

0 Likes
1,086

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'.

Read only

0 Likes
1,086

Gregor,

I have debugged it and it trhows an exception on transfer.

Any idea?

Read only

0 Likes
1,086

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.

Read only

0 Likes
1,086

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