Create a material .NET Connector SAP

橙三吉。 提交于 2021-02-08 08:08:59

问题


Please tell me somebody out there has done this. I am trying to interface with SAP via .NET Connector 3.0. I can read data fine with the remote function calls, but I cannot figure out how to write anything, creating or editing a material for example. Through some research I have determined that BAPI_MATERIAL_SAVEDATA is the rfc I need to be using, but cannot for the life of me figure out how. Here's what I'm trying:

function = destination.Repository.CreateFunction("BAPI_MATERIAL_SAVEDATA");
IRfcStructure structure = function.GetStructure("HEADDATA");
structure.SetValue("material", "000000000000000888");
structure.SetValue("ind_sector", "U");
structure.SetValue("matl_type", "ERSA");
structure.SetValue("basic_view", "X");

structure = function.GetStructure("CLIENTDATA");
structure.SetValue("matl_group", "01");
structure.SetValue("base_uom", "EA");

structure = function.GetStructure("CLIENTDATAX");
structure.SetValue("matl_group", "X");
structure.SetValue("base_uom", "X");
function.Invoke(destination);

I cobbled this together based on a various VB and ABAP examples. The problem is it does nothing. When function.Invoke() is called, it doesn't create a material, it doesn't throw an exception, it just does nothing. Clearly I am not doing something right be I haven't the slightest idea what. Somebody please help!


回答1:


I have no access to a SAP system at the moment, but as far as I know, you have to call the bapi within a transactional scope, e.g. call BAPI_TRANSACTION_COMMIT after creating the material. But maybe the .net connector has another approach for that...

Hope this helps.




回答2:


You need to get the value from the function, based on the output type. Below example for the output type. (table)

    function.Invoke(rfcDest);

    IRfcTable TableResult = function.GetTable("TAG_NAME_OR_METADATA_NAME");


来源:https://stackoverflow.com/questions/9332419/create-a-material-net-connector-sap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!