如何创建视图簇(View cluster)-SE54/SM34

文摘   2024-11-29 19:16   上海  

SM30通过一个表去查对应的表维护程序


本文部分转自:内容雷同不想截图··盗用先辈资料··

http://www.baidusap.com/abap/others/4576

1, 视图簇介绍

SAP系统中经常会看到有层次结构的可以维护数据的屏幕,比如Tcode OMT3:

这个其实就是视图簇(View cluster),是通过SE54将多个表维护视图按照一定的关联关系链接起来,形成层次结构,方便维护数据。

用SE93查看OMT3,看到实际上维护视图簇是调用了Tcode:SM34,而被维护的视图簇为:V_CM1

SM34

2, 视图簇创建

下面介绍一下如何创建视图簇(View cluster)。

首先通过SE11创建两个很简单的表,一个是header表放一个销售订单字段。

另一个是item表,放销售订单和行项目两个字段,然后再创建一个外键,与header表关联起来,目的是为了创建这两张表的维护视图用。

SE11接着创建维护view,

接着通过SE54创建视图簇(View cluster),点击Edit View Cluster按钮

输入view cluster名字点击创建按钮

输入short text,其他用默认的就可以,然后点击object structure

在view cluster中,输入两个创建好的table以及它们之间的关系显示顺序,如下图:

然后,选中zsm34_header行,点击field-dependence按钮生成field dependence

选中zsm34_item,点击左侧field dependence

通过外键vbeln把item和header链接起来。

最后激活

3, 视图簇数据维护

先维护header,然后选中一行数据,点击左侧item接着维护item数据。

以上。


http://www.baidusap.com/abap/others/4576



这是sm34的效果,怎么不好控制权限,界面也不好看。
这是加工后的界面。
主要用到
VIEW_RANGETAB_TO_SELLISTVIEWCLUSTER_MAINTENANCE_CALLVIEW_MAINTENANCE_CALL

显示表维护对话框的标准方法是通过 SM30,调用视图维护:

或为特定表调用 SM30 的自定义参数事务,其中参数VIEWNAMEUPDATE = 'X'

这些都不提供初始选择屏幕。可以通过选中“输入条件”单选按钮来限制条目,但用户更熟悉选择屏幕而不是弹出的对话框。因此,使用选择屏幕而不是“输入条件”单选按钮是很好的 UI。

方法是通过vimsellist来进行数据选择,然后定义正常的 SELECT-OPTIONS 选择屏幕:(VIEW_RANGETAB_TO_SELLIST)


*&---------------------------------------------------------------------**& Report ZPPD174*&---------------------------------------------------------------------**&*&   ZPPC010_INCLUDE 对应 族视图 ZPPC010*&  ZPPC010_INCLUDE_ZPPC001  对应 ZPPC001*& ZPPC010_INCLUDE_ZPPC002   对应 ZPPC002*&*&*&---------------------------------------------------------------------*REPORT ZPPC001.TABLES:T001W.TABLES:ZPPC001.TABLES:ZPPC002.DATA:GT_ZPPC001 TYPE STANDARD TABLE OF ZPPC001.DATA:GT_ZPPC002 TYPE STANDARD TABLE OF ZPPC002.SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TITLE.SELECT-OPTIONS:S_WERKS FOR ZPPC001-WERKS.SELECT-OPTIONS:S_ZRTID FOR ZPPC001-ZRTID.SELECT-OPTIONS:S_ZNAME FOR ZPPC001-ZRTNAME.SELECT-OPTIONS:S_PARTN FOR ZPPC002-PARTNER.SELECTION-SCREEN END OF BLOCK B1.PARAMETERS:P_RD1 RADIOBUTTON GROUP RAD1 DEFAULT 'X' USER-COMMAND FLAG. "PARAMETERS:P_RD2 RADIOBUTTON GROUP RAD1 . "PARAMETERS:P_RD3 RADIOBUTTON GROUP RAD1 . "INITIALIZATION.  PERFORM INIT.AT SELECTION-SCREEN.  PERFORM PAI.AT SELECTION-SCREEN OUTPUT.  PERFORM PBO.START-OF-SELECTION.  PERFORM MAIN.*&---------------------------------------------------------------------**& Form INIT*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM INIT .  TITLE = '查询条件'.  " CASE SY-TCODE.  "    WHEN 'ZPPC011'.  "      P_RD1 = 'X'.  "      P_RD2 = ''.  "      P_RD3 = ''.  "    WHEN 'ZPPC001'.  "      P_RD1 = ''.  "      P_RD2 = 'X'.  "      P_RD3 = ''.  "    WHEN 'ZPPC002'.  "      P_RD1 = ''.  "      P_RD2 = ''.  "      P_RD3 = 'X'.  "    WHEN OTHERS.  "  ENDCASE.ENDFORM.*&---------------------------------------------------------------------**& Form PAI*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM PAI .ENDFORM.*&---------------------------------------------------------------------**& Form PBO*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM PBO .ENDFORM.*&---------------------------------------------------------------------**& Form MAIN*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM MAIN .  CASE 'X'.    WHEN P_RD1.      PERFORM ZPPC010.    WHEN P_RD2.      PERFORM ZPPC001.    WHEN P_RD3.      PERFORM ZPPC002.    WHEN OTHERS.  ENDCASE.ENDFORM.*&---------------------------------------------------------------------**& Form ZPPC010*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM ZPPC010 .  DATA:LT_VIMSELLIST   TYPE STANDARD TABLE OF VIMSELLIST.  DATA:LS_VIMSELLIST   TYPE VIMSELLIST.  DATA:LT_VCL_SEL_LIST TYPE VCLTY_SELLIST_TABLE.  DATA:LS_VCL_SEL_LIST TYPE VCLTY_SELLIST_FOR_OBJECT.  DATA:LS_SEL_LIST     LIKE LINE OF LS_VCL_SEL_LIST-SELLIST.  DATA:L_FIELDNAME      TYPE VIMSELLIST-VIEWFIELD.  DATA:L_VIEWCLUSTER_NAME  LIKE  VCLDIR-VCLNAME.  L_VIEWCLUSTER_NAME = 'ZPPC010'.  CLEAR:LS_VCL_SEL_LIST-SELLIST.  LS_VCL_SEL_LIST-OBJECT = 'ZPPC001'.  CLEAR:LT_VIMSELLIST.  L_FIELDNAME = 'WERKS'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_WERKS.  L_FIELDNAME = 'ZRTID'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZRTID.  L_FIELDNAME = 'ZRTNAME'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZNAME.  APPEND LINES OF LT_VIMSELLIST TO LS_VCL_SEL_LIST-SELLIST.  APPEND LS_VCL_SEL_LIST TO LT_VCL_SEL_LIST.  CLEAR:LS_VCL_SEL_LIST-SELLIST.  LS_VCL_SEL_LIST-OBJECT = 'ZPPC002'.  CLEAR:LT_VIMSELLIST.  L_FIELDNAME = 'ZRTID'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZRTID.  L_FIELDNAME = 'PARTNER'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_PARTN.  APPEND LINES OF LT_VIMSELLIST TO LS_VCL_SEL_LIST-SELLIST.  APPEND LS_VCL_SEL_LIST TO LT_VCL_SEL_LIST.  CALL FUNCTION 'VIEWCLUSTER_MAINTENANCE_CALL'    EXPORTING      VIEWCLUSTER_NAME             = L_VIEWCLUSTER_NAME      MAINTENANCE_ACTION           = 'S'    TABLES      "*     DBA_SELLIST                  = LT_VIMSELLIST      DBA_SELLIST_CLUSTER          = LT_VCL_SEL_LIST    EXCEPTIONS      CLIENT_REFERENCE             = 1      FOREIGN_LOCK                 = 2      VIEWCLUSTER_NOT_FOUND        = 3      VIEWCLUSTER_IS_INCONSISTENT  = 4      MISSING_GENERATED_FUNCTION   = 5      NO_UPD_AUTH                  = 6      NO_SHOW_AUTH                 = 7      OBJECT_NOT_FOUND             = 8      NO_TVDIR_ENTRY               = 9      NO_CLIENTINDEP_AUTH          = 10      INVALID_ACTION               = 11      SAVING_CORRECTION_FAILED     = 12      SYSTEM_FAILURE               = 13      UNKNOWN_FIELD_IN_DBA_SELLIST = 14      MISSING_CORR_NUMBER          = 15      OTHERS                       = 16.ENDFORM.*&---------------------------------------------------------------------**& Form ZPPC001*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM ZPPC001 .  DATA: L_VIEW_NAME LIKE  DD02V-TABNAME.  DATA:LT_VIMSELLIST   TYPE STANDARD TABLE OF VIMSELLIST.  DATA:LS_VIMSELLIST   TYPE VIMSELLIST.  DATA:L_FIELDNAME      TYPE VIMSELLIST-VIEWFIELD.  L_VIEW_NAME = 'ZPPC001'.  "*  GS_VIMSELLIST-VIEWFIELD  = 'MATNR'.  "*  GS_VIMSELLIST-OPERATOR   = 'EQ'.  "*  GS_VIMSELLIST-VALUE    = GS_ZMM_MAT_DESC-MATNR.  "*  GS_VIMSELLIST-AND_OR    = 'OR'.  "*  APPEND LS_VIMSELLIST TO LT_VIMSELLIST.  L_FIELDNAME = 'WERKS'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_WERKS.  L_FIELDNAME = 'ZRTID'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZRTID.  L_FIELDNAME = 'ZRTNAME'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZNAME.  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'    EXPORTING      ACTION                       = 'S'      VIEW_NAME                    = L_VIEW_NAME    TABLES      DBA_SELLIST                  = LT_VIMSELLIST    EXCEPTIONS      CLIENT_REFERENCE             = 1      FOREIGN_LOCK                 = 2      INVALID_ACTION               = 3      NO_CLIENTINDEPENDENT_AUTH    = 4      NO_DATABASE_FUNCTION         = 5      NO_EDITOR_FUNCTION           = 6      NO_SHOW_AUTH                 = 7      NO_TVDIR_ENTRY               = 8      NO_UPD_AUTH                  = 9      ONLY_SHOW_ALLOWED            = 10      SYSTEM_FAILURE               = 11      UNKNOWN_FIELD_IN_DBA_SELLIST = 12      VIEW_NOT_FOUND               = 13      MAINTENANCE_PROHIBITED       = 14      OTHERS                       = 15.  IF SY-SUBRC <> 0.    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  ENDIF.ENDFORM.*&---------------------------------------------------------------------**& Form ZPPC002*&---------------------------------------------------------------------**& text*&---------------------------------------------------------------------**& -->  p1        text*& <--  p2        text*&---------------------------------------------------------------------*FORM ZPPC002 .  DATA: L_VIEW_NAME LIKE  DD02V-TABNAME.  DATA:LT_VIMSELLIST   TYPE STANDARD TABLE OF VIMSELLIST.  DATA:LS_VIMSELLIST   TYPE VIMSELLIST.  DATA:L_FIELDNAME      TYPE VIMSELLIST-VIEWFIELD.  L_VIEW_NAME = 'ZPPC002'.  "*  GS_VIMSELLIST-VIEWFIELD  = 'MATNR'.  "*  GS_VIMSELLIST-OPERATOR   = 'EQ'.  "*  GS_VIMSELLIST-VALUE    = GS_ZMM_MAT_DESC-MATNR.  "*  GS_VIMSELLIST-AND_OR    = 'OR'.  "*  APPEND LS_VIMSELLIST TO LT_VIMSELLIST.  L_FIELDNAME = 'PARTNER'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_PARTN.  L_FIELDNAME = 'ZRTID'.  CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST'    EXPORTING      FIELDNAME          = L_FIELDNAME      APPEND_CONJUNCTION = 'AND'    TABLES      SELLIST            = LT_VIMSELLIST      RANGETAB           = S_ZRTID.  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'    EXPORTING      ACTION                       = 'U'      VIEW_NAME                    = L_VIEW_NAME    TABLES      DBA_SELLIST                  = LT_VIMSELLIST    EXCEPTIONS      CLIENT_REFERENCE             = 1      FOREIGN_LOCK                 = 2      INVALID_ACTION               = 3      NO_CLIENTINDEPENDENT_AUTH    = 4      NO_DATABASE_FUNCTION         = 5      NO_EDITOR_FUNCTION           = 6      NO_SHOW_AUTH                 = 7      NO_TVDIR_ENTRY               = 8      NO_UPD_AUTH                  = 9      ONLY_SHOW_ALLOWED            = 10      SYSTEM_FAILURE               = 11      UNKNOWN_FIELD_IN_DBA_SELLIST = 12      VIEW_NOT_FOUND               = 13      MAINTENANCE_PROHIBITED       = 14      OTHERS                       = 15.  IF SY-SUBRC <> 0.    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  ENDIF.ENDFORM.











曰天曰地
我要到哪里去↔️ 灵台方寸山,斜月三星洞。假如有一天全人类不存在,怎么证明人类存在过。AI怎么考古?会怎么考古⚠️
 最新文章