cancel
Showing results for 
Search instead for 
Did you mean: 

DI Services

Former Member
0 Kudos

I am Using the following code in Visual Basic 6.0 :

Dim oCmpSrv As SAPbobsCOM.CompanyService

Dim oReportLayoutService As ReportLayoutsService

Dim oReportLayout As ReportLayout

Dim oReportParam As ReportParams

'get company service

Set oCmpSrv = oCompany.GetCompanyService

'get report layout service

Set oReportLayoutService = oCmpSrv.GetBusinessService(ServiceTypes.ReportLayoutsService)

'get report params

Set oReportParam = oReportLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportParams)

'report code is the document type code (POR2=PurchaseOrder)

oReportParam.CardCode = "POR2"

'get the default layout of the specific document

Set oReportLayout = oReportLayoutService.GetDefaultReportLayout(oReportParam)

'set the new layout name

oReportLayout.Name = "My layout"

'set the new author name

oReportLayout.Author = "My Author"

'add the new layout to the specific document

oReportLayoutService.AddReportLayout (oReportLayout)

Then the system show the error : "run-time error'-2028"

when is executing the step : 'get the default layout of the specific document

Accepted Solutions (0)

Answers (1)

Answers (1)

rasmuswulff_jensen
Active Contributor
0 Kudos

This line is wrong


oReportParam.CardCode = "POR2" (CardCode is to the BP)

Try this instead...


pIReportParams.CardCode = "BP CardCode";
pIReportParams.ReportCode = "ReportCode";
pIReportParams.UserID = "UserID";

All 3 are needed properties but check out this post for more info

Former Member
0 Kudos

'get company service

Set oCmpSrv = oCompany.GetCompanyService

'get report layout service

Set oReportLayoutService = oCmpSrv.GetBusinessService(ServiceTypes.ReportLayoutsService)

'get report params

Set oReportParam = oReportLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportParams)

'report code is the document type code (POR2=PurchaseOrder)

oReportParam.ReportCode = "POR2"

oReportParam.UserID = 1

oReportParam.CardCode = "V60000"

'get the default layout of the specific document

Set oReportLayout = oReportLayoutService.GetDefaultReportLayout(oReportParam)

'set the new layout name

oReportLayout.Name = "My layout"

'set the new author name

oReportLayout.Author = "My Author"

'add the new layout to the specific document

oReportLayoutService.AddReportLayout (oReportLayout)

It did´nt work, that I am trying to do is get a default report, then change some parameters and add the new report.

In the line : 'add the new layout to the specific document

oReportLayoutService.AddReportLayout (oReportLayout)

Show me the error message : run-time error '438'

Object doesn´t support this property or method