cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Connector BAPI Call with input structure

Former Member
0 Kudos

Hello,

I am trying to connect my .NET program using the SAP .NET connector.

The connection works fine and I am able to invoke the BAPI function module.

But I think that the structure DOCUMENTDATA will be passed empty to the BAPI.

Therfore I get some error messages...

Is the coding correct?

func = funkMeta.CreateFunction

        doc = func.GetStructure("DOCUMENTDATA")

        doc.SetValue("DOCUMENTTYPE", oData.strDocumentType)
        doc.SetValue("DOCUMENTNUMBER", oData.strDocumentNumber)
        doc.SetValue("DOCUMENTVERSION", oData.strDocumentVersion)
        doc.SetValue("DOCUMENTPART", oData.strDocumentPart)

        func.SetValue("DOCUMENTDATA", doc)
        func.Invoke(oConn)

Thanks in advance for your help and ideas,

Regards

Jochen

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi....

Here i am giving code to call structure. It may helps to you.

RfcDestination prd = RfcDestinationManager.GetDestination("SE38");

RfcRepository repo = prd.Repository;

IRfcFunction companyBapi1 = repo.CreateFunction("ZBAPI_PACKAGE_OBJECTLIST"); //Function Module Name

string package = "EU_" + comboBox1.SelectedItem.ToString();

companyBapi1.SetValue("PACKNAME", package); //Input Value

companyBapi1.Invoke(prd);

IRfcTable address1 = companyBapi1["TOBJECTS"].GetTable();//Table Name

if (address1.RowCount != 0)

{

for (int index = 0; index < address1.RowCount; ++index)

{

checkedListBox1.Items.Add(address1[index]["PROGRAM"].GetString()); //Structure NAme

panel2.Visible = true;

}

}

else

{

MessageBox.Show("No Programs Found");

}

stephanreiners
Discoverer
0 Kudos

Hello Jochen,

momentarily I'm facing exact the same problem.

Did you find a sollution?

Regards

Stephan

stephanreiners
Discoverer
0 Kudos

Hello,

SAP-Note 1456826 fixed the problem for us!

Regards

Stephan

CSonek
Discoverer
0 Kudos

Hi Jochen,

why do you create the RfcFunction with the RfcFunctionMetadata.CreateFunction method?

I've created the RfcFunction with the RfcDestination.Repository.CreateFunction(FunctionName) method

and tested your coding. The Structure DOCUMENTDATA was passed filled to the BAPI function module.

Cheers,

Christian

Former Member
0 Kudos

Hi Christian,

thanks for your quick reply. What I am trying to do is to invoke BAPI_DOCUMENt_CREATE2.

The Metadata Call was just for testing to see if it makes any difference. The interesting thing is, that the BAPI will return a message regarding the missing changemaster " " which was not passed in the structure.

Interesting is that this message will be raised independent of passing the values for the document info records...

If I invoke the RFC using the COM API provided by the SAP GUI installation it works. When using the .NET Connector 3.0 I am getting the mentioned result, which sounds strange to me.

Do you have any idea what the reason for this behaviour could be?

Regards

Jochen

Former Member
0 Kudos

ok. very interesting. I debugged it. I passed no values for some fields. Date fields for example. In ABAP the value ############ will be displayed as field content which is probably an indicator that I have to fill something in .NET to set the field to an initial value... What do I have to fill in to set the value to blank?

Former Member
0 Kudos

I have not really an idea how to solve this issue. As mentioned I am calling function module BAPI_DOCUMENT_CREATE2 and I am NOT passing any values for


        doc.SetValue("LABORATORY", "")
        doc.SetValue("ECNUMBER", "")
        doc.SetValue("VALIDFROMDATE", "")

The result is that the values ######## will be passed and display in the debugger. The return message contains that the change master (ECNUMBER) could not be found -> which is clear because it is not initial as passed.

What can the reason be? Unicode problems? Any other ideas?

Has maybe one of you the same issue recognized? How can I solve this?

Regards

Jochen

Former Member
0 Kudos

Hello Jochen,

i have the same problem.

Did you have a solution?

Regards,

Klaus