Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Page Number

amit_khare
Active Contributor
0 Kudos

Hi All,

I require to display page number on the SAPScript.

The problem here is I have to display Page 1 when it is @ that is &PAGE& - 1 value.

Please let me know how to achieve this in the SAPscript.

Thanks in advance.

Amit

Hi, I dont want to display like 1 of 2..

but i want to display Page 1 whwn &PAGE& = 2 and so on.

Message was edited by: Amit Khare

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

Try with this system variable

<b>

&SAPSCRIPT-COUNTER_x& (x= 0..9)</b>

These fields represent ten counter variables that you can use in your text and forms for any counting purposes. You can use the ‘+’ and ‘-’ formatting options to increment or decrement a counter before its value is printed. You can use the DEFINE control command to assign any specific value to a counter.

Regards,

Sailaja.

11 REPLIES 11

Former Member
0 Kudos

can u explain more..?

<b>Page &PAGE& of &SAPSCRIPT-FORMPAGES&</b>

Former Member
0 Kudos
  • &PAGE& OF &SAPSCRIPT-FORMPAGES&

&SAPSCRIPT-FORMPAGES& : this standard script variable stores total no of pages in that layout to print

&PAGE& stores current page no.

Regards

srikanth

Message was edited by: Srikanth Kidambi

Former Member
0 Kudos

hi,

&PAGE& is for current page no

&SAPSCRIPT-FORMPAGES& for total no of pages

Regards,

Sailaja.

Former Member
0 Kudos

Hi,

use

page &page&

&sapscript-formpages&

Regards

amole

Former Member
0 Kudos

Hi,

Write a External perform for this one ..

<b>In the script:</b>

PERFORM <Nmae> ZPROGRAM

USING &PAGE&

Changing &PAGE_NO&

ENDPERFORM

In the Program(ZPROGRAM) .

form <name> tables intab structure itcsy

DATA: var type i.

outab structure itcsy.

clear intab.

read table intab with key name = 'PAGE'.

if sy-subrc = 0.

var = intab-page + 1.

ENDIF.

CLEAR OUTTAB.

READ TABLE OUTAB WITH KEY NAME = 'PAGE_NO'.

IF SY-SUBRC = 0.

OUTAB-VALUE = VAR.

modify outab index sy-tabix.

ENDIF.

in your Script PAGE_NO will have the value of PAGE + 1.

Regards

Sudheer

0 Kudos

hi,

You have to do it in a subroutine in the driver program.

form get_page tables intab structure itcsy
                   outab structure itcsy.
 DATA: v_page type i.
 clear intab.
 read table intab with key name = 'PAGE'.
 if sy-subrc = 0.
  var = intab-page + 1.
 ENDIF.

 CLEAR OUTTAB.
 READ TABLE OUTAB WITH KEY NAME = 'PAGNO'.
 IF SY-SUBRC = 0.
  OUTAB-VALUE = V_page.
 endif.
 modify outab index sy-tabix.
ENDIF.

Call the form in your script.
PERFORM get_page ZPROGRAM
         USING &PAGE&
         Changing &PAGNO&
ENDPERFORM

Regards,

Richa/

Former Member
0 Kudos

Hi Amit,

For displaying Page 1 when the variable &PAGE& holds the value 2 you will need to do the coding in the print program itself.

You can use the FM 'GET_TEXTSYMBOL' EXPORTING line = &PAGE& start_offset = 0. The importing parameter 'value' will contain the current page number.

You can then manipulate this as per your requirement and store the result in a global variable.

Now you can pass this global variable to your SAPScript and display it.

Hope this helps!

Regards,

Saurabh

amit_khare
Active Contributor
0 Kudos

Hi All,

thanks for the reply but the second problem here is I cant change the driver program.

Whatever I do I have to do it in SAPScripts only.

Amit

0 Kudos

the &PAGE& and other fields are SCRIPT specific fields .you can use directly in the script editor. no need to touch the driver program.

0 Kudos

Add the following to the window where you print page number:

/: IF &PAGE& = '2'      
/: DEFINE &PAGE& = '1'  
/: ENDIF

Regards

Sridhar

Message was edited by: Sridhar K

Former Member
0 Kudos

hi,

Try with this system variable

<b>

&SAPSCRIPT-COUNTER_x& (x= 0..9)</b>

These fields represent ten counter variables that you can use in your text and forms for any counting purposes. You can use the ‘+’ and ‘-’ formatting options to increment or decrement a counter before its value is printed. You can use the DEFINE control command to assign any specific value to a counter.

Regards,

Sailaja.