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.
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:
Map with custom truck spot (of course this can have a more realistic position)
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...