目录
一:要件定义:
二,具体代码:
三,测试结果:
一:要件定义:
二,具体代码:
*&---------------------------------------------------------------------*
*& Report Z_LIU_20240701_TEST
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_LIU_20240701_TEST.
DATA : GV_BUKRS TYPE BUKRS, "定义项目类型
GV_BELNR TYPE BELNR_D,
GV_GJAHR TYPE GJAHR,
GV_BLART TYPE BLART,
GV_BLDAT TYPE BLDAT,
GV_BUDAT TYPE BUDAT,
GV_LIFNR TYPE LIFNR,
GV_LAND1 TYPE LAND1,
GV_NAME1 TYPE NAME1,
GV_PSTLZ TYPE PSTLZ.
SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME TITLE TEXT-B01. "做一个大框定义B01命名为:期間
SELECTION-SCREEN BEGIN OF LINE. "放同一行里
SELECTION-SCREEN COMMENT 1(20) TEXT-C01 FOR FIELD P_KIKANN. "定义C01 命名レポート期間
PARAMETERS P_KIKANN TYPE CHAR20 DEFAULT '対象の時間'. "添加初始值:対象の時間
SELECTION-SCREEN POSITION 55. "从第55位开始
SELECT-OPTIONS S_DATA FOR SY-DATLO.
SELECTION-SCREEN END OF LINE. "结束同一行
SELECTION-SCREEN END OF BLOCK BK1.
SELECTION-SCREEN BEGIN OF BLOCK BK2 WITH FRAME TITLE TEXT-B02. "做一个大框定义B02命名为:选择选项
SELECTION-SCREEN BEGIN OF LINE. "放同一行里
SELECTION-SCREEN COMMENT 1(20) TEXT-C02 FOR FIELD RB_KAKE. "定义C02 命名会計期間画面
PARAMETERS RB_KAKE TYPE CHAR1 RADIOBUTTON GROUP GP1 USER-COMMAND US1 DEFAULT 'X'. "单选按钮 rb_kake
SELECTION-SCREEN END OF LINE. "结束同一行
SELECTION-SCREEN BEGIN OF LINE. "放同一行里
SELECTION-SCREEN COMMENT 1(20) TEXT-C03 FOR FIELD RB_SIRE. "定义C03 命名仕入先画面
PARAMETERS RB_SIRE TYPE CHAR1 RADIOBUTTON GROUP GP1. "单选按钮 rb_sire
SELECTION-SCREEN END OF LINE. "结束同一行
SELECTION-SCREEN END OF BLOCK BK2.
SELECTION-SCREEN BEGIN OF BLOCK BK3 WITH FRAME TITLE TEXT-B03. "做一个大框定义B02命名为:選択基準
SELECT-OPTIONS : S_BUKRS FOR GV_BUKRS MODIF ID ET1,
S_BELNR FOR GV_BELNR MODIF ID ET1,
S_GJAHR FOR GV_GJAHR MODIF ID ET1 NO-EXTENSION, "不带复数选择
S_BLART FOR GV_BLART MODIF ID ET1 NO-EXTENSION, "不带复数选择
S_BLDAT FOR GV_BLDAT MODIF ID ET1 NO-EXTENSION, "不带复数选择
S_BUDAT FOR GV_BUDAT MODIF ID ET1 NO-EXTENSION, "不带复数选择
S_LIFNR FOR GV_LIFNR MODIF ID ET2,
S_LAND1 FOR GV_LAND1 MODIF ID ET2,
S_NAME1 FOR GV_NAME1 MODIF ID ET2,
S_PSTLZ FOR GV_PSTLZ MODIF ID ET2 NO INTERVALS. "不带区间选项,有复数选择
SELECTION-SCREEN END OF BLOCK BK3.
INITIALIZATION.
PERFORM F_INITION. "创建子程序
AT SELECTION-SCREEN OUTPUT. "做选择帮助
PERFORM F_SCREEN_PBO. "创建一个控制
AT SELECTION-SCREEN.
PERFORM F_CHECK_DATA.
*&---------------------------------------------------------------------*
*& Form F_INITION
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_INITION .
*付初始值
DATA: LV_DATE_LOW TYPE SY-DATUM,
LV_DATE_HIGH TYPE SY-DATUM,
LV_MONTH TYPE N LENGTH 2,
LV_YEAR TYPE N LENGTH 4.
* 获取当前日期
LV_DATE_LOW = SY-DATLO.
LV_YEAR = LV_DATE_LOW(4).
LV_MONTH = LV_DATE_LOW+4(2).
* 设置月初
CONCATENATE LV_YEAR LV_MONTH '01' INTO S_DATA-LOW.
* 设置月末
CASE LV_MONTH.
WHEN '01' OR '03' OR '05' OR '07' OR '08' OR '10' OR '12'.
CONCATENATE LV_YEAR LV_MONTH '31' INTO S_DATA-HIGH.
WHEN '04' OR '06' OR '09' OR '11'.
CONCATENATE LV_YEAR LV_MONTH '30' INTO S_DATA-HIGH.
WHEN '02'.
IF ( LV_YEAR MOD 4 = 0 AND LV_YEAR MOD 100 <> 0 ) OR ( LV_YEAR MOD 400 = 0 ).
CONCATENATE LV_YEAR LV_MONTH '29' INTO S_DATA-HIGH.
ELSE.
CONCATENATE LV_YEAR LV_MONTH '28' INTO S_DATA-HIGH.
ENDIF.
ENDCASE.
* 添加到内表
APPEND S_DATA.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_SCREEN_PBO
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_SCREEN_PBO.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_KIKANN'.
SCREEN-INPUT = 0.
ENDIF.
IF RB_KAKE = ABAP_ON AND SCREEN-GROUP1 = 'ET2'. "检查变量RB_KAKE是否等于ABAP_ON(假设ABAP_ON是一个特定的值或标志,表明某个条件为真)
"检查当前迭代的屏幕元素是否属于分组'ET2'。
SCREEN-ACTIVE = 0.
ENDIF.
IF RB_SIRE = ABAP_ON AND SCREEN-GROUP1 = 'ET1'."如果上述两个条件都满足,将当前屏幕元素的ACTIVE属性设置为0(禁用该元素)。
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN. "将对SCREEN内表所做的修改应用到实际屏幕上。
ENDLOOP. "结束对SCREEN内表的迭代。
ENDFORM. "结束FORM子程序定义。
*&---------------------------------------------------------------------*
*& Form F_CHECK_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM F_CHECK_DATA .
IF S_BLDAT-LOW NOT IN S_DATA "空的会报错,如果不空就不会报错。
AND S_BLDAT-LOW IS NOT INITIAL.
SET CURSOR FIELD 'S_BLDAT-LOW'. "定义光标,起到一个提示的效果
MESSAGE E001(ZMESSAGEFU) WITH S_BLDAT-LOW . "如果日期不在这个范围内,就会报错。
ENDIF.
ENDFORM.
三,测试结果:
相关操作常用参数:SAP ABAP 常用的参数-CSDN博客
创作不易,请点赞关注支持一下,多谢,多谢!!!