2024 Oct 14 5:36 AM - edited 2024 Oct 15 2:03 AM
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
Request clarification before answering.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
30 | |
8 | |
7 | |
6 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.