cancel
Showing results for 
Search instead for 
Did you mean: 

Page Break on main window and Dynamic Page Sequence in SAP Script

Former Member
0 Kudos

Hello Experts,

I have a requirement that in Sap script I have to dynamically determine the next page, trigger page break when the main window is full on current page.

(Basic requirement is to print maximum line items in minimum number of pages, provided pages are printed as per conditions listed below)

The scenario is as follows. I have three pages in script.

FIRST      -  Contains MAIN, and Multiple Variable Windows ( Can print limited line items )

SECOND -  Contains only Main Window ( Can print maximum line items as full page dedicated for main window )

LAST       -  Contains MAIN and one Variable Window. ( Can print line items less than SECOND page as has another VAR Window )

Depending on the number of Line items the count of pages can be as follows:

FIRST      -  Always 1.

SECOND -  Between 0 and N . ( Where N >=1 )

LAST        - Either 0 or 1.

Total no of pages = Number of FIRST page + Number of SECOND page(s) + Number of LAST page

Conditions:-

1. If the Line items can be fitted on FIRST PAGE, then only 1 Page is printed.

( Second and Last not called )

Total Number of pages = 1. ( FIRST = 1, SECOND = 0, LAST = 0 )

2. If the Line items can be fitted on FIRST AND LAST PAGE, then only two pages are printed in that order

( Second page Not called ).

Total Number of pages = 2 ( FIRST = 1, SECOND = 0, LAST = 1.)

3. If the Line items are greater than above two conditions, then FIRST, SECOND and LAST are called in that order.

( There can be multiple SECOND pages depending on line items )

Total Number of pages = 2 + N ( FIRST = 1, SECOND = N, LAST = 1.) where N>=1

Page Sequence :- ( as per conditions above )


1. FIRST


2  FIRST->LAST


3. FIRST -> SECOND ->LAST ( assuming  there are three Second pages then FIRST->SECOND->SECOND->SECOND->LAST ).



Current Solution :-

I tried achieving the same through counting the number of line items that can be printed in the space on each page in main window. I successfully implemented the logic. For example in my logic I Counted FIRST page can print 6, second can print 12 and last can print 10 line items.

Problem in Current Solution:

But the Problem came as a line item can contain variable number of lines in printing (one line item may be printed in 1 line, another in 10 lines. )

So the counting logic failed.

Question:-

Now how do I achieve dynamic page break ( and correct next page call ) after main window is filled on current page? Also to determine how many first, second and last pages are there in printing?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hemant,

Main window contains the text body that covers many pages and itself controls the page break.

As soon as the window of type main is full, SAP script automatically triggers the page break and continues to output the remaining text in the main window of subsequent pages.

In your case, you can control the last page in your driver program code by calling the last page text element in the write_form just before close_form and end_form.

or you can even put that the below coding in that last page element

IF &PAGE& EQ &SAPSCRIPT-FORMPAGES&

&VALUE&

ENDIF.

former_member220028
Active Contributor
0 Kudos

Hello ,

you can not solve your problem using standard page-prake-controll of sap-script.

because in standard you always define the next page of your current page (this never changes because of the amaount of lines printed)

so ur only solution (with sap-script) is to count the lines yourself and controll the page calling yourself.

counting the lines yourself means, that you define a variable that contains the amount of lines printed.

so after each statement in script, that creates a new line (e.g. each line with TDFORMAT "*" or "SPACE" have to be

  1. text-includes and floating text leads to undefined amount of rows

Former Member
0 Kudos

Hi Stefan,

Thanks for you answer and time. I do understand that the logic is unstable but since our client in working on ECC 4.6, adobe forms is not an option.

I will try to achieve what's required using your answer and if it is not successful, then will try to convince the client to switch to smartform.

Regards,

Hemant

Answers (0)