Skip to Content

SAP ByD - How to access member of collection with specific index

Dear Expert

I have developed SAP ByD for a while and wondering that the SDK does not provide any array data type (like in C, JAVA, etc).


Even though the collection type is pretty much the same as it can contain multiple item. But it has limitation for accessing the item member in the list.



For example.


var result : collectionof DataType::StringDataType;


result.Add(bill_to_id);

result.Add(billto_address1);

result.Add(billto_address2);

result.Add(billto_address3);

result.Add(official_name);

Then I need to access item at index 3.

But the syntax which is available for using is just .GetFirst(), GetLast() ....

Can someone please share any idea how to handle this?.

Is it possible to access it like result[2] ? (same as in other programing language)

Best Regards,

Krit R.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Apr 01, 2016 at 01:46 PM

    A simple foreach should do the trick.

    I don't know if there is a straight forward way 🤣

    var count = 0;
    foreach (var item in result)
    {
         count = count +1;
         if (count == 3)
         {
              //access the item here
              item.somevariable...
         }
    }
    
    
    
    
    Add comment
    10|10000 characters needed characters exceeded