Skip to Content
SAP Visual Business

ABAP Development: HowTo add own images (e.g. for pins and icons)

Tags:

Replacement of the default pins

All pictures, which should be used in and Visual Business application need to be uploaded to the frontend upon the initialization of the application. By default only the three pictures for the pins get uploaded. Those pictures are stored as MIME objects in the public brach of the MIME repository under node BC/VBI.

The easiest way to exchange those images is to store an alternative set somewhere in the MIME repository and to provide the new MIME repository path to the application replacing the default path. When directly using the ABAP API you pass this path as parameter IV_MIME_REP_PATH to method GET_INITIAL_ZIP_ARCHIVE of the VBI application class.

When using the Visual Business WD reuse compont VBI_WD_VISUAL_BUSINESS or the FPM GUIBB you can provide the alternative path via a own configuration:

Via the configuration you can set the path to the folder in the MIME repository, where the images get loaded from.


Information

With this approach it is important to use the same exact names for the images at the alternative MIME repository folder.

Additional images for icons or detail windows

With direct API access, e.g. in an own SAPGUI program, you can provide additional content via parameter IT_ADDITIONAL_RESOURCES to method GET_INITIAL_ZIP_ARCHIVE of the VBI application class. 

Without direct access the starting point for uploading additional images to the frontend is also an own WD component configuration. Under configuration node spConfig you can enter your own implementation classes for the service provider, the UI adapter, and the application class.

In the current scenario we need to replace the default application class CL_VBI_GEOMAP_APPLICATION by an own implementation, which could be simple derived from the default class.

In the derived class we need to redefine method GET_INITIAL_ZIP_ARCHIVE in order to provide entries in table IT_ADDITIONAL_RESOURCES when calling the super implementation. This table is basically a name-value-pair tab. Field NAME holds the name of the image with which you are going to address the image later on, and CONTENT is the binary representation of the image file. In case you load the picture from the MIME repository you can use the following code sample to get the data:

* get MimeRepository API (respecting prefix)

  data: LV_MR_API type ref to IF_MR_API,

   LV_XCONTENT type XSTRING.

  LV_MR_API = CL_MIME_REPOSITORY_API=>IF_MR_API~GET_API( ). "i_prefix = default MIME path

* get the images from the MimeRepository

  LV_MR_API->GET( exporting I_URL = |{ LV_MIME_PATH }Spot.png|

   I_CHECK_AUTHORITY = ABAP_FALSE

   importing E_CONTENT = LV_XCONTENT

   exceptions others = 0 ).

Exchange role icons and pins

The logic which pin and icon is shown for a spot in a certain role and state is fully located in the backend implementation of the GeoMap component. The Visual Business frontend understands only images and SAP icon (referenced by the ID shown in transaction ICON). The assignment of roles and states to there visualization is done in the Control Adapter CL_VBI_CONTROL_ADAPTER_GEO, which is used in the default configuration of the GeoMap component. In the Control Adapter class you find the methods:

  • DETERMINE_SPOT_PINS_ICONS - Sets the name of the pin picture to be used for a certain spot, and
  • DETERMINE_SPOT_ICONS_BY_ROLE - Sets the name of the icon picture or icon ID to be used for the given role.

In order to adapt icons and pins to your needs, or event extent the role concept and the possible states, you can spezialize the control adapter class further and enter your version in an own component configuration.

No comments