Dynamical Determination of Worklist Items: Select Batches by Shelf Life
This article describes how to add batches with the shelf life date within a certain time frame to a worklist.
GBT 2.0 offers the functionality of worklists which enables you to group tracked objects for further checking, and to trigger actions or run reports. You can share a worklist to solve an issue together with other colleagues.
Worklist items can either be read from the standard database tables (stored manually or using a period report) or they can be selected dynamically when displaying a worklist by executing a specific programmed determination.
To select worklist items dynamically, interface /GBT/IF_WORKLIST_ITEM_READ, which has two methods, needs to be implemented:
- Method GET_NAME to define a name for the dynamical determination of worklist items
- Method GET_ITEM_BY_WORKLIST_ID which has the worklist item determination logic
In this example, a worklist is implemented to display all batches which will expire in the next 30 days. This worklist should always display the current result for the date it is displayed.
The implementation of interface /GBT/IF_WORKLIST_ITEM_READ has to be created using transaction SE24.
- Double click on method GET_NAME, copy the following coding into this method, and choose Save (Ctrl+S):
rv_name = 'Batches expiring next 30 days'(001).
- Go back to the class header (F3), and double click on method GET_ITEM_BY_WORKLIST_ID.
- Copy the following coding into this method and choose Save (Ctrl+S):
lv_expiring_date TYPE /gbt/bat_expiry_date,
lt_bat_itm_guid TYPE /gbt/t_obj_guid.
<ls_worklist_itm_key> LIKE LINE OF et_worklist_itm_key,
<lv_bat_itm_guid> LIKE LINE OF lt_bat_itm_guid.
lv_expiring_date = sy-datum + 30. "Expiring in 30 days
* Perform selection to return items with real batches
SELECT obj_guid FROM /gbt/v_bat_itm INTO TABLE lt_bat_itm_guid
WHERE expiry_date >= sy-datum
AND expiry_date <= lv_expiring_date.
LOOP AT lt_bat_itm_guid ASSIGNING <lv_bat_itm_guid>.
APPEND INITIAL LINE TO et_worklist_itm_key
<ls_worklist_itm_key>-worklist_id = iv_worklist_id.
<ls_worklist_itm_key>-obj_guid = <lv_bat_itm_guid>.
<ls_worklist_itm_key>-obj_type = 'BAT'.
- Activate all objects of the new class (Ctrl+F3).
- Add the new class to the GBT customizing Analysis of Global Batch Traceability Network -> Maintain Available Classes for Dynamic Worklist Items.
- Create a worklist with dynamic items:
- In the SAP NetWeaver Business Client (transaction NWBC) select a role and navigate to the Process Worklists screen.
- Choose Create and enter a name and a description for the new dynamic worklist to show all batches which will expire in the next 30 days.
- From the dropdown menu for column Item Selection choose the class name created before ('Batches expiring next 30 days').
- Choose Save to save your changes.