metalsimyaci / SapCo2

SAP Connector for .Net5
MIT License
29 stars 10 forks source link

IRfcTransaction create transaction #7

Open RollyRolls0712 opened 3 years ago

RollyRolls0712 commented 3 years ago

im trying to create or insert data to bapi sap using IRFCTRANSACTION im encountered below error.

attempted to read or write protected memory. this is often an indication that other memory is corrupt IRfcTransaction

Thank you.

metalsimyaci commented 3 years ago

Hi Roly,

IRFCTRANSACTION is a section developed for experimentation. The main problem in the section is that the function that will receive the TransactionID needs to be registered in the system. This is a topic in the SAP NetWeaver RFC library documentation that I don't fully understand yet. Research on the subject continues. I will try to find a method to use transaction with SAPCO2 as soon as possible.

Maybe calling another transaction function like in Sapnco instead of function registration can solve our problem.

//sapnco example

 var dest = SAPUtils.GetRfcDestination(connectionTarget);
var repo = dest.Repository;
var func = repo.CreateFunction("BAPI_MATERIAL_SAVEDATA");
var transaction = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");

SetHeadData(func, material.HeadData);
SetMaterialDescription(func, material.MaterialDescription);
func.Invoke(dest);
transaction.Invoke(dest);

var resultTable = func.GetTable("RETURNMESSAGES");
var errorMessages = SAPUtils.GetListFromRFCTable<ReturnTableMessage>(resultTable);

if (errorMessages.All(x => x.TYPE == "S" || x.TYPE == "H"))
{
    material.MaterialStatus = MaterialStatuses.Success;
    material.ErrorMessages = string.Empty;
}
else
{
    material.MaterialStatus = MaterialStatuses.Error;
    material.ErrorMessages = string.Join("\n", errorMessages.Select(x => x.ToString()));
}

return material;

Thank you for your feedback.

RollyRolls0712 commented 3 years ago

hi metalsimyaci ,

thank you for your feedback however sapnco is for .netframework only ill using .core already see below the details. image thank you,