Skip to Content
Author's profile photo Rajesh Kannan R S

Adobeforms: How to generate multiple copies (first copy, second copy)

“Share your knowledge. It’s a way to achieve immortality” – Dalai Lama

Based on above fact, I would like to share my experience here hoping that it could help some experts someday.

Requirement:

It was a fine morning until i receive this call saying “hey, We need to make our Adobe form to generate 4 copies each time when the output is triggered”. Copies should be in order as below,

  1. Original Copy
  2. Customer Copy
  3. Vendor Copy
  4. Management Copy

I just learnt about Adobe forms and i started to search for solutions online. I couldn’t manage to find clear examples. I decided to try by self which led me to write this blog to make life easier.

First, let me give an overview on my form layout.

We need to add an extra text field on top to the right of logo at the center of page which should display name of the copy.

An easy way would go like this,

  • Start spool Job via “FP_JOB_OPEN”.
  • Loop N times.
  • Call Adobe FM within this loop with text name as a separate parameter.
  • Endloop.
  • Stop spool job via “FP_JOB_CLOSE”

But doing so will bring document navigator at top which means it will create as separate document which my functional is not happy with.

Solutions form my thoughts:

  1. My form has single page. I can copy the same page into 4 pages with copy names at top. But, I can’t find any copy option. So this approach means i should develop same layout again and again for 3 more times.
  2. To use the current form page as a template.

To me the second approach felt easy and i went with that approach.

Steps I did for second solution.

Overall Idea: Each Adobe form will have a body page on hierarchy tab. My idea is to make this body page as table and encapsulate each subform within the body page in a subform which acts like row for my table(body page). My current layout is as below,

Procedure:

Interface Changes: First, We have different internal table as import parameters as below,

I have defined a custom deep structure which includes all these above internal table within itself. In Code initialization part,i have appended all values as required. example as below,

Now we have our internal table IT_INVOICE with all data. Lets concentrate on form layout changes.

Form Layout Changes: First change would be include the copy name text (IT_INVOICE-TEXT) at top of layout. To do this, Insert->Standard->Text Field and bind it to IT_INVOICE-TEXT as below.

From above Layout image, My page area name is “Main_area”. select all layout elements in body page of form and wrap them inside a subform named “Body_row”. (Select all->Right Click->Wrap in subform). Change below settings,

In Page subform(in my case “Main_area”): Palettes->object->Binding-> (Bind IT_INVOICE to this subfom and check “Repeat subform for each item” checkbox and give maximum as 1.

Also change: Palettes->object->Accessibility->Role as “Table”.

In body_row subform: palettes->object->Binding->(Bind data[*] of internal table IT_INVOICE in this subform. Do check “Repeat subform for each item” checkbox and set Min Count as 1.

Also change Palettes->object->Accessibility->Role as “Body row”.

We are almost done. Try to test at this point, Form will generate 4 copies sequentially without page break at each new copy( if 1st copy ends at middle of page 3, second copy will follow immediately instead of breaking to next page).

To achieve page break for each new copy, We can add conditional page break as below,

By this, we come to the end of development. Enjoy !!

Important Note: Each element in layout within body_row subform should be binded to respective element from within IT_INVOICE->DATA->[respective internal table]. If this is not done, values with only appear in first copy of Adobe form rest will follow empty.

Issue: one main drawback of above approach is page numbering which we need to resolve by javascript code. Presume my form has 2 pages of line items, Hence entire output will have 8 pages (4 copies) and page number will be like 1 of 8 …. to ….. 8 of 8. But most of our functional would require page number to reset to 1 for each copy. This i will cover in my next blog as i have handled this entirely in Javascript.

PS: I welcome comments of all kinds. I’m new to adobe forms. I’m not aware of any easier approach to achieve the same. If there is any easy approach to achieve the same, do let me know in comments. I do apologize for my bad language.

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Florian Henninger
      Florian Henninger

      IF it works for you, everything fine, but why you are trying to archive it in one run. Wouldn't it be a lot easier, to call the form several times and give the text via interface and collect afterwards all in one spool or set the options that all end in one spool?

      It is a solution, but would recommend not something complicated to archive this.

      ~Florian

      Author's profile photo Rajesh Kannan R S
      Rajesh Kannan R S
      Blog Post Author

      Thanks Florian. Incase of print preview also, my functonal wants to view how each copy looks in a single go. when i searched for solutions online, i failed to understand how this can be done. so, i decided to give it a try and ended up with this approach.

      Author's profile photo Dhruv Thakkar
      Dhruv Thakkar

      Hi Florian, can you provide any link to your solution?

      Author's profile photo Michelle Crapo
      Michelle Crapo

      Interesting - and I'm thinking to myself there must be an easier way - Florian's idea is a good one.  And now you have another thing to think about. I love comments.

      Michelle.

      Author's profile photo Utkarsh Agarwal
      Utkarsh Agarwal

      Hi Rajesh,

      Your solution is really helpful for such cases but it seems a bit complicated, we can go with your first solution too which is,

      My form has single page. I can copy the same page into 4 pages with copy names at top. But, I can’t find any copy option. So this approach means i should develop same layout again and again for 3 more times.

      We can copy a master page by following steps:

      1. Right click on the master page and click on create new master page

      2. Click on your existing master page and press Ctrl + A (it will take all your children elements                 having visibility as visible, we can manually select the hidden children by keep pressing Ctrl               and selecting the hidden children) and then press Ctrl + C

      3. Click on your new master page and press Ctrl + V, it will copy all the layout but a problem will              be there that the master page will get copied from co-ordinate (0,0), you can avoid that by                  placing  your mouse cursor to the co-ordinate in the page from where you want your master                page to begin(just take the co-ordinate reference from existing master page).

      4. This way you will create a replica of your master page into another master page(similarly you              can crate any number of master pages).

      5. You have to create as many design view pages as master pages, which you can create by                 just clicking on the design view page and press Ctrl + C, then right click and select create a               new page, then press Ctrl + V, a new body page will be copied under that design view page.               Now just drag it from there and drop it below your original design view page (just to keep a                 better view of hierarchy).

      6. Then Go to Palettes-> Object-> Pagination Tab-> Place-> On Page and select On <your new              master page>, you will see an exact replica twice in your Adobe form.

      Hope this would help to someone!!

      Author's profile photo Ionut-Emanuel Chiculita
      Ionut-Emanuel Chiculita

      Hello Rajesh,

      You could do it as the code was intended and use this:

      COPIES Types FPCOPIES NUMC 3 0 0 Number of Copies -> from the structure SFPOUTPUTPARAMS which you pass to FP_JOB_OPEN

        ls_outputparams-device 'PRINTER'.
      ls_outputparams-nodialog abap_true.
      ls_outputparams-reqnew abap_true.
      ls_outputparams-reqimm abap_true.

      ls_outputparams-copies = '3'.

      CALL FUNCTION 'FP_JOB_OPEN'
      CHANGING
      ie_outputparams ls_outputparams
      EXCEPTIONS
      cancel          1
      usage_error     2
      system_error    3
      internal_error  4
      OTHERS          5.

       

      Thanks.

      Author's profile photo Daniel St-Jacques
      Daniel St-Jacques

      Nice blog.

      One more solution would be to have 1 output type per form copy and simply handling header text based on the output type.

      That will allow to send by email the form to hits owner.

      No need to duplicate the form, The same one will be used by all. If another copy is required in the future, simply create a new output type.

      Example:

      1. Original Copy -> Output type ZOC
      2. Customer Copy -> Output type ZCC
      3. Vendor Copy -> output type ZVC
      4. Management Copy -> Output type ZMC

       

      The header text can be handled by the output type description or anyother text handling.

       

      Regards