cancel
Showing results for 
Search instead for 
Did you mean: 

Changing user status via action profile

anais_jaussaud
Participant
0 Kudos

Hi experts,


I am trying to create an action profile that would change the user status when some conditions are fullfilled.

I tried the SET_DOCUMENT_STATUS method but it is not working.

I have set Structure CRMC_SO_STATUS with EXC_STATUS in the "contener"

with an initial value E0003 (wich is my status I want to be)

I already found those topics and tryied different method but it did not work neither:

Does anyone have an easy way to do this ?

Regards,
Anais Jaussaud

Accepted Solutions (1)

Accepted Solutions (1)

anais_jaussaud
Participant
0 Kudos

Hi everyone,

Thanks a lot for all of your replies. One of my dear collegues found the solution, all in customizing.

Use COMPLETE_DOCUMENT method.

First element should be status profile : USER_STAT_PROC with name Status Profile and data type CRM_J_STSMA.

The initial value is thus your status profile concerned by your changing.

Second element should be your status code: STATUS with name STATUS and data type CRM_J_STATUS.

The inital value is the code (E0001...) of the expecteed status.

I believe all of your solutions work but I needed a standard solution on this one.

Thanks and lot and hope it can help

Anaïs

former_member182315
Participant
0 Kudos

Hi Anais - after following the steps which you have given still this is not working:

do you have any solution pls, appreciate if you reply quickly and points will be rewarded.

I am trying to follow the standard approach and followed following steps but here I am observing the system status is updated as "Completed" not the user status, I want to update both the status SYSTEM & USER status.

I followed the following procedure given below:

In action definition :

Method : COMPLETE_DOCUMENT

Element : STATUS

Name STATUS

and data type CRM_J_STATUS.

The inital value is the code  "QUEX" - (quotation expired)

But this is not working can you please somebody guide me, this is eating lot of my time.

Regards

Vani

former_member182315
Participant
0 Kudos

Hi Yaa - please reply.

I am using the standard method given below and in the start condition the following validation given below:

Is this the right thing which I am doing:

In action definition :

Method : COMPLETE_DOCUMENT

Element : STATUS

Name STATUS

and data type CRM_J_STATUS.

The inital value is the code  "QUEX" - (quotation expired)

In the start condition I am defining the validation the current: Quotation Valid To& >=(greater then & equal) %Current Date%.

 

 

Regards

Vani

anais_jaussaud
Participant
0 Kudos

Dear Vani,

I am not sure you will managed to modify system status using the method COMPLETE DOCUMENT. Indeed, this method is done to set the system status to complete.

Then, I think you need to use another method : SET DOCUMENT STATUS might be helpful in this case?

I am trying to have a look what would be the element in the contener then. I'll try to update the message. Could you try on your hand as well?

Regards,

Anaïs

former_member182315
Participant
0 Kudos

Thanks a lot Anais, I am trying here as well much appreciated if you find something for me.

I am trying to achieve for the below.

When the quotation end date is greater then the current date then change the status to "Expired".

Does SET DOCUMENT STATUS help to change the user status,,,?

Regards

Vani

former_member182315
Participant
0 Kudos

Hi Anas - Can you please let me know, is this something can be achievable out of box or we need to go for enhancement.

I tried all the elements but none is working.

Regards

Vani

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Anais,

1. Implement BADi EVAL_STARTCOND_PPF. Check status profile in start condition.

    DATA: lv_object TYPE REF TO cl_doc_crm_order,

        lv_guid TYPE crmt_object_guid,

        lt_status TYPE TABLE OF jstat,

        lv_status_profile TYPE jsto-stsma,

        lv_status TYPE j_status VALUE 'E0002'.

     ep_rc = 4.

     TRY.

         lv_object ?= io_context->appl.

       CATCH cx_root.

     ENDTRY.

     lv_guid = lv_object->get_crm_obj_guid( ).

     CALL FUNCTION 'CRM_STATUS_READ'

       EXPORTING

         objnr            = lv_guid

         only_active      = 'X'

       IMPORTING

         stsma            = lv_status_profile

       TABLES

         status           = lt_status

       EXCEPTIONS

         object_not_found = 1

         OTHERS           = 2.

     IF sy-subrc = 0.

       IF lv_status_profile = 'CRMORDER'.

         READ TABLE lt_status WITH KEY stat = lv_status TRANSPORTING NO FIELDS.

         IF sy-subrc = 4.

           ep_rc = 4.

         ELSE.

           ep_rc = 0.

         ENDIF.

       ELSE.

         ep_rc = 4.

       ENDIF.

     ENDIF.


2. Implement Badi EXEC_METHODCALL_PPF. Write the code to change status.


DATA:lv_object TYPE REF TO cl_doc_crm_order,

           lv_guid TYPE crmt_object_guid.

    TRY.

         lv_object ?= io_appl_object.

         lv_guid = lv_object->get_crm_obj_guid( ).

       CATCH cx_root.

         RETURN.

     ENDTRY.

CALL FUNCTION 'CRM_STATUS_CHANGE_EXTERN'

       EXPORTING

         objnr               = lv_guid

         user_status         = lv_status

       EXCEPTIONS

         object_not_found    = 1

         status_inconsistent = 2

         status_not_allowed  = 3

         OTHERS              = 4.

rp_status = 1

.

3. Create an action profile specifying the start condition method name(given in implementation of EVAL_STARTCOND_PPF) and main method name (given in implementation of EXEC_METHODCALL_PPF)


Thanks,

Ritu

ocpjcp
Active Participant
0 Kudos

Hello,

Have you tried calling this Function Module.

     

CALL FUNCTION 'CRM_STATUS_CHANGE_EXTERN_OW'
        EXPORTING
          objnr               = guid " CRM object GUID
          user_status         = user_status " E0001
          iv_ref_kind         = 'A' " A for header , B for item
        EXCEPTIONS
          object_not_found    = 1
          status_inconsistent = 2
          status_not_allowed  = 3.

Hope this helps.

Regards,

Parveen Kumar

former_member158363
Active Contributor
0 Kudos

Hello Anais,

looking into the method, I believe that the Element name should be PROCESS and it should be type of J_VORGANG data element (you can use TJ01-VRGNG for reference, when creating the container element.

The value here will not be the user status (E0003 in your case) but the business transaction associated with it - in the user status profile customizing, it is the last column:

The transactions are defined by SAP in table TJ01 and you cannot add your own. Also choose transaction for your status carefully, as it also changes system statuses.

I have to admit that I have never used this method - just trying to interpret the ABAP coding .

I usually create own method to change user status, as I usually need to do more things via action.

Just try it and come back if it does not work.

Regards,

Dawood.