VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格

1、业务需求

针对用户使用销售订单时,根据定价和步骤顺序,判断是否有权限,没有权限时隐藏销售订单抬头和行项目的部分价格数据

要限制的定价和步骤在spro中的位置

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第1张图片

限制的步骤

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第2张图片

2、增强实现

2.1权限对象

创建带有定价和步骤的权限对象

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第3张图片

分配权限给需要的用户,也可用权限和代码反向控制

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第4张图片

2.2、隐藏抬头和行项目价格

隐藏抬头和行项目表格中的净值和净价字段

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第5张图片

在程序MV45AFZZ→USEREXIT_FIELD_MODIFICATION中写隐式增强

"--------------------@斌将军--------------------
FORM userexit_field_modification.

* CASE SCREEN-GROUP3.
*   WHEN '900'.
*     IF VBAK-VBTYP NE IF_SD_DOC_CATEGORY=>INQUIRY.
*       SCREEN-ACTIVE = 0.
*     ENDIF.
* ENDCASE.

* CASE SCREEN-NAME.
*   WHEN 'VBAK-VBELN'.
*     SCREEN-ACTIVE = 0.
* ENDCASE.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1)
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZSD007_VA01_PRICE.    "active version
CALL FUNCTION 'ZXX01_USER_EXITS'
  EXPORTING
    i_encode = 'SD007'
  EXCEPTIONS
    close    = 1
    OTHERS   = 2.
IF sy-subrc = 0.
  IF screen-name = 'KOMV-KBETR'
      OR screen-name = 'VBAK-NETWR'"抬头 净值
      OR screen-name = 'VBAK-WAERK'"抬头 货币
      OR screen-name = 'VBAP-NETPR'"项目 净价
      OR screen-name = 'VBAP-NETWR'."项目 净值

    AUTHORITY-CHECK OBJECT 'Z_KONH_KLS'
  ID 'ZKALSM' FIELD vbak-kalsm
  ID 'ZSTUNR' DUMMY
  ID 'ACTVT' DUMMY.
    IF sy-subrc <> 0.
      screen-active = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDIF.
ENDIF.
ENDENHANCEMENT.
*$*$-End:   (1)---------------------------------------------------------------------------------$*$*
ENDFORM.
"--------------------@斌将军--------------------

效果如下

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第6张图片

2.3、隐藏条件页签价格

还需要隐藏抬头和行项目的条件页签中的价格数据

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第7张图片

在程序中定义变量

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第8张图片

在出口处引用自定义代码

"--------------------@斌将军--------------------
*&---------------------------------------------------------------------*
*&      Form  USEREXIT_FIELD_MODIFIC_LEER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form userexit_field_modific_leer.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1)
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZSD007_SALES_PRICE.    "active version
 INCLUDE ZSD007_SALES_PRICE01.
ENDENHANCEMENT.
*$*$-End:   (1)---------------------------------------------------------------------------------$*$*

endform.                               " USEREXIT_FIELD_MODIFIC_LEER
*&---------------------------------------------------------------------*
*&      Form  USEREXIT_FIELD_MODIFIC_KZWI
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form userexit_field_modific_kzwi.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(2) 
*$*$-Start: (2)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 2  ZSD007_SALES_PRICE.    "active version
INCLUDE ZSD007_SALES_PRICE01.
ENDENHANCEMENT.
*$*$-End:   (2)---------------------------------------------------------------------------------$*$*

endform.                               " USEREXIT_FIELD_MODIFIC_KZWI
*&---------------------------------------------------------------------*
*&      Form  USEREXIT_FIELD_MODIFIC_KOPF
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form userexit_field_modific_kopf.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(3)
*$*$-Start: (3)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 3  ZSD007_SALES_PRICE.    "active version
INCLUDE ZSD007_SALES_PRICE01.
ENDENHANCEMENT.
*$*$-End:   (3)---------------------------------------------------------------------------------$*$*

endform.                               " USEREXIT_FIELD_MODIFIC_KOPF
*&---------------------------------------------------------------------*
*&      Form  USEREXIT_FIELD_MODIFICATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form userexit_field_modification.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(4) 
*$*$-Start: (4)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 4  ZSD007_SALES_PRICE.    "active version
INCLUDE ZSD007_SALES_PRICE01.
ENDENHANCEMENT.
*$*$-End:   (4)---------------------------------------------------------------------------------$*$*

endform.                               " USEREXIT_FIELD_MODIFICATION
"--------------------@斌将军--------------------

ZSD007_SALES_PRICE01

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第9张图片

 代码如下

"--------------------@斌将军--------------------
IF screen-name = 'FCODE'.
    CLEAR:old_komk.
    auth_subrc = 4.
  ENDIF.

  IF screen-name = 'RV61A-SELKZ'
      OR screen-name = 'KOMV-KAWRT'
      OR screen-name = 'RV61A-AWEIN'
      OR screen-name = 'KOMV-KBETR'
      OR screen-name = 'RV61A-KOEIN'
      OR screen-name = 'KOMV-KPEIN'
      OR screen-name = 'KOMV-KMEIN'
      OR screen-name = 'KOMV-KWERT'
      OR screen-name = 'KOMV-KUMZA'
      OR screen-name = 'RV61A-MEINS'
      OR screen-name = 'KOMV-KUMNE'
*      OR screen-name = 'KOMP-NETWR' "净值
*      OR screen-name = 'KOMK-WAERK' "货币
*      OR screen-name = 'KOMP-MWSBP' "税收
      OR screen-name = 'RV61A-KMEI1'.
"增强开关
    CALL FUNCTION 'ZXX01_USER_EXITS'
      EXPORTING
        i_encode = 'SD007'
      EXCEPTIONS
        close    = 1
        OTHERS   = 2.
    IF sy-subrc = 0.
      IF komk-kalsm NE old_komk-kalsm OR komv-stunr NE old_komv-stunr.

        AUTHORITY-CHECK OBJECT 'Z_KONH_KLS'
         ID 'ZKALSM' FIELD komk-kalsm
         ID 'ZSTUNR' FIELD komv-stunr
         ID 'ACTVT' DUMMY.

        auth_subrc = sy-subrc.

        old_komk = komk.
        old_komv = komv.
      ENDIF.

      IF auth_subrc <> 0.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDIF.
"--------------------@斌将军--------------------

效果如下

这种方法做完之后,在页签跳转之后,再回到条件页签,此处的价格就又会出现,所以需要再写下边的增强

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第10张图片

在程序LV69AF01→TCTRL_KONDITIONEN_INIT中写隐式增强

"--------------------@斌将军--------------------
FORM tctrl_konditionen_init.
  DATA: da_tfill LIKE sy-tabix.

* Refresh table control if screen number has changed
  STATICS: last_dynnr TYPE dynnr.
  IF sy-dynnr NE last_dynnr AND gf_called_by_lord IS INITIAL.
    last_dynnr = sy-dynnr.
    REFRESH CONTROL 'tctrl_konditionen' FROM SCREEN sy-dynnr.
  ENDIF.

  DESCRIBE TABLE xkomv LINES da_tfill.

......


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1)
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 6  ZSD007_SALES_PRICE.    "active version
"增强开关
CALL FUNCTION 'ZXX01_USER_EXITS'
  EXPORTING
    i_encode = 'SD007'
  EXCEPTIONS
    close    = 1
    OTHERS   = 2.
IF sy-subrc = 0.
  LOOP AT SCREEN.
    IF screen-name = 'KOMP-NETWR' "净值
          OR screen-name = 'KOMK-WAERK' "货币
          OR screen-name = 'KOMP-MWSBP'. "税收.
      AUTHORITY-CHECK OBJECT 'Z_KONH_KLS'
       ID 'ZKALSM' FIELD komk-kalsm
       ID 'ZSTUNR' DUMMY
       ID 'ACTVT' DUMMY.
      IF sy-subrc <> 0.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
ENDENHANCEMENT.
*$*$-End:   (1)---------------------------------------------------------------------------------$*$*
ENDFORM.                    "tctrl_konditionen_init
"--------------------@斌将军--------------------

到此,通过定价和步骤隐藏部分价格的增强就实现了

定期更文,欢迎关注

VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格_第11张图片

你可能感兴趣的:(ABAP,ABAP,屏幕增强)