Jump to content
PMXSD

[RESOLVED]: Concatenate variable in get_list method

Recommended Posts

Good morning collaborators,

I am building a spel code using get_list method to get the amount of CI's which they are element's KPIs in a specific Change Order. For that I used the following code which one works when I put the change order number as hard code as this:

chg::zmatriz_riesgo(...)
{

      object obList;
    int kpi_count, afectados, pruebas, ambiente_homologado, rollback, contingencia, frecuencia;
    string chg_num;
    
    chg_num = argv[3];
    
    // ********** Existencia de Elementos de Configuracion KPI **********
    uuid who;   
    send_wait(0, top_object(), "call_attr", "cnt", "current_user_id");   
    who=msg[0];  
    send_wait(0, top_object(), "call_attr", "api", "get_list", "lrel_asset_chgnr", who, "chg.chg_ref_num IN '633' AND nr.zkpi IN '1'", -1);   
    if (msg_error()) {   
        logf(SIGNIFICANT, msg[0]);   
    }   
    else   
    {    
          obList = msg[0];
          kpi_count = msg[1];
    }

but now I want to do this usable for any change order and I need to concatenate a variable in where clause after chg.chg_ref_num. I tried this but it doesn't work:

chg::zmatriz_riesgo(...)
{

      object obList;
    int kpi_count, afectados, pruebas, ambiente_homologado, rollback, contingencia, frecuencia;
    string chg_num;
    
    chg_num = argv[3];
    
    // ********** Existencia de Elementos de Configuracion KPI **********
    uuid who;   
    send_wait(0, top_object(), "call_attr", "cnt", "current_user_id");   
    who=msg[0];  
    send_wait(0, top_object(), "call_attr", "api", "get_list", "lrel_asset_chgnr", who, "chg.chg_ref_num IN '+chg_num+' AND nr.zkpi IN '1'", -1);   
    if (msg_error()) {   
        logf(SIGNIFICANT, msg[0]);   
    }   
    else   
    {    
          obList = msg[0];
          kpi_count = msg[1];
    }

Can you tell me what is wrong in the concatenation in get_list method?

Regards.

 

 

Edited by PMXSD

Share this post


Link to post
Share on other sites

hi,

you can try to use format function, example:

format("chg.chg_ref_num IN '%s' AND nr.zkpi IN '1'", chg_num);

Regards, cdtj

Share this post


Link to post
Share on other sites

You rock man!! I modified my code adding format function and it works!

Finally, the code is:

chg::zmatriz_riesgo(...)
{

      object obList;
    int kpi_count, afectados, pruebas, ambiente_homologado, rollback, contingencia, frecuencia;
    string chg_num;
    
    chg_num = argv[3];
    
    // ********** Existencia de Elementos de Configuracion KPI **********
    uuid who;   
    send_wait(0, top_object(), "call_attr", "cnt", "current_user_id");   
    who=msg[0];  
    send_wait(0, top_object(), "call_attr", "api", "get_list", "lrel_asset_chgnr", who, format("chg.chg_ref_num IN '%s' AND nr.zkpi IN '1'", chg_num), -1);   
    if (msg_error()) {   
        logf(SIGNIFICANT, msg[0]);   
    }   
    else   
    {    
          obList = msg[0];
          kpi_count = msg[1];
    }

Thank you very much for your quick answer and help!

Regards.

PMX

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Announcements

    • Gregg

      Looking for the wiki content?

      12/20/2015

      Until I can transfer the wiki content over to the new Articles, you can find the old content here: http://www.greggsmith.net/wiki.
    • Gregg

      New site logo

      01/06/2016

      A special thanks to brianshs for creating a new site logo!
×