More TP/VS hacking
There is an icon column in the orders list in TPVS, it is used to exclude some orders from the optimizer. If you have used VS01 this screen is familiar for sure.
Users love to have some visual tips for some special cases they need to take extra attention. And with this icon it's so easy to give then what they love. To put a flag on the icon for some small orders we just need this on exit EXIT_/SAPAPO/SAPLVS_VSGUI_005.
The result is something like this:
This is good for display, but one may want to use this field to exclude some orders from processing. A quick description of the scenario is to have some coded rules that, based on some configuration, puts alert icons in some orders and excludes them from the optimizer. The planners need to review manually those orders with alerts.
It would be good to be able to just lock the order in the EXIT_/SAPAPO/SAPLVS_VSGUI_005 exit, but the lock field is not available at that stage. There is one workaround I use that is good enough for the job. With exit EXIT_/SAPAPO/SAPLVS_VSGUI_005 I put some rules that set some icons for those special cases. By default any order that has an icon will be excluded from the optimizer run. That is made by having some coding to delete items in BADI /SAPAPO/VS_OPT_PREP (after starting optimization in VS01 but before sending the data to the optimizer). Something like this:
With this logic, if the user sees some order with an alert (with an icon) he may want to remove the icon to include the order in the optimizer run. To do that he can choose the order, then choose the "lock from the optimizer" option, and then remove the "lock from the optimizer" by clicking the button again. This has the side effect of removing the icon.
It's not 100% clean, but overall I find this a simple solution to a much demanded request. If it can be made simpler, I would be very interested in knowing :-).
PS. There are probably better ways to see the ID codes of the icons, one way is to use transaction ICON that shows all the icons and then look in debug the EXTRACT[]-ID value for the icon.
Users love to have some visual tips for some special cases they need to take extra attention. And with this icon it's so easy to give then what they love. To put a flag on the icon for some small orders we just need this on exit EXIT_/SAPAPO/SAPLVS_VSGUI_005.
LOOP AT ct_funit.
IF ct_funit-rcap_cap1 < lc_low_limit.
CT_FUNIT-ICON = '@F1@'.
ENDIF.
ENDLOOP.
The result is something like this:
This is good for display, but one may want to use this field to exclude some orders from processing. A quick description of the scenario is to have some coded rules that, based on some configuration, puts alert icons in some orders and excludes them from the optimizer. The planners need to review manually those orders with alerts.
It would be good to be able to just lock the order in the EXIT_/SAPAPO/SAPLVS_VSGUI_005 exit, but the lock field is not available at that stage. There is one workaround I use that is good enough for the job. With exit EXIT_/SAPAPO/SAPLVS_VSGUI_005 I put some rules that set some icons for those special cases. By default any order that has an icon will be excluded from the optimizer run. That is made by having some coding to delete items in BADI /SAPAPO/VS_OPT_PREP (after starting optimization in VS01 but before sending the data to the optimizer). Something like this:
DATA: ls_orders_free TYPE /sapapo/vsr_g_funit,
ls_order TYPE /sapapo/vsr_o_i_order,
ls_ord_servicetime TYPE /sapapo/vsr_o_i_order_s_time,
ls_ord_quan TYPE /sapapo/vsr_o_i_order_quantity,
l_tabix LIKE sy-tabix.
LOOP AT it_orders_free INTO ls_orders_free.
IF NOT ls_orders_free-icon IS INITIAL.
READ TABLE ct_order INTO ls_order
WITH KEY guid = ls_orders_free-orderid.
l_tabix = sy-tabix.
IF sy-subrc = 0.
DELETE ct_order INDEX l_tabix.
ENDIF.
LOOP AT ct_ord_servicetime INTO ls_ord_servicetime
WHERE order_id = ls_order-opt_id.
l_tabix = sy-tabix.
DELETE ct_ord_servicetime INDEX l_tabix.
ENDLOOP.
LOOP AT ct_ord_quan INTO ls_ord_quan
WHERE order_id = ls_order-opt_id.
l_tabix = sy-tabix.
DELETE ct_ord_quan INDEX l_tabix.
ENDLOOP.
ENDIF.
ENDLOOP.
With this logic, if the user sees some order with an alert (with an icon) he may want to remove the icon to include the order in the optimizer run. To do that he can choose the order, then choose the "lock from the optimizer" option, and then remove the "lock from the optimizer" by clicking the button again. This has the side effect of removing the icon.
It's not 100% clean, but overall I find this a simple solution to a much demanded request. If it can be made simpler, I would be very interested in knowing :-).
PS. There are probably better ways to see the ID codes of the icons, one way is to use transaction ICON that shows all the icons and then look in debug the EXTRACT[]-ID value for the icon.