cancel
Showing results for 
Search instead for 
Did you mean: 

ChaRM 7.1: Approveral can be approved by everyone

Former Member
0 Kudos

Hello!

when i create a request for change and send it to status "waiting for  approval" everyone can approve that change.

How is it possible to limit the approval to the selected business partner? It should be just for the selected business partner possible to approve the request for change.

regards

Alex

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

An unanswered OSS Message later and a few hours of tracing, debugging and coding:

My Solution for that Problem - not as good as solution from P Kumar but it works fine for my requirements:

it has two components:

  • one Consistency-Check Rule in SPRO (coded via Badi) that checks if valid Change-Manager and Change-Advisory-Board is maintained in Request for Change Header and that the header is matching the Approval steps.
  • an extended authority-Check for CRM-Approval-Step - see coding below

i use authority object ZBCCH_GEN to check if the user is allowed to approve the change-advisory-board-approval-step. The Change-Manager-Approval-Step is only allowed to change by the entered business partner.

I modified CL_CRM_APPROVAL_UTILITY=>CHECK_AUTHORITY_AT_STEP:

CALL METHOD cl_crm_approval_utility=>check_authority
     EXPORTING
       iv_user          = iv_user
       iv_activity      = iv_activity
     EXCEPTIONS
       no_authority     = 1
       others           = 2          .
   IF sy-subrc <> 0.
     IF cs_approval_s_wrk IS SUPPLIED.
       cs_approval_s_wrk-no_authorization = abap_true.
     ENDIF.
     RAISE no_authority.
*{   INSERT                                                 1
*
*---------------------------------------------------------------------
    else.
     if cs_approval_s_wrk is supplied.
       zcl_bcch_helper=>check_request_approval_step( EXPORTING i_activity = iv_activity CHANGING cs_approval_s_wrk = cs_approval_s_wrk ).
     endif.
*}   INSERT
   ENDIF.

my Function looks like this (translated from German):

METHOD check_request_approval_step.
   DATA ls_approval_s_wrk TYPE crmt_approval_s_wrk.
   DATA lt_approval_s_wrk TYPE crmt_approval_s_wrkt.
   DATA ls_approval_com TYPE crmt_approval_com.
   DATA ls_logical_key TYPE crmt_object_guid.
   DATA l_uname TYPE uname.
   DATA l_partner_no TYPE crmt_partner_no.

   CHECK i_activity = '02'." only changing of approval step

   CALL FUNCTION 'CRM_APPROVAL_READ_OB'
     EXPORTING
       iv_guid              = cs_approval_s_wrk-parent_guid
       iv_no_check          = abap_true
     IMPORTING
       es_approval_com      = ls_approval_com
     EXCEPTIONS
       entry_does_not_exist = 1
       parameter_error      = 2
       OTHERS               = 3.
   check sy-subrc = 0.

   CALL FUNCTION 'CRM_APPROVAL_S_READ_OB'
     EXPORTING
       iv_approval_guid     = cs_approval_s_wrk-parent_guid
       iv_number_int        = cs_approval_s_wrk-step_no
     IMPORTING
       es_approval_s_wrk    = ls_approval_s_wrk
     EXCEPTIONS
       entry_does_not_exist = 1
       parameter_error      = 2
       OTHERS               = 3.
   CHECK sy-subrc = 0.

   ls_logical_key = ls_approval_com-ref_guid.

   CASE cs_approval_s_wrk-step_id.
     WHEN 'ZMCR000001'. "Change-Advisory-Board Approval Step

       AUTHORITY-CHECK OBJECT 'ZBCCH_GEN' ID 'ACTVT' FIELD '01'.
       IF sy-subrc = 0.
         "authority ok - now check for same user
         l_partner_no = ls_approval_s_wrk-partner_no.
         l_uname = zcl_bcch_helper=>get_userid_for_businesspartner( i_partner_no = l_partner_no ).
         IF l_uname <> sy-uname.
           CALL FUNCTION 'CRM_MESSAGE_COLLECT'
             EXPORTING
               iv_caller_name = 'APPROVAL'
               iv_ref_object  = ls_logical_key
               iv_ref_kind    = 'A'
               iv_msgno       = '031' "Information: Approval in substitution
               iv_msgid       = 'ZBC_CHARM'
               iv_msgty       = 'I'.
           cs_approval_s_wrk-no_authorization = abap_true.
           RAISE no_authority.
         ELSE.
           "everything fine - same user
         ENDIF.
       ELSE.
         "no authority
         CALL FUNCTION 'CRM_MESSAGE_COLLECT'
           EXPORTING
             iv_caller_name = 'APPROVAL'
             iv_ref_object  = ls_logical_key
             iv_ref_kind    = 'A'
             iv_msgno       = '030' "User has no authority to approve a Change-Advisory-Board approval
             iv_msgid       = 'ZBC_CHARM'
             iv_msgty       = 'A'.
         cs_approval_s_wrk-no_authorization = abap_true.
         RAISE no_authority.
       ENDIF.

       IF ls_approval_s_wrk-partner_fct <> 'SDCR0003'. "Change-Advisory-Board
         CALL FUNCTION 'CRM_MESSAGE_COLLECT'
           EXPORTING
             iv_caller_name = 'APPROVAL'
             iv_ref_object  = ls_logical_key
             iv_ref_kind    = 'A'
             iv_msgno       = '032' "Wrong partner function in approval step
             iv_msgid       = 'ZBC_CHARM'
             iv_msgty       = 'A'.
         cs_approval_s_wrk-no_authorization = abap_true.
         RAISE no_authority.
       ENDIF.

     WHEN 'ZMCR000002'. "Change-Manager Approval Step 1
       IF ls_approval_s_wrk-partner_no IS NOT INITIAL.
         l_partner_no = ls_approval_s_wrk-partner_no.
         l_uname = zcl_bcch_helper=>get_userid_for_businesspartner( i_partner_no = l_partner_no ).
         IF l_uname <> sy-uname.
           CALL FUNCTION 'CRM_MESSAGE_COLLECT'
             EXPORTING
               iv_caller_name = 'APPROVAL'
               iv_ref_object  = ls_logical_key
               iv_ref_kind    = 'A'
               iv_msgno       = '029' "wrong partner function in approval step
               iv_msgid       = 'ZBC_CHARM'
               iv_msgty       = 'A'.
           cs_approval_s_wrk-no_authorization = abap_true.
           RAISE no_authority.
         ENDIF.
       ENDIF.

       IF ls_approval_s_wrk-partner_fct <> 'SDCR0002'. "Change-Manager
         CALL FUNCTION 'CRM_MESSAGE_COLLECT'
           EXPORTING
             iv_caller_name = 'APPROVAL'
             iv_ref_object  = ls_logical_key
             iv_ref_kind    = 'A'
             iv_msgno       = '032'
             iv_msgid       = 'ZBC_CHARM'
             iv_msgty       = 'A'.
         cs_approval_s_wrk-no_authorization = abap_true.
         RAISE no_authority.
       ENDIF.
   ENDCASE.

ENDMETHOD.

One option for future is limiting the F4 Help to the valid business partners. This can be done by SPRO->Change Management -> Standard Configuration -> Assignement Blocks -> Define Partners in UI -> Specify Partner function display in Transactions. At the Moment I'm not very familiar with creating/customizing this view (especially creating F4 Help and Object relation if needed) so this is moved to future (after GoLive). At the moment i use the Search Help Employee for finding all Users and using consistency check to make sure that only valid business partners are entered - that should be enough for a GoLive.

raquel_pereiradacunha
Active Contributor
0 Kudos

Hi Alexander,

Great answer. Thank you very much for sharing your code. Your solution probably followed the same path as SAP developers are doing because it was mentioned that a modification was necessary for that.

In order to combine your solution with P Kumar's solution would not be very hard for a developer, just need to call some HR functions to read Org Struct I think the hardest part you've already done.

Best regards,

Raquel

Former Member
0 Kudos

Hi Raquel!

but HR is a part on SAP that i don't know well 😉

i will ask colleges to help me on this point.

best regards

Alexander Pichlbauer

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can refer to the  Charms Config & Upgrade guide for it. : https://websmp203.sap-ag.de/~form/sapnet?_OBJECT=011000358700001056012011E&_SCENARIO=011000358700000...

Check this one too : http://wiki.sdn.sap.com/wiki/display/SMAUTH/UC00044

Regards

Mudasir.

Former Member
0 Kudos

Hi!

thats not exactly what i need (but .

If i have the following Approvers:

ZMCR00001 Approval Step 1 Change-Advisory-Board    PartnerId 168

ZMCR00002 Approval Step 2 Change-Manager             PartnerId 200

i want to be sure that partner 168 can only approve step ZMCR00001 and that partner 200 can only approve step ZMCR00002

regards

Alexander

raquel_pereiradacunha
Active Contributor
0 Kudos

Hi Alexander,

as far as I know that is not possible yet in SAP standard. At list this was the answer I've got during Teched 2012 when I asked the same question. If you run a trace you can see that no authorization check is made based on business partner. I heard that this need was being considered by the development team. If I have any news I will post here. Please let us know too if you find a solution. Maybe we could try to find a BADI for that, I haven't tried.

Best regards,

Raquel

Former Member
0 Kudos

Thanks for your Information.Thats not what i wanted to hear, but it explains why i'm not able to customize that 😉

thanks a lot.

I will update that message how i solved that problem.

Former Member
0 Kudos

Hi  Alexander,

For this issue, I raised the OSS & SAP said currently there is no authorization check & they have communicated to SAP Development team to fix it in next releases.

But you can check below mentioned alterante way of controllig it

Step 1:

Define Org Structure (PPOMA_CRM) with Positions CAB & Change Manager. Under Each position assign the members. Example: If you have 10 people in CAB, assign all these members under CAB position. And suppose you have 5 chnage managers, assign these 5 Chnage managers under Chnage manager Position.

Step 2:

Now ask the ABAPER to make some code, which should check the the BP number entered for CAB approval step1 should exist under the CAB position in Org Structure. If BP numbers doesnt exist under CAB position it has to give error 'You are not CAB member'. Same logic applies to Chnage Manager also.

Refer tables HRP1000 & HRP1001 for org structure.

Hope it will help you to get the required authorization control for Approval Steps

Let me know if you succeed.

Regards

P Kumar