Automatic Scroll SAP GUI - vba

I'm trying to scroll until the end of the page and I recorded a script and did some changes. I thought of something like that
For i = 1 To END_PAGE
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").setCurrentCell i, "AUFNR"
Next
Where "AUFNR" is the name of the column I'm analyzing. But how do I know the END_PAGE if the code stops working when it checks a line it doesn't exist?
Here is a screenshot of the table I'm analyzing in SAP GUI
For example I could verify if EACH element has a text but unfortunely I don't know how to do that. Any ideas?

Related

Find Message Number of Popup Dialog Text

I don't find the answer on the internet.
When I open some orders in a transaction, I have sometimes a popup. I want to execute some code if this popup text is 'Consider the subsequent documents'. If it is another text, I will execute some other code.
Problem is, we use SAP in several languages (EN, DE, FR), so I can't just say "if text = 'Consider the subsequent documents'. I know each message has its own ID in SAP. I know how to find this ID manually (see screenshot below), but I can't access it with findById(), even using the Record and Playback tool, because it uses the Performance Assistant window, which is not a children of the SAP session (it's a separate application, see second screenshot).
How could I do?
If session.ActiveWindow.Name = "wnd[1]" Then 'There is a popup
'Find message number (haven't find better way)
session.findById("wnd[1]/tbar[0]/btn[1]").press 'Press "Info"
'Line missing here to click the button in Performance Assistant Window. Record & Playback tool does not catch it.
If session.findById("wnd[2]/usr/txtHELP_INFO-MESSAGENR").Text = "081" Then
'Some code
End If
'close popups
session.findById("wnd[2]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
End If
I found out that it is possible to display the Help in a Modal window (=Popup) rather than in a separate window Performance Assistant. Then it is possible with findById() functions to get the message number Popup raises > F1 > F9 > findByID(...).Text
To set the Help in a Modal window, the user must first (manually or programmatically) check a setting:

Gridview not updating within update panel

Using Visual Studio 2015 (VB) with SQL Server 2012. This is going to be complicated please bear with me.
My questions is why wont my gridview update?
I have a web page that creates txt files in a remote server location. These files are then picked up by a separate (third party tool) which sends them to a government body. The government body then sends a receipt file for each txt file which my web app then picks up and records the result. The result is either an acceptance or a rejection.
On the web page I provide a gridview showing the last ten results and if I send 1 file at a time (with every click of the button) my gridview will refresh without issue showing the results of the receipts. There can be up to minute gap between the creation of the file, the file sending and the receipt being received.
The image below shows an example of my gridview after successful submission and receipt.
As the button is clicked the sent and accepted column display as red with 'No' within them.
When the button is clicked to send the file a sub is processed that creates the file. A timer is then enabled (fires every ten seconds) that runs another sub to check for sent and receipts. I have no issue with this as it works as expected and each cell within the gridview changes to reflect the sent and receipt status.
This is done using a call to build the gridview.
The call
displayLastSentGridView()
displayHistoryGridView()
historyUpdatePanel.Update()
One of the subs to build the gridview
Public Sub displayLastSentGridView()
Dim mlastSent As New lastSent
Dim mLastSents As New List(Of lastSent)
mLastSents = mlastSent.lastSentGridView
gridLastSent.DataSource = mLastSents
gridLastSent.DataBind()
End Sub
Ok so a request came in that when a particular file is created a further 4 are generated (with a different layout) and auto sent. I have implemented this and it works as expected. I then use a new sub to check on the status of these files (as their classification is different). When the file is sent the web page updates the database flagging the entry as sent, when the receipt is accepted it flags it as accepted. My problem occurs here. I use the same code as above to call the gridview updates when the sent even occurs and when the acceptance comes in but the gridviedw does not update.
If I place the code at the end of the sub routine all the cells update i.e. it will update the gridview in one go and all the cells turn green with Yes inside them, but i want it to update each cell as the database notifications are changed.
Below is an excert from my code that checks the folder location strSentFileLocation if it exists the database is updated and then the call to update the gridviews is made. The database update works but the gridview doesnt change.
If File.Exists(strSentFileLocation) Then
db.ngc_updateActivityLogSent(True, seq)
db.ngc_updateActivityLogRejected(False, "N/A", seq)
db.ngc_updateActivityLogAccepted(False, seq)
'update gridviews
displayLastSentGridView()
displayHistoryGridView()
historyUpdatePanel.Update()
End If
My update panel is set to conditional.
Any help greatly appreciated. Thanks
UPDATE
For info the IF statement is nested within a FOR loop.
The from was the for loops, as the sub never actually finished the update panel never got chance to update till right at the end. I have removed the for loop and added in a hidden field that I increment and call the sub until the hidden field reaches a specific value.

Increment a database value after printing a report

I have a database table with just one column, invoiceNumber. This is displayed on a Crystal Report to show the unique number of the report (as it's an invoice).
At the moment, for all of the reports, when viewing them in vb.net, the number being displayed is 1, because that's what the value in the database column is.
What I want to know is, how can I increment the number after and only after the report has been printed (if they cancel the print job it doesn't increment, for example).
I know this is usually simple, it would use SQL after the print code on the button press, however, in the project, I am using a CrystalReportViewer so printing isn't done on a button click, and I don't think the printing in a CrystalReportViewer can be programmed separately?
So how and where do I code the value in the database table to incremement by 1 after the report has printed? Is this even possible?
I would also suggest using a confirmation button for the user to confirm they have printed it OK. No other way to be sure it came out of the printer without jams, smudges, creased paper etc etc
Pseudocode
EventHandlerWhichTriggersReportCreation
Call code to initiate and load CrystalReportViewer
Display dialog/prompt asking user if all printed OK
If all OK, increment counter
You can use a flag which is set on acknowledgement after print is successful.
In another function you can check if flag is set and increment the flag accordingly.

In Livecycle forms make all negative values red

I'm building a form in Adobe Livecycle and would like all negative numbers to display in red. I can accomplish that on individual elements by attaching this code to the exit event:
form1.#subform[0].Table3[0].HeaderRow.concessions1::exit - (FormCalc, client)
if ($.rawValue <0) then
$.font.fill.color.value = "255,0,0"
else
$.font.fill.color.value = "0,0,0"
endif
Currently I have to add this code to every single field, is there a way to make this script run on multiple fields without retyping it for each one?
Thanks
your options are:
Externalize the code in a script object and call the method on the exit event. You can pass the field as an input parameter so that your code is generic.
If you want to do this before a form is submitted, you can create a method that loops through your form fields and reference this code to highlight the negative values.
I hope this helps. Let me know if you have any more questions.
Thanks,
Armaghan.

VB in Access: Combo Box Values are not visible in form view but are visible through Debug.Print

Code in Form onLoad:
country_combo.RowSourceType = "Value List"
Code in a reset function:
Dim lListIndex As Long
With Me.country_combo
For lListIndex = .ListCount - 1 To 0 Step -1
.RemoveItem (lListIndex)
Next lListIndex<br/>
End With
Code to populate country combo:
*For n = 1 To numCountries*
*countryCombo.AddItem (countryRS.Fields("countryName"))*
*countryRS.MoveNext*
*Next n*
I'm having a problem that occurs AFTER the code to populate the country combobox runs. The values are there as I can run Debug.Print(countryCombo.Value) and it prints out the name of the selected country, but I can't see the values in the combobox at all. They're invisible, and as far as I know there is no visiblity property for specific items, unless I'm completely mistaken.
comboBoxError.png http://img110.imageshack.us/my.php?image=comboboxerror.png
I think you should probably use Access's GUI tools to do what you're looking for. In design mode, click on the field you are trying to populate, then click the "lookup" tab. You can then specify a table to populate the field with and your forms should automaticly update as well.
I've also seen what you describe here - as far as I can tell, it's a bug within Access (I was using 2007) that only occurs when you programatically mess with the contents of a combo box. It does not happen every time. The issue corrects itself if you highlight the text that is in the combo box.
I am experiencing a similar issue with Access 2003. Based on the selection of one combo box, the row source of a listbox is set to an SQL string Basically a SELECT DISTINCT [MyField_Selected] FROM MyTable. For some fields the values are visible in the list box and others it is not. The values are there however as I can access them via code. To make it more interesting it works fine in Access 2007.
Just found the resolution on another forum. Check the format property of the field(s) in question on the table. In my case, when Access 2007 created the table, it put an # format in there. I removed that and all works great!