标签:deb 遇到 assigned task sig 过滤 back 屏蔽 函数
示例1:
调用J3RFLVMOBVEDH ,取物料的期初/ 期末庫存数、金额
FORM frm_call_j3rflvmobvedh. DATA: lr_bukrs TYPE RANGE OF bukrs, ls_bukrs LIKE LINE OF lr_bukrs, lr_datum TYPE RANGE OF datum, ls_datum LIKE LINE OF lr_datum. DATA: lo_data TYPE REF TO data. DATA: lv_buper TYPE buper. FIELD-SYMBOLS: <fs_t_data> TYPE ANY TABLE. ls_bukrs-sign = ‘I‘. ls_bukrs-option = ‘EQ‘. ls_bukrs-low = p_bukrs. APPEND ls_bukrs TO lr_bukrs. * Caculate the first & last day of the Month lv_buper = |{ gv_gjahr }{ gv_monat }|. ls_datum-sign = ‘I‘. ls_datum-option = ‘BT‘. ls_datum-low = gv_start_date. ls_datum-high = gv_end_date. APPEND ls_datum TO lr_datum. cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false metadata = abap_false data = abap_true ). SUBMIT j_3rmobvedh WITH so_bukrs IN lr_bukrs WITH so_werks IN s_werks WITH so_lgort IN s_lgort WITH so_matnr IN s_matnr WITH so_budat IN lr_datum WITH p_xnegp = ‘X‘ AND RETURN. TRY. cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lo_data ). ASSIGN lo_data->* TO <fs_t_data>. CATCH cx_salv_bs_sc_runtime_info. * MESSAGE ‘无法获取ALV数据‘ TYPE ‘E‘. MESSAGE s004 DISPLAY LIKE ‘E‘. LEAVE LIST-PROCESSING. ENDTRY. IF <fs_t_data> IS ASSIGNED. gt_3rmobvedh_total = <fs_t_data>. ENDIF. cl_salv_bs_runtime_info=>clear_all( ). ENDFORM.
示例2:
调用 MB51 ,1 取物料查询期间的物料移动数据,2取各个进耗存类别数量、金额
FORM frm_material_list . DATA: lv_va TYPE slis_vari. DATA: lr_mjahr TYPE RANGE OF mjahr, ls_mjahr LIKE LINE OF lr_mjahr, lr_datum TYPE RANGE OF datum, ls_datum LIKE LINE OF lr_datum. DATA: lo_data TYPE REF TO data. FIELD-SYMBOLS: <fs_t_data> TYPE ANY TABLE, <ls_data> TYPE any. ls_datum-sign = ‘I‘. ls_datum-option = ‘BT‘. ls_datum-low = gv_start_date. ls_datum-high = gv_end_date. APPEND ls_datum TO lr_datum. **通过查询条件形成range ls_mjahr(3) = ‘IEQ‘. ls_mjahr-low = p_buper+0(4). APPEND ls_mjahr TO lr_mjahr. PERFORM frm_get_variant CHANGING lv_va."获取程序变式 ***为后续获取ALV数据做设置 cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false metadata = abap_false data = abap_true ). SUBMIT rm07docs " Tcode MB51 WITH matnr IN s_matnr "物料 WITH werks IN s_werks "工厂 WITH lgort IN s_lgort "库位 WITH budat IN lr_datum "过账日期 WITH rhier_l = ‘‘ WITH rflat_l = abap_true"扁平结构 WITH database = abap_true "读取数据库 WITH alv_def = lv_va"变式 AND RETURN. ** WITH charg IN s_charg "批次 * WITH lifnr IN s_lifnr "供应商 * WITH kunnr IN s_kunnr "客户 * WITH bwart IN s_bwart "移动类型 * WITH sobkz IN s_sobkz "特殊库存 * WITH aufnr IN s_aufnr "生产订单 * WITH kostl IN s_kostl "成本中心 * WITH mat_kdau IN s_kdau "销售订单 * WITH mat_kdpo IN s_kdpo "销售订单行项目 * WITH rsnum IN s_rsnum "预留 * WITH rspos IN s_rspos "预留行 * WITH usnam IN s_usnam "用户 * WITH vgart IN s_vgart * WITH mblnr IN s_mblnr * WITH mjahr IN lr_mjahr * WITH budat IN lr_datum * WITH xblnr IN s_xblnr TRY. cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lo_data ). ASSIGN lo_data->* TO <fs_t_data>. CATCH cx_salv_bs_sc_runtime_info. MESSAGE ‘无法获取ALV数据‘ TYPE ‘E‘. ENDTRY. cl_salv_bs_runtime_info=>clear_all( ). IF <fs_t_data> IS ASSIGNED. LOOP AT <fs_t_data> ASSIGNING <ls_data>. MOVE-CORRESPONDING <ls_data> TO gt_itab. APPEND gt_itab. ENDLOOP. ENDIF. SORT gt_itab. DELETE ADJACENT DUPLICATES FROM gt_itab COMPARING ALL FIELDS. ENDFORM.
遇到某些需求,顾问要的就是某张标准程序的 某些栏位,逻辑很难理清楚,特别是取期初,期末库存, 或者是某个特定日期的库存,
所以就要调用标准程序取数
以下参考博文:https://www.cnblogs.com/dy-debug/p/5791534.html
* Execute transaction IA09 to get all Functional Location Tasklists SUBMIT riplko10 WITH SELECTION-TABLE lt_selscreen WITH pn_iflo = abap_true "Select Func Loc Tasklists WITH dy_tcode = ‘IA09‘ WITH dy_selm = ‘D‘ "Dark mode AND RETURN IMPORT sel_tab FROM MEMORY ID ‘RIPLKO10‘.
这种方法性能比较高但是依赖源程序,需要事先将需要的数据EXPORT到内存,如果是标准程序就需要做增强。
方法2:SUBMIT前屏蔽ALV GRID的显示,使用SUBMIT,然后调用
CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF
方法获取数据,(包括显示数据,布局数据,字段数据,过滤器等),这个是SAP提供的API所以我们不关心如何存储,所以该方法不需要修改目标程序就可以直接得到ALV显示的结果,
但不能设置目标程序的中断点,需显示ALV的函数执行完毕方可获取到数据。
FIELD-SYMBOLS <lt_pay_data> TYPE ANY TABLE. DATA lr_pay_data TYPE REF TO data. DATA lt_selscreen TYPE TABLE OF rsparams. "初始设置 CALL METHOD cl_salv_bs_runtime_info=>set EXPORTING display = abap_false metadata = abap_false data = abap_true. * 调用目标程序 SUBMIT h99cwtr0 WITH SELECTION-TABLE lt_selscreen AND RETURN. TRY. "获取ALV显示数据 CALL METHOD cl_salv_bs_runtime_info=>get_data_ref IMPORTING r_data = lr_pay_data. ASSIGN lr_pay_data->* TO <lt_pay_data>. CATCH cx_salv_bs_sc_runtime_info. MESSAGE `无法取得ALV术` TYPE ‘E‘. ENDTRY. "结束 cl_salv_bs_runtime_info=>clear_all( ).
CL_SALV_BS_RUNTIME_INFO 与读取 ALV相关的方法:
SET() - 此方法初始化类(清除内存区域),然后允许标志的设置让任何后续ALV对象如何工作。它应该在装程序调用ALV报告程序之前被调用。
参数:
GET_DATA_REF() - 非常灵活的GET_DATA*方法,这种方法可以用来访问该数据表变量的引用(动态而且易用),所以即使不知道ALV数据表的结构也没关系。
参数:
GET_DATA() - 如果知道需要调用的ALV数据表的结构,可以使用这个方法。
参数:
标签:deb 遇到 assigned task sig 过滤 back 屏蔽 函数
原文地址:https://www.cnblogs.com/rainysblog/p/11688559.html