CA Service Management

  • 1.  AHD03025:Attempt to modify non_CO value

    Posted Mar 10, 2016 12:53 PM

    Hi a spell code was created by our old support team to change the status of change order  depending on the workflow task completed but I am receiving the error message AHD03025:Attempt to modify non_CO value and the change stay locked and no one can be edited.

     

    Here is the MOD

     

    MODIFY wf {

    POST_VALIDATE z_wf_chgstatuschange() 20025 FILTER ( EVENT("UPDATE") );

    };

     

    Here is the spel

     

    wf::z_wf_chgstatuschange(...){

    int debug_mode;
    debug_mode = 1; //mude para 0 para cancelar o debug mode

    if ( debug_mode == 1 ) {
      logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Starting Spell ");
    }

    string spl_new_chgstatus;

    if ( task == "INITWKFW" && status == "COMP" ) {
      spl_new_chgstatus = "APP";
      if ( debug_mode == 1 ) {
       logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Comp Status...");
      }
    } else if ( task == "ULAAPP" && status == "APP" ) {
      spl_new_chgstatus = "ULA";
      if ( debug_mode == 1 ) {
       logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- ULA Status...");
      }
    } else {
      if ( debug_mode == 1 ) {
       logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- No options for this status...");
      }
      return;
    }

    int spl_chg_id;
    spl_chg_id = (int)chg;
    string spl_chgrefnum;
     
    int chg_num;
    object chg_list, obj_chg, grp_leader;

    send_wait( 0, top_object(), "call_attr", "chg", "sync_fetch", "STATIC", format("id=%d",spl_chg_id), -1, 0);
    if ( msg_error() ) {
      logf(ERROR, "z_wf_chgstatuschange.spl -- Error to define the list chg: %s", msg[0]);
      return;
    }
    chg_list = msg[0];
    chg_num = msg[1];

    send_wait( 0, chg_list, "dob_by_index", "DEFAULT", 0, 0);
    if (msg_error()) {
      logf(ERROR, "z_wf_chgstatuschange.spl -- Error Instanciating CHG: %s", msg[0]) ;
      return;
    }
    obj_chg = msg[0];
    spl_chgrefnum = (string)obj_chg.chg_ref_num;

    send_wait(0, top_object(), "get_co_group");
    if (msg_error()) {
      logf(ERROR, "z_wf_chgstatuschange.spl -- Eroor generating grp_leader: %s", msg[0]);
      return;
    }
    grp_leader = msg[0];
     
    send_wait(0, grp_leader, "checkout", obj_chg);
      
    send_wait(0, obj_chg, "call_attr", "status", "set_val", spl_new_chgstatus, "SURE_SET" );
    if (msg_error()) {
      logf(ERROR, "z_wf_chgstatuschange.spl -- Erro saving : %s", msg[0]); <<<<< This is where it error
      return;
    }
    if ( debug_mode == 1 ) {
      logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Changing the status : %s.", spl_chgrefnum);
    }
      
    send_wait(0, grp_leader, 'checkin');
    if (msg_error()) {
      logf(ERROR, "z_wf_chgstatuschange.spl -- Error saving status: %s", msg[0]);
      int i;
      string tmp;
      for(i=0;i<msg_length();i++) tmp += (string)msg[i]+" : ";
      logf(ERROR, "z_wf_chgstatuschange.spl -- Error saving task= %s", tmp);
      return;
    }

    }



  • 2.  Re: AHD03025:Attempt to modify non_CO value

    Posted Mar 11, 2016 03:39 AM

    Hi,

    actually error is on this line :

    send_wait(0, grp_leader, "checkout", obj_chg);

    but you haven't error message log after this send_wait,

    error caused by group_leader logic, here is a great doc SPEL group_leader  by Gutis where you can find all about group_leader's logic.

     

    Modified code could look like:

    wf::z_wf_chgstatuschange(...) {
        int debug_mode, msg_i;
        debug_mode = 1; //mude para 0 para cancelar o debug mode
        if (debug_mode == 1) {
            logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Starting Spell ");
        }
        string spl_new_chgstatus;
        if (task == "INITWKFW" && status == "COMP") {
            spl_new_chgstatus = "APP";
            if (debug_mode == 1) {
                logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Comp Status...");
            }
        } else if (task == "ULAAPP" && status == "APP") {
            spl_new_chgstatus = "ULA";
            if (debug_mode == 1) {
                logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- ULA Status...");
            }
        } else {
            if (debug_mode == 1) {
                logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- No options for this status...");
            }
            return;
        }
        send_wait(0, this, "get_gl");
        if (msg_error()) {
            logf(ERROR, "z_wf_chgstatuschange.spl -- unable to get gl : %s", msg[0]);
            return;
        }
        grp_leader = msg[0];
        object obj_chg;
        send_wait(0, top_object(), "call_attr", "chg", "dob_by_persid", 0, chg.persistent_id);
        if (msg_error()) {
            for(msg_i=0;msg_i<msg_length();msg_i++) { logf(ERROR, "z_wf_chgstatuschange.spl -- msg[%d]: %s", msg_i, msg[msg_i]); }
            return;
        }
        obj_chg = msg[0];
        
        send_wait(0, grp_leader, "checkout", obj_chg);
        if (msg_error()) {
            for(msg_i=0;msg_i<msg_length();msg_i++) { logf(ERROR, "z_wf_chgstatuschange.spl -- msg[%d]: %s", msg_i, msg[msg_i]); }
            return;
        }
        send_wait(0, obj_chg, "call_attr", "status", "set_val", spl_new_chgstatus, "SURE_SET");
        if (msg_error()) {
            logf(ERROR, "z_wf_chgstatuschange.spl -- Erro saving : %s", msg[0]); 
            return;
        }
        if (debug_mode == 1) {
            logf(SIGNIFICANT, "z_wf_chgstatuschange.spl -- Changing the status : %s.", obj_chg.chg_ref_num);
        }
    }
    

    Here I tried to get current group_leader session and checkout chg via it.

     

    We have implemented chg logic similiar to this, but we are using attached events (because it feels slightly safer )

    mod file:
        MODIFY wf POST_VALIDATE z_status_sync(status) 1300 FILTER(status{});
    
    spl file:
        wf::z_status_sync(...) {
            string status_prev, status_new;
            status_prev = argv[2];
            status_new = argv[3];
    
            if ( (status_prev == 'WAIT') && (status_new == 'PEND') ) {
                if (task.code == 'TSK_RE') {
                    evt::z_new_evt((string)"CHG2RE", format("chg:%d", chg.id), 15);
                } else if (task.code == 'TSK_APP') {
                    evt::z_new_evt((string)"CHG2APP", format("chg:%d", chg.id), 15);
                } else if (task.code == 'TSK_AKN') {
                    evt::z_new_evt((string)"CHG2AKN", format("chg:%d", chg.id), 15);
                }
                <...etc...>
            }
        }
    

    z_new_evt is my own function, but it's based on antoher great doc SPEL EVENT methods by Gutis

    Each Attached event have single action macro on other side with simple code, with new chg status appropriate to event name:

    send_wait(0, this, "call_attr", "status", "set_val", "RE", "SURE_SET"); 
    

     

     

    Regards,

    Timur



  • 3.  Re: AHD03025:Attempt to modify non_CO value

    Posted Mar 11, 2016 05:00 AM

    Hi,

    Looking quickly at your code, your logic seems to only do some action base on the task type and corresponding status.

    So if you don't need more logic that this, why to not use status behavior and use action macro.

     

    You may eventually have to spl your macro but the system will take care of the others.

    You action macro will look like the below:

     

    object chg_dob;

    send_wait(0 , this, "call_attr", "chg", "get_dob");

    if (msg_error())

    {

    logf(ERROR, format("unable to retrieve change order associated to wf")) ;

    return;

    }

    chg_dob= msg[0];

    if(!is_null(chg_dob))

    {

    send_wait(0, top_object(), "get_co_group");

    if (msg_error())

    {

    logf(ERROR, "get_group_leader () failed: %s", msg[0]);

    return ;

    }

    chg_dob.status="RE";

    }

     

    You can manage all you chg status using this code just by modifying the last line with the appropriate status code

    Seems to be a more safer way to accomplish what you are doing here and more manageable/resusable without the need to modify your spl after you have loaded all your macro to the system.

     

    Timur,

    I understand your "Safer" approach using attach event. It's already a better way

    However the disadvantage of this in that particular case is that this rely on the animator queue and you don't fully control the execution time specially when you would like immediate action like delay time=00:00:01.

    This will normally not be problematic on non overloaded system and you may not notice timestamp difference there but may you come with a situation where you have a high pick and/or many events to go around same time you may come to important delay.

     

    Just my 2 cents

    /J



  • 4.  Re: AHD03025:Attempt to modify non_CO value

    Posted Mar 13, 2016 03:45 AM

    I have seen this error for number of times, my solution was to use POST_CI trigger, since this ensures that all changes to the object is allready checked in. The only difference is that you will need to pass task type and tasj status as parameters, since their will be not available from context.