“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.
Here is how to use the Project Management object using DI API:
1. Add a Project using DI API:
int absEntryOfCreatedProject = -1;
SAPbobsCOM.CompanyService oCompServ = null;
SAPbobsCOM.ProjectManagementService pmgService = null;
try
{
oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);
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. Update a Project by adding ‘Documents’ to ‘Stages’ using DI API:
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);
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;
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);
}
}
3. Cancelling a Project using DI API:
SAPbobsCOM.CompanyService oCompServ = null;
SAPbobsCOM.ProjectManagementService pmgService = null;
try
{
oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
pmgService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(ServiceTypes.ProjectManagementService);
SAPbobsCOM.PM_ProjectDocumentParams projectToCancelParam = pmgService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_ProjectDocumentParams);
projectToCancelParam.AbsEntry = 1;
pmgService.CancelProject(projectToCancelParam);
}
catch (Exception ex)
{
throw new Exception(string.Format("Call PMG failed with error code: {0}", ex.Message));
}
finally
{
if (pmgService != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);
}
}
4. Adding a SubProject using DI API:
try
{
CompanyService oCompServ = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
ProjectManagementService phaService = (SAPbobsCOM.ProjectManagementService)oCompServ.GetBusinessService(ServiceTypes.ProjectManagementService);
PM_SubprojectDocumentData subProject = phaService.GetDataInterface(ProjectManagementServiceDataInterfaces.pmsPM_SubprojectDocumentData);
subProject.Owner = 4;
subProject.SubprojectName = "SubProjectNameByDI_01_01";
subProject.StartDate = new DateTime(2016, 5, 1);
subProject.DueDate = new DateTime(2016, 5, 15);
subProject.SubprojectEndDate = new DateTime(2016, 5, 31);
subProject.ProjectID = 1;
subProject.SubprojectType = 1;
subProject.SubprojectContribution = 15;
subProject.SubprojectStatus = SubprojectStatusTypeEnum.sst_Open;
subProject.ActualCost = 50;
subProject.PlannedCost = 200;
SAPbobsCOM.PM_SubprojectDocumentParams subprojectParam = phaService.AddSubproject(subProject);
}
catch (Exception ex)
{
throw new Exception(string.Format("Call failed with error code: {0}", ex.Message));
}
finally
{
if (pmgService != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pmgService);
}
}
5. Updating a SubProject by adding Stages to it using DI API:
SAPbobsCOM.ProjectManagementService oProject = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectManagementService);
SAPbobsCOM.PM_SubprojectDocumentData subProject1 = oProject.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_SubprojectDocumentData);
SAPbobsCOM.PM_SubprojectDocumentParams subProjectParam1 = oProject.GetDataInterface(SAPbobsCOM.ProjectManagementServiceDataInterfaces.pmsPM_SubprojectDocumentParams);
subProjectParam1.AbsEntry = 1; //OPHA.AbsEntry
subProject1 = oProject.GetSubproject(subProjectParam1);
SAPbobsCOM.PMS_StagesCollection stagesCollection= subProject1.PMS_StagesCollection;
SAPbobsCOM.PMS_StageData stage = stagesCollection.Add();
stage.StageType = 3; //PMC2.StageID
stage.StartDate = DateTime.Today.Date;
stage.Description = "My DI Test";
oProject.UpdateSubproject(subProject1);
Update: UDFs have been implemented for “PM_ProjectDocumentData”, “PM_StageData”, “PM_SubprojectDocumentData” since SAP Business One Version 9.3 PL01 .
Thanks for sharing this… When we can use it in DTW?
Dear Kuldeep, we are well aware of this requirement, it is also tracked via https://ideas.sap.com/D35622.
Please subscribe to that idea in order to get informed as soon as it get updated.
Best regards, Peter
Delivered with SAP Business One 9.3 PL00
Update an existing ‘Stage’ for the existing Project Management Document, can be found here:
https://answers.sap.com/questions/160076/sap-business-one-project-management-stages-sdk.html
Kind regards,
ANKIT CHAUHAN
SAP SME Support
Hi Ankit,
Thanks for sharing.
Is it possible to update UDF values for PM_ProjectDocumentData or PM_SubprojectDocumentData?
Thanks,
Mark
Hi Former Member,
Currently, I do not find any possibility to do this. I will inform you about it as early as possible.
Kind regards,
ANKIT CHAUHAN
SAP SME Support
Hi Former Member,
Currently, UDFs are not implemented for PM_ProjectDocumentData or PM_SubprojectDocumentData
Kind regards,
ANKIT CHAUHAN
SAP SME Support
Hi ANKIT CHAUHAN,
Can you help give me demo adding Project management with DI API. I dont know how to use DI API with Project Management
Thanks.
Hi,
Sorry for the late reply!
To use the above mentioned program, you need to perform the following:
Hope it helps!
Kind regards,
ANKIT CHAUHAN
SAP SME Support
Hi ANKIT,
Thank you so much
With sharing this, Can I use DI API import with file XML. Pls explain for me
Thanks
Hi,
Can you also give some examples for ProjectManagementConfigurationService.
Specialy the getTasks and addTasks?
Kind regards,
Mark
Hi Ankit!
Firstly, thanks for your post and samples about Project Management. However, I have doubt about how to implement UDF in this code.
After installing SAP 9.3 PL5, I’m trying to integrate Project Management basead on your sample and update UDF, but an error is shown on my application:
Invalid Field Name
The line which is occuring the error:
The field “U_ValorProj” was created correcly in Project Management as Numeric (16.9), but I have no idea how to fix it.
Besides that, I changed the field name to “ValorProj” but the error persists:
Could you help me?
Best Regards
Tulio
Hi ANKIT CHAUHAN
I need to use the PurchaseRequest object (1470000113), but it is not available in the PMDocumentTypeEnum
Thanks for any help
Andres Ramirez Jaramillo
Hi Andres Ramirez Jaramillo,
Kindly help to test the issue in SAP Business One Version 9.3 PL13 or above. This issue appears to be fixed in SAP Business One Version 9.3 PL13 as mentioned in SAP Note 2860252.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
Greetings Ankit,
do you have any code samples on how to add/update subproject stages? (I mean – the OPHA ones)
… or you how to update the code provided by SAP?
tbh I’m a bit lost, im just trying to add new stages.
Thanks in advance for any help!