Skip to Content
0
Former Member
Jan 11, 2017 at 12:00 PM

Reflection in SAP B1 SDK

217 Views

Hi, ALL

I'm trying to implement a reflection over the BusinessPartners object, but I'm getting the following error: "Object reference not set to an instance of an object.".

Bellow follows the source code:

 BusinessPartners PN = sapCom.Company.GetBusinessObject(BoObjectTypes.oBusinessPartners);

            Type BussinessPartnesType = PN.GetType(); // typeof(BusinessPartners);
            PropertyInfo propertySet = BussinessPartnesType.GetProperty("CardName", BindingFlags.Instance);
            propertySet.SetValue(PN, "BusinessPartners Test", null);
            PN.Add();

What can be done to achieve a similar result?