In this blog post we will learn how to attach documents in task list in plant maintenance and print those documents automatically while printing the PM order.
Attachments will be added in task list and while creating PM order those attachments will flow to PM order level automatically. This results in reduced manual error and eliminate duplication of work. This will make the process efficient and will save time.
Attach document in the task list:
(Below steps can be achieved via BASIS and Customizing work, no ABAP coding needed)
Below Business functions should be switched on
Files will be stored in SAP Document Management (DMS)
These objects should be activated in customizing for PMPLKO object (PMPLKO is the document type for PM order)
Refer to Appendix of OSS note 1821916 for customizing steps.
This printing functionality won't work in PRINT PREVIEW
As print is done from Menu bar and it doesn't bring any system command, this functionality should be restricted from other transactions.
Determine Documents for a PM Order
Determine detailed data of document
Open detailed document for printing purpose
This document will be saved in temp folder of computer and this file can be deleted from temp folder
* This method is called while saving PM order
BEGIN OF t_order,
documenttype TYPE bapi_doc_keys-documenttype,
documentnumber TYPE bapi_doc_keys-documentnumber,
documentversion TYPE bapi_doc_keys-documentversion,
documentpart TYPE bapi_doc_keys-documentpart,
END OF t_order.
DATA: ls_order TYPE t_order,
ls_files TYPE cvapi_doc_file,
ls_comp TYPE cvapi_doc_comp,
gt_order TYPE STANDARD TABLE OF t_order,
gt_files TYPE STANDARD TABLE OF cvapi_doc_file,
gt_comp TYPE STANDARD TABLE OF cvapi_doc_comp,
lv_string TYPE string,
lv_objky TYPE bapi_doc_drad-objectkey,
lv_filename TYPE draw-filep,
lt_file_table TYPE STANDARD TABLE OF file_table,
ls_file_table TYPE file_table,
lv_file TYPE string,
lv_rc TYPE i.
* Since print from MENU bar does not bring a Sy-ucomm code => Block other transaction codes
IF sy-tcode = 'IW32' OR sy-tcode = 'IW33' OR sy-tcode = 'IW3D'.
IF sy-ucomm NE 'BU' " BU is the OK code for save.
AND sy-ucomm NE 'YES' " YES is the code for Release+Save
AND sy-ucomm NE 'WEIT' " WEIT is order technically completion status
AND sy-ucomm NE 'BABS' " BABS is order business completion status
AND sy-ucomm NE 'SAVX' " Save and Do confirmation Button" on screen
AND sy-ucomm NE 'SPER'. " Lock order