Google Search - Blog...........

END-OF-PAGE event in reports of sap abap

This event is triggered at the end of page.

Write : / ‘page number’, sy-pagno.

In this case page number will be written on every page.

Conditional triggering of EOP

Consider the following case.

REPORT ZDEMO1 line-count 15(3).
Write: ‘this line is written by top-of-page event’.
Write: ‘this line is written by start-of-selection event’.
Write : ‘this line is written by end-of-page event’.

In this case EOP will never be triggered, as end of page is never reached. The total Line-count defined for page = 15 in which 3 lines are for footer area. The output of the above code will be

This line is written by top of page event.
This line is written by start of selection event.

In output screen, only two lines are written and cursor remains still on 3rd line, the end-of-page event is not triggered. To trigger end of page event, cursor should reach at the last position, in this case on 11th line.

Such cases are quite common, and could be overcome by conditional triggering of end of page.

Sy-linct is the system variable, which gives total line count of a list.
Sy-linno is the system variable, which gives the current line number where the cursor is placed on the list.

Consider the following case:

Report zdemo1 line count 20(1).
Data: m type i.
Write: / ‘this is first line’.
Do 5 times.
Write: / ‘the number is’, sy-index.
M = sy-linct, sy-linno – 1.
Skip x.
Write: / ‘page end’.

The output of above example is as follows :
This is first line.
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

After skipping 10 lines
Page end

In this case, with all write statement, you don’t reach to the end of page. After all write statement, m is calculated in this case:

M = 20 – 8 – 1, So m is 12. And 11 lines are skipped after write statement and end of page is reached. (In this case you have 6 write statement so 6 lines + 1 line for page number and 1 horizontal line which is displayed for any list. So cursor is on 8th line and is subtracted from total line count i.e, 20.)

No comments:

Post a Comment