cancel
Showing results for 
Search instead for 
Did you mean: 

Pass table(or array) to SAP web service from c# .net as input parameter

Former Member
0 Kudos

Hi,

i have consume the SAP web service from .NET environment to get list of customers . my Code as follows ;

Add the web reference

WebReference_PlantList.Y_WEBS3 myList = new Y_WEBS3(); //Create the instence     

              

    WebReference_PlantList.Y_WEBS31[] myPlantInput = new Y_WEBS31[2];  // Declare the array

     WebReference_PlantList.Y_WEBS3Response myPlantResponse  = new Y_WEBS3Response(); // Instantiate the Response

                NetworkCredential myCredentials = new NetworkCredential("xxxx", "xxxxx"); // set the credentials

               myList.PreAuthenticate = true;

               myList.Credentials = myCredentials;

  

               myPlantResponse = myList.CallY_WEBS3(xxxxxxxx);  // from this point onward i am stuck  .if any one can help with rest of the things , that will highly appropriated

i was able to get the data successfully when web service develop only with export parameter , but this case its return a table .

Regards,

T.w.k

Accepted Solutions (1)

Accepted Solutions (1)

hynek_petrak
Active Participant
0 Kudos

Please see the definition of your response class - Y_WEBS3Response and/or the CallY_WEBS3 itself in the Object browser and address your table parameter accordingly.

Some smaple is e.g. here:

Former Member
0 Kudos

Thanks a lot Hynek ,

Its done .. i have create array list with type of web service response class as you mentioned here . Thanks a lot again .

Regards,

Thushara

Former Member
0 Kudos

Sample Code ;

string str_err;

            try

            {

               

                WebReference_PlantList.Y_WEBS3 myList = new Y_WEBS3(); //service

                WebReference_PlantList.Y_WEBS3Response myPlantResponse = new                Y_WEBS3Response(); //response

                             

                WebReference_PlantList.Y_WEBS31 input = new Y_WEBS31();//input

          // Create array list here

                List<WebReference_PlantList.YEMPLANTS> mm = new List<YEMPLANTS>();

                input.ZPLANTDET = mm.ToArray();


                NetworkCredential myCredentials = new NetworkCredential(SAPUserName,                SAPPasword); //set credentials

         

                myList.PreAuthenticate = true;

                myList.Credentials = myCredentials;

                myPlantResponse = myList.CallY_WEBS3(input);

//Loop through the response

                foreach (var item in myPlantResponse.ZPLANTDET)

                {

                 

                    myController.plantList_Service(item.WERKS,item.NAME1 );

                   

                }

              

 

            }

            catch (Exception ex)

            {

              mylog.insert_log(ex.Message);

                throw;

            }

Regards,

Thushara

Answers (0)