Thursday, January 28, 2010

Identify the last page in a SmartForm

In a SmartForm there are times when you want to print something only on the last page. I also had the same requirement, initially I tried the system variable SFSY-FORMPAGES which is used in printing ‘Page x of y’. But found that the variable does not get the actual value until after the end of SmartForm.

Instead, what can be done is create a global variable e.g. GV_LAST_PAGE_FLAG. Add a window below (can be above also?) the main window and add program logic to it where you set the flag for last page. Go to the conditions tab of the window and set the flag ‘Only After End of Main Window’. This will ensure that window is called once the main window is finished printing, which happens on the last page. Use the flag in any place you want after that.

image

image