How to handle 'ENTER' Key on ALV Editable Grid on sub screen (Tabstrips)
Hello Experts ,
I have 2 questions with ALV Editable grid;
please help me if you have answers.
I created ALV grid on one of sub screens on a Tab Strip,
As soon as user types one of the columns of the ALV grid and press u2018ENTERu2019 key, it has to return corresponding details for that line.
I tried to implement this logic in ALV grid event u2018handle_data_changedu2019, but ALV internal table is not getting populated with new entry entered in the grid. but u2018double_clicku2019 event working my purpose, but user might need enter key.
and I thought I would do implement that logic in PAI event of the sub screen, u2018ENTERu2019 key not getting trigger on PAI event of the screen until cursor is on grid.
Another question 2: How do I control and not to be deleted a line on the grid (based on validation), where do I validate and by pass the delete function for a particular line, or suggest me to gray out only one line on the grid .
I would like to have delete function to work as it is ,except for some validations..
Can I implement using PAI event of the sub screen or any by ALV event.
Please suggest me..
Edited by: Ravindranath Arusam on May 13, 2010 2:42 PM
In DATA_CHANGED event, you will get the modified row into the attribute MP_MOD_ROWS of the impoerting object ER_DATA_CHANGED. Since this MP_MOD_ROWS is the Object reference to Data, you need to have the field symbol to get the value.
FIELD-SYMBOLS: <lft_mod_output> TYPE t_t_output.
ASSIGN er_data_changed->mp_mod_rows->* TO <lft_mod_output>.
You can get the Value of the Cell by using the method GET_CELL_VALUE of the same ER_DATA_CHANGED object and use the method MODIFY_CELL To update the value back to ALV.
To Restrict the row deletion:
When the row is deleted it is being added to Attribute mt_deleted_rows of the object ER_DATA_CHANGED. You can put the data back to the table in the DATA_CHANGE_FINISHED event. Visit this post http://help-abap.blogspot.com/2008/10/alv-disable-delete-key-on-keyboard-in.html for more information.
Regards,
Naimesh Patel
Similar Messages
-
How to change enter key behavior in data grid view?
Greetings community
I have a simple problem. I have a table of several columns, and I want it to be editable without using a mouse. I want user to enter value in the first column, press enter key on keyboard, enter value in second column, press enter key,
and so on. I want data grid view to open another row only when all columns in the working row are populated. However, pressing the enter key causes opening new row whenever user presses the enter key.
I tried to set current cell of data grid view in CellValueChanged event , but it didn’t work. Actually, it really moves current cell where I want, but after that it moves it one row down.
I traced the execution of code, and counted CurrentCellChanged events to see what happens.
Does anyone know if there’s any way to suppress this behavior?
Thanks in advanceGreetings community
I have a simple problem. I have a table of several columns, and I want it to be editable without using a mouse. I want user to enter value in the first column, press enter key on keyboard, enter value in second column, press enter key,
and so on. I want data grid view to open another row only when all columns in the working row are populated. However, pressing the enter key causes opening new row whenever user presses the enter key.
I tried to set current cell of data grid view in CellValueChanged event , but it didn’t work. Actually, it really moves current cell where I want, but after that it moves it one row down.
I traced the execution of code, and counted CurrentCellChanged events to see what happens.
Does anyone know if there’s any way to suppress this behavior?
Thanks in advance
Hello,
It perhaps be better using Tab key which is exactly used for switch focus to the next cell instead of dealing with enter key.
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Handling Enter Key in Editable ALV Grid using REUSE_ALV_GRID_DISPLAY
Hello All,
I have seen a number of threads on captioned issue and everyone of them say to create FCODE for Enter in the Screen's PF Status and then handle the event.
But the catch is when you hit Enter key in ALV Grid, it will not trigger any FCODE at all because the FCODE Enter you have created is for the screen and not for the GRID. Can anyone please let me know if SAP has given any standard utility in REUSE_ALV_GRID_DISPLAY FM for handling the Enter key event.
Thanks and regards,
MaheshHi,
Set the PF-status for OK key and use the FCODE or u can usethe dynamic ok_code generated .
Also try 'ENTE' .
Hope thishelps. -
How to handle interactive list in alv reports
hi experts.
how to handle interactive list in alv reports.
regards.
subhasisHI Subhasis,
below is the sample code for handling an interactive ALV report, hope this helps you ..
REPORT ZTEST_ALV123.
TYPE-POOLS:SLIS.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
VGBEL LIKE LIPS-VGBEL,
VGPOS LIKE LIPS-VGPOS,
END OF ITAB1.
DATA: IT_LIPS LIKE ITAB1 OCCURS 0 WITH HEADER LINE.
SELECT VBELN
POSNR
FROM VBAP
INTO TABLE ITAB.
IF SY-SUBRC = 0.
SORT ITAB BY VBELN .
SELECT VBELN
POSNR
VGBEL
VGPOS
INTO TABLE ITAB1
FROM LIPS
FOR ALL ENTRIES IN ITAB
WHERE VGBEL = ITAB-VBELN
AND VGPOS = ITAB-POSNR.
ENDIF.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PFSTATUS'
I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENDIF.
*& Form POPUP
text
-->P_EXTAB text
FORM POPUP USING P_EXTAB TYPE SLIS_T_EXTAB.
"here double click on PFSTATUS and create the status, "activate, before that set PICK for choose(F2).
*- Pf status
SET PF-STATUS 'PFSTATUS'.
ENDFORM. " POPUP
*& Form HANDLE_USER_COMMAND
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
IF RS_SELFIELD-FIELDNAME = 'VBELN'.
READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
LOOP AT ITAB1 WHERE VGBEL = ITAB-VBELN
AND VGPOS = ITAB-POSNR.
MOVE-CORRESPONDING ITAB1 TO IT_LIPS.
APPEND IT_LIPS.
ENDLOOP.
PERFORM INTERACTIVE_REPORT.
ENDIF.
ENDCASE.
ENDFORM. "HANDLE_USER_COMMAND
*& Form interactive_report
text
FORM INTERACTIVE_REPORT .
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'ITEM'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VGBEL'.
X_FIELDCAT-SELTEXT_M = 'SO #'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VGPOS'.
X_FIELDCAT-SELTEXT_M = 'SO ITEM'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 4.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT1
TABLES
T_OUTTAB = IT_LIPS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENDIF.
ENDFORM. " interactive_report
Regards,
Ranjita
null -
How to make ENTER key in internet explorer run the BIP report?
In BI publisher 11g, users wanted that after entering the values for the parameter, they hit the ENTER key ( on the keyboard) and the report should run .
In Mozilla firefox, when I hit ENTER key on the keyboard report runs fine... but in Internet explorer, it does not ( infact in internet explorer TAB key works)
How to make ENTER key in internet explorer run the report?
Thanks
AshishPerform the following steps and tell us if it resolve this issue:
1. In Internet Explorer, click Tools, and then click Internet Options.
2. Click the Security tab.
3. There are four security zones listed:
* Internet
* Local intranet
* Trusted sites
* Restricted sites
Click the zone being used by P6, which is noted at the bottom right hand corner of the browser window when the P6 URL is being accessed.
4. Under Security level for this zone, click Custom Level.
5. Under Downloads, under Automatic prompting for file downloads, click Enable, and then click OK two times.
6. The browser will need to be restarted for the change to take effect.
Refer to the following Microsoft Knowledge base article for additional file download and active x controls which should also be enabled: http://support.microsoft.com/kb/883255 -
ALV Editable Grid Control F4 help problem
HI Experts,
am facing some funny and critical problem in ALV Editable GRID,that is i used OOPS concept for ALV GRID Control output,
in fieldcatalog i given for fields as
wafieldcatlog-f4availabl = 'X'.
wafieldcatlog-ref_table = 'table'.
wafieldcatlog-ref_field = 'field'.
and for seven fields i given like this .
but in that editable if i use F4 help for the field and get that data and later save means that data is not considering and giving error message.
So can any one please help if u confused pls reply fo any clarifications, pls help me out in this situation.
THXwafieldcatlog-f4availabl = 'X'.
wafieldcatlog-ref_table = 'table'. "should be in caps
wafieldcatlog-ref_field = 'field'. "should be in caps.
what error you are getting while saving..? -
Editable ALV - handling Enter key when pressing enter on keyboard
Hi folks.
Now I have searched - and found a lot of threads - in this forum about my little problem.
I'm using the <b>Function Module: REUSE_ALV_GRID_DISPLAY - NOT THE OO-version</b>!!!!!
I have a editable list as result of finding some data. My problem is.
When I change the value in one of the cells, and press the Enter key (not a click with the mouse on the Green button with the checkmark!) nothing happens!
I have
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
And when I put a breakpoint in the USER_COMMAND form nothing happens - <b>ONLY IF I CLIKS WITH MY MOUSE ON THE Green button with the checkmark</b>!!
Hope U have some idea!
Best regards
Carsten :o)Hi,
Following the sample program for EDITABLE BLOCK ALV report.
REPORT YMS_EDITBLOCKALV.
TABLES : rmmg1,MCHB, mkpf.
DATA: BEGIN OF t_mseg OCCURS 0,
zeile LIKE mseg-zeile,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
END OF t_mseg.
DATA:BEGIN OF t_mchb OCCURS 0.
INCLUDE STRUCTURE mchb.
data flag type c.
matnr LIKE mchb-matnr,
charg LIKE mchb-charg,
werks LIKE mchb-werks,
clabs LIKE mchb-clabs,
DATA END OF t_mchb.
TYPE-POOLS slis.
data: progname like sy-repid,
fieldcattab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
data tabindex type i.
data wa_matnr LIKE mchb-matnr.
progname = sy-repid.
SELECTION-SCREEN BEGIN OF BLOCK b_b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_docno FOR mkpf-mblnr OBLIGATORY.
PARAMETERS p_docyr LIKE mkpf-mjahr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b_b1.
START-OF-SELECTION.
SELECT zeile
menge
meins
matnr
werks
charg
bwart
FROM mseg
INTO TABLE t_mseg
WHERE mblnr IN s_docno AND mjahr = p_docyr.
CLEAR fieldcattab.
fieldcattab-col_pos = 1.
fieldcattab-fieldname = 'ZEILE'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Item'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 2.
fieldcattab-fieldname = 'MENGE'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Quantity'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 3.
fieldcattab-fieldname = 'MEINS'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Unit'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 4.
fieldcattab-fieldname = 'MATNR'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Material'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 5.
fieldcattab-fieldname = 'WERKS'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Plant'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 6.
fieldcattab-fieldname = 'CHARG'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Batch No'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 7.
fieldcattab-fieldname = 'BWART'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Inventory'.
fieldcattab-hotspot = 'X'.
APPEND fieldcattab.
end-of-selection.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = PROGNAME
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND1'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = fieldcattab[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT = fieldcattab
IT_HYPERLINK =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_mseg
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM usercommand1 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
tabindex = rs_selfield-tabindex.
read table t_mseg INDEX tabindex.
select * from mchb into table t_mchb where matnr = t_mseg-matnr.
clear fieldcattab.
CLEAR fieldcattab[].
fieldcattab-col_pos = 1.
fieldcattab-fieldname = 'FLAG'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Check Box'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
fieldcattab-checkbox = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 2.
fieldcattab-fieldname = 'MATNR'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Material'.
fieldcattab-emphasize = 'C1'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
fieldcattab-checkbox = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 3.
fieldcattab-fieldname = 'CHARG'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Batch No'.
fieldcattab-emphasize = 'C2'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 4.
fieldcattab-fieldname = 'WERKS'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Plant'.
fieldcattab-emphasize = 'C30'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 5.
fieldcattab-fieldname = 'CLABS'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Stock'.
fieldcattab-emphasize = 'C601'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = PROGNAME
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND2'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = FIELDCATTAB[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_mchb
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endcase.
endform.
FORM usercommand2 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-sel_tab_field = 'T_MCHB-MATNR'.
CALL FUNCTION 'ZALV2'
EXPORTING
CTU = 'X'
MODE = 'E'
UPDATE = 'A'
GROUP =
USER =
KEEP =
HOLDDATE =
NODATA = '/'
MATNR_001 = '200-200'
KZSEL_01_002 = 'X'
IMPORTING
SUBRC =
TABLES
MESSTAB =
SET PARAMETER ID 'RID' FIELD RMMG1-MATNR.
CALL TRANSACTION 'MM03' and skip first screen.
ENDIF.
ENDCASE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = progname
i_callback_user_command = 'USERCOMMAND3'
it_fieldcat = fieldcattab[]
TABLES
t_outtab = t_mchb
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endcase.
ENDFORM.
Thanks,
Sankar M -
Enter Key Event in Editable ALV Grid
Hi all,
I am trying to create and editable ALV grid using the REUSE ALV FM.
On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
Is it possible to capture the Enter keypress on the ALV grid?Hello Preet
I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
I assume that the logic will be similar using ALV function modules.
Regards
Uwe -
Handling 'enter key' event in alv using classes
Hello all,
i have a scenario where i have a grid from which i have to select a row and press 'enter' key, then the row would be added to grid on top of it. we have developed this grids using control and classes.
please any one tell me how would i get the enter key code.
Thanks,
krishnam raju NHI Raju
just go through these
check the sample program.
<b>BALV_POPUP_TO_SELECT
ENTER is nothing but selecting the record.
</b>
Re: ALV 'ENTER' key
and go through this code
constants :
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
I_CALLBACK_USER_COMMAND = P_USER_COMMAND IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING = IT_EXTAB[]
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = P_ZBCAR50
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2.
*& Form F_SET_PF_STATUS
Set PF_STATUS STANDARD modifying the standard toolbar
by excluding some buttons
-->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
CLEAR : WA_EXTAB,
IT_EXTAB.
*--Set the Modified PF status for the ALV.
SET PF-STATUS 'STATUS_01' EXCLUDING RT_EXTAB.
ENDFORM. " SET_PF_STATUS
3.
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_ANSWER TYPE C.
RS_SELFIELD-REFRESH = C_X.
IF R_UCOMM = 'ENTR'.
Do your processing here.
ENDIF
and go through these links
<b>how to identify pressing ENTER on ALV
How to capture the event in ALV grid display?
Re: ALV-Grid: No reaction to Enter-Button
</b>
IF IT HELPS REWARD WITH POINTS
Regards Rk
Message was edited by:
Rk Pasupuleti -
Handling "enter" key while a user clicks a button being displayed in datagrid
Hi,
I have a datagrid of which one non editable column has an itemrenderer render a button while a row is hovered or selected. I am usinhg default tab handling of datagrid. I want to handle the button click event when a user presses enter key while the focus is on this tabbed column.
Can anyone help me how to ahcieve this?This how my datagrid looks ..main file
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
public function myKeyDownEvent(event:Event):void{
mx.controls.Alert.show("Selected " + myGrid.columns[0].popupIndex);
]]>
</fx:Script>
<fx:Declarations>
<fx:XMLList id="transactions">
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Match</type>
<date>11-23-2009</date>
<payee>SAVINGS debit 323</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Savings</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-24-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>0</payment>
<deposit>20</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-23-2009</date>
<payee>SAVINGS debit 327</payee>
<payment>0</payment>
<deposit>10</deposit>
<account>My Savings</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Match</type>
<date>11-23-2010</date>
<payee>SAVINGS debit 323</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Savings</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-24-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>0</payment>
<deposit>20</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-23-2010</date>
<payee>SAVINGS debit 327</payee>
<payment>0</payment>
<deposit>10</deposit>
<account>My Savings</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2010</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
<transaction>
<type>Unassigned</type>
<date>11-21-2009</date>
<payee>CREDITCARD debit 328</payee>
<payment>10</payment>
<deposit>0</deposit>
<account>My Visa</account>
</transaction>
</fx:XMLList>
</fx:Declarations>
<mx:DataGrid id="myGrid" width="100%" height="100%" dataProvider="{transactions}" editable="true" allowMultipleSelection="true" rollOverColor="0x9BDFFA"
selectionColor="0x004B8D" textSelectedColor="white">
<mx:columns>
<mx:DataGridColumn headerText="Type" dataField="type" itemRenderer="TypeItemRenderer" editable="false"/>
<mx:DataGridColumn headerText="Date" dataField="date" />
<mx:DataGridColumn headerText="Payee" dataField="payee" />
<mx:DataGridColumn headerText="Envelope" dataField="envelope" editable="false" />
<mx:DataGridColumn headerText="Payment" dataField="payment" />
<mx:DataGridColumn headerText="Deposit" dataField="deposit" />
<mx:DataGridColumn headerText="Account" dataField="account" editable="false"/>
</mx:columns>
</mx:DataGrid>
</s:Application> -
Cell data not getting refreshed in which user enters data OO ALV(editable)
Hi Friends,
I am using OO ALV for editable grid display.
I am unable to change grid data in the cell in which user enters something, using OO ALV. Did through debugging of my own program and found that some problem with system program. Then I did all system debugging. Could not find out why is the grid not getting refreshed with the new data in the cell in which user had entered some value. Rest of the cell's data are getting refreshed with the values which i am updating in the final internal table. I can see that the data in the final internal table is changed for the cell in which user enters data. But even after the call of
CALL METHOD obj_alvgrid1->refresh_table_display
does not refreshes the data in the cell in which user had entered data. Rest of the cells data are getting refreshed.
Piece of code:
SET HANDLER obj_event_receiver->handle_data_changed
FOR obj_alvgrid1.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4
e_onf4_before
e_onf4_after.
METHOD handle_data_changed.
DATA : v_valid TYPE char1,
v_refresh TYPE char1.
*--check mt_good_cells semantically
CALL METHOD perform_semantic_checks( er_data_changed ).
*--If PBO is again visited, just refresh the ALV grid.
CALL METHOD obj_alvgrid1->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDMETHOD.
METHOD perform_semantic_checks.
LOOP AT er_data_changed->mt_good_cells INTO w_good.
v_index = sy-tabix.
CASE w_good-fieldname.
WHEN 'ZASCAS'.
*Now here based on some conditions I am changing my final internal table i_zamtsmatnp
MODIFY i_zamtsmatnp FROM w_zamtsmatnp INDEX
w_good-row_id TRANSPORTING
zascas modif.
User enters data in zascas field. Based on the data entered, I am changing other fields which is getting refreshed. I am also changing zascas in the program even after user had already entered the value which was bit wrong and i am correcting it in the program on the even "data_changed" even.
Please help me friends as i m strugling past hours wondering why the data is not getting refreshed for the cell in which user enter data.
Regards,
SuryaHi Surya,
The approach you are following is correct. You need to use the comibnation of all these things:
Event - DATA_CHANGED
Methods - CHECK_CHANGED_DATA
- GET_CHANGED_DATA.
However, here are few standard programs which are having similar functionality.
BCALV_EDIT_03
BCALV_EDIT_07
Check out these once.
Note: If anything is helpful, dont forget to reward points
Thanks,
Adithya K
SAP Practise
[email protected] -
Using the enter key on an editable table
Hi,
I'm using 11g adf and I can't figure out how to get past this:
When going through an editable table (with editingMode="editAll") using the enter key, it will stop after a certain number of rows, equal to the value of fetchSize. If I want to go down further, I have to scroll down another way to make it fetch the next set of rows, it won't go to the next row with the enter key. It simply won't execute the query to fetch the next rows.
Increasing the fetchSize will just delay the problem to a row further down (and decrease the performance since the fetch operation can take quite a bit longer).
I've tried to put a clientListener on both the table or the inputText fields to intercept the enter key, but that won't work when the table is in editable mode.
Is there any way to fix this problem?Hi,
I've tried to put a clientListener on both the table or the inputText fields to intercept the enter key, but that won't work when the table is in editable mode.
The clientListener needs to be on the inputText fields. Then in JS you need to call a server listener which will check if the current row is already at the range end and if calls NextSet (you can provide this as a method binding). Unfortunately after this you will need to PPR the table to show the new rows. This is how I would try it.
Frank -
Handling Enter key event in JTable
Hi...
This is particularly for the user "VIRAVAN"...
I have followed your method ,and got results too.. but the
processKeyBinding(.. method is called 4 times,same problem addressed by you before, but I didn't understood it...
Please help me...
Here is my code...
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,int condition, boolean pressed)
System.out.println("Wait");
if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0))
int selRow = getSelectedRow();
int rowCount = getRowCount();
int selCol = getSelectedColumn();
String val =(String)getValueAt(selRow,selCol);
boolean b= getCellEditor(selRow,selCol).stopCellEditing();
System.out.println(b);
System.out.println(rowCount-1 + " "+ selRow + " " + getSelectedColumn());
if((!val.equals("")) && selRow==rowCount-1)
System.out.println(rowCount-1 + " "+ getSelectedRow()+ " " + getSelectedColumn());
blank1 = new String[columns];
for(int p=0;p<columns;p++)
blank1[p]="";
Diary.this.datarows.addElement(blank1);
// dataModel.fireTableStructureChanged();
//dataModel.fireTableDataChanged();
Diary.this.dataModel.fireTableChanged(null);
else if(ks ==KeyStroke.getKeyStroke(KeyEvent.VK_1,0))
System.out.println("One One One One ");
return super.processKeyBinding(ks,e,condition,pressed);It's been a while since I looked at the code, but essentially there are three key event types:
1) key pressed,
2) key typed,
3) key released.
So I would expect the processKeyBind to see all three of them. However, ks==KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0) is true only when a key typed event is detected (the other types can be ignored by passing it up the food chain where they will eventually be consumed). Now...., if I understand you correctly, you want to terminate edit on the present of Enter key, right? Here is how I'd suggest you do:
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (isEditing()) {
Component editorComponent=getEditorComponent();
editorComponent.stopCellEditing();
return true;
return super.processKeyBinding(ks,e,condition,pressed);
}Ok.... now, it appears that you want to do something else also... i.e., add a new row to the table if the editing row is the last row and the editing column is the last column of the last row. You can't do that in the same thread (i.e., you must wait until the update in the current thread is completed). So, what you must do is use the SwingUtilities.InvokeLater, like this:
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (isEditing()) {
Component editorComponent=getEditorComponent();
editorComponent.stopCellEditing();
if (getEditingRow()+1==getRowCount() && getEditingColumn()+1==getColumnCount()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// put the code for adding new row here
return true;
return super.processKeyBinding(ks,e,condition,pressed);
}OK?
;o)
V.V.
PS: posted code is untest but should work! -
Hi Experts,
Am using an editable alv. I want to perform some actions when Enter key is pressed.
I did this in DOMODIFY. But this makes the scroll bar in initial position. Kindly help me on this.
Regards,
Vijayakumar.Hi vijayakumar,
You can refer this link for info about ENTER key event trigger. Could you please post what you want to perform when Enter key is pressed.
Link: [http://wiki.sdn.sap.com/wiki/display/ABAP/InteractiveEditableOOALVgridwithdynamicitab,FCATandENTERkeyeventtrigger]
Regards,
Anand G -
How to handle the hyperlink in alv
Hello friends,
I made one alv report by using function.. now i want that on one coloum, if user click than it can fetch the information regarding it. please tell me how i can do.. i made a hyperlink on that coloum but i dont know how i handle it..
Regards,
Reema Jain.REPORT zdemoab.
TYPE-POOLS: slis.
TABLES: mara.
TYPES: BEGIN OF t_itab,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
END OF t_itab.
DATA: itab TYPE TABLE OF t_itab,
wa_itab like line of itab.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF i_fieldcat,
i_layout TYPE slis_layout_alv,
g_repid TYPE sy-repid.
SELECT matnr mtart INTO TABLE itab FROM mara UP TO 10 ROWS.
CLEAR: wa_fieldcat.
wa_fieldcat-col_pos = 0.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'MARA'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR: wa_fieldcat.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-tabname = 'MARA'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR: wa_fieldcat.
i_layout-colwidth_optimize = 'X'.
i_layout-hotspot_fieldname = 'MATNR'.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND '
is_layout = i_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'MATNR'.
* To pass the material no in ME22 transaction
READ TABLE itab INTO wa_itab INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_itab-matnr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MM03'.
ENDIF.
ENDFORM.
Maybe you are looking for
-
How to load jar file in one shot?
I have a Java app refers some jar files on remote location. Loading class by class is very time consuming. Is it possible to load the jar files as a whole? like what applet does? Tried URLClass loading, even run java -jar, still those load class on d
-
Search file for text and delete the found text. How?
I need to know how to search a file for text and delete the found text. I think grep will let you do this but not sure of the syntax.
-
Question about Tour3D(the source of the Andrew Davison 's book)
In Tour3D'Obstacles class,i want to use BoundingBox instead of BoundingSphere.But it doesn't work. Here is source: // Obstacles.java // Andrew Davison, April 2005, [email protected] /* Obstacles stores a 2D boolean array (obs) representing th
-
Hi, Jdeveloper Version is 11.1.1.3.0 <Key Name="CountryCIdPk" PrimaryKey="true"> <DesignTime> <Attr Name="_DBObjectName" Value="COUNTRY_C_ID_PK"/> </DesignTime> <AttrArray Name="Attributes"> <Item Value="model.Countries.CountryId"/> </AttrArray> </Ke
-
All of a sudden I can't play my playlists. When I attempt to play an album nothing happens.