Is there an event when Select-Options value is changed - abap

Is there an EVENT that triggers when a value is changed in a SELECT-OPTIONS? But directly when it's changed, without having to press Enter, as soon as the user enters a value and clicks somewhere else in the screen, or when a user chooses a value from the F4 value menu.
I've try many event, like:
AT SELECTION-SCREEN on s_carrid.
"This trigger only when user hit "enter"
AT SELECTION-SCREEN on VALUE-REQUEST FOR s_carrid-LOW.
"This trigger when user press F4, but nothing after selecting a value...
Thanks for your help
DATA: v_carrid type s_carr_id.
SELECT-OPTIONS s_carrid for v_carrid no INTERVALS MODIF ID br5.

There's no event triggered when a value is changed in a SELECT-OPTIONS element. Events are raised only when a function code, a menu or a button is pressed, or eventually a radio button or a checkbox.
There's no event triggered when a value is returned from the value help (F4 function key on the input field), the input field is directly filled with the selected value.
Instead, you may define some ABAP code when F4 or the value help button is pressed, display the search help, get the selected value and do whatever you want, like filling the input field with the value, and any other process.

Related

How can I set my ComboBox to allow the user to type in the first few characters and then automatically select the item by pressing ENTER?

I have a feeling this is a very simple thing that I'm overlooking.
I have two ComboBoxes that allow users to search for/select the record that they want to view. One is filled with Customer Names and the other is filled with Customer Numbers, so the user can look for a particular record by either selecting the Name or Number.
Each ComboBox is filled by a Data Table returned from a SQL Server database.
Each ComboBox has DropDownStyle set to DropDown, AutoCompleteMode set to SuggestAppend and AutoCompleteSource set to ListItems.
The user can either select by clicking the DropDown arrow and then clicking on the item they was or they can begin by typing and the ComboBox narrows the number of items in the list based on the characters the user is typing.
Using the mouse to click on the item in the list that they want works fine...it fires off a routine to retrieve the selected item from the database.
However, when the user types in the desired selection and presses ENTER, nothing happens. They must click the DropDown arrow and click on the item in order for the program to pull the appropriate record.
How do I get the ComboBox to pull the appropriate record when the user hits enter?
I'm using Visual Basic.
From the sounds of it, you need three events.
You need to use a timer to know when the user has stopped typing. To do that, you need one event would be when that field they're typing in has it's value change (<control's name>.TextChanged). That would start/restart a timer ticking (so that the user has a couple seconds to pause before the next event fires).
The next event would be the Tick event for that timer. That event would stop the timer, and then give focus to the right field so that when the user hits ENTER, they're not hitting ENTER in the field they've been typing in. You'll need to write a function to look up the right item in the ComboBox and call that.
Then you'd have a third event, either KeyPress, KeyDown, or KeyUp on the ComboBox itself. I'd lean towards the KeyUp to avoid issues if the user holds ENTER for whatever reason. That'd be what selects the item.
As a final FYI, I'm assuming you're using Visual Studio to write your code. If not, you should, and if you are/once you are, you can select the field you want to work with in the drop-down at the top left of the editor and then look at the associated events in the top right drop-down.
Thank you to JMichael for getting me on the right track with this one. I'm posting my solution here just in case it helps someone who has a similar question in the future:
The code that I added to the ComboBox's SelectionChangeCommitted event needed also to be added to the ComboBox's KeyUp event:
Private Sub cboPolicySearch_KeyUp(sended as Object, e As KeyEventArgs) Handles cboPolicySearch.KeyUp
If e.KeyCode = Keys.Enter Then
GetSelectedPolicySearchRecord()
e.Handled = True
End If
End Sub 'cboPolicySearch_KeyUp
The GetSelectedPolicySearchRecord() sub contained all of the information I needed to call my SQL Stored Procedure to select the data for the record that the user selected in the ComboBox.
Previously, this was only being called from the ComboBox's "SelectionChangeCommitted" event which is executed when the user clicks the drop down and then clicks a policy number from the drop down list.
I needed to add the same call to the GetSelectedPolicySearchRecord in the ComboBox's "KeyUp" event for when the user presses enter.

check the Numbers in One textField and print it in another textfield on click of a button

There are two text fields and one button.
1st will allow any text value
2nd Will accept only numeric value from 1st input value, when you will click on Submit button.
Can anyone help me in doing this

Removing Item from Combobox without Firing Change Event

I am creating a userform in Word VBA that only has one combobox named cboType and one command button named cmdNext. In default, cboType have Null value and cmdNext is disabled.
I use cboType_Change event so that when an item is selected from the combobox, cmdNext is enabled and the combobox value is stored to a variable Type. However, I have another sub that will remove each item in cboType when cmdNext is clicked. I find out that removing item also fire the cboType_Change. I don't want this to happen because it will also change the value in variable Type.
In order to overcome this, I have tried using cboType_AfterUpdate event instead of cboType_Change, but I found out that this event will be fired only if the focus moved from cboType (cmiiw). Meanwhile, I don't have any other active/enabled control in the userform, so the cboType_AfterUpdate event won't be fired (the combobox value won't be stored to variable Type and cmdNext won't be enabled).
Any suggestion on how to do this?
If you just want the function to be called, can't you use
Call cboType_AfterUpdate()
to call this manually when the user clicks the cmdNext button?
Not sure if this solves your initial problem that cboType_Change is called when you change some value in the combobox.

Get the value of a cell on a ASPXGridview based on the button click

I have a ASPXGridview with a button as the first column for each of the rows. When I click a button I want it to perform a callback which will get me the value of the cell next to the button click. I'm a bit stuck on this so any advise would be great.
Thanks
I created a call back function to get key field name from a row on selection changed.
Then when I click on the button is gets the selected keys on the page.

Dynamically fill selection-screen parameter on change

Suppose I have a selection-screen block with two parameters. I want to dynamically fill the second parameter based on what the user inputs in the first, for instance by querying a table to find the expected value for the key field in parameter 1.
As an example, say I have a program that does something for a combination of order number (p_aufnr) and WBS element (p_wbs). Instead of asking the user to provide both, I can determine one of them from the PSPEL field on the AUFK table. However, I still want to show this field to the user after he inputs his order number so he can verify that the WBS element is correct.
I've managed to do this by using the AT SELECTION SCREEN ON p_aufnr event to assign a value to p_wbs. This event is processed when the user presses enter. However, I can only ever get it to work once. So if the user enters an order number, realises from the retrieved WBS element that he made a mistake and changes it, the second parameter never changes. Even though the AT SELECTION SCREEN event is processed in the debugger, the parameter is not updated.
Am I not supposed to use this event for my scenario? If so, how would I then implement this sort of dynamic selection screen?
Forgot to add a code sample. The following report illustrates my issue: after entering a value in p_netw and pressing enter, p_wbs is filled with the value 1. However, if you press enter again the AT SELECTION-SCREEN ON routine is processed but the value for p_wbs is not updated, while lv_count is.
DATA: lv_count TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK main.
PARAMETERS: p_netw TYPE aufnr OBLIGATORY MODIF ID auf.
PARAMETERS: p_wbs TYPE i MODIF ID psp.
SELECTION-SCREEN END OF BLOCK main.
AT SELECTION-SCREEN ON p_netw.
ADD 1 TO lv_count.
p_wbs = lv_count.
START-OF-SELECTION.
PERFORM main.
FORM main.
WRITE: 'The value reached ', lv_count.
ENDFORM.
Apparently the data is not written back to the screen if you update the field in the field-specific block. If you move the field update from AT SELECTION-SCREEN ON p_netw to the global AT SELECTION-SCREEN event, it works. Don't ask me why, though - this seems to a case of undocumented system behaviour...
DATA: lv_count TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK main.
PARAMETERS: p_netw TYPE aufnr OBLIGATORY MODIF ID auf.
PARAMETERS: p_wbs TYPE i MODIF ID psp.
SELECTION-SCREEN END OF BLOCK main.
AT SELECTION-SCREEN ON p_netw.
ADD 1 TO lv_count.
AT SELECTION-SCREEN.
p_wbs = lv_count.
You need to use a PAI (process after input) module on your screen which then takes the new p_aufnr and finds the appropriate p_wbs - probably exactly like your at selection screen event. You will then CALL SCREEN ### <-- your screen number to display the data on your screen. Without any code to work off thats all i can help with.