ABAP选择屏幕变量赋值
运行效果:
代码:
************************************************************************
* Program Name :
* Descriptions :
* T-Code :
* Updates Tables :
* Input Parameters :
* Output Parameters :
* Return Codes :
* Special Logic :
* Includes :
************************************************************************
* Modification Log
************************************************************************
* Date Ver. Programmer Descriptions
* -------- ---- ------------ -------------------------------------------
* 2011 01.01 Original Create
*
************************************************************************
REPORT ZMMRTEST.
***********************************************************************
* Tables Definitions
************************************************************************
*TABLES:.
************************************************************************
TABLES: mard.
* Data Definitions
************************************************************************ ************************************************************************
* Includes Module
************************************************************************ ************************************************************************
* Selection Screen
************************************************************************
PARAMETERS: p_werks LIKE marc-werks DEFAULT ''.
SELECT-OPTIONS: s_date FOR sy-datum, "日期范围
s_matnr FOR mard-matnr,
s_lgort FOR mard-lgort. ************************************************************************
* Initialization
************************************************************************
INITIALIZATION.
PERFORM screen_data.
************************************************************************
* At Selection Screen
************************************************************************
AT SELECTION-SCREEN. ************************************************************************
* At Selection Screen Output
************************************************************************
AT SELECTION-SCREEN OUTPUT. ************************************************************************
* Report Format
************************************************************************
TOP-OF-PAGE. END-OF-PAGE.
************************************************************************
* Main Process
************************************************************************
START-OF-SELECTION. END-OF-SELECTION. FORM screen_data.
DATA: lt_mdlg LIKE mdlg occurs WITH HEADER LINE. DATA: l_firstday_tm TYPE sy-datum, "本月第一天
l_lastday_lm TYPE sy-datum, "上个月最后一天
l_firstday_lm TYPE sy-datum. "上个月第一天 CONCATENATE sy-datum+() '' INTO l_firstday_tm.
l_lastday_lm = l_firstday_tm - .
CONCATENATE l_lastday_lm+() '' INTO l_firstday_lm. "上个月范围
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-low = l_firstday_lm.
s_date-high = l_lastday_lm.
APPEND s_date.CLEAR s_date. "单一值物料
s_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
s_matnr-low = 'ATBA3002-XX'.
APPEND s_matnr.CLEAR s_matnr. s_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
s_matnr-low = 'C60011-14-BT'.
APPEND s_matnr.CLEAR s_matnr. IF p_werks = ''.
SELECT * INTO TABLE lt_mdlg
FROM mdlg
WHERE berid = '2000_ND'.
ELSEIF p_werks = ''.
SELECT * INTO TABLE lt_mdlg
FROM mdlg
WHERE berid = '3000_ND'.
ENDIF. "不包含单一值
LOOP AT lt_mdlg.
s_lgort-sign = 'E'.
s_lgort-option = 'EQ'.
s_lgort-low = lt_mdlg-lgort.
APPEND s_lgort.CLEAR s_lgort.
ENDLOOP. ENDFORM.