How to Merge PDF Files using SAP.. absolutely Free?

How to Merge PDF Files using SAP
Merge PDF in SAP

On How to Merge PDF Files using SAP for free? Is it true that you are burnt out on utilizing free web-based PDF consolidation instruments accessible on web with heaps of undesirable promotions and impediments? At any point took a stab at combining PDFs utilizing SAP? No concerns this instructional exercise will assist you with blending numerous PDF utilizing SAP. So, Let’s get Answer the How to Merge PDF Files using SAP for free!

There can be 3 common possibilities to merge PDFs: (How to Merge PDF Files using SAP)

  1. Consolidating two PDFs from outside source
  2. Consolidating two SAP Adobe structures
  3. Consolidating a SAP Adobe structure and a PDF from an outside source. Note: Promotions doesn’t uphold combining PDFs yet, so its precarious one.

A. Merging two PDFs from external source

First case is straightforward and we have a standard SAP program to help us. Program – RSPO_TEST_MERGE_PDF_FILES.

Just you really want to choose the PDFs and execute the program and Ta-Da!
your blended document is prepared.

B. Merging two SAP Adobe Forms or Merging an SAP Adobe Form and a PDF From an external source.

Presently comes the interesting part. How to consolidate at least two SAP Adobe structures or an Adobe structure with an outer PDF?

For this we have PDFTK(PDF Toolbox) as our hero. It is an outer device. You want a few assistance from Premise and Security group to introduce the device and get the expected approvals. So have great terms with your Premise and Security companions.. SAP is a group game and you can’t win it single-handedly.

Let’s begin merging..

Here are steps that you really want to perform prior to composing your code:

  1. Introduce PDFTK and the expected class – Kindly go through the appended connect and play out the means as given. Merge PDF files in ABAP
  2. Make class ZCL_PDF_MERGE utilizing the SAP PDF Merge Nugget
  3. Compose the driver program to carry out this usefulness.

Below are the steps to be performed in the driver program:

  1. Get all the PDF content (Advertisements, PDF from show server, PDF from application server, PDF from DMS server or some other source) in XSTRING design.
  2. Affix all the XSTRING PDFs into one inside table IT_PDF. Circle IT_PDF and call ADD_PDF() strategy for the class ZCL_PDF_MERGE . This will make transitory PDFs in your application server way ZPDFMERGE made by Premise group.
  3. At last, call GET_MERGED() technique which will make the last blended PDF and return the last PDF XSTRING in the variable v_pdf_merged, additionally it will erase every one of the transitory documents those were made previously.
  4. Presently you have the last blended PDF information in XSTRING configuration and you can utilize it according to your necessity (to send sends, to save in show server or application server , to show on the SAP screen very much like an adobe structure yield).
  5. The following is a model code scrap to combine two adobe structure with a PDF from the application server and afterward save it in the show server.

Driver Program Code Snippet:

Essentials Approval object S_LOG_COM ought to be relegated to you and furthermore you ought to have ZPDFMERGE way access.

REPORT zsapyard_pdf_merge.
PARAMETERS : p_path TYPE sdok_filnm. ” app server path
DATA: lo_pdfmerge      TYPE REF TO zcl_pdf_merge,
      v_pdf_merged     TYPE xstring,
      v_pdf            TYPE xstring,
      it_pdf           TYPE STANDARD TABLE OF xstring,
      wa_formoutput1   TYPE fpformoutput,
      wa_outputparams  TYPE sfpoutputparams,
      wa_docparams     TYPE sfpdocparams,
      wa_formoutput2   TYPE fpformoutput,
      v_formname1      TYPE fpname,
      v_formname2      TYPE fpname,
      v_function_name1 TYPE rs38l_fnam,
      v_function_name2 TYPE rs38l_fnam,
      bin_tab          TYPE STANDARD TABLE OF tabl1024,
      lo_gui           TYPE REF TO cl_gui_frontend_services,
      path             TYPE string,
      fullpath TYPE string,
      length           TYPE i,
      filter           TYPE string,
      uact             TYPE i,
      name             TYPE string.

*first adobe form.
v_formname1 = ‘ZTEST1’.

*get function module names for Adobe forms
TRY.
    CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
      EXPORTING
        i_name     = v_formname1
      IMPORTING
        e_funcname = v_function_name1.
*         e_interface_type = lv_interface_type1.

  CATCH cx_fp_api_internal
        cx_fp_api_repository
        cx_fp_api_usage.
*      MOVE sy-subrc TO lv_subrc.
ENDTRY.

* second adobe form
v_formname2 = ‘ZTEST2’.
TRY.
    CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
      EXPORTING
        i_name     = v_formname2
      IMPORTING
        e_funcname = v_function_name2.
*           e_interface_type = lv_interface_type2.

  CATCH cx_fp_api_internal
        cx_fp_api_repository
        cx_fp_api_usage.
*      MOVE sy-subrc TO lv_subrc.
ENDTRY.

wa_outputparams-nodialog = ‘X’.
wa_outputparams-preview = abap_true.
wa_outputparams-reqnew = ‘X’.
wa_outputparams-nopdf = ‘X’.
wa_outputparams-arcmode = ‘1’.

* Set parameters (print/send/output device etc)
CALL FUNCTION ‘FP_JOB_OPEN’
  CHANGING
    ie_outputparams = wa_outputparams
  EXCEPTIONS
    cancel          = 1
    usage_error     = 2
    system_error    = 3
    internal_error  = 4
    OTHERS          = 5.
IF sy-subrc <> 0.
*    MOVE sy-subrc TO lv_subrc.
ENDIF.

wa_docparams-langu = ‘E’.
wa_docparams-replangu2 = ‘E’.
CALL FUNCTION v_function_name1
  EXPORTING
    /1bcdwb/docparams  = wa_docparams
  IMPORTING
    /1bcdwb/formoutput = wa_formoutput1    “1st adobe form
  EXCEPTIONS
    usage_error        = 1
    system_error       = 2
    internal_error     = 3
    OTHERS             = 4.
IF sy-subrc <> 0.
*    MOVE sy-subrc TO lv_subrc.
ENDIF.
CALL FUNCTION v_function_name2
  EXPORTING
    /1bcdwb/docparams  = wa_docparams
  IMPORTING
    /1bcdwb/formoutput = wa_formoutput2     “2nd adobe form
  EXCEPTIONS
    usage_error        = 1
    system_error       = 2
    internal_error     = 3
    OTHERS             = 4.
IF sy-subrc <> 0.
*    MOVE sy-subrc TO lv_subrc.
ENDIF.

*get external source PDF data from the application server
OPEN DATASET p_path FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
  READ DATASET p_path INTO v_pdf.
  IF sy-subrc EQ 0.
  ENDIF.
ENDIF.
CLOSE DATASET p_path.

* create table with all xstring data
APPEND v_pdf TO it_pdf.
v_pdf = wa_formoutput1-pdf.
APPEND v_pdf TO it_pdf.
v_pdf = wa_formoutput2-pdf.
APPEND v_pdf TO it_pdf.

* use ZCL_PDF_MERGE class to get the PDF xstring after merging all PDF’s
CREATE OBJECT lo_pdfmerge.
LOOP AT it_pdf INTO v_pdf.
  lo_pdfmerge->add_pdf( v_pdf ).
ENDLOOP.
v_pdf_merged = lo_pdfmerge->get_merged( ). “final merged data
*download merged PDF to your desktop
CREATE OBJECT lo_gui.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
  EXPORTING
    buffer        = v_pdf_merged
  IMPORTING
    output_length = length
  TABLES
    binary_tab    = bin_tab.

CALL METHOD lo_gui->file_save_dialog
  EXPORTING
    default_extension = ‘pdf’
    default_file_name = ‘merged.pdf’
    file_filter       = filter
  CHANGING
    filename          = name
    path              = path
    fullpath          = fullpath
    user_action       = uact.
IF uact = lo_gui->action_cancel.
  EXIT.
ENDIF.

lo_gui->gui_download( EXPORTING
                        filename = fullpath
                        filetype = ‘BIN’
                        bin_filesize = length
                      CHANGING
                        data_tab = bin_tab ).

What’s more, your combined document is prepared. You can likewise make a spool demand for this or show this on your screen according to your necessity.

YOU MAY BE INTERESTED IN

Core Data Services in ABAP for HANA

ABAP Evolution: From Monolithic Masterpieces to Agile Architects

Introduction to SAP ABAP for HANA

WhatsApp WhatsApp us