ABAP报表事件流

ABAP事件流

  • 六个事件流
    • 1.INITIALIZATION
    • 2.AT SELECTION-SCREEN
    • START-OF-SELECTION
    • END-OF-SELECTION
    • TOP-OF-PAGE
    • END-OF-PAGE

六个事件流

1.INITIALIZATION

初始化事件,该事件只能应用于报表程序,在进入选择屏幕之前运行,一般用于给选择屏幕的字段赋值。
如下:

*声明选择屏幕的内容
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
				p_bukrs FOR zbiao1-bukrs,    "公司代码
                p_bzdzt FOR zbiao1-bzdzt,    "报账单状态
                p_erdat FOR zbiao1-erdat,    "报账单创建日期               
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
PARAMETERS: 
			p_zjsyf TYPE zyke_qj DEFAULT sy-datum+(6) OBLIGATORY.
            r1 RADIOBUTTON GROUP r1 DEFAULT 'X' USER-COMMAND cid, "报账单查询
            r2 RADIOBUTTON GROUP r1. "报账单凭证查询
SELECTION-SCREEN END OF BLOCK b2.

*初始化开始
INITIALIZATION.
 "初始化选择界面
PERFORM frm_init_select.
FORM frm_init_select .
	DATA:  lv_datum_s TYPE sy-datum,
				lv_datum_e TYPE sy-datum.
	APPEND VALUE #( sign = 'I'  option = 'NE' low = '55' ) TO p_bzdzt.
	IF sy-datum+6(2) = '01'.
		APPEND VALUE #( sign = 'I'  option = 'EQ' low = sy-datum ) TO p_erdat.
	ELSE.
		lv_datum_s = sy-datum+(6) && '01'.
		APPEND VALUE #( sign = 'I'  option = 'BT' low = lv_datum_s high = sy-datum ) TO p_erdat.
	ENDIF.
ENDFORM.

2.AT SELECTION-SCREEN

该事件是用来对选择屏幕的操作进行交互和校验的。一般是在屏幕有输入或者改动的情况下执行。还有很多扩展语法,比如:
AT SELECTION-SCREEN ON FIELD.
经实测,选择屏幕输入所有必填字段后,回车即可触发。
点击执行按钮后,也会触发
AT SELECTION-SCREEN ON RADIOBUTTON GROUP 1.
响应屏幕上的radiobutton。
AT SELECTION-SCREEN ON BLOCK 1
框架的触发事件
以上AT SELECTION-SCREEN ON 事件的触发是根据字段在选择屏幕上的位置来的,如果有多个block,先触发block1内的字段,再触发block1,再触发block2内的字段,再触发block2.

AT SELECTION-SCREEN OUTPUT.
该事件是用来实现动态改变选择屏幕的,它会检测选择屏幕的改变,并触发。一般用来根据单选按钮的选择,实现选择屏幕内容的动态隐藏和显示。
如下:

PERFORM frm_set_screen.
*& 选择屏幕动态设置
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_set_screen .
  LOOP AT SCREEN.
    CASE abap_true.	“abap_true = 'X'.
      WHEN r1.
        IF screen-group1 =  'MD1'.
          screen-active   = '1'.
        ELSEIF screen-group1 =  'MD2'.
          screen-active   = '0'.
        ENDIF.
      WHEN r2.
        IF screen-group1 =  'MD1'.
          screen-active   = '0'.
        ELSEIF screen-group1 =  'MD2'.
          screen-active   = '1'.
        ENDIF.
      WHEN OTHERS.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.
ENDFORM.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR field
该事件可以用来为屏幕字段添加搜索帮助
如下:

*实现期间的搜索帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_zjsyf.
  "期间搜索帮助
  PERFORM frm_zjsyf_help.
  
FORM frm_zjsyf_help .
  DATA: lv_sel_month LIKE isellist-month.
  CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
    EXPORTING
      actual_month               = sy-datum+(6)
    IMPORTING
      selected_month             = lv_sel_month
    EXCEPTIONS
      factory_calendar_not_found = 1
      holiday_calendar_not_found = 2
      month_not_found            = 3
      OTHERS                     = 4.
  IF sy-subrc = 0.
    p_zjsyf = lv_sel_month.
  ENDIF.
ENDFORM.

START-OF-SELECTION

选择屏幕的at-selection-screen之后,第二屏的报表出现之前运行,用于取数据。

START-OF-SELECTION.
  "取数据
  PERFORM frm_get_data.
  "ALV显示
  PERFORM frm_alv_show.
  CALL SCREEN 0100.

END-OF-SELECTION

未测,待补充

TOP-OF-PAGE

未测,待补充

END-OF-PAGE

未测,待补充

你可能感兴趣的:(abap,sap,后端,erp)