点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 我正在使用$ batch...
点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 我正在使用$ batch...
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
嗨,
我正在使用$ batch选项插入或更新多条记录。
我已经创建了.xsodata和.xsjslib文件,并能够以202状态执行邮递员,但是记录正在插入到各自的表中。 尝试调试js文件,它不是由邮递员触发的。以下是我使用的详细信息,请对此进行检查和帮助。
邮递员:
URL:https://XXl.hanatrial.ondemand.com/workshop/exercises/g001/service.xsodata/$batch
参数:
Accept:application/json
Content-Type:多部分/混合; boundary =批处理
x-csrf令牌:901F634DD72A2E49A4A72CA89DADB8CF
原始:
-批处理内容-类型:分段/混合; 边界=变更集内容-传输-编码:二进制--changeset内容-类型:应用程序/http内容-传输-编码:二进制内容-ID:1 POST POHeader HTTP/1.1内容-类型:application/json内容-长度:82 { " PURCHASEORDERID":" 0300000003"," HISTORY.CREATEDBY":""," HISTORY.CREATEDAT":"/img/Date(1488931200000)/"," HISTORY.CHANGEDBY":""," HISTORY.CHANGEDAT":null," NOTEID":""," PARTNER":" 0100000000"," CURRENCY":" ERU"," GROSSAMOUNT":" 359072.23"," NETAMOUNT":" 32345.11"," TAXAMOUNT":" 4467.25"," LIFECYCLESTATUS": " 1"," APPROVALSTATUS":" G"," CONFIRMSTATUS":" E"," ORDERINGSTATUS":" C"," INVOICINGSTATUS":" A"} --changeset内容-类型:application/http内容-传输- 编码:二进制内容-ID:2 POST POItem HTTP/1.1内容-类型:application/json内容-长度:45 {" PURCHASEORDERID":" 0300000003"," PURCHASEORDERITEM":" 000010"," PRODUCT":" HT-610 "," NOTEID":""," CURRENCY":" ERU"," GROSSAMOUNT":" 329508.01"," NETAMOUNT":" 779899" ," TAXAMOUNT":" 6732.04"," QUANTITY":" 287.15"," QUANTITYUNIT":" EA"," DELIVERYDATE":"/img/Date(1496361600000)/"} --changeset内容-类型:application/http Content- 传输-编码:二进制PUT $ 1/$ links/POItem HTTP/1.1内容-类型:application/json内容-长度:12 {" uri":" $ 2"} --changeset-- --batch-
.xsodata:
服务名称空间" workshop.exercises.g001.service" {" workshop.exercises.g001 :: PurchaseOrder.Header"作为" POHeader"导航(" Items"为" POItem")导航(在" workshop.exercises。"之前)。 g001:POHeaderPOItem.xsjslib :: poheader_create_before_exiit"); " workshop.exercises.g001 :: PurchaseOrder.Item"作为" POItem"创建事件(在" workshop.exercises.g001:POHeaderPOItem.xsjslib :: poitem_create_before_exiit"之前); 关联" Items"主体" POHeader"(" PURCHASEORDERID")多重性" 1"依赖" POItem"(" PURCHASEORDERID")多重性" *"依赖于" workshop.exercises.g001 :: PurchaseOrder.Item"主体(" PURCHASEORDERID") (" PURCHASEORDERID")使用" workshop.exercises.g001:POHeaderPOItem.xsjslib :: association_create_exit"更新; }
.xsjslib:
$。import(" workshop.exercises.g001.service","会话"); var SESSIONINFO = $ .workshop.exercises.g001.service.session;/** @param {连接}连接-OData请求中使用的SQL连接@param {beforeTableName}字符串-临时表的名称,该表在操作前具有单个条目(仅UPDATE和DELETE事件)@param {afterTableName} 字符串-操作后带有单个条目的临时表的名称(仅CREATE和UPDATE事件)*/function poheader_create_before_exiit(param){let after = param.afterTableName; var pStmt; 试试{pStmt = param.connection.prepareStatment('从虚拟对象中选择" workshop.exercises.g001 :: PurchaseOrderId" .NEXTVAL"); var rs = pStmt.executeQuery(); var PohId =''; while(rs.next()){PohId = rs.getString(1); } pStmt.close(); pStmt = param.connection.prepareStatement('update"'+ after +'" set PURCHASEORDERID =?,'+'" HISTORY.CREATEDBY" =?,'+'" HISTORY.CREATEDAT" =?,'+'" HISTORY。 CHANGEDBY" =?,'+'" HISTORY.CHANGEDAT" =?,'+'" NOTEID" =?,'+'" PARTNER" =?,'+'" CURRENCY" = ?,'+'" GROSSAMOUNT" = ?,'+'" NETAMOUNT" =?,'+'" TAXAMOUNT" =?,'+'" LIFECYCLESTATUS" =?,'+'" APPROVALSTATUS" =?,'+'" CONFIRMSTATUS" =?,'+' " ORDERINGSTATUS" =?,'+'" INVOICINGSTATUS" =?,'); pStmt.setString(1,PohId); pStmt.setString(2,''); pStmt.setString(3,''); pStmt.setString(4,''); pStmt.setString(5,''); pStmt.setString(6,'01'); pStmt.setString(7,'0200000000'); pStmt.setString(8,'EUR'); pStmt.setString(9,'234.45'); pStmt.setString(10,'8764.12'); pStmt.setString(11,'234.56'); pStmt.setString(12,'A'); pStmt.setString(13,'B'); pStmt.setString(14,'C'); pStmt.setString(15,'D'); pStmt.setString(16,'E'); pStmt.execute(); pStmt.close(); } catch(e){}} function poitem_create_before_exiit(param){let after = param.afterTableName; var pStmt; 尝试{pStmt = param.connection.prepareStatement('从虚拟对象中选择" workshop.exercises.g001 :: PurchaseOrderId" .NEXTVAL'); var rs = pStmt.executeQuery(); var PoiId =''; while(rs.next()){PoiId = rs.getString(1); } pStmt.close(); pStmt = param.connection.prepareStatement('update"'+ after +'" set PURCHASEORDERID =?,'+'" PURCHASEORDERITEM" =?,'+'" PRODUCT" =?,'+'" NOTEID" =?,' +'" CURRENCY" =?,'+'" GROSSAMOUNT" =?,'+'" NETAMOUNT" =?,'+'" TAXAMOUNT" = ?,'+'" QUANTITY" = ?,'+'" QUANTITYUNIT" =?,'+'" DELIVERYDATE" =?,'); pStmt.setString(1,PoiId); pStmt.setString(2,''); pStmt.setString(3,''); pStmt.setString(4,''); pStmt.setString(5,''); pStmt.setString(6,''); pStmt.setString(7,''); pStmt.setString(8,''); pStmt.setString(9,''); pStmt.setString(10,''); pStmt.setString(11,''); pStmt.execute(); pStmt.close(); } catch(e){}}函数association_create_exit(param){let princ = param.principalTableName; 让dep = param.dependentTableName; var pStmt = param.connection.prepareStatement('select * from"'+ princ +'"'); var Principal = SESSIONINFO.recordSetToJSON(pStmt.executeQuery(),'Details'); pStmt.close(); var pStmt1 = param.connection.prepareStatement('select * from"'+ dep +'"'); var Dependent = SESSIONINFO.recordSetToJSON(pStmt.executeQuery(),'Details'); pStmt1.close(); $ .trace.debug(JSON.stringify(Principal)); $ .trace.debug(JSON.stringify(Dependent)); var pStmt2 = param.connection.prepareStatement('update" schema"。" workshop.exercises.g001 :: PurchaseOrder.Header"'+'SET" PURCHASEORDERID" =?WHERE" PURCHASEORDERID" =?'); pStmt2.setString(1,Dependent.Details [0] .ADDRESSID); pStmt2.setString(2,Principal.Details [0] .PARTNERID); pStmt2.execute(); pStmt2.close(); }
谢谢
嗨,托马斯,
我正在尝试使用邮递员的以下请求标头和正文运行$ batch服务,并显示"无效的多部分条目"错误。请您对此问题提供帮助。请附上屏幕截图作为参考。
如果我将请求正文中的值更改为{" PURCHASEORDERID":14},而将错误更改为{" error":{" code":""," message":{" lang":" zh-CN", " value":"处理请求流时出错。指定的JSON文本无效。"}}}
batch.jpg
服务:
service {" workshop.exercises.g001 :: PurchaseOrder.Header1"作为" POHeader1"创建事件(在" workshop.exercises.g001:POHeaderPOItem.xsjslib :: poheader_create_before_exiit"之前);
}
.xsjslib:
function poheader_create_before_exiit(param){let after = param.afterTableName; var pStmt = null;
try {pStmt = param.connection.prepareStatment('从虚拟对象中选择" workshop.exercises.g001 :: PurchaseOrderId" .NEXTVAL");
var rs = pStmt.executeQuery();
var PohId ='';
while(rs.next())
{PohId = rs.getString(1); }
pStmt.close(); pStmt = param.connection.prepareStatement(" update \"" + +" \"之后设置PURCHASEORDERID ="");
pStmt.setString(1,PohId);
pStmt.execute();
pStmt.close();
}
抓住(e)
{pStmt.close();
}
}
谢谢
一周热门 更多>