Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

explain the logic in the code

HI all,

Can anyone explain the logic in the code ?

This is to display the pages numbers in page 1 of 4

page 2 of 4

format.

i got this code in one of the forum.

if the lineno is less then 64, then why the control is not executing lines_left and its followed by statements ?

REPORT zreport_pages LINE-SIZE 80 LINE-COUNT 65(1) NO STANDARD PAGE HEADING.

DATA: imara TYPE TABLE OF mara WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

PARAMETERS: p_check TYPE c.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM get_data.

PERFORM write_report.

END-OF-PAGE.

PERFORM end_of_page.

************************************************************************

*FORM GET_DATA .

************************************************************************

FORM get_data.

SELECT * INTO CORRESPONDING FIELDS OF TABLE imara

FROM mara UP TO 315 ROWS.

ENDFORM. "get_data

************************************************************************

*FORM WRITE_REPORT .

************************************************************************

FORM write_report.

DATA: xpage(4) TYPE c.

DATA: lines_left TYPE i.

LOOP AT imara.

WRITE:/ imara-matnr.

AT LAST.

IF sy-linno < 64.

lines_left = ( sy-linct - sy-linno ) - 1.

SKIP lines_left.

sy-pagno = sy-pagno - 1.

ELSEIF sy-linno = 64.

SKIP 1.

sy-pagno = sy-pagno - 1.

ENDIF.

ENDAT.

ENDLOOP.

WRITE sy-pagno TO xpage LEFT-JUSTIFIED.

DO sy-pagno TIMES.

READ LINE 65 OF PAGE sy-index.

REPLACE '****' WITH xpage INTO sy-lisel.

MODIFY CURRENT LINE.

ENDDO.

ENDFORM. "write_report

*************************************************************************

**Form end_of_page .

*************************************************************************

FORM end_of_page.

WRITE:/32 'Test Program', AT 62 'Page:', AT 67 sy-pagno, 'of', '****'.

ENDFORM. "end_of_page

Thanks in advance

krupali

Tags:
replied

Hi KR,

This program just displays first 315 MATNR values from MARA.

Every page consists of 65 lines. At bottom of every page, page number and total page number want to be displayed.

It is checked that last page is filled or incomplete.

If incomplete, those lines are skipped, Just to display page number.

Before that at the end of every page, "PAGE NO 1 OF ****" will be displayed.

After filling last page, the 'TOTAL NUMBER OF PAGES' at the end of every page '*****' replaced by original value.

Regards,

R.Nagarajan.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question