在螢幕上多項選擇示例(More on selection screens)

TolyHuang發表於2007-12-07
程式程式碼:[@more@]

*&---------------------------------------------------------------------*
*& Report ZPROG02
*&
*&---------------------------------------------------------------------*
*& Demo 2 - More on selection screens
*&
*&---------------------------------------------------------------------*

REPORT ZPROG02.

**********************************
*Define Tables
**********************************
TABlES: MARA.

**********************************
*Input Screen
**********************************

**** First Block
SELECTION-SCREEN BEGIN OF BLOCK a001 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: s_date FOR SY-DATUM.
SELECTION-SCREEN END OF BLOCK a001.

SELECTION-SCREEN SKIP 1.

**** Second Block
SELECTION-SCREEN BEGIN OF BLOCK b001 WITH FRAME TITLE text-t02.
PARAMETERS: P_WK RADIOBUTTON GROUP OPT DEFAULT 'X'.
PARAMETERS: P_DY RADIOBUTTON GROUP OPT.

SELECTION-SCREEN SKIP 1.

PARAMETERS: P_SERVER AS CHECKBOX DEFAULT ' '.
PARAMETERS: P_DATE1 LIKE SY-DATUM.

SELECTION-SCREEN SKIP 1.

PARAMETERS: P_LOCAL AS CHECKBOX DEFAULT 'X'.
PARAMETERS: P_DATE2 LIKE SY-DATUM.
SELECTION-SCREEN END OF BLOCK b001.


**********************************
*Declare variable
**********************************
DATA: f_sum TYPE i,
f_v1(3) TYPE c,
f_v2(5) TYPE p DECIMALS 2.

**********************************
*At selection Screen
**********************************
AT SELECTION-SCREEN.

** FILL THE DATE WHEN THE DATE FIELD IS INITIAL
if P_SERVER = 'X' and P_DATE1 is INITIAL.
P_DATE1 = '20060101'.
endif.

** WARNING IF DATE FIELD IS INITIAL.
if P_LOCAL = 'X' and P_DATE2 is INITIAL.
MESSAGE ID 'ZZ' TYPE 'W' NUMBER '000'
WITH 'You must enter date range'.
endif.

** BLOCK FOR INPUT IF A OPTION IS NOT SET
AT SELECTION-SCREEN OUTPUT.
IF P_SERVER = ' '.
LOOP AT SCREEN.
CASE SCREEN-NAME.
WHEN 'P_DATE1'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
**********************************
*Start of selection
**********************************
START-OF-SELECTION.
** Calculation

END-OF-SELECTION.


**********************************
*Output result
**********************************
* Print out

if P_WK = 'X'.
WRITE: / 'Weekly report is output..'.
else.
WRITE: / 'Daily report is output..'.
endif.

if P_SERVER = 'X'.
WRITE: / 'Report has been downloaded to server..'.
endif.

if P_LOCAL = 'X'.
WRITE: / 'Report has been downloaded to local file..'.
endif.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-989471/,如需轉載,請註明出處,否則將追究法律責任。

相關文章