cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in New Page Display in a SAP Script

Former Member
0 Kudos

Hi All

I have applied a line count logic in my SAP script, such that if lines are more than 32, Sub Total is displayed on this page(Sub Total needs 4 lines to display) and from next page,another heading starts. (Total around 39 lines can be displayed in one page)

Sub Total Text contains 2 lines of text, and 2 blank lines after it (Total 4 lines)

Now, if number of lines is around 36, Sub Total, doesnt fully display in this page and the 2 blank lines gets passed to the next page. And I am also firing a new page from my code. As a result, the 2nd page comes fully blank and the data is now being displayed at the 3rd page. How can I prevent the 2nd page from coming blank ??

I am using Function Module 'CONTROL_FORM' (or WRITE_FORM) to fire a new page.

I do not want to apply a line count logic for this as this wont be fool proof !!

I hope I have made the issue clear. Kindly help !!

Thanks

KP

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

First u describe the no of lines in ur table. Now, u write the condition like below:

DATA : lv_lines TYPE i,

lv_count TYPE i.

describe table itab lines lv_lines.

LOOP AT itab.

lv_count = lv_count + 1. ----> Increase the counter for each line

IF lv_lines GT '32' AND lv_lines LT '36'.

IF lv_count EQ 'XX". --->Here, give at what line u want the new page to be triggered

call function 'CONTROL_FORM'

exporting

command = 'NEW-PAGE'.

ENDIF.

ENDIF.

ENDLOOP.

Hope it helps!!

Rgds,

Pavan

Former Member
0 Kudos

Hi Pavan

Thanks for the input. However, I cannot give the upper limit of the lines (like you mentioned 36).. Do we have any other way in which we can find that the text is not fully printed and its passing on to the next page. And in this case I will not fire new page myself !! As SAP is already firing

I saw the documentation for Function Module 'WRITE_FORM', it has an importing parameter as 'PENDING_LINES', however, it says that it only works for TYPE = BOTTOM. My text is displayed in TYPE = MAIN...

Thanks

KP

Former Member
0 Kudos

Hi,

otherwise u can do one thing: U call the PERFORM in the SCRIPT FORM passing the &PAGE&(Contains the current Page No) value to it. take a loal variable and pass the PAGE value to the local variable and check for every line whether both &PAGE& & local varaiable are same, if not then set the FLAG value to 'X' (it means the new page has triggered).

Eg:

In Script:

/: lv_tabix = lv_tabix + 1.

/: PERFORM new_page_flag IN PROGRAM ZXXXXX

/: USING &PAGE&

/: USING &lv_tabix&

/: CHANGING &FLAG&

In ZXXXXX Program:

FORM new_page_flag USING int_tab STRUCTURE itcsy

CHANING out_tab STRUCTURE itcsy.

data : lv_page TYPE i,

lv1_tabix TYPE i.

READ TABLE int_tab WITH KEY name = 'LV_TABIX'.

IF sy-subrc EQ '0'.

lv1_tabix = int_tab-value.

clear : int_tab.

ENDIF.

IF lv1_tabix EQ '1'.

lv_page = '1'.

ENDIF.

READ TABLE int_tab WITH KEY name = 'PAGE'.

IF lv1_tabix GT '1'.

IF lv_page NE int_tab-value.

READ TABLE out_tab WITH KEY name = 'FLAG'.

IF sy-subrc EQ 0.

out_tab-value = 'X'.

MODIFY out_tab.

clear : out_tab.

ENDIF.

ENDIF.

ENDIF.

IF sy-subrc EQ '0'.

lv_page = int_tab-value.

ENDIF.

Hope it helps!!

Rgds,

Pavan