Quantcast
Channel: SAP Business One SDK
Viewing all articles
Browse latest Browse all 49

"Project Management" object is exposed from SAP Business One Version 9.2 PL03

$
0
0

"Project Management" object is exposed as a Service Type Object from SAP Business One Version 9.2 PL03. It is yet to be implemented in DTW.


You can refer to below sample:


1. Add a Project:


int absEntryOfCreatedProject = -1;

 

 

            SAPbobsCOM.CompanyService oCompServ = null;

            SAPbobsCOM.ProjectManagementService pmgService = null;

 

 

            try

            {

                // Company service

                oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();

 

 

                // ProjectManagementService

                pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);

 

 

                // Add project

                SAPbobsCOM.PM_ProjectDocumentData project = (SAPbobsCOM.PM_ProjectDocumentData)pmgService.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentData);

                project.ProjectName = "ProjectByDI_01";

                project.Owner = 1;

                project.StartDate = new DateTime(2016, 2, 1);

                project.DueDate = new DateTime(2016, 11, 30);

                project.ClosingDate = new DateTime(2016, 12, 31);

                project.ProjectType = SAPbobsCOM.ProjectTypeEnum.pt_External;

                project.BusinessPartner = "C20000";              

                project.ContactPerson = 2;

                project.Territory = 1;

                project.SalesEmployee = 5;

                project.AllowSubprojects = SAPbobsCOM.BoYesNoEnum.tYES;

                project.ProjectStatus = SAPbobsCOM.ProjectStatusTypeEnum.pst_Started;

                project.FinancialProject = "PRJ01";

                project.RiskLevel = SAPbobsCOM.RiskLevelTypeEnum.rlt_High;

                project.Industry = 1;

                project.Reason = "Test comment";

                project.AttachmentEntry = 1;

 

 

                SAPbobsCOM.PM_ProjectDocumentParams projectParam = pmgService.AddProject(project);

                absEntryOfCreatedProject = projectParam.AbsEntry;

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

            finally

            {

                if (pmgService != null)

                {

                    MessageBox.Show(absEntryOfCreatedProject.ToString());

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);

                }

            }

 

 

2. Add Document to Stages:


SAPbobsCOM.CompanyService oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();

            SAPbobsCOM.ProjectManagementService pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);

 

 

            SAPbobsCOM.PM_ProjectDocumentParams projectToUpdateParam = pmgService.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);

 

 

            try

            {

              

                projectToUpdateParam.AbsEntry = 1;

                SAPbobsCOM.PM_ProjectDocumentData project = pmgService.GetProject(projectToUpdateParam);

 

 

                // add stage to the project

                SAPbobsCOM.PM_StagesCollection stagesCollection = project.PM_StagesCollection;

                SAPbobsCOM.PM_StageData stage = stagesCollection.Add();

                stage.StageType = 1;

                stage.StartDate = DateTime.Now;

                stage.CloseDate = stage.StartDate.AddDays(30);

                stage.Task = 1;

                stage.Description = "StageWithDocByDI_01";

                stage.ExpectedCosts = 150;

                stage.PercentualCompletness = 7;

                stage.IsFinished = SAPbobsCOM.BoYesNoEnum.tNO;

                stage.StageOwner = 5;

                stage.AttachmentEntry = 1;

 

 

                stage = stagesCollection.Add();

                stage.StageType = 2;

                stage.StartDate = DateTime.Now.AddMonths(1);

                stage.CloseDate = stage.StartDate.AddDays(30);

                stage.Task = 2;

                stage.Description = "StageWithDocByDI_02";

                stage.ExpectedCosts = 250;

                stage.PercentualCompletness = 8;

                stage.IsFinished = SAPbobsCOM.BoYesNoEnum.tNO;

                stage.StageOwner = 5;

                stage.DependsOnStage1 = 1;

                stage.StageDependency1Type = SAPbobsCOM.StageDepTypeEnum.sdt_Project;

                stage.DependsOnStageID1 = 1;

 

 

                // add document to the stage

                SAPbobsCOM.PM_DocumentsCollection documentsCollection = project.PM_DocumentsCollection;

                SAPbobsCOM.PM_DocumentData document = documentsCollection.Add();

                document.StageID = 1;

                document.DocType = SAPbobsCOM.PMDocumentTypeEnum.pmdt_APCreditMemo;

                document.DocEntry = 7;

 

 

                pmgService.UpdateProject(project);

                MessageBox.Show("OK");

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

            finally

            {

                if (pmgService != null)

                {

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);

                }

            }


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>