在PP模块中获取工单信息会比较麻烦,涉及的表有十几张。因此SAP封装了一个函数‘BAPI_PRODORD_GET_DETAIL’满足程序在获取工单信息时节省大量代码。
传值说明:
NUMBER :录入工单号
ORDER_OBJETS :需要获取哪些工单信息。
导出表说明:
抬头(Header)
行项目(Item)
工序中的Sequence
工序(Operation)
子工序(Suboperation or secondary resource)
触发点(Trigger point)
组件(Component)
Production resource/tool
注意:执行这个BAPI需要权限对象 C_AFKO_AWK有03 (display activity).
实现代码如下:
DATA: order_objects TYPE bapi_pp_order_objects, s_header LIKE TABLE OF bapi_order_header1, s_position LIKE TABLE OF bapi_order_item, s_sequence LIKE TABLE OF bapi_order_sequence, s_operation LIKE TABLE OF bapi_order_operation1, s_trigger_point LIKE TABLE OF bapi_order_trigger_point, s_component LIKE TABLE OF bapi_order_component . order_objects-header = abap_true. order_objects-positions = abap_true. order_objects-sequences = abap_true. order_objects-operations = abap_true. order_objects-components = abap_true. CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL' EXPORTING number = '230001210022' "COLLECTIVE_ORDER = order_objects = order_objects TABLES header = s_header position = s_position sequence = s_sequence operation = s_operation trigger_point = s_trigger_point component = s_component. cl_demo_output=>write( s_header ). "抬头状态信息 cl_demo_output=>write( s_position ). " cl_demo_output=>write( s_sequence ). "工艺路线号 cl_demo_output=>write( s_operation ). "工艺路线 cl_demo_output=>write( s_component ). "BOM cl_demo_output=>display( ).
结果如下图: