cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create Linked Button to Other Add On form?

Former Member
0 Kudos


Hello, I am building a matrix in a custom form and need to know how to use a SAPbouiCom,LinkedButton to Enprise_JobCosting add-on form?

In other words, how do I use a linked button to link to a form other than an SAP form? I have viewed the SAP SDK sample code Matrix form, but there is no sample on using a linked button to another Add-On's form.

Any sample would be deeply appreciated,

Mike

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi Mike,

I've actually just done that exact thing (ie put a link in my matrix to open an Enprise Job record).

Firstly, I define the link button column in my matrix:


<column uid="clJobID" type="116" title="Job ID" description="" visible="1" AffectsFormMode="1" width="70" disp_desc="0" editable="0" right_just="0" val_on="Y" val_off="N" backcolor="-1" forecolor="-1" text_style="0" font_size="-1" sortable="1">

     <databind databound="" table="" alias=""/>

     <ExtendedObject linkedObject="-1" LinkedObjectType="-1"/>

</column>

Note that I've set the linkedObject property to -1. This will show the link button on the matrix (if a value exists in the cell) but clicking on the link does nothing in standard SBO. This is exactly what I want because I'm going to trap the Matrix_Link_Pressed event and open the job screen using the UI API.


if (ItemEvent.ItemUID == "MyMatrix" && ItemEvent.Row > 0 && ItemEvent.ColUID == "clJobID")

{

     // User has clicked on a link on the matrix so first I have to read the job number they've selected.

     // In this example it's bound to a DataTable

     SAPbouiCOM.Matrix mt = (SAPBouiCOM.Matrix)form.Items.Item("MyMatrix").Specific;

     mt.FlushToDataSource();

     SAPbouiCOM.DataTable dt = form.DataSources.DataTables.Item("MyTable");

     string jobID = Convert.ToString(dt.GetValue("JobID", ItemEvent.Row - 1));

     if (jobID != "")

     {

          // Call the menu from the Enprise Job Management form

          // Note: this call could fail if the Enprise addon is not running

          app.ActivateMenuItem("JCJob");

          // Now this menu has been called, the client will have a new instance of the Job form open in Find mode

          // Loop through the forms collection to find the first instance of the Job form that can be used to load the job

          SAPbouiCOM.Form jobForm = null;

          for (int i = 0; I < app.Forms.Count; i++)

          {

               if (app.Forms.Item(i).TypeEx == "Enprise_JCMaster" && app.Forms.Item(i).Mode == SAPbouiCOM.BoFormMode.fm_FIND_MODE)

               {

                    jobForm = app.Forms.Item(i);

                    break;

               }

          }

          // If the Job form is open, enter the job number in the Job ID field and click on the Find button to retrieve the record.

          // I freeze the form while doing this so the user doesn't see the data until the form is fully populated.

          if (jobForm != null)

          {

               try

               {

                    jobForm.Freeze(true);

                    // Write the job number to the Job ID field using the control

                    SAPbouiCOM.EditText edit = (SAPbouiCOM.EditText)jobForm.Items.Item("EdJobID").Specific;

                    edit.String = jobID;

                    // Click on the Find button to retrieve the record

                    jobForm.Items.Item("BtnOK").Click(SAPbouiCOM.BoCellClickType.ct_Regular);

               }

               finally

               {

                    jobForm.Freeze(false);

               }

          }

     }

}

The same method can be used to open records for any third-party addon screen or your own UDO screens (assuming that they use the UI API to generate forms and that the form can be put in to Find mode)

Kind Regards,

Owen

Former Member
0 Kudos

Thanks Owen, this is what I was originally looking for.

Thanks also for the sample!

Mike

Answers (1)

Answers (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Mike,

One common approach is to capture the click event when BeforeAction = true and do your own processing (in your case invoke the oApplication.ActivateMenuItem("Menu_To_Form")) then simply set the bubbleEvent to false to prevent B1 from trying to process the event too.

There are samples on how to capture events on the Samples folder of your SDK installation.

Give it a try and let us know if you run into trouble.

Good luck.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Thanks Pedro! I was thinking of something similar but wasn't sure. That works.

Mike