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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...