cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically merging PDF forms in web dypro ABAP

Former Member
0 Kudos

Hi

I have a requirement where I have to create various PDF forms dynamically from a web dynpro application and save them.

But now clients needs that all the forms genereated dynamically should be merged in one single PDF document dynamically.

I am able to generate PDF document dynamically but I want to know how to merge them into a single PDF document dynamically.

Kindly suggest

Regards

Sumit

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_szcs
Active Contributor
0 Kudos

Hi Sumit,

to my knowledge, there is no SAP function to to merge PDF files, but there are alot of tools available that can do this on the operating system level. Just create the PDF files and then merge them with an appropriate system command.

Best regards,

Thomas

Former Member
0 Kudos

Hi Thomas,

Thanks for the reply..

But i need to create it dynamically. Is there any way that while genrating PDFs dynamically i can set the page to the next page so that the other PDF starts from the where the previous one has ended

For eg,.

Suppose I have to create 3 PDFs dynamically so once I created the first one and it contains 3 pages so while creating next PDF i can set the starting of second PDF from page four as so on..So that the final PDF created will have all the three PDF content.

Please suggest if this is possible..

Thanks

Sumit

Former Member
0 Kudos

Sumit,

You need not worry about the page numbers. Since this functionality is not available in SAP the pdf merge software should take of that. Find a pdf merge software good enough to satisfy your company needs and then place these pdf files on unix system via SAP. Let the software trigger once this is done and take care of merge for you. Check if the software can then place in some other folder and then write a sap program or use some other way to send this pdf file as a mail.

Best Regards,

Swanand

thomas_szcs
Active Contributor
0 Kudos

Hi Sumit,

using an operating system command can be done in a dynamic way. You can supply parameters to them. For example, you could save the files to a certain (temporary) directory and run the merge for two files at time until all files are merged in the correct order.

Depending on the type of PDF you could also create one big form in sfp... but I know that at most times this is not feasibile. In case your company has an external output management system connected to SAP, you could also let it do the job. They are built for this kind of stuff.

Best regards,

Thomas

Former Member
0 Kudos

Hi Thomas,

My issue is I have to create PDF forms dynamically for various WBS elements.

Below is sample code.

loop .

//calculating data

lv_xml = lo_adobe->get_wd_context_as_

xml( data_source = lo_node ). //converting data source into XML


  "Print form
  CALL FUNCTION lv_funcname
    EXPORTING
       /1bcdwb/docparams  = ls_docparams
      /1bcdwb/docxml     = lv_xml
    IMPORTING
      /1bcdwb/formoutput = fpformoutput
    EXCEPTIONS
      usage_error        = 1
      system_error       = 2
       internal_error     = 3
      OTHERS             = 4.
  IF sy-subrc <> 0.

  ENDIF.

  ENDLOOP.

  "Close job
  CALL FUNCTION 'FP_JOB_CLOSE'
    IMPORTING
      e_result = ls_result
     EXCEPTIONS
      OTHERS   = 0.
*** saving form as zip***
  zip->add( name = lv_name_str
content = fpformoutput-pdf ).
  zip_xstring = zip->save( ).
************************************

the above code is current code ..in this way we are getting one PDF  for the last data.

I tried changing and now the code an dconcatinating all the XML data for various WBS element into one and finally passing it into the FM , below is modified code

loop .
//calculating data
lv_xml = lo_adobe->get_wd_context_as_xml( data_source = lo_node ). //converting data source into XML

concatenate lv_xml_temp lv_xml into lv_xml_temp in byte mode.

  ENDLOOP.


  "Print form
  CALL FUNCTION lv_funcname
    EXPORTING
      /1bcdwb/docparams  = ls_docparams
      /1bcdwb/docxml     = lv_xml_temp
     IMPORTING
      /1bcdwb/formoutput = fpformoutput
    EXCEPTIONS
      usage_error        = 1
      system_error       = 2
      internal_error     = 3
      OTHERS             = 4.
  IF sy-subrc <> 0.
   "Close job
  CALL FUNCTION 'FP_JOB_CLOSE'
    IMPORTING
      e_result = ls_result
    EXCEPTIONS
      OTHERS   = 0.
*** saving form as zip***
  zip->add( name = lv_name_str
content = fpformoutput-pdf ).
   zip_xstring = zip->save( ).
************************************

this also is not working..

If the meging is done using an operating system command  in a dynamic way then how. Can you please provide me sample code.

Thanks

Sumit

thomas_szcs
Active Contributor
0 Kudos

Hi Sumit,

you need to write the pdf to disk using ABAP statement open dataset and related statements. For setting up the operating system command you need a colleague from the basis team to this up. Usually, only them have the authorization to this. There is a special transaction for that. Once set up, you can call it. More information can be found here http://help.sap.com/saphelp_nw70ehp2/helpdata/de/c4/3a7f2c505211d189550000e829fbbd/frameset.htm.

Best regards,

Thomas