”获取数据子程序
FORM get_DAta .
select a~matnr,a~MEINS,b~maktx
from mara as a inner join makt as b
on a~matnr=b~MATNR where a~ZMATNR=@p_p1 into table @data(lt_outdata) .
ENDFORM .
*展示alv 子程序 直接复制
FORM diaplay_data .
PERFORM set_alv_layout. “样式设定
PERFORM bulid_fieldcat. “格式设定
PERFORM call_alv_func. “alv 函数
ENDFORM.
“样式设定 直接复制
FORM set_alv_layout .
CLEAR: wa_layout.
wa_layout-zebra=’X’. “斑马线
wa_layout-cwidth_opt=’X’. “自动列宽
ENDFORM.
“格式设定 固定换数
FORM bulid_fieldcat .
DEFINE add_col.
* ADD 1 TO pos.
* lw_fieldcat-col_pos=pos.
wa_fieldcat-fieldname=&1.
wa_fieldcat-ref_field=&2.
wa_fieldcat-ref_table=&3.
wa_fieldcat-scrtext_l=&4.
wa_fieldcat-outputlen=&5.
wa_fieldcat-no_zero=&6.
wa_fieldcat-edit=&7.
wa_fieldcat-edit_mask=&8.
wa_fieldcat-key=&9.
CASE wa_fieldcat-fieldname.
WHEN ‘slbox’.
wa_fieldcat-checkbox=’X’ .
wa_fieldcat-edit=’X’ .
wa_fieldcat-edit_mask=’X’.
WHEN OTHERS.
ENDCASE .
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR : wa_fieldcat.
END-OF-DEFINITION.
REFRESH: gt_fieldcat.
“add_col ‘matnr’ space space ‘物料号’ space space space space space.
add_col ‘MEINS’ space space ‘单位’ space space space space space.
add_col ‘maktx’ space space ‘物料名’ space space space space space.
ENDFORM.
“刷新 固定复制
FORM refresh_alv .
DATA: lo_grid TYPE REF TO cl_gui_alv_grid,
lw_stable TYPE lvc_s_stbl.
CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
IMPORTING
e_grid=lo_grid.
lw_stable-row=’X’.
lw_stable-col=’X’.
lo_grid->refresh_table_display(
EXPORTING
is_stable=lw_stable
EXCEPTIONS
finished=1
OTHERS=2 ).
ENDFORM.
“固定,只需要传内表就行
FORM call_alv_func .
gs_glay-edt_cll_cb=abap_true. ” 选中复选款,立刻触发data changed 事件
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program=sy-repid “回调程序
i_callback_pf_status_set=’SET_PF_STATUS’
i_callback_user_command=’USER_COMMAND’
i_grid_settings=gs_glay
is_layout_lvc =wa_layout
it_fieldcat_lvc=gt_fieldcat “需要显示的内表的列
i_save =’A’
TABLES
t_outtab =lt_outdata “需要显示的数据
EXCEPTIONS
program_error =1
OTHERS =2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
“staus 工具栏 直接复制
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
DATA : lw_tab LIKE LINE OF rt_extab.
REFRESH rt_extab.
SET PF-STATUS ‘STD’ EXCLUDING rt_extab.
ENDFORM.
“用户事件 ,这里没写. 但是如果设定函数双击会apap dump
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
* 导入
WHEN ‘&IMPLE’.
ENDCASE.
ENDFORM.
“权限检查,按照不同的情况调用不同的函数,这里需要更换.
*&———————————————————————*
*& Form check_auth
*&———————————————————————*
*& text
*&———————————————————————*
*& –> p1 text
*& <– p2 text
*&———————————————————————*
FORM check_auth .
“select SINGLE WERKS, KUNNR into @data(ls_t001w) from t001w WHERE WERKS=@p_p1 .
AUTHORITY-CHECK OBJECT ‘M_MSEG_WMB’
ID ‘ACTVT’ DUMMY
ID ‘WERKS’ FIELD p_p1 .
IF sy-subrc <> 0.
* Implement a suitable exception handling here
ENDIF.
ENDFORM.
FORM get_DAta .
select a~matnr,a~MEINS,b~maktx
from mara as a inner join makt as b
on a~matnr=b~MATNR where a~ZMATNR=@p_p1 into table @data(lt_outdata) .
ENDFORM .
*展示alv 子程序 直接复制
FORM diaplay_data .
PERFORM set_alv_layout. “样式设定
PERFORM bulid_fieldcat. “格式设定
PERFORM call_alv_func. “alv 函数
ENDFORM.
“样式设定 直接复制
FORM set_alv_layout .
CLEAR: wa_layout.
wa_layout-zebra=’X’. “斑马线
wa_layout-cwidth_opt=’X’. “自动列宽
ENDFORM.
“格式设定 固定换数
FORM bulid_fieldcat .
DEFINE add_col.
* ADD 1 TO pos.
* lw_fieldcat-col_pos=pos.
wa_fieldcat-fieldname=&1.
wa_fieldcat-ref_field=&2.
wa_fieldcat-ref_table=&3.
wa_fieldcat-scrtext_l=&4.
wa_fieldcat-outputlen=&5.
wa_fieldcat-no_zero=&6.
wa_fieldcat-edit=&7.
wa_fieldcat-edit_mask=&8.
wa_fieldcat-key=&9.
CASE wa_fieldcat-fieldname.
WHEN ‘slbox’.
wa_fieldcat-checkbox=’X’ .
wa_fieldcat-edit=’X’ .
wa_fieldcat-edit_mask=’X’.
WHEN OTHERS.
ENDCASE .
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR : wa_fieldcat.
END-OF-DEFINITION.
REFRESH: gt_fieldcat.
“add_col ‘matnr’ space space ‘物料号’ space space space space space.
add_col ‘MEINS’ space space ‘单位’ space space space space space.
add_col ‘maktx’ space space ‘物料名’ space space space space space.
ENDFORM.
“刷新 固定复制
FORM refresh_alv .
DATA: lo_grid TYPE REF TO cl_gui_alv_grid,
lw_stable TYPE lvc_s_stbl.
CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
IMPORTING
e_grid=lo_grid.
lw_stable-row=’X’.
lw_stable-col=’X’.
lo_grid->refresh_table_display(
EXPORTING
is_stable=lw_stable
EXCEPTIONS
finished=1
OTHERS=2 ).
ENDFORM.
“固定,只需要传内表就行
FORM call_alv_func .
gs_glay-edt_cll_cb=abap_true. ” 选中复选款,立刻触发data changed 事件
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program=sy-repid “回调程序
i_callback_pf_status_set=’SET_PF_STATUS’
i_callback_user_command=’USER_COMMAND’
i_grid_settings=gs_glay
is_layout_lvc =wa_layout
it_fieldcat_lvc=gt_fieldcat “需要显示的内表的列
i_save =’A’
TABLES
t_outtab =lt_outdata “需要显示的数据
EXCEPTIONS
program_error =1
OTHERS =2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
“staus 工具栏 直接复制
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
DATA : lw_tab LIKE LINE OF rt_extab.
REFRESH rt_extab.
SET PF-STATUS ‘STD’ EXCLUDING rt_extab.
ENDFORM.
“用户事件 ,这里没写. 但是如果设定函数双击会apap dump
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
* 导入
WHEN ‘&IMPLE’.
ENDCASE.
ENDFORM.
“权限检查,按照不同的情况调用不同的函数,这里需要更换.
*&———————————————————————*
*& Form check_auth
*&———————————————————————*
*& text
*&———————————————————————*
*& –> p1 text
*& <– p2 text
*&———————————————————————*
FORM check_auth .
“select SINGLE WERKS, KUNNR into @data(ls_t001w) from t001w WHERE WERKS=@p_p1 .
AUTHORITY-CHECK OBJECT ‘M_MSEG_WMB’
ID ‘ACTVT’ DUMMY
ID ‘WERKS’ FIELD p_p1 .
IF sy-subrc <> 0.
* Implement a suitable exception handling here
ENDIF.
ENDFORM.
© 版权声明
文章版权归作者所有,未经允许请勿转载。