Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 
perezjquim
Explorer
Hello everyone,

In this blog I'll present to you an alternative way to override target mappings.

Introduction


As a matter of example, let's say that you've developed an extension to a standard Fiori app.
Now, you have to make sure that the extended app runs (instead of the original one) when the end-users try to access it.

This can be done through one of the following ways:

  • As a manual process, by going through every single catalog in which the original app is included and modify them (which is a huge bummer, not to mention that it's not upgrade-safe at all 😊)

  • You can create a custom catalog, in which you create a new target mapping, taking advantage of the sap-priority parameter (that'll ensure that the app with the highest priority will be run) and assign this custom catalog to all users (more detail on this blog)


Even though the second one is pretty neat and near-perfection, there's a third way to do that - through a simple ABAP enhancement.

How-to


Basically, all you need to is the following:

Go to /UI2/CL_TM_PB_ACCESS and enhance the method GET_TARGET_MAPPINGS (implicit enhancement or a post-exit method, do as you please 😊).


In the enhancement, you can then adapt the returning table RT_TM (that contains the user's target mappings) to fit your needs.

For example:

Imagine you wanted to replace "Display Treasure Alerts" Fiori app with an extended one (for simplicity's sake, let's replace it with the MyInbox one):


Then you can include something like the following code in your enhancement (similarly to what you would configure in your new target mapping):
  METHOD ipo_zenh_bc_ui5_tmap_override~get_target_mappings.
*"------------------------------------------------------------------------*
*" Declaration of POST-method, do not insert any comments here please!
*"
*"methods GET_TARGET_MAPPINGS
*" importing
*" !IR_OBJECT type /UI2/CL_TM_PB_ACCESS=>TTR_OBJECT
*" !IR_ACTION type /UI2/CL_TM_PB_ACCESS=>TTR_ACTION
*" !IR_CATALOGS type /UI2/CL_TM_PB_ACCESS=>TTR_CATALOGS
*" !IR_TM_ID type /UI2/CL_TM_PB_ACCESS=>TTR_TM_ID
*" !IR_CHIP_ID type /UI2/CL_TM_PB_ACCESS=>TTR_CHIP_ID
*" !IR_APP_TYPE type /UI2/CL_TM_PB_ACCESS=>TTR_APP_TYPE optional
*" changing
*" value(RT_TM) type /UI2/IF_TM_INDEX_ACCESS=>TP_T_TM_INT
*" raising
*" /UI2/CX_FDM_CACHE_INVALID . "#EC CI_VALPAR
*"------------------------------------------------------------------------*

LOOP AT rt_tm REFERENCE INTO DATA(ls_tm_ext) WHERE object = 'TreasuryAlert' AND action = 'displayPosting'.

ls_tm_ext->additional_data = 'SAPUI5.Component=cross.fnd.fiori.inbox'.
ls_tm_ext->application-sapui5-component = 'cross.fnd.fiori.inbox'.
ls_tm_ext->application-sapui5-uri = '/sap/bc/ui5_ui5/sap/ca_fiori_inbox'.

ENDLOOP.

ENDMETHOD.

In other words, in this case we looped through every target mapping for #TreasuryAlert-displayPosting - the Semantic Object/Action combination for "Display Treasure Alert" app - and replaced the component and the URL with the MyInbox ones.

By doing that, when we try again to enter the aforementioned app, it will instead open MyInbox:


Note: you may need to clear the cache after implementing the enhancement.

This is a pretty straightforward example, but there's a lot you can do here... just make sure you know what you're doing 😊



Advantages



  • Cleaner approach (since you don't have to create an additional catalog and target mapping)

  • No role maintenance nor user role assignment needed (since the enhancement will be applied globally)


Disadvantages


None πŸ˜Š

Conclusion


To sum up, it is also possible to override target mappings by implementing a simple enhancement.
It doesn't invalidate at all the sap-priority approach, since it still is a clean one.
Thus, both approaches are pretty much valid.
Nevertheless, by doing it with this kind of enhancement we can reduce the maintenance effort a bit.

 

Any questions/comments/suggestions?

Feel free to leave them down below.

 

For more Fiori-related resources, feel free to:
– Follow the Fiori topic
– Post/answer Fiori-related questions
– Read other Fiori-related posts

 

Best regards,

Joaquim Perez
1 Comment
Labels in this area