Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I Split the PDF File into different pages?

Former Member
0 Kudos


Hi,

My requirment is to split the pdf file , which is obtained by using FM "convert_otf" , into seperate PDF file for each employee data(PERNR).

Please suggest me the way to slipt the PDF file that has to be downloaded into the presentation server.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Why did you generate a single OTF/spool, if you actually want multiple PDF, would be easier to call the form once for each employee, and then copy each individual OTF into a PDF fille.

Else you have to analyze the coding of OTF or PDF to identify new-page code and then identify the employee number related to each page (If you actualley need to name file from employee number only)

You could also look for a FM for OTF similar to FM RSPO_OUTPUT_LIST_JOB  which allow to copy a spool from a page number to another page in a new spool. (OTF -> spool, RSPO_RGET_PAGE_NUMBER  to get number of page, RSPO_OUTPUT_LIST_JOB to print each page, then convert spool to pdf...) - I never tried, much simpler to generate individal OTF...

Regards,

Raymond

11 REPLIES 11

Former Member
0 Kudos

You should build a correct line break in your form leading to this PDF for this.

If you need more informations, we'll need also more (for example the type of forms used)

0 Kudos

The requirment is as follows :-

In a standard report a sapscript is generated. I had to convert this sapscript into PDF.

The PDF has to be generated in such a way that for each PERNR's data comes in a seperate PDF file.

read_form, open_form and close_form is used for sapscript generation in the report.

I have converted the data using convert_otf into the pdf format.

What changes should i make to create a split in the PDF?

0 Kudos

Well I'm sorry, I don't know much about sapscripts. But you should definately buils this page break in your sapscript.

raymond_giuseppi
Active Contributor
0 Kudos

Why did you generate a single OTF/spool, if you actually want multiple PDF, would be easier to call the form once for each employee, and then copy each individual OTF into a PDF fille.

Else you have to analyze the coding of OTF or PDF to identify new-page code and then identify the employee number related to each page (If you actualley need to name file from employee number only)

You could also look for a FM for OTF similar to FM RSPO_OUTPUT_LIST_JOB  which allow to copy a spool from a page number to another page in a new spool. (OTF -> spool, RSPO_RGET_PAGE_NUMBER  to get number of page, RSPO_OUTPUT_LIST_JOB to print each page, then convert spool to pdf...) - I never tried, much simpler to generate individal OTF...

Regards,

Raymond

0 Kudos

Exactly, manipulating pdf would be a contorted solution somewhere deep down the call chain, for a challenge that, without knowing the exact details, should be easily and quite naturally solvable in at an application/"driver program" level.

cheers

Jānis

0 Kudos

How do i run the standard Sapscript for individual employees in the report?

0 Kudos

It's nearly impossible to say without knowing what script and what report... could you give the names if those are SAP standard ones?

cheers

Janis

0 Kudos

se any tools like a report similar to RPLFST01 to get a list of employee (Import pernrtab from memory id ‘PERNRTAB') then execute the report for each employee.

Could you give more information, name of standard report ?

Regards,

Raymond

0 Kudos

Hi,

HIECEOY0 is the report i am Referring to.

SAPscript for P60 in the include "HIECEOYC"

Here i have used FM " CONVERT_OTF" to convert the sapscript into PDF and "GUI_DOWNLOAD" to save the file in presentation server. But before Saving the file i need to split the pdf for each employee.

Regards,

Srish

0 Kudos

Hi,

Ok, looking at that programm didn't actually help me very much to understand what's going on, or where you have the CONVERT_OTF call... Regardless, if the suggestion by Raymond is not feasible in your scenario, the thing I'd try to do is - splitting the spool (OTF) contents before calling CONVERT_OTF into individual documents (feeding it to convert FM piecemeal)... The link to OTF format and commands documentation is here.

Again, it's difficult to give a good algorithm without knowing the exact OTF contents (could you perhaps somehow export the display of spool in RAW format and attach here?) but it would boil down to approximately following:

1) set the &first_page per PERNR = 1;

2) run through OTF lines until the &end_page for PERNR has been identified somehow (hopefully there are Begin/End Form OTF commands '//' in that spool... and they correspond to the split of spool you need...);

3) extract the otf contents from &first_page to the EP command of &end_page into separate OTF itab and, if necessary, add // (End of form) command at the end of itab;

4) call CONVERT_OTF on the table and download;

5) set the &first_page per PERNR = &end page + 1;

6) repeat from 2) until end of spool OTF data

Something like that... Depending how the Sapscript translates into OTF, you may also need to prepend a few commands found at the very beginning of the spool to each extracted invividual OTF document...

I Hope you can get the gist of what I'm suggesting... splitting OTF is definetly easier than trying to split PDF, I feel. It's not ideal solution, because - what if the structure of OTF contents you would be realying on changes for some reason..?

cheers

Janis

0 Kudos

If you look at the test code of mine from here, beginning from INSERT '//XPOST2       0702 00000+00000+1' INTO gt_otf INDEX 1, what I'm doing with all those INSERTs and APPENDs of OTF commands in table is: simulating a structure of a form with one DINA4 portrait page for POST2 device type... In your case all the //, IN, OP, EP, // commands should actually be in OTF already - it's a matter of finding them and using them to split OTF per PERNR.

cheers

Janis