Skip to Content
Author's profile photo Marçal Oliveras

SAP Work Manager 6.2.0: How To Add Pictures to a Local Notification (using BDS)

Hi there,

I decided to create the post because it’s the second time I have to enhance Work Manager 6.x with this functionality that in my opinion should come out-of-the-box, I hope SAP will add it in the future.

It will also be useful for inexperienced developers since there are not many articles about how to develop in Agentry, and this task involves changes to all the different components.

The Problem:

In Work Manager 6.2 the option to attach pictures to a notification is disabled when the object is local, meaning that it doesn’t exist yet in SAP and therefore it only has a temporary local ID.

This is very inconvenient for field technicians working offline. If they need to create a notification they can’t add pictures to it before they synchronize the data to SAP and that is only possible when they are online. Therefore I assume that a lot of customers had to do the same enhancement.

The below explanation is highly technical and it requires a knowledge of Agentry Framework development, including UI, Java interfacing and Back End processing:

Development Overview:

  • The goal is to activate the add pictures button for local notifications. But unlike the standard action, for local notifications the transaction step won’t have an update step sending the picture directly to the back end. First it will just be added to the DocumentLinks collection, and it will be posted only after its linked notification has been created in SAP during the transmit action,
  • From the back end point of view, when the notification is created, the link between the mobile app object local ID and the  ID given by SAP to the notification is stored in a custom table. Then, when the pictures are posted to SAP, the local notification ID will be replaced by the SAP one in an enhancement in order to attach the pictures to the correct notification.
  • Prerequisite. Work Manager should be configured to use BDS for Notification attachments.
  • Observations: For Work Manager 6.1 the idea can be reused but the DocumentLink actions and objects have some differences, therefore it must be adapted. I haven’t investigated Work Manager 6.2.1 (released on May 2015) but I also saw some differences that may affect my changes.

Agentry UI changes:

The action to add picture to a notification has been replaced for a new action that calls the original one in case of a non-local notification or a new one (without update step) for local notifications.

The non-local notifications will be processed as in the standard solution, but the local ones, will first be first posted in SAP, and later on if they have documents attached, a new action during the transmit will be executed to add them once the real SAP notification ID is known.


  • Created rule Z_EnableLocalNotificationPictureAttachment. This rule determines if the action step DocumentLinkPictureAddForNonLocalNotification for action Z_DocumentLinkPictureAddForNotification has to be called.
  • Created rule Z_EnableNonLocalNotificationPictureAttachment. This rule determines if the action step DocumentLinkPictureAddForLocalNotification for action Z_DocumentLinkPictureAddForNotification has to be called.
  • Modified rule ExecuteDocumentLinksClearLoopForNotifications to not clear document links from local notifications during the transmit action.
  • Modified rule EnableNotificationAttachment in order to show the attachments tab for local notifications as well as the non-locals.


  • Created transaction Z_DocumentLinkPictureAddForLocalNotification copy of the original DocumentLinkPictureAddForNotification but removing the update step, since we need to force the notification creation first in order to have the SAP notification ID.
  • Created transaction Z_DocumentLinkPostForLocalNotification. It is an edit without screen transaction with the update step AttachmentCaptureSteplet that will create the attachment in SAP.


  • Created action Z_DocumentLinkPictureAddForLocalNotification, it will add a picture to the MainObject DocumentLinks collection but without an update step, like the standard solution does for non-local. It also adds a DocumentMetaData object to the Notification collection property.
  • Created action Z_DocumentLinkPictureAddForNotification. It calls the standard action DocumentLinkPictureAddForNotification for non-local notifications and the new Z_DocumentLinkPictureAddForLocalNotification for the local ones.
  • Created action Z_DocumentLinkPostForLocalNotification. It calls the transaction Z_DocumentLinkPostForLocalNotification in order to create the picture in SAP as BDS.
  • Modified action NotificationPostCurrent adding a new subaction step Z_DocumentLinksPostForLocalNotifications. This subaction loops over all the Main Object DocumentsLinks property items and for each one linked to the local notification being posted, calls the action Z_DocumentLinksPostForLocalNotification to create the picture in SAP.


  • Modified NotificationAttachmentTileList_Detail_iPad from NotificationTileView screen set.

  Action from button “Upload picture” modified to use the new Z_DocumentLinkPictureAddForNotification.

This is how the new action to add pictures looks like:

And the new action to add pictures executed after posting the local notification.

Java changes:

  • Created class
    • Overridden method setHeaderParameters(Logger) in order to send the notification ID when posting a local notification. The reason is to have the ID available in SAP, it will be stored in a custom cross reference table and then the pictures attached to the local notification will be correctly added to the right one in SAP.

    protected void setHeaderParameters(Logger log) throws Exception {
        //Set the notification ID for local notificatons, it will be used to create an
        //entry to the custom cross reference table to be able to add pictures knowing only the local ID
        if (_notification.getIsLocal()) {
            setValue(_imports, log, "IV_NOTIF_NO", _notification.getNotifNum());

Configuration Portal Adjustments:

  • Changed global parameter to assign the customer NotificationPostBAPI class
    • Group: BAPI_CLASS
    • Name: NotificationPostBAPI
    • Value:
  • Created global parameter to assign a BAPI wrapper to the new customer NotificationPostBAPI class
    • Group: BAPI_WRAPPER
    • Name:

ABAP Changes:

*2015-08-16 Update: Check Sergey comment on this blog, since he implemented the functionality without ABAP changes. As I mention below in my original text, when I tried to do this first time in version 6.1.0 some deprecated code was triggered using table /SYCLO/MDW03, but standard Java source has been updated since then and probably this is not happening anymore in 6.2.X (or maybe I did something wrong in my attempt): Comment Link

To be able to add attachments to a notification whose ID in the Agentry client is LOCAL_X, the following changes have been implemented in SAP in order to know the notification ID assigned by the backend after its creation and be able to add the corresponding attachment to it.

  • Created table ZAGT_CUST_XREF. This table will store the links between the Agentry client local notification ID and the value assigned by SAP after creation. It is a copy of the standard /SYCLO/MDW03 but reusing the original table was not an option because deprecated Java code was triggered once entries were added to this table and it was not possible (or easy) to control the flow of data. The table has a generic name since it may be used for other Agentry applications or objects.
  • BADI implementation in order to maintain the new cross reference table ZAGT_CUST_XREF every time a notification is created from the device and clear the entries after the fetch.
  • Standard Handler Class: /SMERP/CL_PM_NOTIFICATION_DO
  • Enhancement Spot name: /SMERP/MDO_PM_NOTIFICATION
  • Implemented/Modified methods:
    • BADI Action and implementation description: Added the changes in order to read the local notification ID before calling the notification creation BAPI.
    • Implementation description: If the notification is local (creation), read the IV_NOTIF_NO field and clear it after saving the local ID from Agentry client to a BADI class attribute.

*    Read the client local notification ID into the BADI attribute
      ASSIGN ('CS_MDO_INPUT_VALS-IV_NOTIF_NO->*') TO <lv_notif_no>.
      IF <lv_notif_no> IS ASSIGNED AND <lv_notif_no> CS 'LOCAL_'.
        me->notif_no = <lv_notif_no>.
        CLEAR <lv_notif_no>.

    • BADI Action and implementation description: Read the new ID after creating the notification in SAP and store the cross reference between the local Agentry client ID and the new one in SAP.
    • Implementation description: Store the link between IDs in the new custom table ZAGT_CUST_XREF.

*    Get the local client and the SAP notifications ID values and create an entry in the xref table
      ASSIGN ('CS_MDO_OUTPUT-ES_NOTIF_HEADER->*') TO <ls_bapi_notif_header>.
      IF <ls_bapi_notif_header> IS ASSIGNED AND <ls_bapi_notif_header>-notif_no IS NOT INITIAL.
        CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_c32
            uuid = ls_cust_xref-reference_guid.
        ls_cust_xref-user_guid = <ls_bapi_input>-user_guid.
        ls_cust_xref-object_type = me->wm_obj_type_notif.
        ls_cust_xref-source_obj_key = me->notif_no.
        ls_cust_xref-target_obj_key = <ls_bapi_notif_header>-notif_no.
        ls_cust_xref-effective_ts = 0.
        ls_cust_xref-changed_by = sy-uname.
        /syclo/cl_core_bapi_tools=>get_system_time( IMPORTING ev_system_ts = ls_cust_xref-changed_ts ).
        MODIFY zagt_cust_xref FROM ls_cust_xref.

    • BADI Action and implementation description: Remove all the cross reference custom table notification entries for the user executing the notification fetch.
    • Implementation description: Delete entries from table ZAGT_CUST_XREF for the object type notification and the user executing the fetch.

*    Delete user's notification cross reference IDs
      DELETE FROM zagt_cust_xref
        WHERE user_guid = <ls_bapi_input>-user_guid
          AND object_type = me->wm_obj_type_notif.

Implicit enhancement point added in order to replace the local notification ID for the real one created in SAP when posting a BDS picture. Implementation details:

  • Standard Handler Class: /SMERP/CL_CORE_KWDOCUMENT_DO
  • Enhanced Method: BDS_DOCUMENT_CREATE
  • Implemented Points START:
    • Implementation description: Replace notification local notification ID by the SAP ID (instid) when the BDS document being created is a notification and the ID sent from Agentry starts by “LOCAL_”, meaning that the attachment was added to a local notification before knowing the real ID.

ASSIGN <ls_mob_in_params>-value->* TO <lv_target>.
      IF <lv_target> IS ASSIGNED.
        ASSIGN <lv_target> TO <ls_business_obj>.
 *      Replace the local notification ID for the SAP ID
        IF <ls_business_obj>-typeid = lc_type_maint_notif AND <ls_business_obj>-instid CP 'LOCAL_*'.
          lv_source_obj_key = <ls_business_obj>-instid.
          SELECT SINGLE target_obj_key FROM zagt_cust_xref INTO lv_target_obj_key
            WHERE user_guid = me->active_user_guid
              AND object_type = lc_wm_obj_type_notif
              AND source_obj_key = lv_source_obj_key.
          IF sy-subrc = 0.
            lv_qmnum = lv_target_obj_key.
                input  = lv_qmnum
                output = lv_qmnum.
            <ls_business_obj>-instid = lv_qmnum.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Muralidharan Surendran
      Muralidharan Surendran

      Good work. Its good to see that you shared this on SDN for everyones benefit.

      Author's profile photo Bill Froelich
      Bill Froelich

      Thanks for posting!  This will be helpful for many until it becomes part of the standard product.

      Author's profile photo Former Member
      Former Member

      Thanks, it was helpful.

      I've decided to not implement ABAP at all, though. Instead, in the Transaction Z_DocumentLinkPostForLocalNotification I fill the standard field MiddlewareObjectType by constant value NOTIF_DOCLINK. And next in Java method NotificationPostBAPI.processResults() I set up cross-reference between local and real NotifNum using the same NOTIF_DOCLINK as value of the parameter ObjectType:

        if (_bapiType.equals("CREATE")) {

           if (_notification.getIsLocal()) {

          DocumentLinkComponentManager documentLinkComponentManager =

              (DocumentLinkComponentManager) _user.getComponentManager(DocumentLinkComponentManager.COMPONENT_MANAGER_CLASS_NAME);

          documentLinkComponentManager.addObjectXref(localNotifNum, _notification.getNotifNum(), "NOTIF_DOCLINK");



      Thus, links gets into /SYCLO/MDW03, but it makes no troubles.

      Author's profile photo Marçal Oliveras
      Marçal Oliveras
      Blog Post Author

      Thanks Sergey, I updated the ABAP part with a link to your comment.

      Author's profile photo Former Member
      Former Member

      Nice post.