BP新增页签增强

1、文档说明

S4系统中,对供应商和客户的操作统一到BP中,当需要对主数据新增字段时,可以使用新增页签的办法,展示增强字段。

本文档以客户主数据增强为例,介绍BP新增页签增强。因为BP为供应商和客户共用,因此供应商的新增页签增强,也可以按照本文档实现,方法类似,注意区分。

2、代码实现

2.1、增强表字段

在KNA1表的INCL_EEW_KNA1结构中添加增强字段ZODRATE

在更新结构中也加入增强字段

BP各表新增字段的默认结构

KNA1:INCL_EEW_KNA1,INCL_EEW_KNA1_X

KNB1:INCL_EEW_KNB1,INCL_EEW_KNB1_X

KNVV:INCL_EEW_KNVV,INCL_EEW_KNVV_X

LFA1:INCL_EEW_LFA1,INCL_EEW_LFA1_X

LFB1:INCL_EEW_LFB1,INCL_EEW_LFB1_X

BUT000:INCL_EEW_BUT000-CL_EEW_BUT000,INCL_EEW_BUT000-CL_EEW_BUT000_X

2.2、创建页签函数组

创建函数组

函数组TOP

"--------------------@斌将军--------------------
FUNCTION-POOL ZSD_09.                       "MESSAGE-ID ..

* INCLUDE LZSD_09D...                        " Local class definition

TABLES : kna1.
CONSTANTS : table_name_kna1 TYPE fsbp_table_name VALUE 'KNA1'." tabname
CONSTANTS : false TYPE boole-boole VALUE ' '.
DATA : gs_kna1 TYPE kna1.
"--------------------@斌将军--------------------

创建页签屏幕9001

9001

"--------------------@斌将军--------------------
PROCESS BEFORE OUTPUT.
  MODULE status_9001.
*
PROCESS AFTER INPUT.
  MODULE user_command_9001.
"--------------------@斌将军--------------------

 屏幕流

"--------------------@斌将军--------------------
MODULE status_9001 OUTPUT.
  CALL FUNCTION 'BUS_PBO'.
ENDMODULE.
MODULE user_command_9001 INPUT.
  CALL FUNCTION 'BUS_PAI'.
ENDMODULE.
"--------------------@斌将军--------------------

函数模块:ZSD_09_EVENT_ISDAT  

"--------------------@斌将军--------------------
FUNCTION zsd_09_event_isdat.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------
  CALL FUNCTION 'CVIC_BUPA_KNA1_GET'
    IMPORTING
      e_kna1 = gs_kna1.

  kna1-zodrate = gs_kna1-zodrate.   "增强字段赋值

ENDFUNCTION.
"--------------------@斌将军--------------------

创建结构。

也可以使用标准表中附加的那个结构

函数模块:ZSD_09_EVENT_DSAVB

"--------------------@斌将军--------------------
FUNCTION ZSD_09_EVENT_DSAVB.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

MOVE-CORRESPONDING gs_kna1 TO kna1.
  CALL FUNCTION 'CVIC_BUPA_KNA1_COLLECT'
    EXPORTING
      i_subname = 'ZSSDV002_KNA1' "附加结构
      i_kna1    = kna1.

ENDFUNCTION.
"--------------------@斌将军--------------------

函数模块:ZSD_09_EVENT_XCHNG

"--------------------@斌将军--------------------
FUNCTION zsd_09_event_xchng.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  EXPORTING
*"     VALUE(E_XCHNG) TYPE  BOOLE_D
*"----------------------------------------------------------------------

  IF gs_kna1-zodrate <> kna1-zodrate.
    e_xchng = 'X'.
  ENDIF.

ENDFUNCTION.
"--------------------@斌将军--------------------

函数模块:ZSD_09_EVENT_DLVE1

"--------------------@斌将军--------------------
FUNCTION zsd_09_event_dlve1.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  CLEAR gs_kna1-zodrate.

ENDFUNCTION.
"--------------------@斌将军--------------------

函数模块:ZSD_09_PAI

"--------------------@斌将军--------------------
FUNCTION zsd_09_pai.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------
  DATA: lt_kna1 TYPE TABLE OF kna1.
  FIELD-SYMBOLS: <kna1> LIKE LINE OF lt_kna1.

  CHECK cvi_bdt_adapter=>is_direct_input_active( ) = false.
  cvi_bdt_adapter=>get_current_bp_data(
    EXPORTING
      i_table_name = table_name_kna1
    IMPORTING
      e_data_table = lt_kna1[]
  ).
  IF lt_kna1[] IS INITIAL.
    IF gs_kna1 IS NOT INITIAL.
      gs_kna1-kunnr = cvi_bdt_adapter=>get_current_customer( ).
      APPEND gs_kna1 TO lt_kna1.
    ENDIF.
  ELSE.
    READ TABLE lt_kna1 ASSIGNING <kna1> INDEX 1.
    <kna1>-zodrate = gs_kna1-zodrate.
  ENDIF.

  cvi_bdt_adapter=>data_pai(
    i_table_name = table_name_kna1
    i_data_new   = lt_kna1[]
    i_validate   = false
  ).


ENDFUNCTION.

"--------------------@斌将军--------------------

函数模块:ZSD_09_PBO

"--------------------@斌将军--------------------
FUNCTION ZSD_09_PBO.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------
DATA:lt_kna1   TYPE TABLE OF kna1.
  cvi_bdt_adapter=>data_pbo(
    EXPORTING
      i_table_name = table_name_kna1
    IMPORTING
      e_data_table = lt_kna1[]
  ).
  IF lt_kna1[] IS INITIAL.
    CLEAR gs_kna1.
  ELSE.
    READ TABLE lt_kna1 INTO gs_kna1 INDEX 1.
  ENDIF.

ENDFUNCTION.
"--------------------@斌将军--------------------

另外,可视情况而定,增加ZSD_09_DCHCK函数,增加逻辑判断,用于检查数据

2.3、供应商公司视图增强示例

增强字段

ZMM19_PBO

"--------------------@斌将军--------------------
FUNCTION zmm19_pbo.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  DATA:lt_lfb1  TYPE TABLE OF lfb1,
       lv_lifnr TYPE lfb1-lifnr,
       lv_bukrs TYPE lfb1-bukrs.

  lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
  lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
  IF lv_bukrs IS INITIAL.
    CLEAR:lfb1.
  ELSE.
    cvi_bdt_adapter=>data_pbo(
    EXPORTING
      i_table_name = table_name_lfb1
    IMPORTING
      e_data_table = lt_lfb1[]
  ).

    READ TABLE lt_lfb1 INTO lfb1 WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
    IF sy-subrc EQ 0.
      gs_lfb1 = lfb1.
    ELSE.
      CLEAR:gs_lfb1,lfb1.
    ENDIF.

  ENDIF.
ENDFUNCTION.
"--------------------@斌将军--------------------

ZMM19_PAI

"--------------------@斌将军--------------------
FUNCTION zmm19_pai.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  DATA: lt_lfb1  TYPE TABLE OF lfb1,
        lv_lifnr TYPE lfb1-lifnr,
        lv_bukrs TYPE lfb1-bukrs.

  FIELD-SYMBOLS: <lfb1> LIKE LINE OF lt_lfb1.

  CHECK cvi_bdt_adapter=>is_direct_input_active( ) = false.
  CHECK cvi_bdt_adapter=>get_current_company_code( ) IS NOT INITIAL.

  "公司代码
  lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
  lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).

  cvi_bdt_adapter=>get_current_bp_data(
    EXPORTING
      i_table_name = table_name_lfb1
    IMPORTING
      e_data_table = lt_lfb1[]
  ).
  IF lt_lfb1[] IS INITIAL.
    IF lfb1 IS NOT INITIAL.
      lfb1-lifnr = lv_lifnr.
      lfb1-bukrs = lv_bukrs.
      IF lfb1-lifnr IS NOT INITIAL AND lfb1-bukrs IS NOT INITIAL.
        APPEND lfb1 TO lt_lfb1.
      ENDIF.
    ENDIF.
  ELSE.
    READ TABLE lt_lfb1 ASSIGNING <lfb1> WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
    IF sy-subrc EQ 0.
      <lfb1>-zgmp = lfb1-zgmp.
    ENDIF.

  ENDIF.

  cvi_bdt_adapter=>data_pai(
    i_table_name = table_name_lfb1
    i_data_new   = lt_lfb1[]
    i_validate   = false
  ).

ENDFUNCTION.
"--------------------@斌将军--------------------

ZMM19_EVENT_DSAVB

"--------------------@斌将军--------------------
FUNCTION zmm19_event_dsavb.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  DATA:lt_lfb1      TYPE TABLE OF lfb1,
       ls_lfb1      TYPE lfb1,
       ls_lfb1_temp TYPE lfb1,
       lv_lifnr     TYPE lfb1-lifnr,
       lv_bukrs     TYPE lfb1-bukrs.

  lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
  CHECK lv_bukrs = '3060'.//此处可以根据具体增强的公司代码视图进行控制
  ls_lfb1 = lfb1.
  CHECK ls_lfb1 IS NOT INITIAL.

  MOVE-CORRESPONDING gs_lfb1 TO ls_lfb1_temp.
  IF lv_bukrs IS NOT INITIAL.//避免采购视图切换为公司视图时,得到的公司代码为空,并赋值给系统变量,导致后续系统缺失BUKRS而报各种错误
      ls_lfb1_temp-bukrs = lv_bukrs.
  ENDIF.
  ls_lfb1_temp-zgmp = lfb1-zgmp."是否GMP
  APPEND ls_lfb1_temp TO lt_lfb1.

  CALL FUNCTION 'CVIV_BUPA_LFB1_COLLECT'
    EXPORTING
      i_subname = 'ZMMS_LFB1' "附加结构
    TABLES
      t_lfb1    = lt_lfb1.

  lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
  lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
  READ TABLE lt_lfb1 INTO ls_lfb1 WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
  IF sy-subrc EQ 0.
    lfb1 = ls_lfb1.
    gs_lfb1 = lfb1.
  ENDIF.


ENDFUNCTION.
"--------------------@斌将军--------------------

ZMM19_EVENT_ISDAT

"--------------------@斌将军--------------------
FUNCTION zmm19_event_isdat.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  CALL FUNCTION 'CVIV_BUPA_LFB1_GET'
    IMPORTING
      e_lfb1 = gs_lfb1.

  lfb1-zgmp = gs_lfb1-zgmp.   "增强字段赋值

ENDFUNCTION.

"--------------------@斌将军--------------------

ZMM19_EVENT_XCHNG

"--------------------@斌将军--------------------
FUNCTION zmm19_event_xchng.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  EXPORTING
*"     REFERENCE(E_XCHNG) TYPE  BOOLE_D
*"----------------------------------------------------------------------

  IF gs_lfb1-zgmp <> lfb1-zgmp.
    e_xchng = 'X'.
  ENDIF.

ENDFUNCTION.
"--------------------@斌将军--------------------

ZMM19_EVENT_DLVE1

"--------------------@斌将军--------------------
FUNCTION zmm19_event_dlve1.
*"----------------------------------------------------------------------
*"*"本地接口:
*"----------------------------------------------------------------------

  CLEAR:gs_lfb1,lfb1.

ENDFUNCTION.
"--------------------@斌将军--------------------

创建屏幕

 屏幕流

"--------------------@斌将军--------------------
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
  CALL FUNCTION 'BUS_PBO'.

  DATA:lv_bukrs TYPE lfb1-bukrs.
  lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).

  LOOP AT SCREEN.
    IF screen-name+0(4) = 'LFB1'.
      IF lv_bukrs = '3060'."
        screen-active = '1'.
      ELSE.
        screen-active = '0'.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
  CALL FUNCTION 'BUS_PAI'.
ENDMODULE.
"--------------------@斌将军--------------------

3、BP配置

3.1、配置说明

新增页签涉及到配置,因此请在业务人员使用的配置client中进行,防止出现开发client和配置client中定制配置不一致,导致请求传输后覆盖业务人员配置的内容。

3.2、配置过程

BUS1

BUS23

BUS2

新建字段组,保证编号没被使用

添加字段结构

BUS3

创建视图,引入函数组

选择创建的字段组

BUS4

新增部分

关联视图

BUS5

新增屏幕

新增部分,

如果是基础视图,BUP009必输

如果是供应商的公司视图,则需要添加FI0201

否则会导致进入到增强页签时,或者点击公司代码切换时,公司代码数据显示不正常

同理,如果是供应商采购视图,则需要添加CVIV00

BUS6

创建屏幕顺序ZBPA01

新增屏幕项目,其中项目编号,要保证没被占用。例如可以到BUS7中模块方法ISDAT的事件功能模块中,查看是否有别的BP增强占用了项目号

新增顺序种类

添加屏幕顺序

添加项目到标准屏幕顺序BUP001中

BUSD

对FLCU00和FLCU01两个视图分别执行数据集、调用应用程序、屏幕顺序三种配置

 数据集

调用应用程序

屏幕顺序

重复步骤执行FLCU01

BUS7

BP标准事件调用流程图

配置对应模块方法ISDAT

配置对应模块方法DSAVB

配置对应模块方法XCHNG

配置对应模块方法DLVE1

3.3、SPRO配置

路径如下

分别进入FLCU00和FLCU01中

设置FLCU00中字段状态

FLCU01中字段状态

效果展示

4、结语

以上就是BP新增页签的介绍,希望对您有所帮助。

在总结过程中,该篇文档给予了极大的帮助和借鉴

https://zhuanlan.zhihu.com/p/621051472

定期更文,欢迎关注

 

 
 
 
 
 
 
 
 
posted @ 2024-06-02 21:10  斌将军  阅读(51)  评论(0编辑  收藏  举报