c# - SAP .NET Connector 3.0: Sales Order changes -
i'm using sap .net connector 3.0 build rfc client allow users in easiest way comunicate sap. here provide short samples of stopping me move forwards development. purpose alter existing sales order. bapi_salesorder_change
fm gonna utilize alter header , items data. have sales order 12 items (from 000010 0000120). scenarios b , c doesn't work me.
scenario a: client purchase order changing result: po number changed. no issues.
public datatable bapi_salesorder_change(rfcdestination destination) { rfcrepository repo = destination.repository; irfcfunction salesdoc = repo.createfunction("bapi_salesorder_change"); irfcfunction salesdoccommit = repo.createfunction("bapi_transaction_commit"); salesdoc.setvalue("salesdocument", "3939393837"); irfcstructure salesheader = salesdoc.getstructure("order_header_in"); salesheader.setvalue("purch_no_c", "order_01"); irfcstructure salesheaderinx = salesdoc.getstructure("order_header_inx"); salesheaderinx.setvalue("updateflag", "u"); salesheaderinx.setvalue("purch_no_c", "x"); rfcsessionmanager.begincontext(destination); salesdoc.invoke(destination); salesdoccommit.invoke(destination); rfcsessionmanager.endcontext(destination); irfctable returntable = salesdoc.gettable("return"); homecoming converttodatatable(returntable); }
scenario b: item target qty change result: got message: sales order has been saved. qty wasn't been changed. wrong here?
public datatable bapi_salesorder_change(rfcdestination destination) { //... //same peace of code above irfcstructure salesheader = salesdoc.getstructure("order_header_in"); irfcstructure salesheaderinx = salesdoc.getstructure("order_header_inx"); salesheaderinx.setvalue("updateflag", "u"); irfctable salesitems = salesdoc.gettable("order_item_in"); salesitems.append(); salesitems.setvalue("itm_number", 000120); salesitems.setvalue("target_qty", convert.todecimal("1")); irfctable salesitemsinx = salesdoc.gettable("order_item_inx"); salesitemsinx.append(); salesitemsinx.setvalue("updateflag", "u"); salesitemsinx.setvalue("itm_number", 000120); salesitemsinx.setvalue("target_qty", "x"); //... //invoke methods }
scenario c: new item adding result: error on salesdoc.invoke(destination) method: "screen output without connection user."
public datatable bapi_salesorder_change(rfcdestination destination) { //... //same peace of code above irfcstructure salesheader = salesdoc.getstructure("order_header_in"); irfcstructure salesheaderinx = salesdoc.getstructure("order_header_inx"); salesheaderinx.setvalue("updateflag", "u"); irfctable salesitems = salesdoc.gettable("order_item_in"); salesitems.append(); salesitems.setvalue("itm_number", 130); salesitems.setvalue("material", "000000000081828282"); salesitems.setvalue("target_qty", convert.todecimal("1")); irfctable salesitemsinx = salesdoc.gettable("order_item_inx"); salesitemsinx.append(); salesitemsinx.setvalue("updateflag", "i"); salesitemsinx.setvalue("itm_number", 130); salesitemsinx.setvalue("material", "x"); salesitemsinx.setvalue("target_qty", "x"); //... //invoke methods }
like in abap program, need phone call bapi_transaction_commit after successful phone call bapi_salesorder_change. otherwise, transaction not committed sap.
c# sap sap-connector saprfc
No comments:
Post a Comment