07-07-2006 4:21 PM
Hi,
I want to print page n of 'total pages + 1' in the footer section of my SAPSCRIPT FORM. I have used a PERFORM to add 1 to value of SAPSCRIPT-FORMPAGES symbol. But the problem is that it works fine on second page (prints page 2 of 3) but on the first page it always prints page 1 of 1.
I think the value of SAPSCRIPT-FORMPAGES symbol is not getting passed to the PERFORM parameter on first page but is working fine on subsequent pages.
/: DEFINE &PAGEOUT& = '&SPACE(5)'
/: PERFORM PAGE_SUMM IN PROGRAM ZAPFM06P
/: USING &SAPSCRIPT-FORMPAGES(C)&
/: CHANGING &PAGEOUT&
/: ENDPERFORM
AS <B>Page &PAGE& of &PAGEOUT&</>
Please advice.
Thanks for your help in advance.
07-07-2006 4:29 PM
See if the text element you are using is being conditionally triggered.
Regards,
ravi
07-07-2006 4:24 PM
07-07-2006 4:29 PM
Rich,
I want to print page n of 'total pages + 1'. for example if there are total 2 pages, I want to print
'page 1 of 3' on the first page and
'page 2 of 3' on second / last page.
Thanks,
Sanjay Gera
07-07-2006 4:28 PM
Hi,
you can use this ..
&PAGE& &SAPSCRIPT-FORMPAGES&
but why you want +1.
if that is the case try this..
&PAGE& &SAPSCRIPT-FORMPAGES + 1&
Regards
vijay
07-07-2006 4:31 PM
Vijay,
Business requirement is to print page n of 'total pages + 1'
I have tried &PAGE& of &SAPSCRIPT-FORMPAGES + 1& but it does not work.
Thanks,
Sanjay Gera
07-07-2006 4:29 PM
See if the text element you are using is being conditionally triggered.
Regards,
ravi
07-07-2006 4:35 PM
Ravi,
There is no conditional statement around the text symbol. I have pasted the exact code in the question.
Thanks,
Sanjay Gera
07-07-2006 5:34 PM
I think it's because sapscript doesn't know how many pages it's going to print in the fist page and FORMPAGES variable is not yet populated with total pages.
Regards
Sridahr
07-07-2006 5:38 PM
07-07-2006 7:34 PM
Rich,
Business users always attach an extra page to the printed Purchase order. That is the reason they want me to print 'total number of pages + 1'.
Thanks,
Sanjay Gera
07-07-2006 7:40 PM
Sridhar,
If I print the SAPSCRIPT-FORMPAGES symbol as it is, it is printing the total number of pages. But when I try to assign it's value to a text symbol using DEFINE statement or if I try to pass it to my PERFORM as a parameter to increment it by 1, It does not transfer the value.
Thanks,
Sanjay Gera
07-07-2006 7:41 PM
Sanjay,
Create an Empty page after your 2 pages & call that page as a last page with a START_FORM.I am not sure it would work but give it a try.
07-07-2006 7:46 PM
It's printing total number of pages when u use SAPSCRIPT-FORMPAGES, because, sapscript loads all pages into memory after close_form and replaces variable SAPSCRIPT-FORMPAGES with the new total number.
Try the following:
1. set parameter OPTIONS when calling OPEN_FORM function module as OPTIONS-TDPAGESLCT = '2-'.
This parameter tells sapscript to print from page 2.
2. Create a text element in FIRST page
/E PBREAK
/: NEW-PAGE FIRST
Call this text element after OPEN_FORM using WRITE_FORM
3. Before printing page number: subtract 1 from PAGE variable and populate it into NEW_PAGE variable using PERFORM and print the page# as:
AS <B>Page &NEW_PAGE& of &SAPSCRIPT-FORMPAGES&</>
Regards
Sridhar
Message was edited by: Sridhar K
07-10-2006 9:34 PM
Sridhar,
Your solution has worked perfectly. And you know, I don't have to subtract 1 from the &PAGE& variable either as it is been already taken care due to tdpageslct = '2-' option.
You are great.
Thanks a lot. I am posting reward points for you.
Regards,
Sanjay Gera
07-08-2006 10:23 AM
Hi Sanjay,
In your case where you want to increment the value of the total number of pages always use <b>&SAPSCRIPT-JOBPAGES&</b> and for the individual page <b>&PAGE&</b>.
Since you have to increment the value of the total number of pages, pass the value to a variable increment the variable and then display that variable.
: PERFORM CHECK_PAGE IN PROGRAM Z_SCRIPT
: USING &SAPSCRIPT-JOBPAGES&
: CHANGING &WS_PAGE&
: ENDPERFORM
FORM check_page TABLES p_page STRUCTURE itcsy
p_page1 STRUCTURE itcsy.
READ TABLE p_page INDEX 1.
IF sy-subrc = 0 .
p_page1-value = p_page-value + 1.
MODIFY p_page1 INDEX sy-tabix.
ENDIF.
ENDFORM. "check_page
Now your total number of pages would have been increased by 1 and display this variable in the script. But one point is <b>dont declare</b> the variable <b>WS_PAGE</b> in the driver program. If you declare the value will be reset. It will work believe me it works.
Reward if helpful.
Regards,
Tushar