BEAS Script / #JBS Sending POST to WEBSERVICE
Tryed to get a connection to a webservice from a MES application to send WO information. Came up with the following and it works fine. Any thoughts?
#jbs
let belnrid=dw_1.item.belnr_id.value.toString();
let belposid=dw_1.item.belpos_id.value.toString();
let result;
try {
result=sql(select "BELNR_ID", "BELPOS_ID", "DocEntry", "ItemCode", "ItemName", "WhsCode", "Match", "MENGE", "ME_VERBRAUCH", "UDF2" into belnr_id, belpos_id, docentry, itemcode, itemname, WhsCode, finitemcode, Quantity, UOM, BHR from "BEAS_FTPOS" where "BELNR_ID" = :belnrid and "BELPOS_ID" = :belposid);
let h=new HTTPClient;
h.SendRequest("POST", "http://10.2.10.84:8088/main/system/ws/rest/sio2/BLE_FTPOS",result);
h.SetRequestHeader("Content-Type", "application/json;charset=UTF-8");
if (h.GetResponseStatusCode()!=200) {
let j=h.GetResponseJSON() ; // Convert error message to josn
alert("Can't read Data: Error"+h.GetResponseStatusCode()+h.GetResponseStatusText()+" "+j.error.message.value);
return 1;}
let j=h.GetResponseJSON() ;
dw_1.item.udf4.value="Response "+h.GetResponseStatusCode();
let resp="Response "+h.GetResponseStatusCode();
sql(update "BEAS_FTPOS" set UDF4 = :resp where "BELNR_ID" = :belnrid and "BELPOS_ID" = :belposid);
alert("Response "+h.GetResponseStatusCode()+" "+j.content);
}
catch (re)
{
alert(SQLConnection.sqlErrText);
return;
}
0
-
I want to split the "SQL();" into multiple lines in BEAS Script. I could do a "&" at the end of the line to achieve this. I tried to use "+" at the end of a line and at the beginning of a new line, and I tried with " and escaping the quotes in the query itself, but it did not work either.
Suggestions?
-
Hi Andreas,
use
let result=sqlstatement.execute(` update "BEAS_FTPOS" set UDF4 = :resp
where "BELNR_ID" = :belnrid
and "BELPOS_ID" = :belposid
`);
Please sign in to leave a comment.
Comments
2 comments