Supply Chain Management Blogs by Members
Learn about SAP SCM software from firsthand experiences of community members. Share your own post and join the conversation about supply chain management.
cancel
Showing results for 
Search instead for 
Did you mean: 
sunil_mani
Active Participant
4,359
Introduction

I am Sunil Mani. I have total 10 years of technical experience in SAP . In this blog post, I will be sharing my personal experience to do screen enhancement in /SCWM/TU transaction. Reason behind this screen enhancement is, in Standard SAP, I didn't have an option to customize TU screen to add buttons on application toolbar. In order to overcome this problem, I have implemented the following solution as explained in this blog post.

Solution

As I highlighted in screenshot below, I had a requirement to enhance TU screen with a custom button( Print HU Label). When I click on Print HU Label button, it should pull all the Handling Units assigned to the TU and generate a spool for each item in the Handling Unit.


Please follow the below steps -

The first step to display above highlighted print icon/button when I enter into /SCWM/TU transaction , I had put the below logic in the Method SET_PROCESS_1 and Class lcl_transaction_manager . I created an implicit enhancement at the end of the method and set global variable MT_OIP_DEFINITION with new button details as illustrated below.


FIELD-SYMBOLS: <lfs_oip_hu> TYPE ly_s_oip_definition.
TRY.
<lfs_oip_hu> = mt_oip_definition[ def-v_container = 'CONTAINER_ALV_OIP_1' def-v_class_id = 'OIP_TAB1' ].
* separator
CLEAR ls_button. "Already defined in standard
ls_button-butn_type = cntb_btype_sep.
APPEND ls_button to <lfs_oip_hu>-def-s_toolbar-t_buttons.
* print button
CLEAR ls_button.
ls_button-function = 'OK_PRINT_HU'.
ls_button-butn_type = cntb_btype_button.
ls_button-text = ''.
ls_button-quickinfo = 'Print HU'.
ls_button-icon = icon_print.
APPEND ls_button to <lfs_oip_hu>-def-s_toolbar-t_buttons.
CATCH CX_SY_ITAB_LINE_NOT_FOUND.
ENDTRY.

Register OK code to the standard controller in the METHOD constructorCLASS lcl_oip, Include /SCWM/LUI_TUOIP. Again, I created an implicit enhancement and registered the action code for Print button.
*Register HU print ok code at the controller
DATA: lo_temp TYPE REF TO /scmb/if_controller.
lo_temp = me.
IF lo_temp->mv_class_id = 'OIP_TAB1'.
CLEAR: lt_okcodes.
APPEND 'OK_PRINT_HU' TO lt_okcodes.
lo_temp->mv_class_id = 'ZHU_PRINT'.
*Register the viewer at the controller
so_controller->viewer_register(
io_viewer = lo_temp
it_okcodes = lt_okcodes ).
lo_temp->mv_class_id = 'OIP_TAB1'.
ENDIF.

In the same include, Method /scmb/if_controller~okcode_handler and  CLASS lcl_oip to handle the logic behind our custom button. I created an implicit enhancement and got related TU details and called my custom function module to print hu label.
  DATA: lt_asp_tu         TYPE /scwm/tt_asp_tu,
lv_failed TYPE abap_bool,
ls_asp_tu TYPE /scwm/s_asp_tu.

DATA: lo_tudlv_manager TYPE REF TO /scwm/cl_sr_tudlv,
ls_tu_act_key TYPE /scwm/s_tu_sr_act_num,
lt_bo_tu_hu TYPE /scwm/tt_bo_tu_dlv_no_sort,
ls_bo_tu_hu TYPE /scwm/s_bo_tu_dlv.

Case IV_OKCODE
*Determine the selected line(s)
CALL METHOD get_selected_lines
EXPORTING
iv_suppress_message = abap_true
iv_no_select = abap_true
IMPORTING
et_aspect = lt_asp_tu
ev_failed = lv_failed.
IF lt_asp_tu[] IS INITIAL OR lv_failed = abap_true.
*add error message if no entry is selected
ls_message-msgty = 'E'.
ls_message-msgid = '/SCWM/UI'.
ls_message-msgno = '003'.
go_message_handler->add_system_message(
EXPORTING msg = ls_message ).
ELSE.

LOOP AT lt_asp_tu INTO ls_asp_tu.
*get all assigned HUs
lo_tudlv_manager = /scwm/cl_sr_tudlv=>get_instance( ).
ls_tu_act_key-tu_num = ls_asp_tu-tu_num.
ls_tu_act_key-tu_sr_act_num = ls_asp_tu-tu_sr_act_num.
lo_tudlv_manager->get_bo_tu_dlv(
EXPORTING
is_tu_act_key = ls_tu_act_key
iv_one_record_per_hu = abap_false
IMPORTING
et_bo_tu_hu = lt_bo_tu_hu ).

******
Own custom Logic based on a requirement
*******
ENDIF.
ENDCASE.

Conclusion

As we don't have any standard screen enhancement to add a custom solution. I implemented above solution and overcame the standard restriction to customize TU transaction.

Thanks for reading !

Thanks

Sunil Mani
3 Comments
Labels in this area