SM30表维护视图
在BAPI:VIEW_MAINTENANCE_CALL中断点
点击上述选择页面的确定按钮,进入DEBUG界面
rangetab值
客制化程序模拟上述选择条件
PARAMETERS: p_bukrs TYPE zfit_038_hd-bukrs OBLIGATORY.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) TEXT-011 FOR FIELD p_l_kun.
PARAMETERS:p_l_kun TYPE zfit_038_hd-kunnr_sap .
SELECTION-SCREEN COMMENT 52(5) TEXT-012 FOR FIELD p_h_kun.
PARAMETERS:p_h_kun TYPE zfit_038_hd-kunnr_sap .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) TEXT-013 FOR FIELD p_l_star .
PARAMETERS:p_l_star TYPE zfit_038_hd-startdate .
SELECTION-SCREEN COMMENT 52(5) TEXT-012 FOR FIELD p_h_star .
PARAMETERS:p_h_star TYPE zfit_038_hd-startdate .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) TEXT-014 FOR FIELD p_l_over .
PARAMETERS:p_l_over TYPE zfit_038_hd-overdate .
SELECTION-SCREEN COMMENT 52(5) TEXT-012 FOR FIELD p_h_over .
PARAMETERS:p_h_over TYPE zfit_038_hd-overdate .
SELECTION-SCREEN END OF LINE.
根据上述rangetab值清单设置BAPI VIEW_MAINTENANCE_CALL TABLE参数DBA_SELLIST
CONSTANTS:
gc_view TYPE dd02v-tabname VALUE 'ZFIT_038_HD'.
DATA: gt_sellist TYPE TABLE OF vimsellist.
PERFORM frm_set_sellist.
*&---------------------------------------------------------------------*
*& Form FRM_SET_SELLIST
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_sellist .
* 获取表ZFIT_038_HD结构
DATA: lt_tab TYPE STANDARD TABLE OF dfies.
PERFORM frm_get_fieldinfo TABLES lt_tab
USING gc_view.
* 设置选择条件
CLEAR: gt_sellist.
"设置选择条件:公司
READ TABLE lt_tab TRANSPORTING NO FIELDS WITH KEY fieldname = gc_fd_1.
IF sy-subrc = 0.
DATA(lv_tabix) = sy-tabix.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_1
operator = |EQ|
value = p_bukrs
tabix = lv_tabix
converted = |X| ) ).
ENDIF.
IF p_l_kun IS NOT INITIAL OR p_h_kun IS NOT INITIAL.
READ TABLE lt_tab TRANSPORTING NO FIELDS WITH KEY fieldname = gc_fd_2.
IF sy-subrc = 0.
lv_tabix = sy-tabix.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_2
operator = COND #( WHEN p_h_kun IS INITIAL THEN |EQ|
ELSE |GE| )
value = p_l_kun
invd_value = p_l_kun
tabix = lv_tabix
converted = |X| ) ).
IF p_h_kun IS NOT INITIAL.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_2
operator = |LE|
value = p_h_kun
invd_value = p_h_kun
tabix = lv_tabix
converted = |X| ) ).
ENDIF.
ENDIF.
ENDIF.
IF p_l_star IS NOT INITIAL OR p_h_star IS NOT INITIAL.
READ TABLE lt_tab TRANSPORTING NO FIELDS WITH KEY fieldname = gc_fd_3.
IF sy-subrc = 0.
lv_tabix = sy-tabix.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_3
operator = COND #( WHEN p_h_star IS INITIAL THEN |EQ|
ELSE |GE| )
value = p_l_star
date_value = p_l_star
tabix = lv_tabix
converted = |X| ) ).
IF p_h_star IS NOT INITIAL.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_3
operator = |LE|
value = p_h_star
date_value = p_h_star
tabix = lv_tabix
converted = |X| ) ).
ENDIF.
ENDIF.
ENDIF.
IF p_l_over IS NOT INITIAL OR p_h_over IS NOT INITIAL.
READ TABLE lt_tab TRANSPORTING NO FIELDS WITH KEY fieldname = gc_fd_4.
IF sy-subrc = 0.
lv_tabix = sy-tabix.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_4
operator = COND #( WHEN p_h_over IS INITIAL THEN |EQ|
ELSE |GE| )
value = p_l_over
date_value = p_l_over
tabix = lv_tabix
converted = |X| ) ).
IF p_h_over IS NOT INITIAL.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_4
operator = |LE|
value = p_h_over
date_value = p_h_over
tabix = lv_tabix
converted = |X| ) ).
ENDIF.
ENDIF.
ENDIF.
IF p_l_no IS NOT INITIAL OR p_h_no IS NOT INITIAL.
READ TABLE lt_tab TRANSPORTING NO FIELDS WITH KEY fieldname = gc_fd_5.
IF sy-subrc = 0.
lv_tabix = sy-tabix.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_5
operator = COND #( WHEN p_h_no IS INITIAL THEN |EQ|
ELSE |GE| )
value = p_l_no
invd_value = p_l_no
tabix = lv_tabix
converted = |X| ) ).
IF p_h_no IS NOT INITIAL.
gt_sellist = VALUE #( BASE gt_sellist
( viewfield = gc_fd_5
operator = |LE|
value = p_h_no
invd_value = p_h_no
tabix = lv_tabix
converted = |X| ) ).
ENDIF.
ENDIF.
ENDIF.
DATA(lv_line) = lines( gt_sellist ).
IF lv_line GT 1.
LOOP AT gt_sellist ASSIGNING FIELD-SYMBOL(<fs_sel>)
WHERE and_or = space.
IF sy-tabix LT lv_line.
<fs_sel>-and_or = 'AND'.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_FIELDINFO
*&---------------------------------------------------------------------*
*& 获取表或结构字段信息
*&---------------------------------------------------------------------*
*& --> LT_TAB
*& --> GC_TABNAME_1
*&---------------------------------------------------------------------*
FORM frm_get_fieldinfo TABLES pt_tab STRUCTURE dfies
USING pv_tabname TYPE dd02l-tabname.
CLEAR: pt_tab,pt_tab[].
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = pv_tabname
TABLES
dfies_tab = pt_tab
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
ENDFORM.
通过BAPI调用维护视图,并传入设置的选题条件字段信息
PERFORM frm_maintain_view TABLES gt_sellist
USING gc_view.
*&---------------------------------------------------------------------*
*& Form FRM_MAINTAIN_VIEW
*&---------------------------------------------------------------------*
*& 表视图维护
*&---------------------------------------------------------------------*
*& --> P_
*&---------------------------------------------------------------------*
FORM frm_maintain_view TABLES pt_sellist STRUCTURE vimsellist
USING pv_view_name TYPE dd02v-tabname.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = 'U' "S = Display U = Change T = Transport
view_name = pv_view_name
* show_selection_popup = 'X'
TABLES
dba_sellist = pt_sellist[]
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.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/17917.html