Pada bagian ini kita akan membuat program yang menggunakan kriteria atau semacan filter sebelum menampilkan data, tujuannya supaya data yang kita inginkan tidak semuanya tampil hanya data tertentu saja berdasarkan kriteria yg kita masukkan.
Seperti sebelumnya sebagai latihan kita akan menggunakan Table Sbook.
Screen Kriteria
Source unntuk membuat screen seperti diatas
TABLES SBOOK.
SELECTION-SCREEN BEGIN OF BLOCK ESI WITH FRAME TITLE TEXT-010.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: SO_CARR FOR SBOOK-CARRID.
SELECT-OPTIONS: SO_FLDT FOR SBOOK-FLDATE.
SELECT-OPTIONS: SO_CLSS FOR SBOOK-CLASS.
*SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK ESI.
Screen Hasil Akhir
Source untuk menampilkan
SELECT * FROM SBOOK WHERE CARRID IN SO_CARR
AND FLDATE IN SO_FLDT
AND CLASS IN SO_CLSS.
WRITE :/2 SBOOK-BOOKID,
16 SBOOK-CARRID,
26 SBOOK-FLDATE,
38 SBOOK-CUSTOMID,
50 SBOOK-CLASS,
59 SBOOK-ORDER_DATE,
71 SBOOK-PASSNAME.
ENDSELECT.
Pada hasil akhir, pada bagian atas ada semacam header. untuk header saja source codenya
*----------------------------------------------------------------------*
* FORM TOP-OF-PAGE *
*----------------------------------------------------------------------*
FORM TOP-OF-PAGE.
WRITE:/1 'Report ID : ', SY-REPID,
33 'LATIHAN ABAP 02',
67 'Date: ', SY-DATUM.
WRITE:/1 'User ID : ', SY-UNAME,
33 'SBOOK LIST',
67 'Page: ', SY-PAGNO LEFT-JUSTIFIED.
* SKIP 1.,
PERFORM HEADER_DESC.
ENDFORM. "top-of-page
*----------------------------------------------------------------------*
* FORM HEADER_DESC *
*----------------------------------------------------------------------*
FORM HEADER_DESC.
ULINE /(86).
WRITE: /1 SY-VLINE,
2 'BOOK ID', 14 SY-VLINE,
16 'CARRID', 24 SY-VLINE,
26 'FLDATE', 36 SY-VLINE,
38 'CUSTOMID', 48 SY-VLINE,
50 'CLASS', 57 SY-VLINE,
59 'ORDER_DATE', 69 SY-VLINE,
71 'PASSNAME', 86 SY-VLINE.
ULINE /(86).
ENDFORM. "header_desc
--------------
Source gabungannya adalah
REPORT ZABAP03
LINE-COUNT 55(0).
TABLES SBOOK.
SELECTION-SCREEN BEGIN OF BLOCK ESI WITH FRAME TITLE TEXT-010.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: SO_CARR FOR SBOOK-CARRID.
SELECT-OPTIONS: SO_FLDT FOR SBOOK-FLDATE.
SELECT-OPTIONS: SO_CLSS FOR SBOOK-CLASS.
*SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK ESI.
SELECT * FROM SBOOK WHERE CARRID IN SO_CARR
AND FLDATE IN SO_FLDT
AND CLASS IN SO_CLSS.
WRITE :/2 SBOOK-BOOKID,
16 SBOOK-CARRID,
26 SBOOK-FLDATE,
38 SBOOK-CUSTOMID,
50 SBOOK-CLASS,
59 SBOOK-ORDER_DATE,
71 SBOOK-PASSNAME.
ENDSELECT.
TOP-OF-PAGE.
PERFORM TOP-OF-PAGE.
END-OF-PAGE.
*----------------------------------------------------------------------*
* FORM TOP-OF-PAGE *
*----------------------------------------------------------------------*
FORM TOP-OF-PAGE.
WRITE:/1 'Report ID : ', SY-REPID,
33 'LATIHAN ABAP 02',
67 'Date: ', SY-DATUM.
WRITE:/1 'User ID : ', SY-UNAME,
33 'SBOOK LIST',
67 'Page: ', SY-PAGNO LEFT-JUSTIFIED.
* SKIP 1.,
PERFORM HEADER_DESC.
ENDFORM. "top-of-page
*----------------------------------------------------------------------*
* FORM HEADER_DESC *
*----------------------------------------------------------------------*
FORM HEADER_DESC.
ULINE /(86).
WRITE: /1 SY-VLINE,
2 'BOOK ID', 14 SY-VLINE,
16 'CARRID', 24 SY-VLINE,
26 'FLDATE', 36 SY-VLINE,
38 'CUSTOMID', 48 SY-VLINE,
50 'CLASS', 57 SY-VLINE,
59 'ORDER_DATE', 69 SY-VLINE,
71 'PASSNAME', 86 SY-VLINE.
ULINE /(86).
ENDFORM. "header_desc