Search on this Website

Thursday, May 15, 2008

Example of Report having all events

REPORT ZKA_REPORT MESSAGE-ID ZKA LINE-SIZE 255 LINE-COUNT 10(2).

TABLES: ZKA_EMP,ZKA_COM.

DATA: ITAB LIKE ZKA_EMP OCCURS 0 WITH HEADER LINE.

DATA: JTAB LIKE ZKA_COM OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS: EMP_NO FOR ZKA_EMP-EMPNO.

SET PF-STATUS 'ZKA_MENU'.

INITIALIZATION.


EMP_NO-LOW = '1'.

EMP_NO-HIGH = '10'.

EMP_NO-SIGN = 'I'.

EMP_NO-OPTION = 'BT'.

APPEND EMP_NO.

CLEAR EMP_NO.

AT SELECTION-SCREEN.

IF EMP_NO-LOW < '1'. MESSAGE S000(ZKA). ELSEIF EMP_NO-HIGH > '10'.

MESSAGE S001.

ENDIF.

START-OF-SELECTION.

SELECT * FROM ZKA_EMP INTO TABLE ITAB WHERE EMPNO IN EMP_NO.

LOOP AT ITAB.

WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,

29 ITAB-EMPPHONE,39 SY-VLINE.

HIDE: ITAB-EMPNO.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

TOP-OF-PAGE.

WRITE:/5 SY-ULINE(35).

WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE,

29 'EMPPHONE',39 SY-VLINE.

WRITE:/5 SY-ULINE(35).

END-OF-PAGE.

WRITE:/5 SY-ULINE(35).

WRITE:/ 'THE PAGE NO IS',SY-PAGNO.

END-OF-SELECTION.

WRITE:/ 'THE RECORD IS CLOSED'.

AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT * FROM ZKA_EMP INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT ITAB.

WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,

29 ITAB-EMPPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ELSEIF SY-LSIND = 2.

SELECT * FROM ZKA_COM INTO TABLE JTAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT JTAB.

WRITE:/5 SY-VLINE,6 JTAB-COMNO,17 SY-VLINE,18 JTAB-COMNAME,28 SY-VLINE,

29 JTAB-COMPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ENDIF.

AT PF7.

IF SY-LSIND = 1.

SELECT * FROM ZKA_EMP INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT ITAB.

WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,

29 ITAB-EMPPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ELSEIF SY-LSIND = 2.

SELECT * FROM ZKA_COM INTO TABLE JTAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT JTAB.

WRITE:/5 SY-VLINE,6 JTAB-COMNO,17 SY-VLINE,18 JTAB-COMNAME,28 SY-VLINE,

29 JTAB-COMPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ENDIF.

AT USER-COMMAND.

IF SY-UCOMM = '0001'.

IF SY-LSIND = 1.

SELECT * FROM ZKA_EMP INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT ITAB.

WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,

29 ITAB-EMPPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ELSEIF SY-LSIND = 2.

SELECT * FROM ZKA_COM INTO TABLE JTAB WHERE EMPNO = ITAB-EMPNO.

LOOP AT JTAB.

WRITE:/5 SY-VLINE,6 JTAB-COMNO,17 SY-VLINE,18 JTAB-COMNAME,28 SY-VLINE,

29 JTAB-COMPHONE,39 SY-VLINE.

ENDLOOP.

WRITE:/5 SY-ULINE(35).

ENDIF.

ENDIF.

Output is Given Below :



Other Related Link :

System fields used in interactive Reporting
Standard SAP Reports
A Complete Guide to ABAP Report
Download ABAP report Tutorial

No comments: