我正在开发一个Web服务,它将使用. NET在SAP中创建订单。现在,当我运行下面的代码时,我没有收到任何错误,也没有创建任何订单。我希望有人能帮忙
string message = "";
// create initial connection
Z_SALESORDER_CREATE createOrder = new Z_SALESORDER_CREATE();
try
{
NetworkCredential cred = new NetworkCredential("password", "username");
createOrder.Url = "http://saphost:8010/sap/bc/srt/wsdl/bndg_d0823E1C21F1A334DSE0001555D658D08/wsdl11/allinone/ws_policy/document?sap-client=110";
createOrder.Credentials = cred;
}
catch (Exception ex){
message = "An error occured." + ex.Message;
}
// ORDERS_HEADER_IN
Bapisdhd1 order_header_in = new Bapisdhd1();
order_header_in.DocType = "OR";
order_header_in.CollectNo = "1109512";
order_header_in.SalesOrg = "10090";
order_header_in.DistrChan = "100";
order_header_in.Division = "000";
order_header_in.DlvBlock = "020";
order_header_in.PurchNoC = "E-COMM ORDER TEST ORDER";
// ORDER_ITEMS_IN
Bapisditm order_items_in = new Bapisditm();
order_items_in.ItmNumber = "198295";
order_items_in.Material = "454659";
order_items_in.GrossWght = 0.003M;
order_items_in.NetWeight = 0.003M;
order_items_in.UntofWght = "KG";
Bapisditm order_items_in2 = new Bapisditm();
order_items_in2.ItmNumber = "198425";
order_items_in2.Material = "454664";
order_items_in2.GrossWght = 0.003M;
order_items_in2.NetWeight = 0.003M;
order_items_in2.UntofWght = "KG";
Bapisditm order_items_in3 = new Bapisditm();
order_items_in3.ItmNumber = "198725";
order_items_in3.Material = "454647";
order_items_in3.GrossWght = 0.003M;
order_items_in3.NetWeight = 0.003M;
order_items_in3.UntofWght = "KG";
Bapisditm order_items_in4 = new Bapisditm();
order_items_in4.ItmNumber = "198275";
order_items_in4.Material = "45696INK";
order_items_in4.GrossWght = 0.003M;
order_items_in4.NetWeight = 0.003M;
order_items_in4.UntofWght = "KG";
// ORDER_PARTNERS
Bapiparnr order_partners = new Bapiparnr();
order_partners.PartnRole = "SP";
order_partners.PartnNumb = "110512";
order_partners.PartnRole = "BP";
order_partners.PartnNumb = "110512";
order_partners.PartnRole = "PY";
order_partners.PartnNumb = "110512";
order_partners.PartnRole = "SH";
order_partners.PartnNumb = "120109";
Bapicond order_conditions = new Bapicond();
order_conditions.ItmNumber = "000010";
order_conditions.CondStNo = "013";
order_conditions.CondCount = "01";
order_conditions.CondType = "ZPRM";
order_conditions.CondValue = 1;
order_conditions.Currency = "USD";
// commit transation
Bapiret2 commit = new Bapiret2();
message += commit.Message + commit.MessageV1 + commit.MessageV2 + commit.MessageV3 + commit.MessageV4 + commit.LogMsgNo + commit.LogNo;
字符串
3条答案
按热度按时间yqyhoc1h1#
问题是我需要构建一个数组并将其插入对象。见下文。
字符串
我还需要将zSalesOrderCreate对象绑定回Z_SALESORDER_CREATE方法。
型
sczxawaw2#
虽然我不是.Net的Maven,但这里有一些奇怪的东西。BapiRet 2不是一个方法,而是一个类,在R/3中有一个同名的结构,通常用于获取函数调用的执行信息...
我想你只是创建了一个变量,它将/应该包含你的web服务的答案,因为你没有调用later,所以变量是空的……因此空的错误消息...
问候
rsl1atfo3#
您没有收到任何消息,因为您从未调用该服务。代理类Z_SALESORDER_CREATE应该有一个同名或几乎同名的方法,该方法实际调用服务。BAPIRET2只是一个包含来自服务的返回消息的结构。准备调用参数,使用这些参数调用服务方法,然后检查BAPIRET2结构的结果。