cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass multiple rows from .net to sap

krishna_k19
Contributor
0 Kudos

Dear all,

    I created RFC function module for creating sales order from .net to sap. Its working fine in sap if your passing multiple line items also, but i'm not able to pass multiple rows through that structure , i'm passing single row that time its working fine. Here i'm pasting the code also , pls suggest me..

                              RfcDestination destination = RfcDestinationManager.GetDestination(rfc);

                    IRfcFunction fnOrderDetails = destination.Repository.CreateFunction("YBAPI_VA01_EC");   // This is RFC Name

                    IRfcStructure structInputs = destination.Repository.GetStructureMetadata("ZECOM_VA01").CreateStructure();  // Structure Name

                    DataTable dt1 = (DataTable)ViewState["dt"];

                   for (int i = 0; i < dt1.Rows.Count; i++)

                    {

                        structInputs.SetValue("AUART", "ZBV");  //dt1.Rows[i]["OrderType"].ToString());              // Filling the Structure

                        structInputs.SetValue("VKORG", "9000"); //dt1.Rows[i]["SalesOrganization"].ToString());

                        structInputs.SetValue("VTWEG", "06");   //dt1.Rows[i]["DistributionChannel"].ToString());

                        structInputs.SetValue("SPART", "03");  //dt1.Rows[i]["Division"].ToString());

                        structInputs.SetValue("BSTNK", "ECOM_pO");

                        structInputs.SetValue("KUNNR", "90031");  //dt1.Rows[i]["Customer"].ToString());

                        structInputs.SetValue("MATNR", "1718-0101-BLACK");  //dt1.Rows[i]["MaterialNo"].ToString());

                        structInputs.SetValue("WERKS", "9200"); //dt1.Rows[i]["Plant"].ToString());

                        structInputs.SetValue("J_3ASIZ", "30ABLACK"); // dt1.Rows[i]["Grid"].ToString());

                        structInputs.SetValue("WMENG", "1.000");   //dt1.Rows[i]["Quantity"].ToString());

                        IRfcTable tableimport = fnOrderDetails.GetTable("ZECOM_VA01");

                        //IRfcStructure structInputs = destination.Repository.GetStructureMetadata("ZECOM_VA01").CreateStructure();

                        tableimport.Insert(structInputs);

                       

                    }

 

                    RfcSessionManager.BeginContext(destination);

                    fnOrderDetails.Invoke(destination);                               // Calling the Function Module 

                    var result = fnOrderDetails.GetString("SALESDOCUMENT");  // Returning the Sales Document No.

This is .net side Code.

---> Sap side, PFA..

Regards,

Krishna

 

Accepted Solutions (1)

Accepted Solutions (1)

former_member197445
Contributor
0 Kudos

Assuming the ZECOM_VA01 import parameter is a table type or a table parameter just use YBAPI_VA01_EC.CreateTable and insert the rows.

                  

You can see a similar example here.

http://scn.sap.com/thread/1915377

krishna_k19
Contributor
0 Kudos

Thanks yar,

     by using that link i resolved my issue.

Regards,

Krishna

former_member197445
Contributor
0 Kudos

Can you mark the question as asnwered, please?  Thanks.

Answers (0)