on 07-14-2008 5:19 PM
I have a SAPScript form that has a text element for a paragraph that will have multiple detail lines and will be repeated multiple times. It will also have a summary paragraph at the end.
The problem is that if printing the summary will cause a page break, the user wants the page break to come before the last detail line.
Iu2019ve tried using the PROTECT command, but it doesnu2019t work across paragraphs. Iu2019ve also tried using the FM CONTROL_FORM in the print program to put in a PROTECT before each detail line but this doesnu2019t work either.
Any thoughts??
Rob
Edited by: Rob Burbank on Jul 14, 2008 2:01 PM
There isn't any direct solution, but the workaround would be, call next page using command NEXT-PAGE page when last line goes to next page. In this work around, the total number of lines per page and number of line items should be known.
E.g.
My SAPScript is like:
FIRST ....next .... FIRST
MAIN Window
/E LINE
P1 ITAB-FLD1
P2 ITAB-FLD2
/E SUMMARY
P1 sum1
P1 sum2
MAIN window has length of 10 lines.
Now, my itab has 5 records so, last line will go on to the next page alongwith the summary.
So, add one more element in the MAIN which can call the next page
/E NEXT_PAGE
/: NEXT-PAGE FIRST
In the program,
LOOP AT ITAB.
IF COUNT = 5
* WRITE ELEMENT NEXT_PAGE USING WRITE_FORM
CLEAR COUNT
ENDIF
* WRITE LINE ELEMENT
COUNT = COUNT + 1
AT LAST.
* CALL SUMMARY
ENDAT.
ENDLOOP.
I am away from the system, otherwise I could have provided an accurate solution.
Regards,
Naimesh Patel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried like this?
/E LINE
* &wa_tab-fld1&
* &wa_tab-fld2&
/E LAST_LINE
/: PROTECT
* &wa_tab-fld1&
* &wa_tab-fld2&
/E SUMMARY
* Summary line 1
* Summary Line 2
/: ENDPROTECT
Here LINE element is for normal lines, LAST_LINE is for the last record and SUMMARY is for the summary section.
In the program,
LOOP AT ITAB INTO WA_TAB.
AT LAST.
L_LAST = 'X'.
ENDAT.
IF L_LAST IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LINE'
WINDOW = 'MAIN'.
ELSE.
CLEAR L_LAST.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LAST_LINE'
WINDOW = 'MAIN'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SUMMARY'
WINDOW = 'MAIN'.
ENDIF.
ENDLOOP.
I have tried this and it gives me the required result.
Regards,
Naimesh Patel
Naimesh - this seems to have done the trick.
My problem was that I thought you could not protect across paragraphs; obviously, that was incorrect.
In the present case, there were additional PROTECT/ENDPROTECTs in the form and calls to FM CONTROL_FORM with PROTECTs and ENDPROTECTs. I was able to remove one call to this FM (ENDPROTECT) after the last detail line. That forced the summay to be protected. (That and a bit of other tweaking.)
Thanks again.
Rob
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
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.