cancel
Showing results for 
Search instead for 
Did you mean: 

How to count Total Number of Pages in SAPSCRIPT

Former Member
0 Kudos

Hi,

Iam unable to print total number of pages in the First Page of SAPSCRIPT.Iam writing the Logic in the Varibale window.

Please kindly help me.

In First Page , The preview is

Page 1 of 1-

In Second Page , Teh Preview is

Page 2 of 2

The Logic is ....

1. Variable window of Script

PERFORM CHECK_PAGE IN PROGRAM ZZZF_SAPSCRIPT_EXITS

USING &SAPSCRIPT-FORMPAGES&

CHANGING &WS_PAGE&

ENDPERFORM

Page &PAGE(C)& of &WS_PAGE&

2. Program

FORM check_page TABLES p_pagein STRUCTURE itcsy

p_pageout STRUCTURE itcsy.

DATA : p_i TYPE sypagno.

READ TABLE p_pagein INDEX 1.

IF sy-subrc = 0 .

p_i = p_pagein-value.

p_i = p_i - 1 .

READ TABLE p_pageout INDEX 1.

CLEAR p_pageout-value.

*p_pageout-value = p_i+0(3).

WRITE P_I TO p_pageout-value.

condense p_pageout-value no-gaps.

MODIFY p_pageout INDEX sy-tabix.

ENDIF.

ENDFORM. "check_page

Please help me ASAP.

Regards,

Deepthi.

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Try this

'On The Form'

IF &NEXTPAGE& EQ 0

DEFINE &DECRE& := '2'

PERFORM SET_TEXT_SYMBOL IN PROGRAM YSS20200

USING &SAPSCRIPT-FORMPAGES&

USING &DECRE&

ENDPERFORM

ENDIF

'In The Program'

DATA : BEGIN OF script_table OCCURS 0.

INCLUDE STRUCTURE itcsy.

DATA END OF script_table.

----


  • Used to modify total pages so they print correctly

----


FORM set_text_symbol TABLES input_table LIKE script_table[]

output_table LIKE script_table[].

DATA: pageno TYPE i,

intCnt type i,

chrPg(2) type c.

READ TABLE input_table INDEX 1.

MOVE input_table-VALUE TO pageno.

READ TABLE input_table INDEX 2.

MOVE input_table-VALUE TO intCnt.

subtract intcnt from pageno.

write pageno to chrpg.

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'

EXPORTING

NAME = 'FORMPAGES'

VALUE = chrpg

  • VALUE_LENGTH = 0

  • REPLACE_SYMBOLS = ' '

.

ENDFORM.

Former Member
0 Kudos

Hi Deepthi,

We are also getting similar issue could you please let me know how did you resolve this issue?

Former Member
0 Kudos

Hi Ravishankar,

i have created a new window only in First page & Next Page and copied the SAME code but ima getting as

Page 1 of 3

Page 2 of 3

ie., it is including mail page also.

which should not happen.

I want the Output as

Page 1 of 2.

Page 2 of 2.

Regards,

Deepthi.

Former Member
0 Kudos

Hi Ravi Shankar,

If i dont write the code than total number of pages become 3(Mail page , First Page , Next Page).I want only the First page and Next Page to be counted.

So , that is not working.......

Regards,

Deepthi.

ravishankar_reddy2
Active Participant
0 Kudos

Hi,

U have to create one window in the next page and first page,

dont cretae a window in mail page.

and write that line in both the windows.

regards,

ravi shankar reddy

mahaboob_pathan
Contributor
0 Kudos

hi,

/: Page &PAGE& OF &SAPSCRIPT-FORMPAGES&

Former Member
0 Kudos

Hi Anil,

Still it is not solved.

Though i have made the chanegs that were given by u.

Is there any other way..

Please help me.

Regards,

Deepthi.

ravishankar_reddy2
Active Participant
0 Kudos

Hi,

I think no need to write code for that pages

just create one window and write it as

pages &PAGES& of &SAPSCRIPT-FORMPAGES&

dont use it in first page write it from ur second page

i used it , it is working fine.

I hope it will work for u.

regards,

ravi shankar reddy

Edited by: Ravi Shankar Reddy S on Feb 7, 2008 11:41 AM

Former Member
0 Kudos

Hi Deepthi,

Please declare P_I as character and take p_pagein-value into it and then move P_I into another variable and do the manipulations....

did u try to debug keeping breakpoint in this subroutine..

check whether the values are populated right or not....

this should be helpful...

Thanks,

Anil

Former Member
0 Kudos

Hi Deepthi,

Change the way u read the table in the subroutine 'check_page'

use like this...

READ TABLE p_pagein WITH KEY 'SAPSCRIPT-FORMPAGES'.

....

....

Also change the other read also as

READ TABLE p_pageout WITH KEY 'WS_PAGE'.

.....

.....

Thanks,

Anil

Please reward if helpful

Former Member
0 Kudos

Hi,

I can not use this logic directly.Because.....

I have 3 pages in total in my Script

1. Mail Page

2. First Page

3. Next Page

Here, I have to skip mail page means i should not count mail page..

I have to count only first page & Next page..

So, this logic doesn't work

I have tried doing SAPSCRIPT-formpages - 1.

But that couldn't work...

So , please help me.

Regards,

Deepthi.

Former Member
0 Kudos

Hello,

DO like this

 /: Page &PAGE& OF &SAPSCRIPT-FORMPAGES& 

&SAPSCRIPT-FORMPAGES&:
This field contains a number representing the total number of pages of the currently formatted form (any output between START_FORM and END_FORM). The page counter mode (START, INC, HOLD) of the individual pages is ignored. You can use this symbol to formulate information like


‘Page x of y’ for your output.

Cheers,

Vasanth

ravishankar_reddy2
Active Participant
0 Kudos

Hi,

just use this in next page also.

/: Page &PAGE& of &SAPSCRIPT-FORMPAGES&

i hiope it may work,

regards,

ravi shankar reddy