cancel
Showing results for 
Search instead for 
Did you mean: 

Update through Routing Script

former_member557371
Participant
0 Kudos

Hi,

I am trying to update the Custom Data of Shop Order through Routing script , but it is not happening.

do we need some setting ( like security or other) ? Please suggest?

FYI - when I am doing the same through MII query it is happening successfully

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

sergiy_katerinich
Active Contributor
0 Kudos

Hi!

I wounder how you are doing this. Please share your script.

Regards,

Sergiy

former_member557371
Participant
0 Kudos

importClass(Packages.com.sap.me.frame.BasicBOBeanException);
importClass(Packages.com.sap.me.frame.Data);

throw new BasicBOBeanException(101, new Data("ERROR","Error1"));

sfcHandle=COMPLETE_DATA.getHandle("SFC_BO");
operationHandle=COMPLETE_DATA.getHandle("OPERATION_BO");

//get shoporderBO
getRouterSQL = "select shop_order_bo from sfc where  sfc= '" + SFC + "'" ;
SFCRouterData=executeQuery(getRouterSQL);
SFCRouter=SFCRouterData.get("SHOP_ORDER_BO");
throw new BasicBOBeanException(101, new Data("ERROR","Error1"+SFCRouter));

  //check for a Parametric measure LABELTEST_PASS_FAIL
  Sql1="SELECT TOP(1)";
  Sql1=sql1+" t1.max_measure_actual";
  Sql1=sql1+" FROM";
  Sql1=sql1+" (";
  Sql1=sql1+" SELECT MAX(pm.actual) as max_measure_actual";
  Sql1=sql1+" FROM parametric p";
  Sql1=sql1+" inner join parametric_measure pm";
  Sql1=sql1+" on pm.parametric_bo = p.handle";
  Sql1=sql1+" WHERE p.para_context_gbo = '"+sfcHandle+"' and";
  Sql1=sql1+" p.operation_bo = '"+operationHandle+"' and";
  Sql1=sql1+" pm.measure_name = ' LABELTEST_PASS_FAIL ' ";
  Sql1=sql1+" GROUP BY p.handle";
  Sql1=sql1+" HAVING MAX(pm.actual) = 'PASS'";
  Sql1=sql1+" ) t1";
  res1=executeQuery(sql1);
  if (res1 == null)
  {
    throw new BasicBOBeanException(101, new Data("ERROR","Label verification has failed, please log a Non Conformance before you continue."));
     
}
  else
  {
  Sql2=" update custom_fields";
  Sql2=sql2+" set value = 'Y'";
  Sql2=sql2+" where attribute = 'LABEL_VERIFIED’ and";
  Sql2=sql2+" handle = '"+ SFCRouter +"'";
  executeUpdate(sql2);
exit(false);
  }

sergiy_katerinich
Active Contributor
0 Kudos

I guess that executeUpdate() could have been banned in the last releases, though it worked in old ones. And I would agree with that. The reason, at least, is that routing scripts do not guarantee transactional mechanism: if anything fails during script execution, it will not be rolled back. And the second reason is that originally the routing scripts were designed only for decision-making of choosing the next step - no collection/update of production data was planned.

former_member557371
Participant
0 Kudos

Thanks for the information, that was the only reason I think this update script was working good in v6.0/6.1 not in v15.

Thanks