efficient searching needles in a haystack - find xsteps containing process messages and function...

19
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules Applies to: SAP ERP 2005 (ECC 6.00) including all Enhancement Packages for ERP 2005. For more information, visit the Manufacturing homepage . Summary Companies use XSteps containing customer function calls or customer process messages. There has been no standard solution for identifying manufacturing orders, Standard XSteps or routings that are affected by changing mentioned objects. Sample report for such where-used checks is described and explained in this document. Author: Dr. Uwe Dittes Company: SAP AG Created on: 21. November 2011 Author Bio Dr. Uwe Dittes made his PhD in Chemistry at the University of Heidelberg, followed by certification as technical operation manager (IHK). He worked several years in chemical and pharmaceutical industry (development & production). Dr. Dittes joined the development organisation of SAP in 2001. He has a strong expertise in ERP Core Manufacturing (SAP PP-PI, SAP PP-SFC) and Business Suite Application Integration with SAP Plant Connectivity (PCo). He has also been working as external lecturer at the Baden-Wuerttemberg Cooperative State University (DHBW) in Mannheim, teaching fundamentals of SAP ERP, Lean Production, Cloud computing, and Mathematics.

Upload: basusap

Post on 01-Dec-2015

55 views

Category:

Documents


6 download

DESCRIPTION

X-STEPS

TRANSCRIPT

Page 1: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

Efficient Searching Needles in a

Haystack - Find XSteps Containing

Process Messages and Function

Modules

Applies to:

SAP ERP 2005 (ECC 6.00) including all Enhancement Packages for ERP 2005. For more information, visit the Manufacturing homepage.

Summary

Companies use XSteps containing customer function calls or customer process messages. There has been no standard solution for identifying manufacturing orders, Standard XSteps or routings that are affected by changing mentioned objects. Sample report for such where-used checks is described and explained in this document.

Author: Dr. Uwe Dittes

Company: SAP AG

Created on: 21. November 2011

Author Bio

Dr. Uwe Dittes made his PhD in Chemistry at the University of Heidelberg, followed by certification as technical operation manager (IHK). He worked several years in chemical and pharmaceutical industry (development & production). Dr. Dittes joined the development organisation of SAP in 2001. He has a strong expertise in ERP Core Manufacturing (SAP PP-PI, SAP PP-SFC) and

Business Suite Application Integration with SAP Plant Connectivity (PCo). He has also been working as external lecturer at the Baden-Wuerttemberg Cooperative State University (DHBW) in Mannheim, teaching fundamentals of SAP ERP, Lean Production, Cloud computing, and Mathematics.

Page 2: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Table of Contents

Introduction ......................................................................................................................................................... 3

Find the Needles in a Haystack – Sample Coding for Report ZUD_WUL_PM_FM ........................................... 3

Execute Where-used Search .............................................................................................................................. 3

Technical Background ........................................................................................................................................ 4

Determine Application Content ....................................................................................................................... 4

Storage of Parameter Values of Medium and Large Size .............................................................................. 4

Ideas for Improvements ...................................................................................................................................... 5

Steps for Implementing Sample Report .............................................................................................................. 5

Related Content ................................................................................................................................................ 18

Copyright........................................................................................................................................................... 19

Page 3: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Introduction

XSteps are meanwhile used by many customers of various industries. In the beginning (2001) main focus on XSteps was creation of browser-based PI Sheets and control recipes, mainly used by pharmaceutical companies, working in regulated environment. Since Enhancement Package 3 for SAP ERP 2005 (ECC 6.03) XSteps can also be used in production procedures for the discrete industries. They serve as a basis for control instructions and electronic work instructions.

XSteps offer a quite high bandwidth of flexibility: It is possible to assign customer function modules and let them execute during processing PI Sheets or electronic work instructions (dynamic function module calls). Also customer-defined process messages can be integrated in XSteps allowing customer-specific information transfer from shop-floor systems to SAP ERP systems.

Things get complicated in case these customer function modules or process messages have to be changed. Functional scope may be extended or adjusted because of legal reasons. To know which SAP objects like manufacturing orders, routings, master recipes, or Standard XSteps (SXS) are affected by such changes is essential. Identification of these objects can be done with the help of where-used lists. Unfortunately SAP standard doesn’t provide such functionality. How get forward? Create a report that does the needful:

Allow entering function modules or process messages as search parameters

Detect process instructions of XStep trees that contain search parameter value

Determine XStep trees to which process instruction nodes belong to

Get details about SAP objects (SXS, manufacturing order, routing) that contain these XStep trees

Display results

This document describes a sample report that offers all mentioned features. Setting up this report is quite easy. Use it as a basis for your own report and adjust it to your needs.

Find the Needles in a Haystack – Sample Coding for Report ZUD_WUL_PM_FM

Attached to this document you find the source code of report ZUD_WUL_PM_FM, our first approach for a where-used list. It reuses an algorithm which is used in SAP XStep repository (TA CMXSV) to identify SXS reference nodes in applications that refer to a chosen Standard XStep. In case SXS is referenced the corresponding application data is displayed in an ALV grid result list. Similar to this approach our sample report also displays results in an ALV grid.

Execute Where-used Search

Start sample report. Select object (function module or process message) you want to search for by clicking appropriate radio button. In case option ‘Usage: Function Module’ is ticked an input field is shown that allows selection of function modules via direct input or F4 help.

Figure 1: Select-options for Function Modules assigned to Process Instructions used in XSteps

If you want to search for process messages you’ll have to tick option ‘Usage: Process Messages’. Input field for process message category also offers F4 help functionality:

Page 4: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

Figure 2: Select-option for Process Messages assigned to Process Instructions used in XSteps

Press F8 key to execute where-used search. Results of where-used search are displayed in an ALV grid:

Figure 3: Results of Where-used Search

Technical Background

Determine Application Content

The names of process message categories or function modules are stored in database table for XStep parameter values that don’t exceed 40 characters (small values, database table CMX_XS_DB_VS). Entries also contain node ID (NID) of process instruction they belong to. The only way to get information about the application that contains the corresponding XStep tree is to find the XStep root node. Starting with process instruction tree node it is necessary to climb up the XStep tree until the top node (XStep root node) is reached. Depending on the assigned application XStep tree nodes can contain several versions (historical XStep nodes [routings & master recipes]) or only in a single version (non-historical objects [manufacturing orders and SXS]). Node information is therefore stored in different database tables CMX_XS_DB_NOBJ or CMX_XS_DB_HOBJ, also node relations (database tables CMX_XS_DB_HREL and CMX_XS_DB_NREL).

Storage of Parameter Values of Medium and Large Size

Parameter values that exceed 40 characters like operation long texts or HTML fragments are stored in a different way: Parameter values that contain up to 255 characters are stored in database table CMX_XS_DB_VM. Database table CMX_XS_DB_VL is used to store parameter values that exceed 255 characters. Data sets of medium and long parameter values contain GUID as key field. Process instruction nodes are linked to these medium and long parameter values by corresponding database table entries in database table CMX_XS_DB_VS: Data set contain GUID of long text as parameter value, as well as object ID (OID) of corresponding process instruction node.

Page 5: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

Ideas for Improvements

Use this report as basis for your own piece of software. Here are some ideas for further improvements:

Improve performance by implementing packaged database selection. Use OPEN CURSOR logic.

Add additional selection parameter for process message selection per plant

Create own field catalog for ALV grid result list. Dynamically hide and display columns based on result list data. Use configurable CL_ALV_GRID_XT instead of function module 'REUSE_ALV_GRID_DISPLAY_LVC'.

Call where-used search in Standard XStep Repository (TA CMXSV) via context menu: Implement BAdI CMX_XS_SRV_ACT. Use existing BAdI implementation CMX_XS_SRV_ACT_XSV as template.

Steps for Implementing Sample Report

Start transaction SE38 or SE80. Create report ZUD_WUL_PM_FM and maintain description. Enter the following source code lines.

Code

*&--------------------------------------------------------------------------------------------* *& Report ZUD_WUL_PM_FM *&--------------------------------------------------------------------------------------------* *& Where-used analysis for XStep process instructions containing either *& function modules or process messages *&--------------------------------------------------------------------------------------------* REPORT zud_wul_pm_fm. TYPES: BEGIN OF ty_s_nodes_hist, nid TYPE cmx_xs_node_guid, oid TYPE cmx_xs_node_guid, pi_guid TYPE cmx_xs_node_guid, ntype TYPE cmx_xs_node_type, END OF ty_s_nodes_hist, BEGIN OF ty_s_nodes_nhist, nid TYPE cmx_xs_node_guid, pi_guid TYPE cmx_xs_node_guid, ntype TYPE cmx_xs_node_type, END OF ty_s_nodes_nhist, BEGIN OF ty_s_pi_data, nid TYPE cmx_xs_node_guid, oid TYPE cmx_xs_node_guid, del TYPE boole_d, change_number TYPE cmx_xs_node_guid, END OF ty_s_pi_data. TYPES: ty_t_nodes_hist TYPE SORTED TABLE OF ty_s_nodes_hist WITH NON-UNIQUE KEY table_line, ty_t_nodes_nhist TYPE SORTED TABLE OF ty_s_nodes_nhist WITH NON-UNIQUE KEY table_line, ty_t_pi_data TYPE SORTED TABLE OF ty_s_pi_data WITH NON-UNIQUE KEY table_line, ty_t_tc_50 TYPE STANDARD TABLE OF tc50. DATA: lt_contx_nid_mrc TYPE cpc_cmx_t_context,

Page 6: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

lt_contx_nid_por TYPE cocr_cmx_t_nid_con, lt_contx_nid_rtg TYPE cpc_cmx_t_context, lt_fcat TYPE lvc_t_fcat, lt_no_parent_hist TYPE ty_t_nodes_hist, lt_no_parent_nhist TYPE ty_t_nodes_nhist, lt_parent_hdel TYPE ty_t_nodes_hist, lt_parent_hist TYPE ty_t_nodes_hist, lt_parent_nhist TYPE ty_t_nodes_nhist, lt_pi_data_hdel TYPE STANDARD TABLE OF cmx_xs_db_hdel, lt_pi_hist_data TYPE ty_t_pi_data, lt_pi_nhist_data TYPE ty_t_pi_data, lt_pi_result TYPE cmx_xsr_t_sxs_where_used_list, lt_pi_xsr_data TYPE ty_t_pi_data, lt_roots_hist TYPE ty_t_nodes_hist, lt_roots_nhist TYPE ty_t_nodes_nhist, lt_roots_nid_hist TYPE cmx_xs_t_node_guid, lt_roots_nid_nhist TYPE cmx_xs_t_node_guid, lt_tc_50 TYPE ty_t_tc_50, lt_xs_instr TYPE STANDARD TABLE OF cmx_xs_db_instr, lt_xs_par_vs TYPE STANDARD TABLE OF cmx_xs_w_value_db_key, lt_xsr_vers TYPE STANDARD TABLE OF cmx_xsr_db_vers. DATA: ls_caufvd TYPE caufvd, ls_change_number TYPE aenr, ls_contx_nid_por TYPE cocr_cmx_s_nid_con, ls_contx_nid_rtg TYPE cpc_cmx_w_context, ls_fcat TYPE lvc_s_fcat, ls_parent_hist TYPE ty_s_nodes_hist, ls_parent_nhist TYPE ty_s_nodes_nhist, ls_pi_data_hdel TYPE cmx_xs_db_hdel, ls_pi_result TYPE cmx_xsr_w_sxs_where_used_list, ls_predec_hist TYPE ty_s_nodes_hist, ls_predec_nhist TYPE ty_s_nodes_nhist, ls_xs_instr TYPE cmx_xs_db_instr, ls_xsr_vers TYPE cmx_xsr_db_vers. DATA: lv_change_number TYPE aenr-aennr, lv_child_node TYPE cmx_xs_node_guid, lv_dom_name TYPE cmx_types_domain_name, lv_index TYPE sy-tabix, lv_sttxt TYPE sttxt, lv_value TYPE cmx_types_value_small. DATA: lo_library TYPE REF TO if_cmx_xs_library. FIELD-SYMBOLS: <ls_node_nhist> TYPE ty_s_nodes_nhist, <ls_node_hist> TYPE ty_s_nodes_hist, <ls_pi_hist_data> TYPE ty_s_pi_data, <ls_parent_hdel> TYPE ty_s_nodes_hist, <ls_pi_nhist_data> TYPE ty_s_pi_data. CONSTANTS: lc_appl_man_order TYPE cmx_xs_application VALUE 'MOR', lc_appl_master_rec TYPE cmx_xs_application VALUE 'MRC', lc_appl_stand_rout TYPE cmx_xs_application VALUE 'RTG', lc_dom_name_func TYPE cmx_types_domain_name VALUE 'PPPI_FUNCTION_NAME',

Page 7: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

lc_dom_name_pm TYPE cmx_types_domain_name VALUE 'PPPI_MESSAGE_CATEGORY', lc_icon_recipe TYPE icon_d VALUE '@HR@', "ICON_ROUTING, lc_icon_deleted TYPE icon_d VALUE '@11@', "ICON_DELETE, lc_icon_order TYPE icon_d VALUE '@9Z@', "ICON_ORDER lc_icon_repository TYPE icon_d VALUE '@CT@', lc_ntype_instr TYPE cmx_xs_node_type VALUE 'I', lc_ntype_root TYPE cmx_xs_node_type VALUE 'T'. * Parameters for selection SELECTION-SCREEN BEGIN OF BLOCK par WITH FRAME TITLE text-par. PARAMETERS: p_rbfunc TYPE c RADIOBUTTON GROUP rbg1 DEFAULT 'X' USER-COMMAND uc_rbg, p_rbpm TYPE c RADIOBUTTON GROUP rbg1. PARAMETERS: p_func TYPE rs38l_fnam MATCHCODE OBJECT pb_func_key, p_pm TYPE co_costr. SELECTION-SCREEN END OF BLOCK par. *********************************************************************** AT SELECTION-SCREEN OUTPUT. *********************************************************************** * Hide or inactivate selection parameters LOOP AT SCREEN. CASE screen-name. WHEN '%_P_FUNC_%_APP_%-TEXT' OR 'P_FUNC'. IF p_rbfunc = 'X'. screen-input = '1'. screen-invisible = '0'. ELSE. screen-input = '0'. screen-invisible = '1'. ENDIF. MODIFY SCREEN. WHEN '%_P_PM_%_APP_%-TEXT' OR 'P_PM'. IF p_rbpm = 'X'. screen-input = '1'. screen-invisible = '0'. ELSE. screen-input = '0'. screen-invisible = '1'. ENDIF. MODIFY SCREEN. WHEN OTHERS. CONTINUE. ENDCASE. ENDLOOP. *********************************************************************** AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pm. *********************************************************************** SELECT * APPENDING TABLE lt_tc_50 FROM tc50 WHERE cstyp = 'MS'. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING ddic_structure = 'TC50'

Page 8: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

retfield = 'COSTR' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = 'P_PM' value_org = 'S' TABLES value_tab = lt_tc_50 EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. *********************************************************************** START-OF-SELECTION. *********************************************************************** * Get information about process instruction objects that contain * requested function module/process message category IF NOT p_func IS INITIAL. lv_dom_name = lc_dom_name_func. lv_value = p_func. ENDIF. IF NOT p_pm IS INITIAL. lv_dom_name = lc_dom_name_pm. lv_value = p_pm. ENDIF. SELECT oid pos FROM cmx_xs_db_vs APPENDING TABLE lt_xs_par_vs WHERE domname = lv_dom_name AND value = lv_value. IF NOT sy-subrc = 0 OR lt_xs_par_vs[] IS INITIAL. * No entries found MESSAGE e005(cpc_cmx_xs). RETURN. ENDIF. * Determine additional process instruction data SELECT * FROM cmx_xs_db_instr APPENDING TABLE lt_xs_instr FOR ALL ENTRIES IN lt_xs_par_vs WHERE oid = lt_xs_par_vs-oid. * Determine Process Instruction nodes (historical) SELECT oid nid del change_number FROM cmx_xs_db_hobj APPENDING TABLE lt_pi_hist_data FOR ALL ENTRIES IN lt_xs_par_vs WHERE oid = lt_xs_par_vs-oid. * Determine Process Instruction nodes (non-historical) SELECT nid FROM cmx_xs_db_nobj APPENDING TABLE lt_pi_nhist_data FOR ALL ENTRIES IN lt_xs_par_vs WHERE nid = lt_xs_par_vs-oid. * Search root nodes: Use similar algorithm that is implemented for * where-used list of Standard XSteps in include ICMXXSRIMP02, line 2099 * METHOD search_roots_for_ref_on_db.

Page 9: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

* Create internal table to search the application context assigned to * root node of manufacturing orders or Standard XSteps (SXS) * [non historic] LOOP AT lt_pi_nhist_data ASSIGNING <ls_pi_nhist_data>. ls_parent_nhist-nid = <ls_pi_nhist_data>-nid. ls_parent_nhist-pi_guid = <ls_pi_nhist_data>-nid. ls_parent_nhist-ntype = lc_ntype_instr. INSERT ls_parent_nhist INTO TABLE lt_parent_nhist. ENDLOOP. CLEAR: ls_parent_nhist. LOOP AT lt_parent_nhist ASSIGNING <ls_node_nhist>. lv_child_node = <ls_node_nhist>-nid. WHILE lv_child_node IS NOT INITIAL. * Get the predecessor node via the child NID information CLEAR ls_predec_nhist. SELECT SINGLE nid INTO ls_predec_nhist-nid "#EC * FROM cmx_xs_db_nrel WHERE child_nid = lv_child_node. IF sy-subrc = 0. * Get node type: Search for root nodes (node type = 'T') SELECT SINGLE ntype INTO ls_predec_nhist-ntype FROM cmx_xs_db_nobj WHERE nid = ls_predec_nhist-nid. IF sy-subrc = 0. IF ls_predec_nhist-ntype = lc_ntype_root. * Found non-historical root node as parent ls_predec_nhist-pi_guid = <ls_node_nhist>-pi_guid. INSERT ls_predec_nhist INTO TABLE lt_roots_nhist. * Store root node data for accessing application context later INSERT ls_predec_nhist-nid INTO TABLE lt_roots_nid_nhist. CLEAR: lv_child_node, ls_predec_nhist. ELSE. * Different node type: Search for root node lv_child_node = ls_predec_nhist-nid. ENDIF. ELSE. * No entry found in CMX_XS_DB_NOBJ INSERT <ls_node_nhist> INTO TABLE lt_no_parent_nhist. CLEAR: lv_child_node, ls_predec_nhist. ENDIF. ELSE. * No entry found in CMX_XS_DB_NREL INSERT <ls_node_nhist> INTO TABLE lt_no_parent_nhist. CLEAR: lv_child_node, ls_predec_nhist. ENDIF. ENDWHILE. ENDLOOP. * Create table to search the application context that is assigned to * root node of master recipes or routings [historic] LOOP AT lt_pi_hist_data ASSIGNING <ls_pi_hist_data>. ls_parent_hist-oid = <ls_pi_hist_data>-oid. ls_parent_hist-pi_guid = <ls_pi_hist_data>-oid.

Page 10: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 10

ls_parent_hist-ntype = lc_ntype_instr. * Fill in the node ID (NID), needed for searching the root node SELECT SINGLE nid INTO ls_parent_hist-nid FROM cmx_xs_db_hobj WHERE oid = <ls_pi_hist_data>-oid. READ TABLE lt_parent_hist WITH KEY nid = ls_parent_hist-nid TRANSPORTING NO FIELDS. IF sy-subrc = 0. * Only insert one entry per NID (OID entries will be added later) CONTINUE. ELSE. IF <ls_pi_hist_data>-del IS INITIAL. INSERT ls_parent_hist INTO TABLE lt_parent_hist. ELSE. * Process instruction node was deleted, get information about * XStep tree root via DB table CMX_XS_DB_HDEL INSERT ls_parent_hist INTO TABLE lt_parent_hdel. ENDIF. ENDIF. ENDLOOP. CLEAR: ls_parent_hist. UNASSIGN <ls_pi_hist_data>. CLEAR lv_child_node. LOOP AT lt_parent_hist[] ASSIGNING <ls_node_hist>. lv_child_node = <ls_node_hist>-nid. WHILE lv_child_node IS NOT INITIAL. CLEAR ls_predec_hist. SELECT SINGLE oid INTO ls_predec_hist-oid "#EC * FROM cmx_xs_db_hrel WHERE child_nid = lv_child_node. IF sy-subrc = 0. * Get node type and node ID (NID): Search for root nodes * (node type = 'T') SELECT SINGLE nid ntype INTO CORRESPONDING FIELDS OF ls_predec_hist FROM cmx_xs_db_hobj WHERE oid = ls_predec_hist-oid. IF sy-subrc = 0. IF ls_predec_hist-ntype = lc_ntype_root. ls_predec_hist-pi_guid = <ls_node_hist>-pi_guid. INSERT ls_predec_hist INTO TABLE lt_roots_hist. * Store root node data for accessing application context later INSERT ls_predec_hist-nid INTO TABLE lt_roots_nid_hist. CLEAR: ls_predec_hist, lv_child_node. ELSE. * Different node type: Search for root node lv_child_node = ls_predec_hist-nid. ENDIF. ELSE. * No entry found in CMX_XS_DB_HOBJ INSERT <ls_node_hist> INTO TABLE lt_no_parent_hist. CLEAR: lv_child_node, ls_predec_hist. ENDIF. ELSE. * No entry found in CMX_XS_DB_HREL INSERT <ls_node_hist> INTO TABLE lt_no_parent_hist.

Page 11: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 11

CLEAR: lv_child_node, ls_predec_hist. ENDIF. ENDWHILE. ENDLOOP. IF NOT lt_parent_hdel[] IS INITIAL. * Already deleted historical Process Instruction nodes exist: Add * corresponding root nodes SELECT * FROM cmx_xs_db_hdel "#EC CI_NOFIRST APPENDING TABLE lt_pi_data_hdel FOR ALL ENTRIES IN lt_parent_hdel WHERE node_nid = lt_parent_hdel-nid. LOOP AT lt_parent_hdel ASSIGNING <ls_parent_hdel>. CLEAR: ls_pi_data_hdel, ls_predec_hist. READ TABLE lt_pi_data_hdel INTO ls_pi_data_hdel WITH KEY node_nid = <ls_parent_hdel>-nid. IF sy-subrc = 0. ls_predec_hist-ntype = lc_ntype_root. ls_predec_hist-nid = ls_pi_data_hdel-root_nid. ls_predec_hist-oid = ls_pi_data_hdel-root_nid. ls_predec_hist-pi_guid = <ls_parent_hdel>-pi_guid. INSERT ls_predec_hist INTO TABLE lt_roots_hist. * Store root node data for accessing application context later INSERT ls_predec_hist-nid INTO TABLE lt_roots_nid_hist. ELSE. INSERT <ls_parent_hdel> INTO TABLE lt_no_parent_hist. ENDIF. ENDLOOP. ENDIF. * Find out the application context: * - Master recipe/routings (header info, historical relation) * - Manufacturing order (order number, non-historical relation) * - SXS repository (non-historical relation) lo_library = cl_cmx_xs_system=>get_library( ). IF NOT lt_roots_hist[] IS INITIAL. * Get context for task list type 'master recipe' lo_library->get_context_by_nids( EXPORTING application = lc_appl_master_rec nids = lt_roots_nid_hist IMPORTING result = lt_contx_nid_mrc ). * Get context for task list type 'standard routing' lo_library->get_context_by_nids( EXPORTING application = lc_appl_stand_rout nids = lt_roots_nid_hist IMPORTING result = lt_contx_nid_rtg ). * Get context for other routing types -> add coding block here * Fill result structure with historical data LOOP AT lt_pi_hist_data ASSIGNING <ls_pi_hist_data>.

Page 12: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 12

CLEAR: ls_pi_result. ls_pi_result-ref_guid = <ls_pi_hist_data>-oid. ls_pi_result-aennr = <ls_pi_hist_data>-change_number. * Read buffered information about change number IF NOT <ls_pi_hist_data>-change_number IS INITIAL. CLEAR: ls_change_number, lv_change_number. lv_change_number = <ls_pi_hist_data>-change_number. CALL FUNCTION 'BU_CHANGE_NUMBER_READ' EXPORTING i_aennr = lv_change_number IMPORTING o_aenr = ls_change_number EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE s005(cc) WITH <ls_pi_hist_data>-change_number. EXIT. ENDIF. ENDIF. * Fill date from of change number ls_pi_result-date_from_chgno = ls_change_number-datuv. * Get information if root node was deleted but not archived * -> entry in CMX_XS_DB_HOBJ with deletion indicator IF NOT <ls_pi_hist_data>-del IS INITIAL. ls_pi_result-del = lc_icon_deleted. ENDIF. * Add context information of master recipe or standard routing READ TABLE lt_roots_hist ASSIGNING <ls_node_hist> WITH KEY pi_guid = <ls_pi_hist_data>-oid. IF <ls_node_hist> IS ASSIGNED. CLEAR: ls_contx_nid_rtg. * Check for master recipe context first READ TABLE lt_contx_nid_mrc INTO ls_contx_nid_rtg WITH KEY nid = <ls_node_hist>-nid. IF sy-subrc <> 0. * Check for standard routing context READ TABLE lt_contx_nid_rtg INTO ls_contx_nid_rtg WITH KEY nid = <ls_node_hist>-nid. ENDIF. IF NOT ls_contx_nid_rtg IS INITIAL. ls_pi_result-plnty = ls_contx_nid_rtg-plnty. ls_pi_result-plnnr = ls_contx_nid_rtg-plnnr. ls_pi_result-plnal = ls_contx_nid_rtg-plnal. ls_pi_result-icon_appl = lc_icon_recipe. ENDIF. ls_pi_result-ref_root_id = <ls_node_hist>-nid. ENDIF. * Add the completed result line entry to result table INSERT ls_pi_result INTO TABLE lt_pi_result. ENDLOOP. ENDIF. IF NOT lt_roots_nhist[] IS INITIAL.

Page 13: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 13

lo_library->get_context_by_nids( EXPORTING application = lc_appl_man_order nids = lt_roots_nid_nhist IMPORTING result = lt_contx_nid_por ). IF NOT lt_contx_nid_por[] IS INITIAL. LOOP AT lt_pi_nhist_data ASSIGNING <ls_pi_nhist_data>. READ TABLE lt_roots_nhist ASSIGNING <ls_node_nhist> WITH KEY pi_guid = <ls_pi_nhist_data>-nid. lv_index = sy-tabix. IF <ls_node_nhist> IS ASSIGNED. CLEAR: ls_contx_nid_por, ls_pi_result. READ TABLE lt_contx_nid_por INTO ls_contx_nid_por WITH KEY nid = <ls_node_nhist>-nid. IF NOT ls_contx_nid_por IS INITIAL. ls_pi_result-aufnr = ls_contx_nid_por-aufnr. ls_pi_result-icon_appl = lc_icon_order. ls_pi_result-ref_guid = <ls_pi_nhist_data>-nid. ls_pi_result-ref_root_id = <ls_node_nhist>-nid. * Add additional order data and order status CALL FUNCTION 'CO_SF_CAUFV_GET' EXPORTING aufnr_imp = ls_pi_result-aufnr IMPORTING caufvd_exp = ls_caufvd EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc = 0. ls_pi_result-matnr = ls_caufvd-matnr. ls_pi_result-auftyp = ls_caufvd-autyp. ELSE. * Order data not available on data base (order archived?) CLEAR: ls_pi_result-matnr, ls_pi_result-auftyp. ENDIF. ls_pi_result-werks = ls_caufvd-werks. * Get system status for order CALL FUNCTION 'STATUS_TEXT_EDIT' EXPORTING objnr = ls_caufvd-objnr only_active = 'X' spras = sy-langu IMPORTING line = lv_sttxt EXCEPTIONS object_not_found = 1 OTHERS = 2. IF sy-subrc = 0. ls_pi_result-por_status = lv_sttxt. ELSE. * Order data not available on data base (order archived?). * Set text indicating that status can't be determined ls_pi_result-por_status = text-nsd. ENDIF. * Add the completed result line entry to result table INSERT ls_pi_result INTO TABLE lt_pi_result. * Remove XS root node entry from buffer table

Page 14: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 14

DELETE lt_roots_nid_nhist WHERE table_line = <ls_node_nhist>-nid. ELSE. INSERT <ls_pi_nhist_data> INTO TABLE lt_pi_xsr_data. * Non-historical node belongs to XStep tree of SXS reference CONTINUE. ENDIF. ENDIF. ENDLOOP. ENDIF. ENDIF. * Check for process instruction nodes that belong to XStep trees of * Standard XSteps (SXS). Library method GET_CONTEXT_BY_NIDS can't be * used IF NOT lt_pi_xsr_data[] IS INITIAL. * Get SXS data via SXS version SELECT * FROM cmx_xsr_db_vers APPENDING TABLE lt_xsr_vers FOR ALL ENTRIES IN lt_roots_nid_nhist WHERE root_id = lt_roots_nid_nhist-table_line. LOOP AT lt_pi_xsr_data ASSIGNING <ls_pi_nhist_data>. READ TABLE lt_roots_nhist ASSIGNING <ls_node_nhist> WITH KEY pi_guid = <ls_pi_nhist_data>-nid. IF <ls_node_nhist> IS ASSIGNED. CLEAR: ls_pi_result. READ TABLE lt_xsr_vers INTO ls_xsr_vers WITH KEY root_id = <ls_node_nhist>-nid. IF NOT ls_xsr_vers IS INITIAL. ls_pi_result-icon_appl = lc_icon_repository. ls_pi_result-ref_guid = <ls_pi_nhist_data>-nid. ls_pi_result-ref_root_id = <ls_node_nhist>-nid. ls_pi_result-version_id = ls_xsr_vers-version_id. ls_pi_result-vers_name = ls_xsr_vers-vers_name. ls_pi_result-item_id = ls_xsr_vers-item_id. * Add the completed result line entry to result table INSERT ls_pi_result INTO TABLE lt_pi_result. ENDIF. ENDIF. ENDLOOP. ENDIF. * Add short text of process instruction LOOP AT lt_pi_result INTO ls_pi_result. READ TABLE lt_xs_instr INTO ls_xs_instr WITH KEY oid = ls_pi_result-ref_guid langu = sy-langu. IF sy-subrc = 0. ls_pi_result-stext = ls_xs_instr-stext. ELSE. READ TABLE lt_xs_instr INTO ls_xs_instr WITH KEY oid = ls_pi_result-ref_guid. IF sy-subrc = 0. ls_pi_result-stext = ls_xs_instr-stext. ELSE. * No description found/maintained

Page 15: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 15

ls_pi_result-stext = text-upi. ENDIF. ENDIF. MODIFY lt_pi_result FROM ls_pi_result. ENDLOOP. * Display results using ALV result list. Where-used list structure for * Standard XSteps is reused. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'CMX_XSR_W_SXS_WHERE_USED_LIST' i_internal_tabname = 'LT_PI_RESULT' CHANGING ct_fieldcat = lt_fcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * Don't show (empty) field content which is specific for Standard XStep * where-used search DELETE lt_fcat WHERE fieldname = 'EXPAN_LEVEL' OR fieldname = 'PARENT_FOLDER_ID' OR fieldname = 'REF_STEXT' OR fieldname = 'REF_OPEN' OR fieldname = 'SFCPF' OR fieldname = 'COUNTER' OR fieldname = 'MATXT'. * Set proper column headers CLEAR: ls_fcat, lv_index. * Icon indicating application to which XSteps belong to (routing,..) READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'ICON_APPL'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-iap. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF. CLEAR: ls_fcat, lv_index. * Icon indicating that this historical version was deleted (remains on * database) READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'DEL'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-ide. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF. CLEAR: ls_fcat, lv_index. * Node ID of process instruction node READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'REF_GUID'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-rgu. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF.

Page 16: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 16

CLEAR: ls_fcat, lv_index. * Node ID of XStep tree to which process instruction node belongs to READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'REF_ROOT_ID'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-rri. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF. CLEAR: ls_fcat, lv_index. * Version ID for Standard XStep (SXS) READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'VERSION_ID'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-vid. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF. CLEAR: ls_fcat, lv_index. * Node ID for Standard XStep (SXS) READ TABLE lt_fcat INTO ls_fcat WITH KEY fieldname = 'ITEM_ID'. IF sy-subrc = 0. lv_index = sy-tabix. ls_fcat-coltext = text-rid. MODIFY lt_fcat FROM ls_fcat INDEX lv_index. ENDIF. * Show results using ALV Grid CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_grid_title = text-gti it_fieldcat_lvc = lt_fcat[] TABLES t_outtab = lt_pi_result EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. UNASSIGN: <ls_node_hist>, <ls_node_nhist>, <ls_pi_nhist_data>.

Activate your changes. Then maintain text symbols and selection texts:

Sym Text dLen mLen

GTI Found references in function modules/process messages 53 70

IAP Application 11 40

IDE Deleted 7 40

NSD No order status (order not existing) 36 40

PAR Select-Options 14 40

RGU Process Instruction (OID) 25 40

RID Standard XStep (NID) 20 40

RRI XStep Tree Root Node (NID) 26 40

Page 17: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 17

UPI No description for process instruction 38 40

VID SXS Version (NID) 17 40 Table 1: Text Symbols

Name Text Dictionary

P_FUNC Function Module X

P_PM Mess./instruct. cat. X

P_RBFUNC Usage: Function Module

P_RBPM Usage: Process Message Table 2: Selection Texts

After activation of text elements sample report is ready to be used.

Page 18: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 18

Related Content

State of the Art Maintaining Process Instructions with XSteps - Available Functional Enhancements

Using BAdIs for Custom Valuation and Generation in XSteps

Digital Signatures for SAP Applications Using the Digital Signature Tool – Developer Guidelines and Best Practices

For more information, visit the Manufacturing homepage.

Page 19: Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

Efficient Searching Needles in a Haystack - Find XSteps Containing Process Messages and Function Modules

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 19

Copyright

© Copyright 2011 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Oracle Corporation.

JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and implemented by Netscape.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.