The SAP TM geo-map component can be used to display master data and business documents. Sometime the requirement exists in custom development projects to add custom objects to the map. This MKS describes how this can be done with minimal effort.

First of all an enhancement spot implementation class (for example ZCL_MAP_ENHANCE) is needed. This class must implement interface /SCMTMS/IF_EX_MAP_ENHANCE_VB21. Then the enhancement spot implementation can be setup under path IMG -> SAP Transportation Management -> Business Add-Ins (BAdIs) for Transportation Management -> Geographical Map -> Enhancement for Geographical Map -> BAdI: Enhancement for Geographical Map.

MKS61_01_IMG.jpg

To add the custom object, an implementation in enhancement interface method ADJUST_NEW_OBJECTS can be done. This method is called whenever an object is added to the map. It is possible to adjust those spot and link like objects, but also to remove them or add totally new objects.

Example: You want to add an additional spot for each Freight Order representing the resource. The FO is added to the map and supplied to the enhancement method in table CT_LINK_OBJECTS. The FO stage key is the GUID. Adding the new spot needs structure if_vbi_service_provider=>spot_entry containing the following important fields:

GUID                   – Key (usually object key or stage key)

ID                        – Name

TYPE                   – Spot or Link

ROLES                – a table of roles indicating what kind of object it is -> determines for example the icon

DESCRIPTION    – a table of descriptions for tooltip, label, details

FLY_TO               – shall the map zoom to this object

SHOW_LABEL     – shall the label be displayed by default

POSITION           – Longitude and Latitude of spot

With the following code already a spot should be displayed:

METHOD /scmtms/if_map_enhance_vb21~adjust_new_objects.

     DATA: ls_spot        LIKE LINE OF ct_spot_objects,

               lv_role        TYPE vbi_object_role,

               ls_description TYPE vbi_s_object_descr_entry.

     ls_spotguid = /sctm/cl_guid_convert=>get_guid_x16( ).

     ls_spotid   = ‘MY_TRUCK’.

     ls_spotpositionxpos = ‘2’.

     ls_spotpositionypos = ‘3’.

     lv_role = if_vbi_geomap_const=>gc_object_roletruck.

     INSERT lv_role INTO TABLE ls_spotroles.

*Add a description

     CLEAR ls_description.

     ls_descriptioncategory   = if_vbi_const=>gc_descr_categorytooltip.

     ls_descriptionfield_name = ‘Vehicle’.

     ls_descriptionvalue      = ls_spotid.

     APPEND ls_description TO ls_spotdescription.

     INSERT ls_spot INTO TABLE ct_spot_objects.

ENDMETHOD.

TruckCustom.jpg

Map with custom truck spot (of course this can have a more realistic position)

Challenges:

  • Depending on the map component the enhancement shall be active, it can be a challenge to keep the object consistently on the map or remove it at the right point in time. This might require some internal object handling in the custom class.
  • Different icons: When not using the standard roles determining standard icons, it might be required to set the icon in /SCMTMS/IF_MAP_ENHANCE_VB21~ADJUST_SPOT_ICONS.
  • Adding object to the map without others: method ADJUST_NEW_OBJECTS is only called when new objects are added. If you want to show objects without this pre-requisite, either a roundtrip with a new object must be triggered that will be removed immediately and replaced by the custom objects, or a modification is required. (As soon as this comes up I might enhance the enhancement spot…)

A lot more to tell about the options to enhance the map…

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply