Please follow the steps in the attached document. If you cannot set the ID of report after loading, you have to dynamically query the ID from the table to access the report. Details are in given the document.
Attachment : Detail Document with Image
Step 1 : Create a crystal report for the Printlayout of the user defined form.The parameter of the crystal
report must be DocKey@ with type number. Ref the Image below
Step 2 : Upload this report to SAP B1.
Step 3 : Have to add the Event trigger in the InitialSettings.cs.Advertisement
Add the below codes in the
InitialSettings()
<Code>
Global.SapApplication.LayoutKeyEvent += new
SAPbouiCOM._IApplicationEvents_LayoutKeyEventEventHandler(SapApplication_LayoutKeyEvent);
<Code>
Add the event function to trigger the event function of “VPurchaseRequest.cs”
<code>
private void SapApplication_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool
BubbleEvent)
{
Global.bubblevalue = true;
if (eventInfo.ReportCode == "RCRI" & eventInfo.ReportTemplate == "RCRI0012")
{
VPurchaseRequest.Instance.SapApplication_LayoutKeyEvent(ref eventInfo, out
BubbleEvent);
}
BubbleEvent = Global.bubblevalue;
}
report must be DocKey@ with type number. Ref the Image below
Step 2 : Upload this report to SAP B1.
Step 3 : Have to add the Event trigger in the InitialSettings.cs.
Add the below codes in the
InitialSettings()
<Code>
Global.SapApplication.LayoutKeyEvent += new
SAPbouiCOM._IApplicationEvents_LayoutKeyEventEventHandler(SapApplication_LayoutKeyEvent);
<Code>
Add the event function to trigger the event function of “VPurchaseRequest.cs”
<code>
private void SapApplication_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool
BubbleEvent)
{
Global.bubblevalue = true;
if (eventInfo.ReportCode == "RCRI" & eventInfo.ReportTemplate == "RCRI0012")
{
VPurchaseRequest.Instance.SapApplication_LayoutKeyEvent(ref eventInfo, out
BubbleEvent);
}
BubbleEvent = Global.bubblevalue;
}
<code>
RCRI – Is the type code of Crsyatl report
RCRI0012 – Is the DocCode of crystal report loaded in the SAP db. This can be copied from the Report and Layout Manger, this is marked in the previous image.
Step 4 : Add the below code to the init() of the user form load M-Class.
<code>
SAPbobsCOM.ReportTypesService rptTypeService = (SAPbobsCOM.ReportTypesService)
Global.SapCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportTypesService);
SAPbobsCOM.ReportTypeParams rptParams = (SAPbobsCOM.ReportTypeParams)
rptTypeService.GetDataInterface(SAPbobsCOM.ReportTypesServiceDataInterfaces.rtsReportTypeParams);
rptParams.TypeCode = "RCRI";
SAPbobsCOM.ReportType updateType = rptTypeService.GetReportType(rptParams);
updateType.DefaultReportLayout = "RCRI0012";
rptTypeService.UpdateReportType(updateType);
form.ReportType = "RCRI";
<code>
This will enable Print Preview, Print, Layout Designer in the Toolbar. Also we can see the
layout set to default while select the Layout Designer of the user form. We can also see all other crsyatl
report loaded in the system. The above code will set the default layout for the user form.
Step 5 : Add the below code in the V-Class
<code>
public void SapApplication_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool
BubbleEvent)
{
BubbleEvent = true;
if (eventInfo.ReportCode == "RCRI" & eventInfo.ReportTemplate == "RCRI0012")
{
BubbleEvent = true;
eventInfo.LayoutKey = "1"; // Docentry of the document
}
}
RCRI – Is the type code of Crsyatl report
RCRI0012 – Is the DocCode of crystal report loaded in the SAP db. This can be copied from the Report and Layout Manger, this is marked in the previous image.
Step 4 : Add the below code to the init() of the user form load M-Class.
<code>
SAPbobsCOM.ReportTypesService rptTypeService = (SAPbobsCOM.ReportTypesService)
Global.SapCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportTypesService);
SAPbobsCOM.ReportTypeParams rptParams = (SAPbobsCOM.ReportTypeParams)
rptTypeService.GetDataInterface(SAPbobsCOM.ReportTypesServiceDataInterfaces.rtsReportTypeParams);
rptParams.TypeCode = "RCRI";
SAPbobsCOM.ReportType updateType = rptTypeService.GetReportType(rptParams);
updateType.DefaultReportLayout = "RCRI0012";
rptTypeService.UpdateReportType(updateType);
form.ReportType = "RCRI";
<code>
This will enable Print Preview, Print, Layout Designer in the Toolbar. Also we can see the
layout set to default while select the Layout Designer of the user form. We can also see all other crsyatl
report loaded in the system. The above code will set the default layout for the user form.
Step 5 : Add the below code in the V-Class
<code>
public void SapApplication_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool
BubbleEvent)
{
BubbleEvent = true;
if (eventInfo.ReportCode == "RCRI" & eventInfo.ReportTemplate == "RCRI0012")
{
BubbleEvent = true;
eventInfo.LayoutKey = "1"; // Docentry of the document
}
}
<code>
eventInfo.LayoutKey = "1"; "1" is hard coded here, this is the docentry of the document to be passed
to the crsytal report. This value must be dynamically set to the LayoutKey (use your own logic for this).
eventInfo.LayoutKey = "1"; "1" is hard coded here, this is the docentry of the document to be passed
to the crsytal report. This value must be dynamically set to the LayoutKey (use your own logic for this).
No comments:
Post a Comment