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: 

SAP Script: Print total number of pages while printing multiple documents.

Former Member
0 Kudos

Hi All,

We have a requirement to print multiple shipment documents using SAP Script. In print output, page count should come like ' Page 1 of Page n'.

Where n is the total number of form pages.

Lets take an example, we have two shipment document and both of them are having total page count as 2 and 3. When we take a print preview, we get the print output for total page count as 5.

So for first shipment document page count is displayed as 'Page 1 of Page 5, Page 2 of Page5. And second shipment document page count is coming as 'Page 1 of Page 5' , 'Page 2 of Page 5' and 'Page 3 of Page 5'.

here total page count is coming as grand total pages of sap script while we only want to print document wise page count. Out output should be like 'Page 1 of Page 2' , 'Page 2 of Page 2' for first shipment document and for second shipment document it should be like 'Page 1 of Page 3', 'Page 2 of Page 3' and 'Page 3 of Page 3'.

For printing page count i am doing as &PAGE&  of &SAPSCRIPT-FORMPAGES&.

Please suggest, how to achieve total number of pages as per this requirement.

your suggestion will be highly appreciated.

Regards,

Amit

1 ACCEPTED SOLUTION

custodio_deoliveira
Active Contributor
0 Kudos

Hi amit,

That's exactly how you should do (&PAGE&  of &SAPSCRIPT-FORMPAGES&) but for each document you need a new form to be printed. So for each shipment you need to call FM START_FORM and END_FORM.

You will have something like this

call function open_form.

loop at lt_shipment. "assume each line is one shipment

call function start_form.

call function write_form.

bla bla bla

call function end_form

endloop.

call function close_form .

Regards,

Custodio

2 REPLIES 2

custodio_deoliveira
Active Contributor
0 Kudos

Hi amit,

That's exactly how you should do (&PAGE&  of &SAPSCRIPT-FORMPAGES&) but for each document you need a new form to be printed. So for each shipment you need to call FM START_FORM and END_FORM.

You will have something like this

call function open_form.

loop at lt_shipment. "assume each line is one shipment

call function start_form.

call function write_form.

bla bla bla

call function end_form

endloop.

call function close_form .

Regards,

Custodio

0 Kudos

I just missed to use START_FORM.

Thanks a lot . It worked as required.

Regards,

Amit