How to validate cells of selected rows in editable ALV
Hi,
I have created an ALV grid which is editable. Now I have entered the values in the grid, and selected some rows for which I need to validate the cells. But this is not happening. It is validating all the cells edited in the grid.
Can anyone help me...
Regards,
Satish Kanteti.
Hi Satish,
Follow below steps,
1. Declare a additional field for selection flag in your internal table like below,
DATA: BEGIN OF g_t_vekp OCCURS 0,
flag(1) TYPE c, " <------ Flag for selection
venum TYPE vekp-venum,
exidv TYPE vekp-exidv,
vbeln_gen TYPE vekp-vbeln_gen,
END OF g_t_vekp.
2. Add extra parameter 'i_callback_user_command' in FM 'REUSE_ALV_GRID_DISPLAY'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_r_repid
i_callback_user_command = 'USER_COMMAND' " <------ Additional parameter
is_layout = g_wa_layout
it_fieldcat = g_t_fieldcat[]
TABLES
t_outtab = g_t_vekp
EXCEPTIONS
program_error = 1
OTHERS = 2.
3. Define a form 'USER_COMMAND' like below to check or save only selected rows.
FORM user_command USING l_r_ucomm LIKE sy-ucomm l_r_selfield TYPE slis_selfield.
CASE l_r_ucomm.
*Updating database when 'Save' is pressed
WHEN '&DATA_SAVE'.
LOOP AT g_t_vekp INTO g_wa_vekp WHERE flag = 'X'. " <---- Loop through only selected rows
" Ur operation on selected records
ENDLOOP.
ENDCASE.
l_r_selfield-refresh = 'X'.
ENDFORM. "user_command
Might solve ur problem.
Thanks,
Edited by: Sap Fan on Oct 13, 2009 5:10 PM
Similar Messages
-
How can I get the selected rows from two ALV grids at the same time?
I have a program that uses two ALV grids in one dialog screen. I'm using the OO ALV model (SALV* classes).
The user can select any number of rows from each grid. Then, when a toolbar pushbutton is pressed, I'd have to retrieve the selected rows from both grids and start some processing with these rows.
It is no problem to assign event handlers to both grids, and use the CL_SALV_TABLE->GET_SELECTIONS and CL_SALV_SELECTIONS->GET_SELECTED_ROWS methods to find out which rows were marked by the user. Trouble is, this only works when I raise an event in each grid separately, for instance via an own function that I added to the grid's toolbar. So, I can only see the selected rows of the same grid where such an event was raised.
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.
As it is right now, I can have an own button in both grid's toolbar, select the rows, click on the extra button in each grid (this will tell me what entries were selected per grid). Then, I'd have to click on a third button (the one in the dialog screen's toolbar), and process the selected rows from both grids.
How can I select the rows, then click on just one button, and process the marked entries from both grids?
Is it somehow possible to raise an event belonging to each grid programmatically, so that then the corresponding CL_SALV_SELECTIONS->GET_SELECTED_ROWS will work?
Thanks.Hello Tamas ,
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.--->
is it possible to have a check box in each grid & get the selected lines in PAI of the screen ?
regards
prabhu -
How can I programmatically select row to edit in ADF - 11g
Hello,
I'm having a table with rowSelection="single" and editingMode="clickToEdit". Currently i'm facing two issues.
First issue: the first click on a table row makes the row selected, on second click it becomes editable. If I click on another row it gets selected, but previously selected row remains editable. I would like to change this, so when I select another row, the previously selected one to become read-only again. By now, I didn't find any solution to set programmatically the 'editable' state of a row.
The second issue might be a bug and is related to deleting an editable row. I select a row, click to edit it, and then delete it. The next row get's selected, but clicking on it to edit, has no effect unless I press the 'ESC' select another row before. Does anyone have a tip how to workaround it?
Thank you very much!
Enikotry adding this method in the table selectionListener.
public void table1_selectionListener(SelectionEvent selectionEvent) {
public String getCurrentRow() {
BindingContainer bindings = getBindingsForDCB();
RichTable table=table1;
DCIteratorBinding outListIter = getBindingsForDCB().findIteratorBinding("outlistOutIterator");
RowKeySet rowSet = table.getSelectedRowKeys();
Iterator rowKeySetIter = rowSet.iterator();
while (rowKeySetIter.hasNext()) {
List l = (List) rowKeySetIter.next();
Key key = (Key)l.get(0);
outListIter.setCurrentRowWithKey(key.toStringFormat(true));
Row r = outListIter.getCurrentRow();
return null;
} -
Detect selected row/column in ALV when clicking my button
Hello,
I use the cl_salv_table to display my ALV. I have implemented some double click events an so one. But now I like to be able detect u201Cselected row and coll when I press a button I my Application toolbar.
How do I get the selected row/column when pressing my button?
Regards,
KennethGive this a try:
class lcl_disp_code definition.
public section.
methods: disp_code
for event double_click
of cl_gui_alv_grid
importing es_row_no
e_column.
endclass. "lcl_disp_code DEFINITION
* CLASS lcl_disp_code IMPLEMENTATION
class lcl_disp_code implementation.
method disp_code.
perform restrict_data
using es_row_no-row_id.
endmethod. "on_double_click
endclass. "lcl_disp_code IMPLEMENTATION
Rob -
Edit a selected row in an alv report after pressing a push button ?
hi all ,
I want to edit a selected row in an alv report but that too after i press a push button . After pressing the push button , a pop up shud *** showing all the entries of the selected row which shud be editable and after editing it shud be saved into the database table.
How can i do this please help asap ???May this prog. of mine can solve your requirement.
REPORT z_demo_alv_jg.
TYPE-POOLS *
TYPE-POOLS: slis.
INTERNAL TABLES/WORK AREAS/VARIABLES *
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.
FIELD-SYMBOLS *
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.
SELECTION SCREEN *
PARAMETERS: tabname(30) TYPE c,
lines(5) TYPE n.
START-OF-SELECTION *
START-OF-SELECTION.
Storing table name
p_table = tabname.
Create internal table dynamically with the stucture of table name
entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.
LEAVE TO LIST-PROCESSING.
ENDIF.
Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.
SORT i_fieldcat BY col_pos.
Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.
REFRESH <dyn_tab_temp>.
Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*& Form SET_PF_STATUS
Setting custom PF-Status
-->RT_EXTAB Excluding table
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'Z_STANDARD'.
ENDFORM. "SET_PF_STATUS
*& Form user_command
Handling custom function codes
-->R_UCOMM Function code value
-->RS_SELFIELD Info. of cursor position in ALV
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.
Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.
Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.
Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.
CASE r_ucomm.
When a record is selected
WHEN '&IC1'.
Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.
IF sy-subrc = 0.
Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.
Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'Z_DEMO_PDF_JG'
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
Make all the fields input enabled except key fields
w_field-input = 'X'.
MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.
ENDIF.
Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.
If the record is changed then track its index no.
and populate it in an internal table for future
action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.
ENDIF.
When save button is pressed
WHEN 'SAVE'.
Sort the index table
SORT i_index.
Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.
LOOP AT i_index.
Find out the changes in the internal table
and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.
ENDLOOP.
Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.
REFRESH <dyn_tab_temp>.
Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.
ENDIF.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "user_command
Regards,
Joy. -
How to make a filed mandatory of an editable ALV
Hi Guru,
Pls tell me how to make a filed mandatory of an editable ALV so that while a new records is inserted the mandatory fields are filled.hi,
You can make fields as mandatory fields using data changed event.
validate the entered or blank entries of a column in data changed event and call method 'add_protocol_entry' to raise errors.
Check the program : BCALV_EDIT_03 & BCALV_EDIT_04for more details.
Refer to this link....
about field in alv
obligatory field editable in ALV -
Interactive Report: how to get value of given row/col cell in selected row
Hi -- I have an interactive report. Instead of the default behavior of the link going to a single row view, I want it to
go to a form for editing the row. This means I have to be able to populate the form w/ the correct row's information...
so need to get the value(s) for the PK column(s) in the selected row of the interactive report, so I can select the row
from the database.
How can I do this? I see in the report attributes, Link Column section, I can set Rows Uniquely Identified by, and a Unique
Column (though there could be more than one in a PK). I imagine I'd want to use the rowid, but I'm not sure how the
rowid of the selected IR row can be referenced. And at that point, I'm not sure how to get the IR column value for
that row. (Say I'm on the 8th row and I need the first column... How is the column referenced? By a number, it's name,
its heading?)
Or maybe I'm not on the right track at all...
Ideas?
Thanks,
CarolHi Carol,
What I´m trying to do is: defining a button such as when you click it a pl-sql procedure is called, which needs as an input parameter the id of the row selected in my form. what I need first, then, is to get the id of the selected row. how did you get it?
Thanks in advance
Francesco -
Need help on how to specify the current select row in a View Object
Hi,
I have a ADF table on my page, when I was selecting the rows in this table, I want the set and get methods in the ViewRowImpl class to do some customized actions. I found out that each time regardless the row I select in the table, the viewrowimpl class will always return the data in the first row, I tried to use getCurrentRow in VO row impl. but still, gets the first row.
Does anyone know how to get the selected row value in the View Object, or View Row Impl rather???
Thanks!Hi,
you can call a method exposed by the AM and pass teh rowKey of the selected row as an argument. When you configure the exposed AM method in the pageDef (creating a method binding) the argument is shown in a dialog from where you can use EL like #{bindings.iteratorName.currentRow.rowKey} to access the current selected row.
Frank -
How to read attributes of selected row in table?
hi,
can anyone give me a example, how to get value of currently selected row of af:table,in backingbeans? assuming using jdv10g & single selection in table.
thanks & regardsin the table selectionlistener
BindingContainer bindings = getBindingsForDCB();
RichTable table=table1;
DCIteratorBinding outListIter = getBindingsForDCB().findIteratorBinding("yourtableIterator");
RowKeySet rowSet = table.getSelectedRowKeys();
Iterator rowKeySetIter = rowSet.iterator();
while (rowKeySetIter.hasNext()) {
List l = (List) rowKeySetIter.next();
Key key = (Key)l.get(0);
outListIter.setCurrentRowWithKey(key.toStringFormat(true));
Row r = outListIter.getCurrentRow();
} -
How do I sort only selected rows?
Hi, in Maverick, the option to sort only selected rows seems to be gone anyone out there who knows how to do this? Cheers Paull
Hi SG,
Firstly, I wasn't saying that Wayne's posts were rubbish, I said his comment about V2 not having sorts by rows was rubbish as I proved with my image. I am just really frustrated professional person who has been signing Apples and Numbers praises that has been left feeling really let down.
Personally, I do not wan't an OSX version Numbers to be the same as the IOS version. My old IOS version was perfectly adequate as was my OSX vesrion. I'm not interested in doing this on my phone or iPad BUT when I am at work on my 27" iMac, I don't want to use a piece of software that is written to be more compatible with a mobile device so I couldnt care if the IOS version has a Reorganize panel.
I'm saying that they (Apple) shouldn't dress this up as V3 of numbers. They should call it
NUMBERS LITE COMPATIBLE WITH IOS DEVICES
Which is really what it is, and then most of us who require a serious spreadsheet, wouldn't have bothered downloading it and wasted hours only to find out that it is not fit for purpose.
The problem I have is that there will no longer be any improvements to V2 so this is now what we are stuck with with the only alternative being to return to Excel, which I hate with a vengence.
Also, we are stuck with this version if we want to use sheets we create in OSX in our ipads. Once again, not even close to being acceptable.
All in all, not what I expect from Apple, or is this just the type of thing we have to expect from them now.
Spencer -
How to directly access a SELECTED row in a table using MasterColumn
I'm using a table with MasterColumn (TreeByNestingTableColumn) contains checkbox element.
In order to get the selected row I have to navigate the whole tree which is a very expensive when the tree is big.
I also tried without check box by just using MULTI ROW SELECTION property of the table but that didn't work.
Is there a way to directly access selected row like we do in the standrard table control?
Any help would be appretiated.
regards
Qamarhi, Qamar
Just Check out the Following Link's
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on creating a tree structure in a table - 27.htm
and also if u had not seen it before...............
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on creating tables in web dynpro - 11_0_.htm
regard's
Dheerendra -
How to make sure newly created row is editable by default programatically
Hi All,
I got a problem with creating new row in single row selection table with on click property enabled for editing mode.
Function requirement is like: I have Mater-Detail. While creating detail lines, line has to be created with default line number. Eg: Master1 can have line numbers 1,2,3..etc, Master2 can have 1,2,3.. etc.
In applicationTable for Pattern Create
Action Listener=”#{CreateAndEditFiscalDocumentBean.createChargeLine}”
In Table rowSelection="single" and editingMode="clickToEdit"
Here the problem is:
When I first come to the page,the first row in the detail table is editable and could able to edit any other row on click . But When I create a new row , I got a new row with line number but it is not editable.
I want it to be editable on create and previously selected row should be read only. I have tried several ways but nothing is working.
My observation is, when I call the bean method in Action Listener of application Table in create patteren, I am facing this problem. If I do not call this method, it is working as expected. But I need to call this method because it has to create row with line number.
I am putting below two scenarios which I have tried. I am not successful in the both the scenarios.
Could you please help me in achieving expected functionality.
Many thanks in advance for your time and help.
Scenario 1:
Jsff:
ApplicationTable: createActionListener="#{CreateAndEditFiscalDocumentBean.createChargeLine}"
Table: rowSelection="single", editingMode="clickToEdit"
Bean Code:
public void createChargeLine(ActionEvent actionEvent) {
FacesContext fc = FacesContext.getCurrentInstance();
ExpressionFactory factory = fc.getApplication().getExpressionFactory();
MethodExpression method=factory.createMethodExpression(fc.getELContext(),"#{bindings.createChargeLine1.execute}",String.class,new Class[]{});
method.invoke(fc.getELContext(),null);
AMImpl Code:
public void createChargeLine() {
ViewObject itemChargeVO = this.getFiscalDocumentCharges();
ViewObject fiscalDocumentHeaderVO = this.getFiscalDocumentHeader();
Row toRow = fiscalDocumentHeaderVO.getCurrentRow();
Row newRow = null;
Row latestRow = itemChargeVO.first();
Integer line_number = new Integer(0);
int numberOfItemLines = 0;
if (latestRow != null) {
RowSet rs = itemChargeVO.getRowSet();
numberOfItemLines = numberOfItemLines + 1;
if (rs != null) {
line_number =
(Integer)rs.first().getAttribute("LineNumber");
while (rs.hasNext()) {
numberOfItemLines = numberOfItemLines + 1;
Row row = rs.next();
if (line_number.compareTo((Integer)row.getAttribute("LineNumber")) <
0)
line_number =
(Integer)row.getAttribute("LineNumber");
line_number = line_number + 1;
newRow = itemChargeVO.createRow();
newRow.setAttribute("LineNumber", line_number);
itemChargeVO.insertRowAtRangeIndex(numberOfItemLines + 1, newRow);
itemChargeVO.setCurrentRow(newRow);
} else {
newRow = itemChargeVO.createRow();
newRow.setAttribute("LineNumber", new Integer(1));
itemChargeVO.insertRowAtRangeIndex(0, newRow);
itemChargeVO.setCurrentRow(newRow);
Scenario 2:
Bean method changes:
public void createChargeLine1(ActionEvent actionEvent) {
Row newLine = ApplicationsTableEventHandler.getInstance().processCreate(getChargeTable());
newLine.setAttribute("LineNumber", new Integer(1));
}Hi Jerry,
Please refer to the following blog and check whether you followed all the steps:
/people/harikrishna.sunku/blog/2008/12/18/work-center-and-navigation-link-creation-in-crm-2007
You basically need to ensure that your custom work center is assigned to a navigation bar profile; and this navigation bar profile is assigned to your business role.
Regards,
Shiromani -
Dear Fnds,
My requirement is, Iam displaying output data in ALV. in the output ALV i have 10 rows.
in the 10 rows if i select 5 rows(any rows), Example 3,7,1,2,5, Do we have any function module or class to determine the selected row sequence (which one we have selected as first, second and thrid etc.)srinu reddy wrote:
Dear Fnds,
>
> My requirement is, Iam displaying output data in ALV. in the output ALV i have 10 rows.
>
> in the 10 rows if i select 5 rows(any rows), Example 3,7,1,2,5, Do we have any function module or class to determine the selected row sequence (which one we have selected as first, second and thrid etc.)
Hi,
I think you can achieve this thru GET CURSOR statement which will tell you current cursor position. I don`t think you can store it in a internal table to know the sequence.
Try, have a look at this document. http://help.sap.com/saphelp_470/helpdata/en/9f/dbabf135c111d1829f0000e829fbfe/content.htm
Hope, you find this useful.
Reetesh -
Get Current row in Editable ALV
Hi,
I have editable alv, when i press "insert row" or "Append row" i need to get current inserted/appended row element reference or index.
How can i get this??
Please suggest.Hi kranthi ,
While inserting row you must be selecting a row, you can get the index of the selected row by this following code
get Index of selected table item
CALL METHOD NODE_NAME->GET_LEAD_SELECTION_INDEX
RECEIVING INDEX = Lv_Indx.
( DATA: Lv_Indx Type i )
or while you are appending a row you can use Describe int_table LINES lv_line and use the value of 'lv_line' as the index.
Regards -
How can we find out data in an editable ALV grid has been changed or not?
Hi Experts,
How can we find out whether a data in an editable ALV grid has been changed or not.
I am using the
FM -> REUSE_ALV_GRID_DISPLAY_LVC
for ALV display.
I have to chekc whther data has been changed or not befor saving. if changed then only i want to
SAVE
. I cannot use the internal table comparison method for this purpose also i am not using OOP ALV.
So kindly sugest me an alternative.
Thanks and Regards,
ShahanaHi,
Thanks for your answer. I already saw this post.
See this method.
CALL METHOD reuse_alv_grid->check_changed_data
IMPORTING
e_valid = lv_check.
This will update the internal table with the edited values. Then we can go for internal table comparison.
But my scenario will not allow me for itab comparisons.I just want to know the ALV data has been changed or not.
Regards,
Shahana
Maybe you are looking for
-
After upgrading to IOS Yosemite, Thunderbird will no longer send emails to the contacts in my history file that drops down when I "write" a new message. I continue to get a return response that there is a syntax error in the address field of the mess
-
ORA-00349: failure obtaining block size for '+Z' in Oracle XE
Hello, I am attempting to move the online redo log files to a new flash recovery area location created on network drive "Z" ( Oracle Database 10g Express Edition Release 10.2.0.1.0). When I run @?/sqlplus/admin/movelogs; in SQL*Plus as a local sysdba
-
HT4168 Pages only exports first ten pages to epub
Hi, community! Here's my problem: I'm trying to export a comic, pasted into Pages, as an epub file but no matter what I do I only get the first ten pages to export. The weird part is that I have another file - where I did exactly same thing - and it
-
Webutil file load/upload problem
Hi, When i upload/download file from DB or AS and filename contains only english letters there is no problem. But when i wanna upload file which filename contains baltic leters webutil demo showing thah all ok,no errors, but blob column is empty. I t
-
Delete confirmations for PO line item
Hello gurus, There is confirmation manually created/entered for a PO line items. I am trying to delete it but unable to do so in change mode. What could be the reason? Please advise Thanks RJS