1

I am creating an add on which will open a Crystal Report from BP Master, there will be a button which will open that. But i am not be able to call the default SAP B1 Report viewrr . Can anybody sugest me that ?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    Have you tried `Application.SBO_Application.ActivateMenuItem("519");` on the button click event? – Vyron Paschalidis Nov 18 '19 at 12:58
  • 1
    Yes, But how can i pass the parameter ? –  Nov 18 '19 at 13:29
  • 1
    Try getting the active form `Application.SBO_Application.Forms.ActiveForm` and complete the EditText(s). Their ID will always be the same when the parameter form opens and then `oButton.Click()` (after you assign the `oButton` to the Ok button, whose ID will also never change) to accept the parameters. – Vyron Paschalidis Nov 18 '19 at 14:51
  • 1
    It is not a pretty task but this is the approach I take for some time now. With 9.3 I haven't found something prettier on the UI side. – Vyron Paschalidis Nov 18 '19 at 14:52

1 Answers1

2
public static bool Layout_Preview(string ReportName, string First_Parameter)
                {
                    Recordset oRS = (Recordset)SBOC_SAP.G_DI_Company.GetBusinessObject(BoObjectTypes.BoRecordset);
                    oRS.DoQuery("SELECT MenuUID FROM OCMN WHERE Name = '" + ReportName + "' AND Type = 'C'");
                    SAPbouiCOM.Form form = null;
                    if (oRS.RecordCount > 0)
                    {
                        string MenuID = oRS.Fields.Item(0).Value.ToString();
                        SBOC_SAP.G_UI_Application.ActivateMenuItem(MenuID);
                        form = SBOC_SAP.G_UI_Application.Forms.ActiveForm;
                        ((EditText)form.Items.Item("1000003").Specific).String = First_Parameter;
                        form.Items.Item("1").Click(BoCellClickType.ct_Regular);
                        return true; 
                    }
                    else
                    {
                        SBOC_SAP.G_UI_Application.MessageBox("Report layout 'ReportName' not found.", 0, "OK", null, null);
                        return false;
                    }

                }