zoukankan      html  css  js  c++  java
  • ABAP modify screen:修改屏幕,实现隐藏、禁止输入字段

    Loop at screen会loop处理屏幕上的每一个组件,并对其做相应的处理。

    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.
    PARAMETERS S_DATE TYPE DATUM   DEFAULT SY-DATUM MODIF ID OO.
    SELECTION-SCREEN: END OF BLOCK B1.

    SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME.
    SELECT-OPTIONS: S_DATE2 FOR SY-DATUM  MODIF ID PP.
    SELECTION-SCREEN: END OF BLOCK B2.

    SELECTION-SCREEN: BEGIN OF BLOCK B3 WITH FRAME.
    PARAMETERS : R1 RADIOBUTTON GROUP D1 DEFAULT 'X' USER-COMMAND SINGLECLICK,   

                 R2 RADIOBUTTON GROUP D1 .
    SELECTION-SCREEN: END OF BLOCK B3.

    选择r1 的时候只显示B1;r2时候只显示B2

    AT SELECTION-SCREEN OUTPUT.
      IF R1 = 'X'.
        LOOP AT SCREEN.
          IF SCREEN-GROUP1 = 'PP'.
            SCREEN-ACTIVE = '0'.
          ENDIF.
          MODIFY SCREEN.
        ENDLOOP.
      ELSEIF R2 = 'X'.
        LOOP AT SCREEN.
          IF SCREEN-GROUP1 = 'OO'.
            SCREEN-ACTIVE = '0'.
          ENDIF.
          MODIFY SCREEN.
        ENDLOOP.
      ENDIF.

    • Modiy屏幕的时候,如果屏幕有必输字段则不能修改,只有把必输项输入值后才能修改屏幕,需要有所取舍;
    • 注意:

    PARAMETERS : R1 RADIOBUTTON GROUP D1 DEFAULT 'X' USER-COMMAND SINGLECLICK,  红色这一段话必须有,否则不能动态修改屏幕;选择一次单选框就会触发一次atselection-screen output,实现动态修改屏幕.

    • SCREEN结构解释:

    在SAP屏幕中,一个字段就像.NET中的一个控件,这个 字段对应一个SCREEN结构,就像控件的多个属性。

    SE11可以查看SCREEN结构中的字段,只是没有备注。

    名称                  长度       说明

    NAME               30          屏幕字段的名称

    GROUP1            3            属于字段组1的字段

    GROUP2            3            属于字段组2的字段

    GROUP3            3            属于字段组3的字段

    GROUP4            3            属于字段组4的字段

    ACTIVE             1            可见并准备输入的字段

    REQUIRED          1            字段输入是强制的,即该值为X是表示该字段必须输入

    INPUT               1            字段准备输入

    OUTPUT            1            字段仅用于显示

    INTENSIFIED      1           高亮显示字段

    INVISIBLE          1           禁用字段

    LENGTH             1           减少字段输出长度

    DISPLAY_3D       1           以三维框架显示字段

    VALUE_HELP       1           显示有值帮助的字段  

    上述长度为1的字段,=1表示有效,=0则相反。

    转自:https://blog.csdn.net/zhongguomao/article/details/52710924

    可以参考以下

    REPORT zlongtext_up_down NO STANDARD PAGE HEADING.
    
    TABLES: crmc_text,stxh,qmel,qmsm,qmfe,qmma,qmur,stpo.
    
    DATA: fldcat          TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          slayt           TYPE slis_layout_alv,
          varnt           LIKE disvariant,
          repid           LIKE sy-repid,
          i_title         TYPE lvc_title,
          i_grid_settings TYPE lvc_s_glay.
    DATA: slines TYPE string.
    
    DATA: header LIKE thead .
    DATA: it_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
    DATA: BEGIN OF istr ,
            tdobject LIKE stxh-tdobject,"文本: 应用程序对象
            tdid     LIKE stxh-tdid,"Text ID
            tdspras  LIKE stxh-tdspras,"语言代码
            tdname   LIKE stxh-tdname,"Name
            tdformat TYPE tdformat ,"标记列
            line     TYPE tdline ,"文本行
          END OF istr.
    
    *ALV显示
    DATA: BEGIN OF itab OCCURS 0.
            INCLUDE STRUCTURE istr.
    DATA:END OF itab.
    *文本下载
    DATA:itab_d LIKE istr OCCURS  0 WITH HEADER LINE.
    DATA: BEGIN OF it_head OCCURS 0,
            tdobject LIKE stxh-tdobject,"文本: 应用程序对象
            tdid     LIKE stxh-tdid,"Text ID
            tdspras  LIKE stxh-tdspras,"语言代码
            tdname   LIKE stxh-tdname,"Name
          END OF it_head.
    DATA : catalog LIKE tcatalog OCCURS 0 WITH HEADER LINE.
    DATA: filename TYPE string,
          lf_rc    TYPE c.
    
    SELECTION-SCREEN BEGIN OF BLOCK b0   WITH FRAME TITLE t0.
    PARAMETERS: pr1 RADIOBUTTON GROUP typ0 USER-COMMAND sele DEFAULT 'X' MODIF ID m0.
    PARAMETERS: pr2 RADIOBUTTON GROUP typ0  MODIF ID m0.
    SELECTION-SCREEN END OF BLOCK b0.
    
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.
    
    SELECT-OPTIONS: s_object FOR crmc_text-r3object OBLIGATORY DEFAULT 'VBBK' MODIF ID m1 ,
                    s_tdid   FOR crmc_text-r3id MODIF ID m1 ,
                    s_tdname FOR stxh-tdname MODIF ID m1.
    PARAMETERS incstr TYPE string MODIF ID m1.
    SELECTION-SCREEN SKIP.
    PARAMETERS: p_alv RADIOBUTTON GROUP typ USER-COMMAND sele DEFAULT 'X'  MODIF ID m1.
    PARAMETERS: p_dc RADIOBUTTON GROUP typ  MODIF ID m1.
    PARAMETERS: p_dn RADIOBUTTON GROUP typ  MODIF ID m1.
    PARAMETERS: p_df RADIOBUTTON GROUP typ  MODIF ID m1.
    SELECTION-SCREEN END OF BLOCK b1.
    
    SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE t4.
    PARAMETERS: p_upc RADIOBUTTON GROUP typ2 USER-COMMAND sele DEFAULT 'X' MODIF ID m2.
    PARAMETERS: p_upa RADIOBUTTON GROUP typ2 MODIF ID m2.
    PARAMETERS: p_file LIKE ibipparms-path OBLIGATORY DEFAULT 'C:longtext.txt' MODIF ID m3 ,
                p_kong AS CHECKBOX MODIF ID m3 .
    SELECTION-SCREEN END OF BLOCK b4.
    
    
    AT SELECTION-SCREEN OUTPUT.
    
      t0 = '功能选择'.
    
      %_pr1_%_app_%-text = '导出'.
      %_pr2_%_app_%-text = '导入'.
    
      t1 = '导出功能'.
      %_p_alv_%_app_%-text = 'ALV显示'.
      %_p_dc_%_app_%-text = '复制到剪贴板'.
      %_p_dn_%_app_%-text = '保存到本地文本文件'.
      %_p_df_%_app_%-text = '保存到服务器文件'.
      %_p_alv_%_app_%-text = 'ALV显示'.
      %_s_object_%_app_%-text = '文本对象'.
      %_s_tdid_%_app_%-text   = '标识'.
      %_s_tdname_%_app_%-text = 'KEY'.
      %_incstr_%_app_%-text = '长文本包含字符串'.
    
      t4 = '导入功能'.
      %_p_upc_%_app_%-text = '数据来自剪贴板(不要复制标题)'.
      %_p_upa_%_app_%-text = '数据来自文本文件'.
      %_p_file_%_app_%-text   = '文件名'.
      %_p_kong_%_app_%-text = '允许上载长文本为空'.
    
      CLEAR:fldcat,fldcat[].
      PERFORM catlg_set USING 'TDOBJECT' '应用程序对象'(101).
      PERFORM catlg_set USING 'TDID' 'TEXT ID'(102).
      PERFORM catlg_set USING 'TDSPRAS' '语言代码'(103).
      PERFORM catlg_set USING 'TDNAME' 'NAME'(104).
      PERFORM catlg_set USING 'TDFORMAT' '标记列'(105).
      PERFORM catlg_set USING 'LINE' '文本行'(106).
    
      LOOP AT SCREEN.
        IF pr1 = 'X'.
          IF screen-group1 = 'M2' OR  screen-group1 = 'M3' .
            screen-active = '0'.
          ELSE.
            screen-active = '1'.
          ENDIF.
        ENDIF.
    
        IF pr2 = 'X' AND p_upa <> 'X'.
          IF screen-group1 = 'M1' OR screen-group1 = 'M3' .
            screen-active = '0'.
          ELSE.
            screen-active = '1'.
          ENDIF.
        ENDIF.
    
        IF pr2 = 'X' AND p_upa = 'X'.
          IF screen-group1 = 'M1'  .
            screen-active = '0'.
          ELSE.
            screen-active = '1'.
          ENDIF.
        ENDIF.
    
        MODIFY SCREEN.
      ENDLOOP.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = ' '
        IMPORTING
          file_name     = p_file.
      filename = p_file.
    
    
    
    START-OF-SELECTION.
  • 相关阅读:
    第八章:简单之美——布尔代数和搜索引擎的索引
    第六章:信息的度量和作用
    第五章:隐马尔可夫模型
    第四章谈谈中文分词
    第二章:自然语言处理———从规则到统计
    转:中文分词算法笔记
    NLTK之WordNet 接口【转】
    sentiwordnet的简单使用
    20169202 2016-2017-2 《移动平台开发实践》实验总结--七周
    20169202 2016-2017-2《移动平台》第七周学习总结
  • 原文地址:https://www.cnblogs.com/BruceKing/p/11864668.html
Copyright © 2011-2022 走看看