Summary: This article illustrates the possibility of doing mass processing in POWL
In one of my projects there was a requirement wherein the user should be able to process up to 5 different work orders/operations at the same time. These work orders will be selected from a power list(POWL) in portal.
The standard POWL behavior throws an error message on certain actions if more than one rows are selected. This behavior can be overridden by creating an implicit enhancement in the respective feeder class.
Feeder class
The feeder class is the central and the most important place while developing and modifying Power Lists. The feeder class includes the handling of actions initiated by the user while pressing a button.
How to find the feeder class used for your POWL. (reference http://scn.sap.com/thread/1983141 )
Method 1 : T-code POWL_TYPE contains the Feeder class name assigned to the POWL type .
One can check the POWL type with description and find the feeder class associated with it and then put a break point in method IF_POWL_FEEDER~GET_OBJECT_DEFINITION of the feeder class and ensure that feeder class is correct.
Or Method 2: Go to POWL_UI_COMP webdynpro component, navigate to MASTER_CONTENT view method tab .
In the ONACTIONREFRESH_CURRENT event in the method tab set a break point in the lr_model->refresh_current( ). Click the "Refresh" button from the POWL table of which you want to find the feeder class , you will get the POWL type inside the method ( variable name- ms_current_query-type ). Now go to POWL_TYPE t-code and find the feeder class which is assigned to this POWL TYPE
Mass selection
Create an implicit enhancement at the end of the method IF_POWL_FEEDER~HANDLE_ACTION of your feeder class. Code snippet given below.
i_actionid is the action for which you need to select more than one rows in POWL. In this example i_actionid='CONF' for the 'Enter Confirmation' button from the screenshot above.
The selected orders/operations are stored in a transaction table ZTI_PMCONF for the current logged in user.
ENHANCEMENT 1 ZPMZCONF_POWL_CL. "active version *
DATA ls_order_op type ZTI_PMCONF.
DATA ltt_powl_msg TYPE POWL_MSG_TTY.
IF lv_selected GT 5 AND i_action_index IS INITIAL AND mv_bp_version NE '10' AND i_actionid = 'CONF'.
** display error message "Select upto 5 rows only" if more than 5 work orders are selected in POWL
delete lt_powl_msg index 1.
e_messages[] = lt_powl_msg[].
ls_powl_msg-msgtype = cl_rplm_qimt_co=>sc_error.
ls_powl_msg-msgid = 'ZZPM'.
ls_powl_msg-msgnumber = '144'.
APPEND ls_powl_msg TO lt_powl_msg.
e_messages[] = lt_powl_msg[].
ELSEIF lv_selected <> 1 AND i_action_index IS INITIAL AND mv_bp_version NE '10' AND i_actionid = 'CONF'.
** suppress standard error message "Select one line only" to allow multiple line selections for this action
delete lt_powl_msg index 1.
e_messages[] = lt_powl_msg[].
** delete all the previous user selections stored in the transaction table if any, this is also deleted immediately after the values are set in the application
DELETE FROM ZTI_PMCONF WHERE UNAME eq sy-uname.
COMMIT WORK.
DATA lv_tab TYPE sy-tabix.
lv_tab = 0.
** Loop through the number of selected lines
DO lv_selected TIMES.
lv_tabix = lv_tab + 1.
READ TABLE c_selected INTO ls_index INDEX lv_tabix.
READ TABLE c_result_tab INTO ls_result INDEX ls_index-tabix.
** Check if order is locked
CALL METHOD me->check_order_lock
EXPORTING
iv_aufnr = ls_result-aufnr
IMPORTING
e_messages = ltt_powl_msg.
IF ltt_powl_msg IS NOT INITIAL.
LOOP AT ltt_powl_msg INTO ls_powl_msg.
APPEND ls_powl_msg TO lt_powl_msg.
ENDLOOP.
ENDIF.
** if there are no errors or no work orders are locked, save the selected work orders and operation in the database table ZTI_PMCONF
IF lt_powl_msg IS INITIAL.
ls_order_op-AUFNR = ls_result-aufnr.
ls_order_op-VORNR = ls_result-vornr.
ls_order_op-UNAME = sy-uname.
INSERT INTO ZTI_PMCONF VALUES ls_order_op.
clear ls_order_op.
ENDIF.
lv_tab = lv_tab + 1.
ENDDO.
IF lt_powl_msg IS INITIAL.
** Get role id
IF i_applid = cl_rplm_qimt_co=>sc_applid_mt.
lv_role_id = cl_rplm_qimt_co=>sc_roleid_mt_compl_conf.
ELSE.
lv_role_id = cl_rplm_qimt_co=>sc_roleid_others.
ENDIF.
** Get POWL api
cl_powl_runtime_services=>get_powl_object_info_handle(
RECEIVING
ro_powl_object_info_handle = lo_obj_info
EXCEPTIONS
no_wdr_component = 1
OTHERS = 2 ).
IF sy-subrc = 0 AND lo_obj_info IS NOT INITIAL.
lv_environment = lo_obj_info->mv_client_environment.
ENDIF.
** The custom form developed for this requirement(not in scope of this article) can be accessed via second level navigation or from the POWL
worklist. It behaves differently in both cases, so to identify if it is called via second level navigation or via POWL, a parameter is passed which is read in the HANDLEDEFAULT method of the window
** set parameter POWL_FLAG to check if the application is being called via POWL or second level navigation
ls_name_value-key = 'POWL_FLAG'.
ls_name_value-value = 'X'.
INSERT ls_name_value INTO TABLE lt_name_value.
ls_powl_follow_up-bo_system = cl_rplm_qimt_co=>sc_system_erp.
IF lv_environment NE if_wd_application=>co_client_environment-nwbc.
ls_powl_follow_up-bo_name = 'maintenance_order_confirmation'.
ELSE. "PFCG usage in NWBC
ls_powl_follow_up-bo_name = 'maintenance_ord_conf'.
ENDIF.
ls_powl_follow_up-bo_op_name = 'create'.
ls_powl_follow_up-parameters = lt_name_value.
ENDIF.
e_portal_actions = ls_powl_follow_up.
*----------------------------------------------------------------------*
*- Return the message table
*----------------------------------------------------------------------*
e_messages[] = lt_powl_msg[].
ENDIF.
ENDENHANCEMENT.
Note: I tried using a singleton class for this approach instead of using a transaction table. However, the session is not retained across POWL and the custom application.