Skip to Content

Bottom area trouble in triggering new page

Most of the times when we are dealing with SAP SCRIPTs displaying multiple line items in main window and displaying the totals at the end of main window and that should be displayed at the bottom of that particular page, we display them by putting the totals inside BOTTOM – ENDBOTTOM.

It displays fine, when  the line items are very less or much more to flow to a new page. But in some cases it is possible that the line items exactly fit till the end of the page and there is no place for displaying totals i.e BOTTOM-ENDBOTTOM. In such cases, SAP SCRIPT doesn’t trigger a new page because the triggered new page has empty body i.e main window with no values and hence there will be not be any totals displayed.

To handle this issue, we have to make sure that it should trigger a new page at the end of main window only in such cases.

For this, in the print program, the WRITE_FORM which is used to call the TEXT ELEMENT displaying totals in SAP script should be used as shown below.

      CALL FUNCTION ‘WRITE_FORM’
EXPORTING
element       =
‘TOTAL_AMOUNT’

         type          = ‘BOTTOM’

        IMPORTING
pending_lines = lv_pending
EXCEPTIONS
OTHERS        = 01.

In the Importing parameters we have to pass a variable to capture pending_lines, this is a Boolean value. This is set to ‘X’ if there are lines still to be displayed but there is not space or else it will be a space.

So, if we put a check after this function module, if lv_pending is set then we have to call a new page, this will do the job.

      IF lv_pending EQ ‘X’.

CALL FUNCTION ‘ZCONTROL_FORM’
EXPORTING
command         =
‘NEW-PAGE’
EXCEPTIONS
UNOPENED        =
1
UNSTARTED       =
2
OTHERS          = 3.
IF sy-subrc <> 0.

ENDIF.

ENDIF.

Since it has a new page, the totals will be displayed at the end of this page.

Hope this helps you.

1 Comment
You must be Logged on to comment or reply to a post.