cancel
Showing results for 
Search instead for 
Did you mean: 

class proxy->save_document_to_url does not work

Dio
Explorer
298

Hi experts,

I only have 1 year of experience in ABAP. It's been 1 week I'm trying to figure out how to solved my problem, but still not found the right answer.
I created program to print Purchase Order document using BDS and not smartforms because I think it was more simple and everything runs smoothly. Until my user asks for the document to be automatically made into an email attachment in .pdf format. Here's my logic :

1. User run the program (PO.JPG for output example).
2. Button to send email 
2.1. call method save_document_to_url -> save to ftp server with .pdf format (nothing error message but the file was not created)
2.2. call method send email with .pdf attachment taken from the ftp server

My problem is point 2.1, I have no idea how to save the document with .pdf format. Can anyone help me solved my problem. I would really appreciate any help.

here's my code :

 

 

 

 

 

 

FORM f_insert_contents .

  DATA: lt_forms       TYPE soi_form_list,
        error          TYPE REF TO i_oi_error,
        lv_tgl         TYPE c LENGTH 15.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      text = 'Loading data, please wait...'.

  CALL METHOD o_oi->form_unprotect.
  CALL METHOD o_oi->form_get_data
    CHANGING
      data = lt_forms[].

  IF NOT lt_forms[] IS INITIAL.

    LOOP AT lt_forms INTO DATA(wa_form).

      CASE wa_form-name.
        WHEN '[VENDOR]'.
          DATA(lv_name) = |{ t_header-name1  } { t_header-name2 }|.
          wa_form-value = lv_name.
        WHEN '[ALAMAT_VENDOR]'.
          wa_form-value = t_header-alamat.
        WHEN '[ALAMAT2]'.
          wa_form-value = t_header-str_suppl1.
        WHEN '[ALAMAT3]'.
          wa_form-value = t_header-str_suppl2.
        WHEN '[ALAMAT4]'.
          wa_form-value = t_header-mc_city1.
        WHEN '[ALAMAT5]'.
          wa_form-value = t_header-bezei.
        WHEN '[PO_NUMBER]'.
          wa_form-value = t_header-ebeln.
        WHEN '[REV]'.
          wa_form-value = t_header-revno.
        WHEN '[DATE]'.
          lv_tgl = |{ t_header-aedat+6(2) }.{ t_header-aedat+4(2) }.{ t_header-aedat(4) }|.
          wa_form-value = lv_tgl.
        WHEN '[PO_DESC]'.
          wa_form-value = t_header-podesc.
        WHEN '[ATTN]'.
          wa_form-value = t_header-verkf.
        WHEN '[FAX]'.
          wa_form-value = t_header-telfx.
        WHEN '[EMAIL]'.
          wa_form-value = t_header-smtp_addr.
        WHEN '[TOP]'.
          wa_form-value = lv_top.
        WHEN '[UOM]'.
          wa_form-value = t_header-waers.
        WHEN '[SUB_TOTAL]'.
          WRITE t_header-subtotal DECIMALS 2 TO lv_subtotal CURRENCY t_header-waers. "Rev 3
          wa_form-value = lv_subtotal.
        WHEN '[PPN]'.
*          IF lt_mwskz EQ 'V1'.
          IF lt_mwskz2[] IS NOT INITIAL.
            wa_form-value = |PPN|. "Rev 4
          ELSE.
            wa_form-value = ' '.
          ENDIF.
        WHEN '[TOTAL_PPN]'.
*          IF lt_mwskz EQ 'V1'.
          IF lt_mwskz2[] IS NOT INITIAL.
            t_header-total_ppn = t_header-total_ppn / 10.
            WRITE t_header-total_ppn DECIMALS 2 TO lv_ppn CURRENCY t_header-waers. "Rev 3
            wa_form-value = lv_ppn.
          ELSE.
            wa_form-value = ' '.
          ENDIF.
        WHEN '[TOTAL]'.
          t_header-total = ( t_header-total_ppn * 10 ) + t_header-subtotal.
          WRITE t_header-total DECIMALS 2 TO lv_total CURRENCY t_header-waers. "Rev 3
          wa_form-value = lv_total.
        WHEN '[KETERANGAN]'.
          wa_form-value = t_header-keterangan.
        WHEN '[REMARKS]'.
          wa_form-value = t_header-remarks.
      ENDCASE.

      MODIFY lt_forms FROM wa_form.
    ENDLOOP.

    CALL METHOD o_oi->form_set_data
      EXPORTING
        data = lt_forms[].
**
**    CALL METHOD o_oi->export_document
**      EXPORTING
**        file_name   = 'C:\Users\XXXXXXXXX\Downloads\PDFPO.pdf'
**        prompt_user = abap_true.

  ENDIF.

  CALL METHOD o_oi->word_insert_table
    EXPORTING
      data_table      = t_result[]
      doctable_number = 1.

  DATA: numbytes TYPE i,
        url      TYPE bapiuri-uri.

*  user_info-user = 'sap.XXX'.
*  user_info-password = 'XXXXX'.
  user_info-proxy = '10.xx.xx.xx:21'.
  user_info-proxyuser = 'sap.XXX'.
  user_info-proxypassword = 'XXXXXX'.
*  user_info-scrambled = 'X'.

  url = 'ftp://10.xx.xx.xx/t.pdf'.

  CALL METHOD o_oi->save_document_to_url
    EXPORTING
      url           = url
      user_info     = user_info
    CHANGING
      document_size = numbytes.

ENDFORM.

 

 

 

 

 

Please correct me if I made a mistake.

Regards,
Dio
 

Sandra_Rossi
Active Contributor
0 Kudos

Alas, it's not a question about SAP Websites...

Do you know that you can display the image instead of an hyperlink?

Sandra_Rossi_0-1728884108423.png

 

Sandra_Rossi
Active Contributor
0 Kudos

So, you're talking about I_OI_FORM (the Form Interface), but I don't recognize the methods form_unprotect, form_get_data, form_set_data, export_document, word_insert_table.

What are these methods?

Accepted Solutions (0)

Answers (2)

Answers (2)

Sandra_Rossi
Active Contributor
0 Kudos

Word permits the export to PDF by either file > print > PDF printer (but make sure that all users have a PDF printer) or via file > export > create PDF/XPS document (all users should have Word 365).

You may run these commands via direct OLE commands (https://community.sap.com/t5/application-development-discussions/how-to-use-doi-retain-excel-formula...).

No doubt that Word is more easy to develop than Smart Forms, but for the users it comes with many very big flaws (slow, doesn't work at all for users with the wrong Word configuration, nor in background).

Dio
Explorer
0 Kudos
yes but is it all done manually? Is there no way to save the output in .pdf format to a local or FTP server automatically? like using GUI_DOWNLOAD or FTP_R3_TO_SERVER ?
Sandra_Rossi
Active Contributor
0 Kudos
What is the issue of downloading the PDF via CALL METHOD ... OF ... (OLE)?
Sandra_Rossi
Active Contributor
0 Kudos
Note that you may also run these commands via VBS stored via I_OI_SCRIPT_COLLECTION (not much different from direct OLE).
Dio
Explorer
0 Kudos
I'm using method o_oi->save_document_to_url as you can see in my program. It's not error but the file not created in my FTP Server
Sandra_Rossi
Active Contributor
0 Kudos
Create the file in the SAP GUI temporary folder of the user (CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY) and then upload it.
Dio
Explorer
0 Kudos

Hi Sandra,

Sorry for the wrong question and thank you for your response, basically I using class I_OI_FORM you can check in SE24.
cl_office_integration.JPG
inside the cl_office_integration is :
Capture.JPG

1. form_protect means you can't edit the document when it show up and 
2. form_unprotect is the opposite.
3. form_get_data means get data from the application.
4. form_set_data means you put the data to the template that you upload in OAOR.
5. word_insert_table means put the data into table in template (word document).
6. export_document = I_OI_DOCUMENT_PROXY->save_as ( you do it manually because a pop up appears and you have to determine the name and save it in what folder, my need is to save it automatically in .pdf format without the pop up appearing )

For me, it's quite simple than smartforms.

Sandra_Rossi
Active Contributor
0 Kudos
Thank you. Be careful to not use Answer if it's not a solution. Instead, use Replies > Comment.