on 03-01-2016 1:09 PM
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello HEMANT MIRCHANDANI,
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 followed by a statement that increase the linecount.
now you know exactly how many lines are printed. you can now check this variable in the driver programm and compare with the maximum amonunt of lines you want on this page. if the maximum amount of lines is reached, you can call the next page.
now going this (in my opinion only way), you will face 2 problems:
regarding problem 1:
the only way to know how many lines will be there is, to know that number befor you start your printing.
so collect all data in internal tables and try to figure out, how many lines this will create.
after this check, you can start your printing, because now u know what page to call.
regarding problem 2:
the amount depends on e.g. the font-size. so the best way is, to test the output and figure out, how many lines fit on each page.
i think its good to create some sort of "customizing" so you can change the max numer very easy.
regarding problem 3:
normaly you call the entry-points "TDFORMAT /E" to print something in script. after each call, you return to your driver programm. if u now call entry points, that will create more than 1 line, you may exceed the maximum lines befor returning to your driver programm and so befor beeing able to call the next page. this can only be solved, if you know, how many lines each entry points creates. and call the next page, befor calling the next entry point. you somehow have to define a constant (in your driver programm) how many lines each entry-point has, to evaluate if you need to call the next page befor the next "entry-point-call".
Same is with includes. if you include some sort of SO10-Texts in your script, you have to know how many lines this creates and somehow define this constant in your driver programm and evaluate if you need to call the next page, befor the entry-point-call.
the problem is that you just know by testing, how many lines each entry-point-call creates. this is measured by font-size, window-size, floating text, includes, font-art, distance between lines...
you get the idea of it? you have to count everything manually. this will make your programm very unstable. if you somehow forgot something, your formular can crash or look very wired.
also this sort of implementation makes it very hard to change someting, because you have to test if the changes will effect the number of lines. e.g. if you want to increase whitespace on each side of the paper, this will effect the amount of letters that fit in 1 line.
i can not recommend this sort of implementation!
maybe going with newer techniques like adobe-formes can solve this requirement better. because there you collect all data in your driver programm befor you do the adobe call. so i quess it might be possible that adobe forms fits better here. i guess u have to ask some adobe-developers if you want to know more about it.
regards
Stefan Seeburger
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
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.