Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Page counter over multiple Smartforms

The customer has provided me with a technical Smartforms challenge:

First they have multiple forms that need to be printed in a single job. No problem using the control parameters.

However the first two forms have to use continued page numbering, while the last has to start from 1.

So for example:

Form1 - 2 pages

Form2 - 2 pages

Form3 - 1 page

Should result in:

Page 1 of 4

Page 2 of 4

Page 3 of 4

Page 4 of 4

Page 1 of 1

Currently I get (using FORM and JOBPAGES variables):

Page 1 of 5

Page 2 of 5

Page 1 of 5

Page 2 of 5

Page 1 of 1 (using SFSY-FORMPAGES here, works as expected)

For the first two forms this renders both the SFSY-FORMPAGES as the SFSY-JOBPAGES variables useless... the first will only contain the number of pages in the current form, while the latter contains the number of pages in the entire job.

Is there a way to trick the program/smartforms into combining the page counter of the first two?

Former Member
Former Member replied

You have to first generate OTF ...calculate the pages and then use them in the forms:

DATA: ssfctrlop TYPE ssfctrlop,

ssfcrescl TYPE ssfcrescl.

ssfctrlop-getotf = 'X'.

CALL FUNCTION '/1BCDWB/SF00000047'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = ssfctrlop

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

job_output_info = ssfcrescl

  • JOB_OUTPUT_OPTIONS =

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

delete SSFCRESCL-otfdata[] where TDPRINTPAR NP 'PAGE'.

if sy-subrc = 0.

No of lines remaing in the itab is the no pages for the form

endif.

ENDIF.

OTFDATA has two parameters : TDPRINTCOM and TDPRINTPAR

data returned will be like --> IN |05%PAGE1 where PAGE1 is your smartform page name

So first generate otfs for the forms. Add up the total no of lines.

Pass the the total no pages into the form and use it as page nos...

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question