Problem: you want to enable user to execute action assigned to a message visible in Message Log in TCODE CRMD_ORDER (under the clock with check mark icon). Also, you want this action to be your customer defined action, with customer code behind it.
Solution: There is a way to do it, although it requires you to modify standard SAP objects.
First, a bit of information about the actions defined for the messages. You can define these actions in the transaction SM34 for view CRMV_MESSAGES. Select the Application Area (this corresponds to Message Class) and select message you want to add action to. Let’s say, you want to add standard Service Contract selection action. For this you need to enter CONTRACT_SRV_SEL as action name.
Unfortunately there is no Search Help for the actions possible. Also, at this moment only standard SAP actions are possible for execution. You can add a non-standard one but it will not be executed.
So, what do you need to do to enable CRM to execute your customer action (with customer code behind it)? There are few steps in the process:
- Take a look at FM CRM_1O_FCODE_FILTER. This function determines the prefix of the assigned action. It is important that you check this function, as not all prefixes will allow you to execute the customer code. You should be interested in prefixes, that make FM CRM_1O_FCODE_FILTER return value in the ev_non_appl_prefix parameter.
Prefix is the first word of the action name. In the example above the prefix is CONTRACT.
- Prefix returned from CRM_1O_FCODE_FILTER is then used in FM CRM_1O_FCODE_EXECUTE to determine the function name for action execution. Name is determined in this simple manner:
CONCATENATE 'CRM_' ev_non_appl_prefix '_FCODE' INTO lv_function_name.
CONCATENATE 'CRM_' ev_non_appl_prefix '_FCODE' INTO lv_function_name.
For action CONTRACT_SRV_SEL executed FM will be CRM_CONTRACT_FCODE. As you can see, this means that only standard functions can execute actions for messages. This also means that you will need to change one of these function modules to enable customer action with customer code.
- Go into SE37 and enter FM name CRM_CONTRACT_FCODE. In the function’s body you will see a simple CASE for variable iv_okcode. This variable contains the name of the action (CONTRACT_SRV_SEL) and it triggers proper FM for this action, i.e.: CRM_SRV_CONTRACT_SEL_UI.
CASE iv_okcode. * popup for sales contract/sales agreement selection WHEN 'CONTRACT_SALES_SEL'. CALL FUNCTION 'CRM_CONTRACT_CHOOSE_DIALOG'. * popup for service contract selection WHEN 'CONTRACT_SRV_SEL'. CALL FUNCTION 'CRM_SRV_CONTRACT_SEL_UI'. * ...
CASE iv_okcode. * popup for sales contract/sales agreement selection WHEN 'CONTRACT_SALES_SEL'. CALL FUNCTION 'CRM_CONTRACT_CHOOSE_DIALOG'. * popup for service contract selection WHEN 'CONTRACT_SRV_SEL'. CALL FUNCTION 'CRM_SRV_CONTRACT_SEL_UI'. * ...
- Now, you need to modify this FM (CRM_CONTRACT_FCODE). Best option will be to add an Enhancement implementation at the end of the function. In this implementation you need to add your CASE over the iv_okcode parameter. It should look something like this:
CASE iv_okcode. * my customer action WHEN 'CONTRACT_MY_ACTION'. CALL FUNCTION 'ZMY_ACTION'. WHEN OTHERS. * do nothing ENDCASE.
CASE iv_okcode. * my customer action WHEN 'CONTRACT_MY_ACTION'. CALL FUNCTION 'ZMY_ACTION'. WHEN OTHERS. * do nothing ENDCASE.
This way CONTRACT_MY_ACTION will execute ZMY_ACTION FM (as it will be ignored by a standard SAP code).
- Now, all you need to do is assign customer action CONTRACT_MY_ACTION to one of the messages in the CRMV_MESSAGES maintenance view (SM34). And, of course, create ZMY_ACTION FM with the logic you want user to execute.
You might be also interested in post: [cref keeping-message-on-the-document-sticky-messages].
Komentowanie jest zakończone.