cancel
Showing results for 
Search instead for 
Did you mean: 

Adobe Form with fragment - how to call it in an ABAP program? Options please?

mmcisme1
Active Contributor
5,985

The requirement is to attach an Adobe form to an e-mail. I don't have any problems with the e-mail attachment part of this. However, I have never tried to write an ABAP program with an Adobe fragment. So after looking for the answer using different searches, and not finding one I figure I'd post here.

The Adobe form needs to stay a fragment type because I am using it with FIORI. (My first thought had been to simply create an interface for it.) The form fragment is "defined" in SEGW. If I get desperate, I can call the service to get my XML filled. Then I can call the Adobe form using a call FM, and sending the XML. That is the last option that I'm thinking about.

I can call a BAPI FM to pull the purchase contract data, and then use transform to get my XML. Then call the Adobe form with the FM sending the XML, I created. I didn't want to worry about two different outputs. I want to be able to compare the same code.

I can even call the methods used in the gateway definition to fill the XML data. That just seems like a lot of work, but I may have to do this.

I looked at having an XML output in OPD. Only to realize that I really didn't know how to trigger the execution of the OPD. Maybe I'll take a look at the BRF+.

Any other suggestions? Is there a better/easier way of doing this? I'm on 1709 on-premise system with 7.52 Netweaver. Anything that I shouldn't do that I listed above?

In case you are wondering - My ultimate goal here is to create an E-mail with the Adobe form filled and sent. The form is not an interactive form. I don't have any issue with sending the string that I get back as an attachment.

Any help you give would be appreciated!

View Entire Topic

Hello Michelle,

you can use method get_instance of class cl_somu_form_services to generate the PDF as an xstring. The following report generates a PDF for the given purchase order using the fragment based form MM_PUR_PURCHASE_ORDER and displays it in a popup window.

Best regards,
Sascha

*&---------------------------------------------------------------------*
*& Report Z_DISPLAY_PO_FORM_PREVIEW
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_display_po_form_preview.



SELECTION-SCREEN BEGIN OF BLOCK b1.
  PARAMETERS: p_po_num TYPE ebeln MATCHCODE OBJECT h_ekko OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.



INITIALIZATION.



START-OF-SELECTION.
  DATA: lo_cl_somu_form_services TYPE REF TO cl_somu_form_services.
  DATA: lt_keys TYPE cl_somu_form_services=>ty_gt_key.
  DATA: ls_ekko TYPE ekko.
  DATA: lt_master_keys TYPE cl_somu_form_services=>ty_gt_key.
  DATA: lv_content TYPE  xstring.
  DATA: lv_xml TYPE xstring.
  DATA: lv_pages TYPE  fppagecount.
  DATA: lv_trace_string  TYPE string.
  DATA: lv_stop_processing TYPE  abap_bool.
  DATA: lt_message TYPE cl_somu_form_services=>ty_gt_message.
  DATA: lv_output_length TYPE i.
  DATA: lt_generated_pdf  TYPE STANDARD TABLE OF tbl1024.

  FIELD-SYMBOLS: <ls_key> TYPE cl_somu_form_services=>ty_gs_key.



  SELECT SINGLE *
    FROM ekko
    INTO ls_ekko
    WHERE ebeln = p_po_num.


  " --------------------------- Values for the purchase order form ---------------------------
  APPEND INITIAL LINE TO lt_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'PurchaseOrder'.
  <ls_key>-value = p_po_num.

  APPEND INITIAL LINE TO lt_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'SenderCountry'.
  <ls_key>-value = 'DE'.

  APPEND INITIAL LINE TO lt_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'PurchaseOrderChangeFlag'.
  <ls_key>-value = space.

  APPEND INITIAL LINE TO lt_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'Language'.
  <ls_key>-value = 'E'.


  " --------------------------- Values for the master form template ---------------------------
  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'PrintFormDerivationRule'.
  <ls_key>-value = 'PURCHASE_ORDER_MASTER_FOR_COMPANY'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'WatermarkText'.
  <ls_key>-value = space.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'LocaleCountry'.
  <ls_key>-value = 'DE'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'LocaleLanguage'.
  <ls_key>-value = 'E'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'OutputControlApplicationObjectType'.
  <ls_key>-value = 'PURCHASE_ORDER'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'OutputControlApplicationObject'.
  <ls_key>-value = p_po_num.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'OutputRequestItem'.
  <ls_key>-value = '000001'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'OutputDocumentType'.
  <ls_key>-value = 'PURCHASE_ORDER'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'Recipient'.
  <ls_key>-value = ls_ekko-lifnr.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'RecipientRole'.
  <ls_key>-value = 'LF'.

  APPEND INITIAL LINE TO lt_master_keys ASSIGNING <ls_key>.
  <ls_key>-name = 'SenderCountry'.
  <ls_key>-value = 'DE'.


  lo_cl_somu_form_services = cl_somu_form_services=>get_instance( ).


  lo_cl_somu_form_services->get_document( EXPORTING iv_master_form_name  = 'SOMU_FORM_MASTER_A4'
                                                    iv_form_name         = 'MM_PUR_PURCHASE_ORDER'
                                                    it_key               = lt_keys
                                                    it_master_key        = lt_master_keys
                                                    iv_form_language     = 'E'
                                                    iv_form_country      = 'DE'
                                          IMPORTING ev_content           = lv_content
                                                    ev_xml               = lv_xml
                                                    ev_pages             = lv_pages
                                                    ev_trace_string      = lv_trace_string
                                                    ev_stop_processing   = lv_stop_processing
                                                    et_message           = lt_message ).
  IF sy-subrc <> 0.
  ENDIF.


  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = lv_content
    IMPORTING
      output_length = lv_output_length
    TABLES
      binary_tab    = lt_generated_pdf.


  " Shows a preview of the generated PDF file in a popup window.
  CALL FUNCTION 'FDM_COLL_INV_PDF_SHOW'
    EXPORTING
      t_pdf = lt_generated_pdf.
mmcisme1
Active Contributor
0 Kudos

Thank you! That worked.