本文主要是介绍测试APO函数 /SAPAPO/OM_ORDER_GET_DATA,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
S4 hana 1709环境中,APO模块的LiveCache数据,都是通过存储过程到ABAP层的函数来实现访问。它们都在 /SAPAPO/OM_PLANNING函数组里:
近段时间关注了这个函数:/SAPAPO/OM_ORDER_GET_DATA,放几段测试的代码备忘:
ZJAMES_L001程序通过函数/SAPAPO/OM_ORDER_GET_DATA得到订单下的BOM组件也就是零部件,其中函数参数:ATC理解为工艺路线,inputs可以理解为投料,output理解为产成品。
*&---------------------------------------------------------------------*
*& Report ZJAMES_L001
*&---------------------------------------------------------------------*
*& 这个程序测试函数
*&---------------------------------------------------------------------*
REPORT ZJAMES_L001.
DATA gs_gen_params TYPE /sapapo/om_gen_params.
DATA:
lv_ordid TYPE /sapapo/om_orderuid,
lt_ordid TYPE /sapapo/om_tab_ordid,
ls_ordid TYPE LINE OF /sapapo/om_tab_ordid,
lt_ordkeys TYPE /sapapo/om_ordkey_tab.
DATA:
gt_ordstat TYPE TABLE OF ztpd0002_ordstat, "#EC NEEDED
gt_ordkeys TYPE /sapapo/om_ordkey_tab, "#EC NEEDED
gt_act TYPE /sapapo/om_tab_act, "#EC NEEDED
gt_shift TYPE /sapapo/rrp_per_stamp_res_tab, "#EC NEEDED
gt_inputs TYPE /sapapo/om_io_pp_tab, "#EC NEEDED
gt_outputs TYPE /sapapo/om_io_pp_tab, "#EC NEEDED
gt_pldord_atp TYPE RANGE OF /sapapo/om_atpcat, "#EC NEEDED
gt_ordbom_ekgrp TYPE RANGE OF /sapapo/matloc-ekgrp, "#EC NEEDED
gt_ordbom_matkl TYPE RANGE OF /sapapo/matkey-matkl. "#EC NEEDED
DATA: T1 TYPE I,
T2 TYPE I,
T TYPE P DECIMALS 0.
DATA: GV_C(6) TYPE C .
*&---------------------------------------------------------------------*
*& Screen
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-t01.
SELECT-OPTIONS:
s_m FOR ls_ordid.
SELECTION-SCREEN END OF BLOCK b1.
*&---------------------------------------------------------------------*
*& INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
START-OF-SELECTION.
gs_gen_params-simversion = '000'.
* ls_ordid = '051MbrXE7jkUtKu9vyvHAW'.
* APPEND ls_ordid TO lt_ordid.
LOOP AT s_m INTO DATA(ls_m).
ls_ordid = ls_m-LOW.
APPEND ls_ordid TO lt_ordid.
ENDLOOP.
GET RUN TIME FIELD T1."开始时间
CALL FUNCTION '/SAPAPO/OM_ORDER_GET_DATA'
EXPORTING
is_gen_params = gs_gen_params
iv_simsession = space
it_order = lt_ordid
IMPORTING
et_ordkeys = gt_ordkeys
et_activities = gt_act
et_ext_inputs = gt_inputs
et_ext_outputs = gt_outputs
EXCEPTIONS
lc_connect_failed = 1
lc_com_error = 2
lc_appl_error = 3
OTHERS = 4.
GET RUN TIME FIELD T2."结束时间
T = ( T2 - T1 ) / 1000000.
GV_C = T.
CONDENSE GV_C NO-GAPS.
TYPES:
BEGIN OF ty_pvcmpd,
bomid TYPE /sapapo/om_bomid,
pvguid TYPE pvs_pvguid,
pvcdcnt TYPE pvs_count,
zz_com_code TYPE zz_comcode,
zz_work_ws TYPE zz_workws,
zz_work_st TYPE zz_workst,
zz_bom_line TYPE zz_bomline,
aennr TYPE pvs_aennr,
datuv TYPE cc_ccdat,
END OF ty_pvcmpd.
DATA:
ls_inputs TYPE /sapapo/om_io_pp,
ls_pvcmpd TYPE ty_pvcmpd,
lt_pvcmpd TYPE TABLE OF ty_pvcmpd.
LOOP AT gt_inputs INTO ls_inputs WHERE bomid IS NOT INITIAL.
TRY.
CALL METHOD cl_system_uuid=>if_system_uuid_static~convert_uuid_c22
EXPORTING
uuid = ls_inputs-bomid
IMPORTING
uuid_x16 = ls_pvcmpd-pvguid.
ls_pvcmpd-bomid = ls_inputs-bomid.
APPEND ls_pvcmpd TO lt_pvcmpd.
CLEAR: ls_pvcmpd.
CATCH cx_uuid_error.
CONTINUE.
ENDTRY.
ENDLOOP.
WRITE:
/'批量调用 耗时:' , GV_C , '秒',
/'gt_ordkeys行数:' , lines( gt_ordkeys ) ,
/'gt_act行数:' , lines( gt_act ) ,
/'gt_inputs行数:' , lines( gt_inputs ) ,
/'gt_outputs行数:' , lines( gt_outputs ) .
ZJAMES_L002是单次调用这个函数的计时,目的是同上面程序对比,这个函数是批量调用速度快还是单个订单调用速度快。
*&---------------------------------------------------------------------*
*& Report ZJAMES_L002
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZJAMES_L002.
DATA gs_gen_params TYPE /sapapo/om_gen_params.
DATA:
lv_ordid TYPE /sapapo/om_orderuid,
lt_ordid TYPE /sapapo/om_tab_ordid,
lt_temp TYPE /sapapo/om_tab_ordid,
ls_ordid TYPE LINE OF /sapapo/om_tab_ordid,
lt_ordkeys TYPE /sapapo/om_ordkey_tab.
DATA:
gt_ordstat TYPE TABLE OF ztpd0002_ordstat, "#EC NEEDED
gt_ordkeys TYPE /sapapo/om_ordkey_tab, "#EC NEEDED
gt_act TYPE /sapapo/om_tab_act, "#EC NEEDED
gt_shift TYPE /sapapo/rrp_per_stamp_res_tab, "#EC NEEDED
gt_inputs TYPE /sapapo/om_io_pp_tab, "#EC NEEDED
gt_outputs TYPE /sapapo/om_io_pp_tab, "#EC NEEDED
gt_pldord_atp TYPE RANGE OF /sapapo/om_atpcat, "#EC NEEDED
gt_ordbom_ekgrp TYPE RANGE OF /sapapo/matloc-ekgrp, "#EC NEEDED
gt_ordbom_matkl TYPE RANGE OF /sapapo/matkey-matkl. "#EC NEEDED
DATA: T1 TYPE I,
T2 TYPE I,
T TYPE P DECIMALS 0.
DATA: GV_C(6) TYPE C .
*&---------------------------------------------------------------------*
*& Screen
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-t01.
SELECT-OPTIONS:
s_m FOR ls_ordid.
SELECTION-SCREEN END OF BLOCK b1.
*&---------------------------------------------------------------------*
*& INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
START-OF-SELECTION.
gs_gen_params-simversion = '000'.
* ls_ordid = '051MbrXE7jkUtKu9vyvHAW'.
* APPEND ls_ordid TO lt_ordid.
LOOP AT s_m INTO DATA(ls_m).
ls_ordid = ls_m-LOW.
APPEND ls_ordid TO lt_ordid.
ENDLOOP.
GET RUN TIME FIELD T1.
LOOP AT lt_ordid INTO DATA(ls_temp).
APPEND ls_temp TO lt_temp.
CALL FUNCTION '/SAPAPO/OM_ORDER_GET_DATA'
EXPORTING
is_gen_params = gs_gen_params
iv_simsession = space
it_order = lt_temp
IMPORTING
et_ordkeys = gt_ordkeys
et_activities = gt_act
et_ext_inputs = gt_inputs
et_ext_outputs = gt_outputs
EXCEPTIONS
lc_connect_failed = 1
lc_com_error = 2
lc_appl_error = 3
OTHERS = 4.
refresh lt_temp.
ENDLOOP.
GET RUN TIME FIELD T2.
T = ( T2 - T1 ) / 1000000.
GV_C = T.
CONDENSE GV_C NO-GAPS.
WRITE: /'单次调用总耗时:' , GV_C , '秒'.
这篇关于测试APO函数 /SAPAPO/OM_ORDER_GET_DATA的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!