Merge PDF files in ABAP



Similar documents
Step by Step Guide for Language Translation Tool

Step by Step Guide How to Copy Flat File from Other Application Server to BI and Load through Info Package

Restricting Search Operators in any Search View

ALE Settings, for Communication between a BW System and an SAP System

Exposing RFC as Web Service and Consuming Web Service in Interactive Forms in ABAP

ABAP Debugging Tips and Tricks

SAP CRM 7.0 for Newbies: (Part 1) Simple BOL Object Creation for CRM Webclient UI

Quick Viewer: SAP Report Generating Tool

Table of Contents. Passing Data across Components through Component Controller between Two Value Nodes

Creating Content Using SO10 Objects and Text Symbols

SAP NetWeaver Developer Studio 7.30 Installation Guide

How to Assign Transport Request for Language Translation?

Data Extraction and Retraction in BPC-BI

How to Modify, Create and Delete Table Entries from SE16

Reverse Transport Mechanism in SAP BI

Tutorial - Creating Pop Up Window Using New Features in WebDynpro Java CE 7.1 Ehp1

ABAP How To on SQL Trace Analysis

Creating Transaction and Screen Variants

Deleting the User Personalization done on Enterprise Portal

SAP BW - Excel Pivot Chart and Pivot Table report (Excel)

Creating Web Service from Function Modules/BAPIs & Integrating with SAP Interactive Forms

How to Create an ecatt?

SAP CRM Campaign Automation

Creating New Unit of Measure in SAP BW

ABAP Proxy Interfacing

Embedding Crystal Reports inside ECC ALV Reports

BW Performance Monitoring

Create Automatic Mail Notification/ Alert for Process Chain Monitoring

Deleting the Requests from the PSA and Change Log Tables in Business Intelligence

Step by Step Procedure to Block and Debug a CIF Queue Flowing from R/3 to APO System

SAP BW 7.3: Exploring Semantic Partitioning

Standard SAP Configuration of SMS through HTTP with Third Party SMS Gateway

LSMW: Upload Master Data using Batch Input Recording

Web Dynpro ABAP: ALV and Table in Popup Window

SAP FI - Automatic Payment Program (Configuration and Run)

SAP CRM System 6.0/7.0. For more information, visit the Customer Relationship Management homepage

Step By Step Procedure to Create Logical File Path and Logical File Name

SAP Workflow in Plain English

Creation and Configuration of Business Partners in SAP CRM

Web Dynpro: Multiple ALV Grids and Layouts in ALV

Working with SAP BI 7.0 Data Transfer Process (DTP)

Display Options in Transaction SE16

Creating and Scheduling Publications for Dynamic Recipients on SAP Business Objects Enterprise

Integration of SAP R/3 with BO Universe Using Data Federator Connector

How to Generate Stack Xml for Ehp4 and Above Upgrade

Process Controlled Workflow SRM 7.0 (Using BRF)

Configuration of Enterprise Services using SICF and SOA Manager

Transfer of GL Master from Source SAP System to a Target SAP System through IDOCS

Step by Step Procedures to Load Master Data (Attribute and Text) from FlatFile in BI 7.0

Understanding BW Non Cumulative Concept as Applicable in Inventory Management Data Model

Deploying Crystal Reports on Top of a SAP BI Query

Release Strategy Enhancement in Purchase Order

How to Integrate CRM 2007 WebClient UI with SAP NetWeaver Portal

Workflow Troubleshooting and Monitoring in SAP ECC 6.0

Guidelines for Effective Data Migration

Converting and Exporting Data in XML Format

Adobe Document Service Configuration and Troubleshooting Guide

Multi Provider Creation Based on Sales and Planning Info Cubes

Table of Content. SAP Query creation and transport Procedure in ECC6

A Step-by-Step guide on SMTP Configuration and File to Mail Scenario Using Process Integration Scenario in PI 7.1

Configuring HTTPs Connection in SAP PI 7.10

Understanding BEx Query Designer: Part-2 Structures, Selections and Formulas

Different Types of Alerts for Process Chains. Table of Content

Deploying JDBC drivers in PI 7.1x Systems

Compounding in Infoobject and Analyzing the Infoobject in a Query

Step by Step Guide to Archiving and Deleting of XML Messages in SAP NetWeaver PI

ALV List with Radio Buttons

Sending an Image File Through XI in a File-to-Mail Scenario

SAP BW - Generic Datasource Function Module (Multiple Delta Fields)

SAP CRM 7.0 E2C Setup: CRM via Toolset

How to Get Work Items from Workflow in your Outlook Inbox

Salesforce.com Integration Using SAP PI: A Case Study

Creating Mobile Applications on Top of SAP, Part 1

Inventory Management in SAP BW

Order Split Usage in Production Orders

SAP CRM Middleware Configurations

SPDD & SPAU Adjustments Handbook

Consuming Services in SOA Manager

Splitting the Custom Container & Display more than one ALV

Using PI to Exchange PGP Encrypted Files in a B2B Scenario

First step to Understand a Payroll Schema

Scenario... 3 Step-by-Step Solution Virtual Infocube... 4 Function Module (Virtual InfoCube)... 5 Infocube Data Display... 7

Organizational Management- Organizational Structure Creation

Step by Step Procedure to Create Broadcasters, to Schedule and to Enhance of SAP- BI Queries from Query Designer

Extractor in R/3 and Delta Queue

Forgot or Lock "Administrator or J2EE_ADMIN" Password

Universal Management Service 2015

Step by Step Guide to Extract Batch Master Data via Generic and Classification Datasource to BW

Step by Step guide of Report-to- Report Interface in BW Reporting

How to Develop Programs for SAP Mobile RF

Enhancing Performance Management System (Performance Appraisal) with EHP4

SAP CRM-BW Adapter an Overview

Currency Conversion using Variables in SAP BI -Reporting

Invoice Collaboration: Self Billing Invoice

Direct Subcontracting Process (SAP SD & MM)

Integrating SAP CRM with the SAP R/3 HR module

Integrated Testing Solution Using SAP Solution Manager, HP-QC/QTP and SAP TAO

Understanding DSO (DataStore Object) Part 1: Standard DSO

Data Flow from LBWQ/SMQ1 to RSA7 in ECC and Delta Extraction in BI

Customer Exit Variables in SAP BW/BI Reports First day of the Current/Previous Month

Transcription:

Applies to: SAP Net Weaver 7.0, ABAP. For more information, visit the ABAP homepage. Summary This article explains how to merge PDF files using an external non SAP solution from ABAP. Author: Krisztian Katona Company: Swisscom Created on: 06 September 2010 Author Bio Krisztian Katona is working as SAP developer at Swisscom specialized to technologies as ABAP Objects, WebDynpro and Process Integration. 2010 SAP AG 1

Table of Contents Introduction... 3 How does it work... 3 How to set up the environment... 3 Step 1: Installing PDFTK... 3 Step 2: Setting up the external execution of PDFTK... 4 Step 3: Define a temporary directory path in SAP... 5 Step 4: Set up number range... 6 Add new interval to the number range.... 7 Step 5: Installing ZCL_PDF_MERGE... 7 ABAP Code example... 8 Merging individual PDFs into a new PDF... 8 Related Content... 9 Disclaimer and Liability Notice... 10 2010 SAP AG 2

Introduction This article will show you how to merge two ore more PDF files into one using ABAP. As the ABAP language or the integrated Adobe Document Services does not support PDF merge operations hence we have to use PDFTK which is an external non SAP solution for PDF manipulation and ZCL_PDF_MERGE an ABAP class to manage the merging process. How does it work The PDFTK based merge process consist the following steps: The source PDF files are written to a temporary directory on the SAP application server (class ZCL_PDF_MERGE) Run PDFTK to merge the PDF files and save the merged file Read the merged PDF file and forward it to the ABAP program (class ZCL_PDF_MERGE) How to set up the environment This document will describe the process to set up the SAP PDF merging environment on Linux machines. As PDFTK is an open source cross-platform product, it is also possible to set up the environment in different operating systems but it is out of the scope of this article. Step 1: Installing PDFTK Download the PDFTK binary and install it onto the SAP application server. Make sure the binary is on the PATH and the user of the SAP installation has the execution right. As SAP cannot handle the asterix character when executing external OS commands we have to use a shell script as a transient layer. Create a shell script called runpdftk.sh and place it into the application server. The shell script should have the following content: #!/bin/sh exec "/usr/local/bin/pdftk" $1*.pdf cat output $2 2010 SAP AG 3

Step 2: Setting up the external execution of PDFTK Go to transaction SM49. Press the create button and add the new command ZPDFMERGE Write the absolute path of the shell script you created in the previous step into the Operating system command field. Check Additional Parameters Allowed Save your changes To run external OS commands authorization object S_LOG_COM (COMMAND=ZPDFMERGE OPSYSTEM=Linux HOST=*) is necessary. 2010 SAP AG 4

Step 3: Define a temporary directory path in SAP This will be a directory in the application server to store temporary files for the merge operation. Go to transaction FILE Click on the New Entries button and add the logical path ZPDFMERGE Double click on the Assignment of Physical Paths to Logical Path label on the tree structure and add the following Physical path: /tmp/<filename> 2010 SAP AG 5

Step 4: Set up number range A number range will be used to compose the name of the temporary files. Go to transaction SNRO Create number range object ZPDFMERGE. Create a number range (by clicking on the Number ranges label on the toolbar) with the following parameters: 2010 SAP AG 6

Add new interval to the number range. You can do this by pressing the number range button on the SNRO screen. Step 5: Installing ZCL_PDF_MERGE Download and install ZCL_PDF_MERGE SAP nugget from http://code.google.com/p/sappdfmerge/ and install it using SAPLINK. For documentation on using SAPLINK check this link. 2010 SAP AG 7

ABAP Code example Merging individual PDFs into a new PDF The following code sample illustrates how to use ZCL_PDF_MERGE class for a PDF merge operation. DATA: lo_pdfmerge TYPE REF TO zcl_pdf_merge, lv_pdf_merged TYPE xstring, lv_pdf TYPE xstring. [ ] CREATE OBJECT lo_pdfmerge. LOOP AT lt_pdf INTO lv_pdf. lo_pdfmerge->add_pdf( lv_pdf ). ENDLOOP. lv_pdf_merged = lo_pdfmerge->get_merged( ). You can call the ADD_PDF method and add PDF pages one by one in XSTRING format. Finally call the GET_MERGED method 2010 SAP AG 8

Related Content For more information, please visit the ABAP homepage. PDF files in SAP Offline Interactive Forms Using ABAP 2010 SAP AG 9

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this do cument, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2010 SAP AG 10