1

I am aware of the option to call RFC-functions with .NCo 3.0 but is it possible to call transactions/programs directly with the SAP Connector? (Like using the fields defined in SAP as parameters and fill them, or use a variation, something like this?).

This answer provides a workaround that I am aware of, and sure - I could call a VBScript from my C# code but that is not what I want to do. I also checked all of the 64 Questions tagged with sap-connector but there was nowhere a direct answer if it is possible or not.

Also the SAP documentations I got from the SAP marketplace aren't mentioning transactions/programs at all. Does this mean it is not wanted/possible ?

If so, why is it possible to do it with macros/pre-recorded VBScripts but not with the .NET-Connector ? Or am I just doing something wrong ?

When I try to call a program/transaction with the standart-code:

SAPHandle.ECCDestinationConfig cfg = new SAPHandle.ECCDestinationConfig();

RfcDestinationManager.RegisterDestinationConfiguration(cfg);

RfcDestination dest = RfcDestinationManager.GetDestination("QP2");

dest.Ping(); //works fine -> Connection is OK

RfcRepository repo = dest.Repository;

IRfcFunction zzmkalzzm23fnc = repo.CreateFunction("ZMZKALZZM23");

it gives me the following (expectable) error:

metadata for function ZMZKALZZM23 not available: FU_NOT_FOUND: function module ZMZKALZZM23 is not available

DatRid
  • 1,169
  • 2
  • 21
  • 46
  • 2
    CreateFunction, as the name already suggests, creates a proxy to call a remote-enabled function module in the SAP system. You can't call a transaction or program this way. I am not aware of any way to call a report with SAP Net Connector. The solution you linked uses SAP Gui, which provides the SAP system with a UI to display graphical elements. AFAIK, SAP NCo doesn't provide such an interface and you can't call reports from NCo. – Dirk Trilsbeek Aug 11 '16 at 19:31
  • Thank you Dirk for your reply. I ended up building a RFC specified for this case. However thanks for removing my doubt if it may be possible. – DatRid Aug 26 '16 at 06:27
  • @Dirk: This is the correct answer. You should turn it into an "Answer" instead of just a "Comment", so that the question can be tagged as answered. :-) – Lanzelot Sep 06 '18 at 19:03
  • I agree with Lanzelot, @DirkTrilsbeek Just forgot to mention this back then because I hoped for an answer which would make it possible. However as it isn't, just place your comment as answer and I'll accept it. – DatRid Sep 07 '18 at 08:10

1 Answers1

1

CreateFunction, as the name already suggests, creates a proxy to call a remote-enabled function module in the SAP system. You can't call a transaction or program this way. I am not aware of any way to call a report with SAP .Net Connector. The solution you linked uses SAP Gui, which provides the SAP system with a UI to display graphical elements. AFAIK, SAP NCo doesn't provide such an interface and you can't call reports from NCo.

However, there are products that allow you to execute transactions and catch their output. We are using the product Theobald Xtract to extract SAP ERP data for BI purposes, but they also have a more generic .Net library (Theobald ERPConnect) available that may be able to provide this functionality. It won't be as simple as calling a function and extracting the strongly typed data, but with some filtering you should be able to get the output you need. Those products are not cheap, but they do provide a nice set of functionality you otherwise would have to reinvent yourself.

Some example code how you could call the transaction you ended up calling through VBS-Scripts. From the Theobald ERPConnect Knowledgbase:

private void button1_Click(object sender, System.EventArgs e)
{
    // Reset the batch steps
    transaction1.BatchSteps.Clear();

    // fill new steps
    transaction1.ExecutionMode =    ERPConnect.Utils.TransactionDialogMode.ShowOnlyErrors;
    transaction1.TCode = "MMBE";
    transaction1.AddStepSetNewDynpro("RMMMBEST","1000");
    transaction1.AddStepSetOKCode("ONLI");
    transaction1.AddStepSetCursor("MS_WERKS-LOW");
    transaction1.AddStepSetField("MS_MATNR-LOW",textBox1.Text);
    transaction1.AddStepSetField("MS_WERKS-LOW",textBox2.Text);

    // connect to SAP
    r3Connection1.UseGui = true;

   R3Connection r3Connection1= new R3Connection("SAPServer",00,"SAPUser","Password","EN","800");
     r3Connection1.Open(false);
     // Run
     transaction1.Execut e();

}
DatRid
  • 1,169
  • 2
  • 21
  • 46
Dirk Trilsbeek
  • 5,873
  • 2
  • 25
  • 23
  • Ah, the library you mention is exactly what I searched for back then. Thanks a lot! I quickly checked their docs and they really provide the functionality I need. (Call a transaction, read the following table etc). Good to know. – DatRid Sep 07 '18 at 10:00