如何通过SAP B1中的C#代码创建矩阵样式UDO

2020-09-08 06:03发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


专家们,

我想使用C#代码(不是手动)将用户定义的对象(UDO)添加为矩阵样式。

请问有人建议在此提供任何参考代码吗?

注意:不是手动操作,只能通过C#代码抛出。

谢谢

Chenna

(5.5 kb)

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


专家们,

我想使用C#代码(不是手动)将用户定义的对象(UDO)添加为矩阵样式。

请问有人建议在此提供任何参考代码吗?

注意:不是手动操作,只能通过C#代码抛出。

谢谢

Chenna

(5.5 kb)
付费偷看设置
发送
4条回答
SKY徐
1楼 · 2020-09-08 06:43.采纳回答

您好 Chenna Gadicherla

以下代码对我来说很好 。 您可以尝试一下,让我知道:

 SAPbobsCOM.UserObjectsMD oUserObjectMD = null;
             SAPbobsCOM.UserObjectMD_FindColumns oUDOFind = null;
             SAPbobsCOM.UserObjectMD_FormColumns oUDOForm = null;
             SAPbobsCOM.UserObjectMD_EnhancedFormColumns oUDOEnhancedForm = null;
             GC.Collect();
             oUserObjectMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)作为SAPbobsCOM.UserObjectsMD;
             oUDOFind = oUserObjectMD.FindColumns;
             oUDOForm = oUserObjectMD.FormColumns;
             oUDOEnhancedForm = oUserObjectMD.EnhancedFormColumns;
             var retval = oUserObjectMD.GetByKey(" UDOCODE");
             如果(!retval)
             {
                 oUserObjectMD.Code =" UDOCODE";
                 oUserObjectMD.Name =" NAME";
                 oUserObjectMD.TableName =" UDOTABLE";
                 oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData;
                 oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.MenuCaption ="菜单标题";
                 oUserObjectMD.FatherMenuID = 48896;
                 oUserObjectMD.MenuUID =" UDOMenuUID";
                 oUserObjectMD.Position = 5;




                //=================================
                 oUDOFind.ColumnAlias ="代码";
                 oUDOFind.ColumnDescription ="代码";
                 oUDOFind.Add();
                 oUDOFind.ColumnAlias ="名称";
                 oUDOFind.ColumnDescription ="名称";
                 oUDOFind.Add();
                //=======================================


                //========================================
                 oUDOForm.FormColumnAlias ="代码";
                 oUDOForm.FormColumnDescription ="代码";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();


                 oUDOForm.FormColumnAlias =" U_FirstName";
                 oUDOForm.FormColumnDescription =" U_名字";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();


                 oUDOForm.FormColumnAlias =" U_Email";
                 oUDOForm.FormColumnDescription ="电子邮件";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();


                //========================================


                 oUDOEnhancedForm.ColumnAlias ="代码";
                 oUDOEnhancedForm.ColumnDescription ="代码";
                 oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 1;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Add();


                 oUDOEnhancedForm.ColumnAlias =" U_FirstName";
                 oUDOEnhancedForm.ColumnDescription ="名字";
                 oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 2;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Add();


                 oUDOEnhancedForm.ColumnAlias =" U_Email";
                 oUDOEnhancedForm.ColumnDescription ="电子邮件";
                 oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 3;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Add();


                 如果(!retval)
                 {
                     如果((oUserObjectMD.Add()!= 0))
                     {
                         MessageBox.Show(oCompany.GetLastErrorDescription());
                     }
                     其他
                     {
                     }
                 }
             }
 

亲切的问候,

ANKIT CHAUHAN

SAP Business One支持

Climb_Ma
2楼-- · 2020-09-08 06:44

您好 ANKIT CHAUHAN

我尝试使用下面提到的代码,但是"注册UDO"仅创建为"标题"线型。 但是我正在寻找矩阵样式的默认表单。

请看下面的代码

私有无效RegisterMatrixStyleUDO()
         {
        SAPbobsCOM.UserObjectsMD oUserObjectMD = null;
        SAPbobsCOM.UserObjectMD_FindColumns oUDOFind = null;
        SAPbobsCOM.UserObjectMD_FormColumns oUDOForm = null;
        SAPbobsCOM.UserObjectMD_EnhancedFormColumns oUDOEnhancedForm = null;
       GC.Collect();
  oUserObjectMD = SBO_Company.GetBusinessObject(BoObjectTypes.oUserObjectsMD)作为UserObjectsMD;
             oUDOFind = oUserObjectMD.FindColumns;
             oUDOForm = oUserObjectMD.FormColumns;
             oUDOEnhancedForm = oUserObjectMD.EnhancedFormColumns;
             var retval = oUserObjectMD.GetByKey(" UDOCODE");
             如果(!retval)
             {
                 oUserObjectMD.Code =" UDOCODE";
                 oUserObjectMD.Name =" NAME";
                 oUserObjectMD.TableName =" UDOTableName";
         oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData;
                 oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO;
                 oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO;
          oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUserObjectMD.EnableEnhancedForm = BoYesNoEnum.tYES;
                 oUserObjectMD.MenuCaption ="菜单标题";
                 oUserObjectMD.FatherMenuID = 48896;
                 oUserObjectMD.MenuUID =" UDOMenuUID";
                 oUserObjectMD.Position = 5;


                //=================================
                 oUDOFind.ColumnAlias ="代码";
                 oUDOFind.ColumnDescription ="代码";
                 oUDOFind.Add();
                 oUDOFind.ColumnAlias ="名称";
                 oUDOFind.ColumnDescription ="名称";
                 oUDOFind.Add();
                //=======================================

                //========================================
                 oUDOForm.FormColumnAlias ="代码";
                 oUDOForm.FormColumnDescription ="代码";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();

                 oUDOForm.FormColumnAlias =" U_FirstName";
                 oUDOForm.FormColumnDescription =" U_名字";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();

                 oUDOForm.FormColumnAlias =" U_Email";
                 oUDOForm.FormColumnDescription ="电子邮件";
                 oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOForm.Add();

                //========================================

                 oUDOEnhancedForm.ColumnAlias ="代码";
                 oUDOEnhancedForm.ColumnDescription ="代码";
                oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 1;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Editable = BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Add();

                 oUDOEnhancedForm.ColumnAlias =" U_FirstName";
                 oUDOEnhancedForm.ColumnDescription ="名字";
                oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 2;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Add();

                 oUDOEnhancedForm.ColumnAlias =" U_Email";
                 oUDOEnhancedForm.ColumnDescription ="电子邮件";
                oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Editable = BoYesNoEnum.tYES;
                 oUDOEnhancedForm.ColumnNumber = 3;
                 oUDOEnhancedForm.ChildNumber = 1;
                 oUDOEnhancedForm.Editable = BoYesNoEnum.tYES;
                 oUDOEnhancedForm.Add();

                 如果(!retval)
                 {
                     如果((oUserObjectMD.Add()!= 0))
                     {
                      int transTemp4 = System.Convert.ToInt32(lErrCode);
                      SBO_Company.GetLastError(out transTemp4,out sErrMsg)
 Interaction.MsgBox(sErrMsg,(Microsoft.VisualBasic.MsgBoxStyle)(0),null);
                     }
                     其他
                     {
                     }
                 }
             }
             Marshal.ReleaseComObject(oUserObjectMD);
         } 

如果我想念什么,请建议我。 您能帮我解决这个问题吗?

谢谢

SAP小黑
3楼-- · 2020-09-08 06:44

您好 ANKIT CHAUHAN

我可以知道,是否可以通过代码抛出来创建矩阵样式的默认UDO表单?

如果是,请您建议步骤。

谢谢

Chenna。

Violet凡
4楼-- · 2020-09-08 06:48

嗨 ANKIT CHAUHAN,

非常感谢您的支持,对我来说很好。

谢谢

Chenna。

一周热门 更多>