Skip to Content

Adding UDO via SAP HANA Service Layer WCF

Hi,
I am trying to add UDO using SAP HANA Service Layer WCF but I am not be able to add child tables into it.

 try
            {
                UserObjectsMD oUserObjectMD = new ServiceReference1.SAPB1.UserObjectsMD();
                oUserObjectMD.Code = _StrUDOCode;
                oUserObjectMD.Name = _StrUDOName;
                string _StrUDOType = UDOType.ToString().Replace(" SAPbobsCOM.BoUDOObjType.", "");
                oUserObjectMD.ObjectType = _StrUDOType;
                oUserObjectMD.TableName = _StrParentTableName;
                oUserObjectMD.CanCancel = "tYES";
                oUserObjectMD.CanClose = "tYES";
                oUserObjectMD.CanCreateDefaultForm = "tNO";
                oUserObjectMD.CanDelete = "tYES";
                oUserObjectMD.CanFind = "tYES";
                oUserObjectMD.CanLog = "tYES";
                oUserObjectMD.LogTableName = "A" + _StrParentTableName;
                oUserObjectMD.CanYearTransfer = "tYES";
                oUserObjectMD.ManageSeries = _StrSeriesManaged;

/*************************************************************************/
                // Adding Child Tables to UDO
/*************************************************************************/
               try
                {
                    Cls_SBOAddOn.serviceLayer.AddToUserObjectsMD(oUserObjectMD);
                    Cls_SBOAddOn.serviceLayer.Configurations.RequestPipeline.OnEntryStarting((arg) => { arg.Entry.Properties = FilterNullValues(arg.Entry.Properties.ToList(), true); });
                    DataServiceResponse response = Cls_SBOAddOn.serviceLayer.SaveChanges(); //HERE IS WHERE THE ERROR HAPPENS!!!!!!!
                    if (null != response)
                    {
                        ChangeOperationResponse opRes = (ChangeOperationResponse)response.SingleOrDefault();
                        object retDoc = ((System.Data.Services.Client.EntityDescriptor)(opRes.Descriptor)).Entity;
                        if (null != retDoc)
                        {
                            return true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    string sError = ex.Message;
                    if (ex.InnerException != null) { sError = ex.InnerException.Message; }
                    Cls_SBOAddOn.serviceLayer.Detach(oUserObjectMD);
                    return false;
                }


                return false;
            }
            catch (Exception ex)
            {
                return false;
            }

Kindly help me.

Thanks & Regards.
Manish Pant
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Dec 17, 2018 at 09:07 AM

    Hi Manish Pant,

    Use the following piece of code to add the Child Tables to the UDO:

    oUserObjectMD.ChildTables.TableName = "TableName";
    oUserObjectMD.ChildTables.Add();
    

    Hope it helps!

    Kind regards,

    ANKIT CHAUHAN

    SAP Business One Support

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 17, 2018 at 10:27 AM

    Hi Manish Pant,

    Try to use UserObjectMD_ChildTables for Service Layer as shown below:

    Hope it helps!

    Kind regards,

    ANKIT CHAUHAN

    SAP Business One Support


    Add comment
    10|10000 characters needed characters exceeded

  • Dec 21, 2018 at 03:08 PM

    Hi Manish Pant,

    Can you please provide an explanation why it will not work for you if single sign-on is being used?

    Kind regards,

    ANKIT CHAUHAN

    SAP Business One Support

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ankit,

      This will not work as I am using Service Layer Single Sign-On in which your given piece of code is not available in Service Layer Single Sign-On.

      I had already given the whole code in above post.

      Thanks & Regards.