cancel
Showing results for 
Search instead for 
Did you mean: 

Restricting number of line items in the main window

Former Member
0 Kudos

Hi All,

I got one script requirement like, as of now in a the output it is printing some 8 to 9 line items in the main window.But new requirement is like we need to restrict that no of items to 5 or 6.Can anybody provide me the logic with sample code for this requirement plz .

Regards,

Rakesh.

Accepted Solutions (1)

Accepted Solutions (1)

former_member188685
Active Contributor
0 Kudos

You might be calling the WRITE_FORM for main window in loop. so if the sy-tabix reaches 6or7 then exit the loop.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Find where the WRITE command for the line items is in your print program.

Add the following in the global data section

constants: c_lines_per_page type i value '5'.
data: z_lines_per_page type i.

Add the following inside the loop but BEFORE the WRITE call.

if z_lines_per_page = c_lines_per_page.
  clear z_lines_per_page.
  control function 'CONTROL_FORM'
    exporting
      command = 'NEW-PAGE'.
endif.
add 1 to z_lines_per_page.

Every 5 lines it will trigger a new page. Change the constant if you want to change the number of lines. Don't put the check after the write or you could trigger blank pages.