Saturday, February 18, 2006

More on TPVS

There are not many options to analyse the results of automatic planning in TPVS. The shuffler shipments tab is good to check the capacity used by the trucks that result from planning. And the orders tab is good to check what are the locations and dates of the orders combined in each transport. The orders tab would be more useful if there was a column with the shipment number, so that all shipments could be checked at once. It is a simple enhancement to make. Here goes a quick recipe.

1) Add a new field to the append of structure /SAPAPO/VSR_G_FUNIT (for example named ZZ_SHIPNUM)

2) In exit EXIT_/SAPAPO/SAPLVS_VSGUI_005 use something like this code


LOOP AT ct_funit.
l_tabix = sy-tabix.
* Only the orders already planned
IF ct_funit-state <> 0.
CALL FUNCTION 'Z_TPGET_SHIPNUM'
EXPORTING
p_orderid = ct_funit-orderid
IMPORTING
p_shipment = ct_funit-zz_shipnum
EXCEPTIONS
failed = 1
OTHERS = 2.

IF sy-subrc = 0.
MODIFY ct_funit INDEX l_tabix TRANSPORTING zz_shipnum.
ENDIF.
ENDIF.
ENDLOOP.


3) The function Z_TPGET_SHIPNUM


FUNCTION z_tpget_shipnum.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(P_ORDERID) TYPE /SAPAPO/ORDERID
*" EXPORTING
*" REFERENCE(P_SHIPMENT) TYPE /SAPAPO/VS_G_DISPSID
*" EXCEPTIONS
*" FAILED
*"----------------------------------------------------------------------

DATA: l_simsessid TYPE /sapapo/om_simsession,
l_simverid TYPE /sapapo/vrsioid,
ls_gen_params TYPE /sapapo/om_gen_params,
lt_shipments TYPE /sapapo/vsr_ship_tab,
ls_shipments TYPE /sapapo/vsr_ship_str,
lt_orders TYPE /sapapo/vsr_funit_id_tab,
l_shipment_no TYPE /sapapo/vs_g_dispsid.

CALL FUNCTION '/SAPAPO/RRP_SIMSESSION_GET'
IMPORTING
es_gen_params = ls_gen_params.

CALL FUNCTION '/SAPAPO/TSIM_SIMULATION_GET'
IMPORTING
e_simsessid = l_simsessid
e_simverid = l_simverid.

CALL FUNCTION '/SAPAPO/DM_VS_SHIPMENT_READ'
EXPORTING
is_gen_params = ls_gen_params
iv_simsession = l_simsessid
iv_orderid = p_orderid
IMPORTING
et_assigned_order = lt_orders
et_shipments = lt_shipments
EXCEPTIONS
lc_connect_failed = 1
lc_com_error = 2
lc_appl_error = 3
not_found = 4
wrong_inputs = 5
internal_structure_error = 6
invalid_resource = 7
timestamp_error = 8
invalid_pegarea = 9
invalid_order = 10
OTHERS = 11.

IF sy-subrc <> 0.
RAISE failed.
ENDIF.

READ TABLE lt_shipments INTO ls_shipments INDEX 1.

IF sy-subrc = 0.
CALL FUNCTION '/SAPAPO/VS_SHIPMENT_GET_TEXT'
EXPORTING
is_gen_params = ls_gen_params
iv_simsession = l_simsessid
iv_shipment_guid = ls_shipments-shipment_guid
IMPORTING
ev_text = l_shipment_no
EXCEPTIONS
shipment_read_failed = 1
OTHERS = 2.

IF sy-subrc <> 0.
RAISE failed.
ENDIF.

p_shipment = l_shipment_no.

ENDIF.

ENDFUNCTION.

Labels: ,

2 Comments:

Anonymous Anonymous said...

Just a hint to your point 2):
Being in a LOOP, the MODIFY statement (without the TABLE option) uses the current index of the loop. So you do not need to track it yourself in a local variable.

11:50 AM  
Blogger pvl said...

Using those sy variables is dangerous ... it's hard to find a bug related to some unexpected change in those variables. That's why I usually save the value of sy-tabix in the start of the loop, or save the value of sy-subrc after the function call, etc.

But yes, I agree that the code snippet would be cleaner without the redundant l_tabix variable.

4:25 PM  

Post a Comment

<< Home