Skip to Content

In this blog i will describe step by step, how to create and use own custom consistency checks in Charm Change Documents f.e. when status is changed.
We already know that there is standard consistency checks delivered by SAP, Posted by Michael Vollmer

http://scn.sap.com/community/it-management/alm/solution-manager/blog/2013/05/15/charm-framework-an-overview-of-existing-consistency-checks

Example Scenario: When  Normal Change switching from “In development” to “To be tested”, check that Unit test is attached and have right status.

Steps:

  1. Create custom  Z/Y condition
  2. Create Z/Y custom message class
  3. Register custom message class to use in consistency checks
  4. Map messages to conditions ( errors, warnings or cancel )
  5. Assign Custom check to User status of Normal Change
  6. Implement BADI – write logic here
  7. See results

All IMG links are available in SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks. The only object that we have not here is tcode SE91 for creating custom message class to use it here.

1. Let’s start first Create custom  Z/Y condition

Go to SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks – Define Conditions

charm 1.JPG

New entries enter give name starting from Z/Y, text – description of condition and assign CL_SOCM_INSTANCE

   * Note for all custom checks always use CL_SOCM_INSTANCE

Example

Charm 3.JPG

Save it, done.

2. Create Z/Y custom message class
Tcode SE91, create Z message class next create a message

cham 4.png

Unmark SelfExplanatory, create long text for your message example

* Note to insert a link press top menu Include – link – Document class = URL Link

charm 5.png

3. Register custom message class to use in consistency checks

Now lets register message for use in Consistency checks Go to SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks – Register Messages

Add created Z/Y message class, after this go to Single messages – check S – column marked

* Note The Save Message flag must be active for the message to be visible in the change transaction.

charm 6.png

Save, done.

4. Map messages to conditions ( errors, warnings or cancel )

Go to SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks – Define Basic Settings

charm 8.JPG

5. Assign Custom check to User status of Normal Change

Go to SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks – Assign Conditions to Status Values

Now we need to map Condition check + Message + Status value where check must be triggered

charm 7.JPG

     *A little explanation this entry means: when status is E0004 ( to be tested ) if consistency checks fails show message 000 of class Z class      and       reset status      back to E0002 ( In development )

Now we done here save and leave.

6. Implement BADI – write logic here

Go to SPRO – SAP Solution Manager – Capabilities (Optional) – Change Control Management – Standard Configuration – Change Request Management Framework – Consistency Checks – Implement BAdI Extension

Last we need to write logic, for this we need to Implement and activate BADI for SOCM_CHECK_CONDITION

Give Z/Y name to Implementation

charm 9.png

Add filter value = Your created  Z/Y custom condition in 1st step

charm 10.png

Now go to Interface and drill down to CHECK_CONDITION method, now here you need to write your logic. I will not describe deeply here.

I will just explain the check behavior, because you may have issues like “some actions are not performed” as error message.


  DATA:
      l_check TYPE boolean.
  conditions_ok = abap_true.
  CASE flt_val.
    WHEN 'ZUNIT_TEST_EXIST'.
      CLEAR l_check.
      l_check = check_real_status( i_guid = hf_instance->change_document_id i_status = hf_instance->estat ).
      CHECK l_check = abap_true.
      CLEAR l_check.
      l_check = check_project_type( i_tasklist = hf_instance->tasklist_id i_project_type  = 'M').
      CHECK l_check = abap_true.
      conditions_ok = check_doc_status( i_guid = hf_instance->change_document_id i_status = 'REVIEW' ).




In my scenario check should trigger only if status are changing from In Development -> To Be tested. ( standard behavior check will be triggered in all situations when changing to and from To be tested ).

To avoid this I’ve created method that read db table CRM_JEST and checks that actual status are not yet in there – this means check will be triggered only when changing from In Development to To be Tested.

Coding:


METHOD check_real_status.
  DATA
        l_stat TYPE jstat.
  SELECT SINGLE stat INTO l_stat
    FROM crm_jest
    WHERE objnr = i_guid
      AND stat = i_status
      AND inact = ''.
  IF sy-subrc <> 0.
    result = abap_true.
  ELSE.
    result = abap_false.
  ENDIF.
ENDMETHOD.


7. See results

Launch tcode SM_CRM create Normal Change set it to In Development, release tasks and try to set To be tested by choosing related Actions Pass Normal Change to test.

Okay here it is, you will see message with Details even with link in it and status is not changed until check conditions is fulfilled.

charm 11.JPG

Enjoy using it šŸ˜‰

To report this post you need to login first.

13 Comments

You must be Logged on to comment or reply to a post.

      1. Fran G

        Hello Daniyar,

        Can I implement the same to Attachments tab?

        I need to check if a particular document is attached in the attachments tab on a status change.

        Request your inputs.

        Thanks,

        Greg

        (0) 
        1. Daniyar Kulmanov Post author

          Hi Greg,

          Sure you can, but in this case you need your own code in #6.

          So you need to search a possibility to read Attachments tab of Normal change.

          I’m ABAP-er also, if you need i can try to help of searching this method, just ask?

          Rg Dan.

          (0) 
          1. Fran G

            Hello Dan,

            Thanks for your reply. I am very new to SolMan, CRM and WebDynpro environment. I am doing lot of debugging to find the behaviour of this.

            Would be helpful if you can also look for an option to do this.

            Many Thanks,

            Greg

            (0) 
              1. Fran G

                Hello Dan,

                Thanks for the help. I managed to get this done by the following FM. It reads the attachment of an object when passed the GUID.

                FM – ICT_READ_ATTACHMENTS

                Once I have the attachments, I did some custom code to get my validations done.

                Thanks for your help.

                Best Regards,

                Greg

                (0) 
          2. Fran G

            Hi Dan,

            I need help in another scenario…is it possible to implement consistency check for button click.

            When the user clicks on create TR button, I should check if all the TRs for that normal change is released. If there is an active TR, the new TR creation should be restricted.

            Additionally….if there is only a Customizing TR existing, workbench TR can be created and vice versa.

            Can this be acheived by consistency check.

            Thanks,

            Greg

            (0) 
            1. Daniyar Kulmanov Post author

              Hi Greg,

              With standard customizing you cannot do this, because button logic is in BSP application.

              You can add this check in

              AIC_CM_TRANS

              view AIC_CM_TRANS/TransportReq

              Event Handler – EH_ONTRANSREQ or EH_ONTRANSPORTREQ or EH_ONSELTRANSREQ

              check logic you can take example in:

              class CL_CHM1_INSTANCE – IF_SOCM_INSTANCE~CHECK_STATUS_CONDITION

              line number 264 *  process standard checks from TSOCM_CONDITIONS

              Rg Dan

              (0) 
              1. Fran G

                Hi Dan,

                Thanks for the reply. Do you mean to edit the event handler and add some custom code.

                Can you give little more explanation.

                Thanks,

                Greg

                (0) 
  1. Marcos Carvalho

    Hi Daniyar Kulmanov,


    Congratulations for post! 


    Recently I created too some implementations at BADI: SOCM_CHECK_CONDITION.

    Based in your explanations and I identified that execution some implementations they were called twice (even it is parameterized to be called only in a status iteration), generating error in second time (expected, because the implementation should be not recalled again after the first execution). My question is if this similar error has happened in during execution to their implementations?

    Best Regards,

    Marcos Carvalho

    (0) 
  2. Sudarshan B

    Hello Daniyar,

    Great blog ! Thanks for the details, I followed the steps given and was able to successfully achieve the condition checks.
    However, I have a small issue. Although I was able to display error on the UI based on the condition check, the transaction was still getting saved. Meaning, the UI shows 2 messages – one for the error from the condition check and secondĀ success message stating that the transaction is saved (standard message). Refer the image.

    I do not want to save the transaction in case of any errors, so I did some analysis and found the there is a BADI called ORDER_SAVE where we can restrict the saving. Cool !!
    However, when tested, I noticed that the BADI ORDER_SAVE gets calledĀ before the BADI SOCM_CHECK_CONDITION is called. Therefore I could not stop saving the transaction since by the time my condition checks are performed, the ORDER_SAVE BADI is already completed execution.

    Hope you understand my situation here. Do you have any pointers on how I can restrict saving the transaction if there are any error during the condition checks?

    Thanks.

    Regards,
    Sud
     

    (0) 

Leave a Reply