cancel
Showing results for 
Search instead for 
Did you mean: 

View Crystal Report from add-on

costas_ioannou2
Active Participant

Hi all

I want to view crystal reports from an add-on built using the SDK. How can this be done? Is there sample code?

Thanks,

Costas

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi!

I am facing the exactly the same issue as Costas described. SAP B1 version is 9.3 HANA.

I would love to take a look at the sample by Trinidad (http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/26720). Unfortunately the link is outdated. Could anybody share any hint?

In the meantime I am playing with my form LayoutKey%, Print%, ReportData% events hoping that it is a proper direction.

Regards,

Jakub

--- UPDATE ---

I think I am almost there.

What I have done:

1) Created a Crystal Report layout with Dockey@ numeric param matching my UDO document entry.

2) Imported via "Report and Layout Import Wizard" as Layout attached to USRT document type.

3) Added the following code to my UDO code behind:

        /// <summary>
        /// Initialize components. Called by framework after form created.
        /// </summary>
        public override void OnInitializeComponent()
        {
            this.UIAPIRawForm.ReportType = "USRT";
            this.OnCustomInitialize();
        }


        /// <summary>
        /// Initialize form event. Called by framework before form creation.
        /// </summary>
        public override void OnInitializeFormEvents()
        {
            this.LayoutKeyBefore += new LayoutKeyBeforeHandler(this.Form_LayoutKeyBefore);
        }


        private void Form_LayoutKeyBefore(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            eventInfo.LayoutKey = "2"; // dummy value - to be taken from current doc
        }


4) opened my UDO from B1 client and set my CR layout as default.

Now the thing works as a charm when I have only one UDO. If I add another UDO it tries to use the same layout.

Any hints appreciated 🙂

Jakub

0 Kudos
Former Member
0 Kudos

Hi Costas,

Refer This.....

[http://forums.sdn.sap.com/thread.jspa?threadID=1871564]

[http://forums.sdn.sap.com/thread.jspa?threadID=1703947]

Thanks

Shafi

costas_ioannou2
Active Participant
0 Kudos

Hi guys,

Thanks for the replies. I took a look at the suggestions.

@shafi_sunshine - Thanks for the links, but they are a little confusing. Isn't there a sample code that we can look at. The threads I looked at don't have complete examples and are difficult to follow.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

Could you please explain more in detail what you need to do?

Do you want to associate a CrystalReport report to one of your user defined forms?

Or do you want to associate a CrystalReport report to one of your forms? Possible since B1 8.81 version.

Or change the associated reports to B1 forms from SDK?

Or something different?

Regards,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

Thanks for the reply. I would like to be able to run a crystal report from one of my forms developed using the SDK. For example let's say I have a UDO, that has been customized with fields and a matrix. I have also developed a crystal report to print data from my UDO tables. I would like to be able to run the report from my UDO form and pass the Document number of my UDO to the crystal report without the user having to manually enter the selection criteria. I would like the crystal report to be displayed within SAP just like they would if I were manually running the report from the main menu.

I hope this clears things up,

Costas

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

SDK version 8.81 has some new features around CrystalReports and allows you to associate a report to your own form so B1 will automatically handle it as for B1 forms.

DI API

u2022 Add a new report type => ReportTypesService (new in 8.81).

u2022 Add a new report layout => ReportLayoutsService.

u2022 Set the report layout into the report type.

u2022 Link the Report layout code to the Crystal Report file => Use the CompanyService.SetBlob method.

UI API

u2022 Link the new report type to your form

oMyForm.ReportType = reportType.TypeCode;

u2022 Listen to LayoutKeyEvent and set the LayoutKey to the value of the edit text in your form containing the key needed by the report (fired when you print or print preview a layout of an add-on form)

eventInfo.LayoutKey = edTxtKey.Value;

Let me know if it is not clear enough. I'll try to create a blog with a sample inside asap.

Hope it helps,

Trinidad.

Former Member
0 Kudos

Hi Trininad,

Would you please provide a sample program?

Regards,

Toms

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Toms,

I have published a short Blog showing some lines of code, let me know if you can make it work with it:

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/26720

Regards,

Trinidad.

Former Member
0 Kudos

Hi Trinidad,

Thanks for your quick response. Let me check it.

with warm Regards,

Toms

costas_ioannou2
Active Participant
0 Kudos

Thanks Trinidad you've been very helpful

I'll have a look at the blog as well.

Kind Regards,

Costas

Former Member
0 Kudos

Hi Trinidad,

I was trying to associate a Crystal Report to my form.

While compiling the Addon Project, it shows an error as below

"Error: listener Form_GV.OnAfterPrintLayoutKey is not supported and will not be registered."

I am using the following development environments:

1. SAP B1 8.81 PL 6

2. B1DE 2.2

3. Visual Studio 2008

Event handler is defined as below:

&lt;B1Listener(BoEventTypes.et_PRINT_LAYOUT_KEY, False)&gt; _

Public Overridable Sub OnAfterPrintLayoutKey(ByVal pVal As LayoutKeyInfo)

Dim ActionSuccess As Boolean = pVal.ActionSuccess

Dim form As Form = B1Connections.theAppl.Forms.Item(pVal.FormUID)

with warm regards,

Toms

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

I've tried to use the code from the blog, but I'm running into a couple of problems. I get the message "Add-on 9000058 failed with exception; Event Type: 80" when I try to press print preview.

Could you please explain what data goes in the variables?

Also is this code only run once for each layout?

Thanks again,

Costas

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Toms,

I have just had a look to B1DE 2.2 and the LayoutKeyEvent is not implemented.

Did you created the code by hand?

If you want to use B1DE you will need to handle the LayoutKeyEvent manually in your code by declaring an event handler for the LayoutKeyEvent by using normal SDK code (see SDK samples). You will not be able to use the OnBefore, OnAfter tags from B1DE automatically.

PS: We will try to release a new version of B1DE as soons as possible, but I cannot give you a date.

Regards,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

I've been playing around with the code and I have two main problems.

Firstly even though I create in my Crystal Report a parameter named DocKey@, it doesn't retrieve it from the form. When the print layout button is pressed it asks me to enter this parameter manually.

The second problem is that every time I run this code a new Template is created, How to I tell my add-on to use an already existing Template and layout?

Kind Regards,

Costas

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

Do you receive correctly the LayoutKeyEvent?

Did you tried to set the key value needed for your report in the LayoutKeyEvent handler?

eventInfo.LayoutKey = edTxtKey.Value;

Regarding the creation of the new report you need to do it only once (like UDTs or UDFs you add with DI API). You will need to check in your add-on whether the report is already available or not to run the creation code or not.

Regards,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

Thanks for replying. I have set the layoutKeyEvent here is my Code:

private void SBO_Application_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool BubbleEvent)

{

BubbleEvent = true;

oItem = oForm.Items.Item("DocNum");

oEdit = (SAPbouiCOM.EditText)(oItem.Specific);

eventInfo.LayoutKey = oEdit.Value;

}

When I press print preview I get a red error at the bottom saying :"Input String was not in a correct format". The report opens but it requests me to manually enter the DocKey@ parameter.

Thanks again,

Costas

former_member689126
Active Contributor
0 Kudos

Hi Trinidad

I am also getting the same error another thing is that the LayoutKeyEvent is not triggering .

Regards

Arun

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

It seems the value you are passing is not correct regarding the type declared for your key in the Crystal Report. Are you sure about the declaration in your CrystalReport DocKey?

After entering the DocKey by hand does it show correctly your report?

Have you tried to set a fixed value in your code receiving the event just to do a small test?

I have tested with a sample in my machine and after receiving the LayoutKeyEvent if I set the correct value that the CrystalReport is expecting as key then the right report is shown with the right values into it.

If I don't implement the LayoutKeyEvent then the key is asked by Crystal Reports before showing me the report.

@Arun: Are you sure you registered for receiving the LayoutKeyEvent (if using C#) and that you are using the right signature for catching the event? Your add-on keeps running for receiving the events after creating the report?

Regards,

Trinidad.

former_member689126
Active Contributor
0 Kudos

Hi Trinidad.

Thanks for your reply

This is my layout event code, i am using vb.net

Private Sub SBO_Application_LayoutKeyEvent(ByRef eventInfo As SAPbouiCOM.LayoutKeyInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.LayoutKeyEvent

BubbleEvent = True

eventInfo.LayoutKey = 1

End Sub

Regards

Arun

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

I carried out a few tests as you suggested. When I enter the required parameter manually, the report displays however the data is not correct. I don't understand why since the report runs correctly outside of SAP. Also I tried setting in my code the correct value

eventInfo.LayoutKey = "1";

This does not work since the report still asks for the parameter to be entered manually.

Does it matter that in my report the parameter is a number? The LayoutKey requests a string, but docEntry can only be numeric.

Thanks,

Costas

Former Member
0 Kudos

Hi, Trinidad,

I have this problem, too.

I've copied step by step the instructions from your blog but in the finish I received an error "Input string was not in a correct format.". I've tried Documents reports with numeric DocKey@ and Master Data with string DocKey@, user-defined tables or system tables - everything failed.

If I pass key value in code (even hard-coded), fails. If I pass the same key value directly into CR parameters window, it work OK, report shows the correct data.

It seems to me the mechanism of converting the eventInfo.LayoutKey into CR parameter doesn't produce the same results as direct input.

Btw - is there any possibility to debug the parameter passed to CR via B1?

Regards,

Ivan

Conf: B1 8.81 PL07, SQL Server 2008R1

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

I have attached here a very simple report that works fine in my machine.

For running that report I used the code you see in the blog.

In the layout key event I have simply set a fixed value:

void SBO_Application_LayoutKeyEvent(ref SAPbouiCOM.LayoutKeyInfo eventInfo, out bool BubbleEvent)
    {
        BubbleEvent = true;
        eventInfo.LayoutKey = "3";
    }

Let me know if you can make it work with that report.

Hope it helps,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

Thanks for the reply. I downloaded the file, but I cannot open it in Crystal Reports. Is it corrupt?

Costas

Former Member
0 Kudos

Hi Trinidad,

How can i reference to LayoutKeyEvent in vb.net. When i try to use the code

Private Sub SBO_Application_LayoutKeyEvent(ByRef eventInfo As SAPbouiCOM.LayoutKeyInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.LayoutKeyEvent

End Sub

I receive the errors: 'SAPbouiCOM.LayoutKeyInfo' is not defined. and Event 'LayoutKeyEvent' cannot be found.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Fedias,

I have tried the following code and compilation doesnt' show me any problem. Are you compiling with B1 8.81?

    Private Sub SBO_Application_LayoutKeyEvent(ByRef oVal As SAPbouiCOM.LayoutKeyInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.LayoutKeyEvent
        SBO_Application.MessageBox("")
    End Sub

Hope it helps,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

I have downloaded the crystal report, but I'm not sure about one thing. I have tried to create the table and fields from the report in my database so that I can test it. There is a field called "key". If it is a UDF shouldn't it be called U_Key? Am I supposed to do something else?

Thanks again for your help,

Costas

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

The report is using a table that is not a UDT and then the key field doesn't have the U_ prefix (it is not a good sample but I got it from someone else and I didn't change it...)

The name of the table is:

@CR_8110

With 2 fields:

key => int

Name => nvarchar(50)

Regards,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

Thanks again for your help. I have created the table and used your report with my add-on. The message still appears saying "Input string was not in a correct format" and it still asks me to manually enter the parameter. Once I enter the parameter it displays the correct information in the report.

Costas

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Costas,

I also had that problem and fixed it by opening the report file with Crystal Report and setting my database. After that the report worked fine.

Just open the rpt file and try to find out the problem by looking at the database links inside the report.

Regards,

Trinidad.

costas_ioannou2
Active Participant
0 Kudos

Hi Trinidad,

Thanks for the reply. I have already done that. The report runs outside of SAP on my database and it was saved configured on our system. However it still asks me to manually enter the parameter.

Costas

former_member689126
Active Contributor
0 Kudos

Hi Trininad,

I am also getting the same message "Input string was not in a correct format". But the event is triggering successfully and it will open the report window asking for parameter.

Regards

Arun

former_member202745
Active Participant
0 Kudos

Hi Trinidad,

i try this to, but still return the same error that Costas reported.

Regards,

Leonardo Azevedo.

former_member210167
Participant
0 Kudos

Is there any news about this matter? I'm trying to do the same and got same error. I'm stuck!

Thanks!

costas_ioannou2
Active Participant
0 Kudos

Just as a side note. As a work around, I have developed an add-on that uses the activateMenuItem to launch the reports from the main menu while on my add-on form. I then use the ui API to automatically enter values into the form that prompts for parameter values. It's not the same but it works.

Costas

Former Member
0 Kudos

Hi Trinidad,

It works fine, but if I have more than one parameter?

how can i pass them?

Thanks

aikmeng_lee2
Explorer
0 Kudos

I have the same problem and very disappointed to see Gordon mention that the feature might only work for System Tables. Do you mind to share with me how you automate the parameter fill in process, Costas? Can't figure out how you refer to the parameter screen.

Thanks in advance!

costas_ioannou2
Active Participant
0 Kudos

Hi Aik,

I use :

oForm2 = SBO_Application.Forms.ActiveForm;

To get the form.

I have also built a setup form where I store details about each report's parameter window, so that when the parameter form is launched my add-on knows if it is dealing with textboxes or comboboxes etc. You could of course just hardcode it for each report, but that means having to change the add-on each time you change the report.

Hope this helps,

Costas

aikmeng_lee2
Explorer
0 Kudos

Thank you Costas, that is helpful.

Sorry for the delay in reply I was outstation for the pass few days.

szymkaw
Explorer
0 Kudos

Our problems with this error can be solved by setting ObjectType = -1 in srf/xml file of UDO Form. Look at this post http://forums.sdn.sap.com/message.jspa?messageID=9811691#9811691

I've checked this and it work perfect. Unfortunately sometimes it's necessary to set ObjectType (to automatically manage UDO). So We have to report this as an error. I searched notes and I didn't found solution.

former_member202745
Active Participant
0 Kudos

Hi Szymon,

so unfortunately we must choose to SAP manage our form automatically or print our Crystal Layout....it's giving me headache....

SAP Team where are u?!

Regards,

Leo Azevedo.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi all,

I have got from development the following explanation.

There is a limitation in B1 8.81 version: Only UDO objects whose id is numeric are supported. If the UDO code is alphanumeric such as CR_8110, it will not work.

The limitation has been fixed in B1 8.82 and should be merged back to 8.81 soon.

Could you please test it with B1 8.82 and let me know if it works for you?

Regards,

Trinidad.

szymkaw
Explorer
0 Kudos

Maria, thanks for response.

Iu2019ve checked version 8.8.2 PL 0 and it seems that nothing changed.

Unfortunately SBO doesnu2019t let me set numeric value as a UDO ID (there is an error during UDO registration). So we cannot use this tip.

Tomorrow I try to upgrade to PL 3. I let You know about results.

szymkaw
Explorer
0 Kudos

Same error after upgrade to PL 3 :(.

Any ideas?

szymkaw
Explorer
0 Kudos

Great !!! In version 8.81 patch 11 everything works fine. I can't wait for 8.82 patch.

Best Regards

Szymon

former_member202745
Active Participant
0 Kudos

Hi Szymon,

I'm using 8.82 pl04 and doesn't work. Layout still asking the user for input parameter. I do not know what to do....

Regards,


Leonardo.

Former Member
0 Kudos

HI

You can import the crystal report into Your addon by going to Administration->Setup_>General->Report and layout manager.

In that you have to select your addon module and select the position and click 'import' and give the path of that .rpt file and finish the wizard.

so that the report will appearing in that addon module itself