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 break in different pages with multiple line items in SAP SCRIPT

SwarnaliBasu
Participant
0 Kudos
106

Hi All

I have a requirement where my 1st page will print 10 records and from 2nd page onwards it will print 25 records.

The leftovers will move to last page.

For eg. if I have 75 line items, then 1st page will have 10 records, 2nd page will have 25 records, 3rd page will have 25 records, last page:15 records.

for 1st page I have written the code as: But I need to modify the code as the above logic, Please help

<code>*increase the no of records
st_index = st_index + 1.



if st_index eq 11.
**deduce acc to page numbers
*total of the line items
CALL FUNCTION 'WRITE_FORM'
       EXPORTING
         element                  = c_e_tbl_pg_total "PAGE_TOTAL'
         function                 = c_f_set          " 'SET'
         type                     = c_t_body         " 'BODY'
         window                   = c_w_main         " 'MAIN'
*     IMPORTING
*       PENDING_LINES            =
       EXCEPTIONS
         element                  = 1
         function                 = 2
         type                     = 3
         unopened                 = 4
         unstarted                = 5
         window                   = 6
         bad_pageformat_for_print = 7
         spool_error              = 8
         codepage                 = 9
         OTHERS                   = 10.
     IF sy-subrc NE 0.
       err_element-fname = t042e-zforn.
       err_element-fenst = c_w_main.                 " 'MAIN'
       err_element-elemt = c_e_tbl_items.            " 'TBL_ITEMS'
*     Create masssage in readable form
       CALL FUNCTION 'FORMAT_MESSAGE'
         EXPORTING
           id        = sy-msgid
           lang      = sy-langu
           no        = sy-msgno
           v1        = sy-msgv1
           v2        = sy-msgv2
           v3        = sy-msgv3
           v4        = sy-msgv4
         IMPORTING
           msg       = err_element-text
         EXCEPTIONS
           not_found = 1
           OTHERS    = 2.
       COLLECT err_element.
     ENDIF.
**start a new page
     CALL FUNCTION 'CONTROL_FORM'
       EXPORTING
         COMMAND         = c_newpage
      EXCEPTIONS
        UNOPENED        = 1
        UNSTARTED       = 2
        OTHERS          = 3
               .
     IF SY-SUBRC <> 0.
        err_element-fname = t042e-zforn.
       err_element-fenst = c_w_main.                 " 'MAIN'
       err_element-elemt = c_e_tbl_items.            " 'TBL_ITEMS'
*     Create masssage in readable form
       CALL FUNCTION 'FORMAT_MESSAGE'
         EXPORTING
           id        = sy-msgid
           lang      = sy-langu
           no        = sy-msgno
           v1        = sy-msgv1
           v2        = sy-msgv2
           v3        = sy-msgv3
           v4        = sy-msgv4
         IMPORTING
           msg       = err_element-text
         EXCEPTIONS
           not_found = 1
           OTHERS    = 2.
       COLLECT err_element.    ENDIF.
       ST_INDEX = 1.
       CLEAR st_sum.

ENDIF.</code>

5 REPLIES 5

Former Member
0 Kudos
72

Hi

I thinlk you needs only two pages the FIRST and NEXT:

- the MAIN in the first has to be sized in order to print max 15 rows

- the MAIN in  the next has to be sized in order to print max 25 rows

Max

0 Kudos
72

Hi Max

Thanks for the reply..But can you specify how can I limit them,

I have 2 pages MAIN and NEXT

0 Kudos
72

Hi

It depends on the size of the main in the page, you can set the high of main in order to print max a certain number of rows (so items).

In this way you don't need the abap control, but the system automatically will print the first page with 15 row and the next with 25

0 Kudos
72

Hi Max

By that way the other windows are hidden. Is there any other way we can control this?

0 Kudos
72

Hidden? Why?

I suppose your first page has to be arranged in order to print 15 row and the next in order to print 25, so why the others windows will be hiddend:

I mean the MAIN of the next page has to be higher of the MAIN in the first one

The other windows won't be hidden else it means your pages are not drawn correctly.

Max