cancel
Showing results for 
Search instead for 
Did you mean: 

Adding UDO via SAP HANA Service Layer WCF

former_member374449
Participant
0 Kudos
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

Accepted Solutions (0)

Answers (3)

Answers (3)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

former_member374449
Participant
0 Kudos

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.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

former_member374449
Participant
0 Kudos

Hi Ankit,

I am adding UDO via SAP Business One Service Layer Single Sign On process.

So this will not works for me.

Thanks & Regards.

Manish Pant

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

former_member374449
Participant
0 Kudos

Hi Ankit,

This piece of code will work for DI API but I am using SAP HANA Service Layer.

So this property is not accessible in Service layer.

Thanks & Regards.

Manish Pant