Scenario: You’ve setup lots of work modes and assigned them to lots of SAP systems and lots of databases.
However, you now would like to remove them all.
Unfortunately the only method provided by SAP to remove workmodes, is very slow as you must manually go through each SAP system and then each database and remove the workmodes. This is very time consuming.
Instead, it’s possible to do this using the ABAP API provided by SAP.
I’ve provided below a sample of the ABAP I have used to remove all workmodes.
I created it to remove all workmodes from all SAP systems and all databases.
Below we make a call to get the workmodes assign to all SAP systems:
DATA lt_entries type DSWPT_DTM_DT_ALLDT_DISPLAY.
CALL FUNCTION ‘FDSWP_GET_DOWNTIMES_UPTIMES’ DESTINATION ‘NONE’
IV_DOWNTIMES = ‘X’
IV_UPTIMES = ‘X’
IV_COMPONENT_KEY = ‘SID’
IV_COMPONENT_TYPE = ‘SMSY’
IV_IS_DB = ‘-‘
EV_ERROR = lv_error
ET_ENTRIES = lt_entries
We then call the function in a loop (looping on lt_entries) to delete the workmode assignment:
DATA ls_guid type DSWPS_DTM_DT_ALLDT_DISPLAY-ENTRY_GUID.
CALL FUNCTION ‘FDSWP_DELETE_WORKMODE_DTM’ DESTINATION ‘NONE’
IV_WORKMODE_ENTRY_GUID = ls_guid
EV_DELETED = lv_error.