Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

Form 10060213 (Select PL and print), .Click() Not working

$
0
0

Ok, long story short. I want to automatically select a PL and print when the user clicks a button I added on the Invoice.

 

The Pseudocode goes like this:

 

On MyCustomButton.Click
{

  Click_MenuItem(522)

}

This emulates the user clicking File->Select Print Layout and Print

 

When the form loads (and this happens under the hood.The method how I do this part is irrelevant)

On Form10060213Draw AND !BeforeAction AND ActionSuccess

{

   oForm = SBO_Application.Forms.Item(sFormUID);

   MoveToDesiredPL()

   oForm.Items.Item("410000018").Click();

}

 

Under normal circumstances (No Add-On) a "Select Printer" Dialog Window (OS Native) would appear if the user clicks the OK Button. In my case, nothing happens. Instead, the System Form is closed as if I had pressed Cancel. I know I am not sending the click to the Cancel button because, since I use the FormDraw event, I am able to see that the clicked item is the OK button.

I tried with a SBO_Application.SendKeys("{ENTER}"); but I get the same results. Nothing happens.

 

Funny enough, if I remove the autoclick line from my code, and I do a click on my button followed by an <ENTER> (Immediatelly after it, before the window even shows) I get the desired effect... but the client wants it to be automatic, meaning he expects not to press enter nor click the OK button.

 

I'm looking for clues as to why isn't the <Click> event calling the button behaviour correctly.

 

Here is a excerpt of my code that should do the same as my full code (minus the layout selection)

 

privatevoid SBO_Application_ItemEvent( string FormUID, ref SAPbouiCOM.ItemEvent pVal, outbool BubbleEvent )

{

  BubbleEvent = true;

 

  iFormType = pVal.FormType;

 

  sFormUID = FormUID;

 

  if ( pVal.FormType != 0)

  { 

     SAPbouiCOM.BoEventTypes EventEnum = pVal.EventType;

     if (pVal.FormType == 10060213 && EventEnum == SAPbouiCOM.BoEventTypes.et_FORM_DRAW && !pVal.Before_Action && pVal.ActionSuccess)

     {

       oForm.Items.Item("410000018").Click();

    }

  }

}

     

This will automatically click the OK button when the form draws (Rendering the layout selection impossible, it's just for testing purposes) and you will see that the select printer dialog never shows;


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>