Skip to Content
SAP Global Batch Traceability

Add new search criteria to the Batch Search Screen

Tags:

This document describes how to create new search criteria in the Batch Search using fields from batch, handling unit, delivery, and material document.

Standard search criteria

On the Batch Search Screen, Global Batch Traceability 2.0 provides the following search criteria in the standard:

  • Batch
    • Batch Number (BATNR)
    • Material Number (MATNR)
    • Plant (PLANT)
    • Logical System (LOGSYS)
    • Vendor Batch Number (PRT_BATNR)
  • Material
    • Material Description (MATERIAL_DESCR)
  • Product Group
    • Filled dynamically
  • Handling Unit
    • Handling Unit (HUMNR)
    • Packaging Material (PACK_MAT)
    • Warehouse (WHSENUMBER)
    • WM Transfer Order (WMTONR)
  • Delivery
    • Ship-To Party (SHIP_TO)
    • Sold-To Party (SOLD_TO)
    • Actual Goods Issue Date (GI_DATE)
  • Material Document
    • Posting Date (PSTNG_DATE)
    • Movement Type (MOVE_TYPE)
  • Characteristics
    • Filled dynamically (can be defined by creating batch class GBT_SEL_CRITERIA as described in SAP note 1870447)

It is easily possible to add fields (standard or customer fields) from the objects Batch, Handling Unit, Delivery, Material Document, and Purchase Order as new search criteria to the batch search.

Add new search criteria using BAdI /PLMB/EX_SPI_METADATA_DYN

The search criteria can be modified by implementing method GET_NEW_NODE_DEFINITION of the BAdI /PLMB/EX_SPI_METADATA_DYN (part of Enhancement Spot /PLMB/ES_SPI).


Create a new BAdI implementation for /PLMB/EX_SPI_METADATA_DYN and implement method /PLMB/IF_EX_SPI_METADATA_DYN~GET_NEW_NODE_DEFINITION to add or delete search criteria.

The following example adds the field PROD_DATE (Date of Manufacture) from the batch master:


  DATA:
    ls_component        TYPE /plmb/s_spi_component_descr,
    ls_component_detail TYPE /plmb/s_spi_criteria_details.

  FIELD-SYMBOLS:
    <ls_query_def> LIKE LINE OF cs_metadata_node-queries-sp.


  READ TABLE cs_metadata_node-queries-sp ASSIGNING <ls_query_def>
    WITH KEY query_name = /gbt/cl_nw_mp=>gc_query_name-batch_by_char.
  CHECK sy-subrc = 0.

* Batch: 'Date of Manufacture'
  CLEAR ls_component.
  CLEAR ls_component_detail.
  ls_component-name = 'SAP%PROD_DATE'.
  ls_component-type = '/GBT/BAT_PROD_DATE'.
  APPEND ls_component TO <ls_query_def>-definition-criteria-components.
  ls_component_detail-name          = ls_component-name.
  ls_component_detail-description_s = '009'.
  ls_component_detail-description_l = /gbt/cl_spi_util=>get_data_element_description( ls_component-type ).
  CONCATENATE 'BAT:' ls_component_detail-description_l INTO ls_component_detail-description_l SEPARATED BY space.
  ls_component_detail-options = /gbt/cl_spi_util=>fill_char_select_options( ).
  INSERT ls_component_detail INTO TABLE <ls_query_def>-definition-criteria-component_details.


To delete search criteria you do not want to provide to the users, add the coding similar to the following example in the same method:


* Remove Material Documents Posting Date
  DELETE <ls_query_def>-definition-criteria-components WHERE name = 'MDI%PSTNG_DATE'.
  DELETE TABLE <ls_query_def>-definition-criteria-component_details WITH TABLE KEY name = 'MDI%PSTNG_DATE'.


Add new search criteria via implicit enhancement

As an alternative, you can create an implicit enhancement at the end of method /GBT/CL_NW_MP->ADD_SEL_CRIT_COMPLEX_SEARCH and add some coding to define the additional search criteria.

The following example describes how to add the field PROD_DATE (Date of Manufacture) to the batch search:

  1. Start transaction SE24 or SE80 to display class /GBT/CL_NW_MP. Open method ADD_SEL_CRIT_COMPLEX_SEARCH.
  2. Choose 'Edit' -> 'Enhancement Operations' -> 'Show Implicit Enhancement Options' from the menu.
    Choose 'Method' -> 'Enhance' from the menu or press Ctrl+F4 to switch to enhancement mode.
  3. Place the cursor at the line before the ENDMETHOD statement and choose 'Edit' -> 'Enhancement Operations' -> 'Create Implementation' from the menu or press Shift+Ctrl+F8.
  4. On the following popup 'Choose Enhancement Mode' choose button 'Code'.
  5. On the following popup 'Create Enhancement Implementation' enter a name and a short description, e.g. Z_ADD_SEL_CRITERIA and 'Add search criteria to batch search' and press Enter.
  6. Enter the following coding in the enhancement:

    * Batch: 'Date of Manufacture'
      CLEAR ls_component.
      CLEAR ls_component_detail.
      ls_component-name = 'SAP%PROD_DATE'.
      ls_component-type = '/GBT/BAT_PROD_DATE'.
      APPEND ls_component TO cs_criteria_def-components.
      ls_component_detail-name          = ls_component-name.
      ls_component_detail-description_s = '007'.  "First sort field
      ls_component_detail-description_l = /gbt/cl_spi_util=>get_data_element_description( ls_component-type ).
      ls_component_detail-options = /gbt/cl_spi_util=>fill_char_select_options( ).
      INSERT ls_component_detail INTO TABLE cs_criteria_def-component_details.
  7. Check and activate the enhancement (Ctrl+F2 and Ctrl+F3).


In the same way you can also remove standard selection criteria which you do not want to provide to the users.
For example to remove the field 'Posting Date' from the selection, add the following lines to the implicit enhancement:


* Remove Material Documents Posting Date
  DELETE cs_criteria_def-components WHERE name = 'MDI%PSTNG_DATE'.
  DELETE TABLE cs_criteria_def-component_details WITH TABLE KEY name = 'MDI%PSTNG_DATE'.

Prefix for object type

To enable the query to identify the object to which the field belongs to, a prefix is used in the technical name of the new search criterion.

In the example above, the prefix 'SAP%' is used for the batch field PROD_DATE in variable ls_component-name.

The following prefixes have to be used for the different object types in the batch search:

  • Batch: SAP%
  • Handling Unit: HUX%
  • Delivery: DLV%
  • Material Document: MDI%
  • Purchase Order: PUI%
  • Production Order: POR%

Sorting of search criteria

The sequence of the search criteria is defined first by the number in field ls_component_detail-description_s and then by the text in field ls_component_detail-description_l.

Each object type like batch or delivery has a number range for the first sort field ls_component_detail-description_s to group the search criteria:

  • Batch: 001 - 009
  • Product Group: 010
  • Handling Unit: 021 - 030
  • Deliveries: 031 - 040
  • Material Documents: 041 - 050
  • Characteristics: 999

You can define the sequence of the search criteria either by assigning specific numbers, or by using the same number to sort alphabetically by field ls_component_detail-description_l.


No comments