How to Delete certain rows from table view collection
Hi Experts,
I need to display result on the basis of certain process type. So i have used code like below.
lv_iterator = me->typed_context->searchresult->collection_wrapper->get_iterator( ).
lv_entity = lv_iterator->get_first( ).
WHILE lv_entity IS BOUND.
CLEAR:lv_object.
lv_object = lv_entity->get_property_as_string( iv_attr_name = 'PROCESS_TYPE' ).
IF lv_object <> 'XXX'.
lr_entity ?= lv_entity.
me->typed_context->searchresult->collection_wrapper->remove( lv_entity ).
lr_entity->delete( ).
ENDIF.
lv_entity = lv_iterator->get_next( ).
ENDWHILE.
But only some of the entities from the collection are getting removed. Still some wrong entities exists which i cant even able to delete it by using ,
me->typed_context->searchresult->collection_wrapper->remove( lv_entity ).
lr_entity->delete( ).
Am i missing anything here?
Regards,
Santhosh
Hi Santhosh,
Maybe that is happening because you're removing elements from an object (collection_wrapper) inside your loop.
Can you try to create an collection wrapper copy by using GET_COPY method, and then use and loop the iterator on your copied object, and remove the unwanted entities on your main object?
Kind regards,
Garcia
Similar Messages
-
How to delete certain rows from Table view
Hi Experts,
I need to display result on the basis of certain process type. So i have used code like below.
lv_iterator = me->typed_context->searchresult->collection_wrapper->get_iterator( ).
lv_entity = lv_iterator->get_first( ).
WHILE lv_entity IS BOUND.
CLEAR:lv_object.
lv_object = lv_entity->get_property_as_string( iv_attr_name = 'PROCESS_TYPE' ).
IF lv_object <> 'XXX'.
lr_entity ?= lv_entity.
me->typed_context->searchresult->collection_wrapper->remove( lv_entity ).
lr_entity->delete( ).
ENDIF.
lv_entity = lv_iterator->get_next( ).
ENDWHILE.
But only some of the entities from the collection are getting removed. Still some wrong entities exists which i cant even able to delete it by using ,
me->typed_context->searchresult->collection_wrapper->remove( lv_entity ).
lr_entity->delete( ).
Am i missing anything here?
Regards,
SanthoshHi Santhosh,
Maybe that is happening because you're removing elements from an object (collection_wrapper) inside your loop.
Can you try to create an collection wrapper copy by using GET_COPY method, and then use and loop the iterator on your copied object, and remove the unwanted entities on your main object?
Kind regards,
Garcia -
How to delete a row from table control
I have created a push button on the screen for delete.
its getting stored in ok_code.
'FLAG' is the name of the mark on the table control.
I am getting probs in this line.
I am not getting anything in mark_field.
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
The code is:
MODULE tablctrl2_user_command INPUT.
PERFORM user_ok_tc USING 'TABLCTRL2'
'I_ZSKILLEMP'
'FLAG'
CHANGING ok_code.
ENDMODULE.
FORM user_ok_tc USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name
CHANGING p_ok LIKE sy-ucomm.
-BEGIN OF LOCAL DATA----
DATA: l_ok TYPE sy-ucomm,
l_offset TYPE i.
-END OF LOCAL DATA----
Table control specific operations *
evaluate TC name and operations *
SEARCH p_ok FOR p_tc_name.
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_offset = strlen( p_tc_name ) + 1.
l_ok = p_ok+l_offset.
execute general and TC specific operations *
CASE l_ok.
WHEN 'INSR'. "insert row
PERFORM fcode_insert_row USING p_tc_name
p_table_name.
CLEAR p_ok.
WHEN 'DELE'. "delete row
PERFORM fcode_delete_row USING p_tc_name
p_table_name
p_mark_name.
CLEAR p_ok.
FORM fcode_delete_row
USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name .
-BEGIN OF LOCAL DATA----
DATA l_table_name LIKE feld-name.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
-END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
get the table, which belongs to the tc *
CONCATENATE p_table_name '[]' INTO l_table_name. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
delete marked lines *
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
access to the component 'FLAG' of the table header *
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
IF <mark_field> = 'X'.
DELETE <table> INDEX syst-tabix.
IF sy-subrc = 0.
<tc>-lines = <tc>-lines - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.Hi...
i got the same prob...but got the solution too...
you have to take an internal table of same type of dbase table..and maintain a flag in it...which will be get filled automatically with 'X'.
here is the code..go throug it..
REPORT YH642_DIALOG_TABLECONTROL.
CALL SCREEN 999.
DATA:
W_INDEX TYPE I.
DATA:
W_UCOMM LIKE SY-UCOMM.
***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'TAB'
*&SPWIZARD: DEFINITION OF DDIC-TABLE
TABLES: YH642_RAM.
DATA:
BEGIN OF DDTAB,
TAB_FLAG TYPE C,
MANDT LIKE YH642_RAM-MANDT,
EID LIKE YH642_RAM-EID,
ENAME LIKE YH642_RAM-ENAME,
MOBILE LIKE YH642_RAM-MOBILE,
END OF DDTAB.
*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'TAB'
TYPES: BEGIN OF T_TAB,
TAB_FLAG TYPE C,
MANDT LIKE YH642_RAM-MANDT,
EID LIKE YH642_RAM-EID,
ENAME LIKE YH642_RAM-ENAME,
MOBILE LIKE YH642_RAM-MOBILE,
END OF T_TAB.
*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'TAB'
DATA: G_TAB_ITAB TYPE T_TAB OCCURS 0,
H_TAB_ITAB TYPE T_TAB OCCURS 0,
G_TAB_WA TYPE T_TAB. "work area
DATA: G_TAB_COPIED. "copy flag
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TAB' ITSELF
CONTROLS: TAB TYPE TABLEVIEW USING SCREEN 0999.
*&SPWIZARD: LINES OF TABLECONTROL 'TAB'
DATA: G_TAB_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE TAB_INIT OUTPUT.
IF G_TAB_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'YH642_RAM'
*&SPWIZARD: INTO INTERNAL TABLE 'g_TAB_itab'
SELECT * FROM YH642_RAM
INTO CORRESPONDING FIELDS
OF TABLE G_TAB_ITAB.
G_TAB_COPIED = 'X'.
H_TAB_ITAB[] = G_TAB_ITAB[].
REFRESH CONTROL 'TAB' FROM SCREEN '0999'.
ENDIF.
ENDMODULE. "TAB_INIT OUTPUT
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MOVE ITAB TO DYNPRO
MODULE TAB_MOVE OUTPUT.
MOVE-CORRESPONDING G_TAB_WA TO DDTAB.
ENDMODULE. "TAB_MOVE OUTPUT
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE TAB_GET_LINES OUTPUT.
G_TAB_LINES = SY-LOOPC.
ENDMODULE. "TAB_GET_LINES OUTPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TAB'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MODIFY TABLE
MODULE TAB_MODIFY INPUT.
MOVE-CORRESPONDING DDTAB TO G_TAB_WA.
MODIFY G_TAB_ITAB
FROM G_TAB_WA
INDEX TAB-CURRENT_LINE.
ENDMODULE. "TAB_MODIFY INPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TAB'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE TAB_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'TAB'
'G_TAB_ITAB'
'TAB_FLAG'
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.
ENDMODULE. "TAB_USER_COMMAND INPUT
INCLUDE TABLECONTROL_FORMS *
*& Form USER_OK_TC *
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
L_OFFSET = STRLEN( P_TC_NAME ) + 1.
L_OK = P_OK+L_OFFSET.
L_OK = 'DELE'.
*&SPWIZARD: execute general and TC specific operations *
CASE L_OK.
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.
WHEN 'DELE'. "delete row
MESSAGE 'Are you really going to delete??' type 'I'.
PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
WHEN 'L--'. "total left
PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
WHEN 'L-'. "column left
PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
WHEN 'R+'. "column right
PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
WHEN 'R++'. "total right
PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'DMRK'. "demark all filled lines
PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'SASCEND' OR
'SDESCEND'. "sort column
PERFORM FCODE_SORT_TC USING P_TC_NAME
l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
*& Form FCODE_INSERT_ROW *
FORM FCODE_INSERT_ROW
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
*& Form FCODE_DELETE_ROW *
FORM FCODE_DELETE_ROW
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
IF <MARK_FIELD> = 'X'.
W_INDEX = SYST-TABIX.
DELETE <TABLE> INDEX SYST-TABIX.
IF SY-SUBRC = 0.
<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.
READ TABLE H_TAB_ITAB INDEX W_INDEX INTO G_TAB_WA.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING G_TAB_WA TO YH642_RAM.
DELETE YH642_RAM.
ENDIF.
ENDFORM. " FCODE_DELETE_ROW
*& Form COMPUTE_SCROLLING_IN_TC
text
-->P_TC_NAME name of tablecontrol
-->P_OK ok code
FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
P_OK.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TC_NEW_TOP_LINE TYPE I.
DATA L_TC_NAME LIKE FELD-NAME.
DATA L_TC_LINES_NAME LIKE FELD-NAME.
DATA L_TC_FIELD_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
ASSIGN (L_TC_LINES_NAME) TO <LINES>.
*&SPWIZARD: is no line filled? *
IF <TC>-LINES = 0.
*&SPWIZARD: yes, ... *
L_TC_NEW_TOP_LINE = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
ENTRY_ACT = <TC>-TOP_LINE
ENTRY_FROM = 1
ENTRY_TO = <TC>-LINES
LAST_PAGE_FULL = 'X'
LOOPS = <LINES>
OK_CODE = P_OK
OVERLAPPING = 'X'
IMPORTING
ENTRY_NEW = L_TC_NEW_TOP_LINE
EXCEPTIONS
NO_ENTRY_OR_PAGE_ACT = 01
NO_ENTRY_TO = 02
NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
*&SPWIZARD: get actual tc and column *
GET CURSOR FIELD L_TC_FIELD_NAME
AREA L_TC_NAME.
IF SYST-SUBRC = 0.
IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column *
SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: set the new top line *
<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
*& Form FCODE_TC_MARK_LINES
marks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
&SPWIZARD: EGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: mark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
*& Form FCODE_TC_DEMARK_LINES
demarks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: demark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = SPACE.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
*& Module STATUS_0999 OUTPUT
text
MODULE STATUS_0999 OUTPUT.
SET PF-STATUS 'SS_STD'.
SET TITLEBAR 'TITLE'.
ENDMODULE. " STATUS_0999 OUTPUT
*& Module USER_COMMAND_0999 INPUT
text
MODULE USER_COMMAND_0999 INPUT.
DATA:
H_TAB_WA LIKE G_TAB_WA.
CASE W_UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'TAB_MODI' OR 'SAVE'.
LOOP AT G_TAB_ITAB INTO G_TAB_WA.
FORMAT INPUT OFF.
MOVE-CORRESPONDING G_TAB_WA TO YH642_RAM.
READ TABLE H_TAB_ITAB WITH KEY EID = G_TAB_WA-EID INTO H_TAB_WA.
IF SY-SUBRC EQ 0.
IF G_TAB_WA NE H_TAB_WA.
MODIFY YH642_RAM.
ENDIF.
ELSE.
INSERT YH642_RAM.
ENDIF.
ENDLOOP.
SORT G_TAB_ITAB.
ENDCASE.
*CALL SCREEN 700.
ENDMODULE. " USER_COMMAND_0999 INPUT -
How to delete multiple rows from ADF table
How to delete multiple rows from ADF table
Hi,
best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
Frank -
How To Delete a Row From a TableView !!!!
Hi,
Does any know how to delete a row from a table view model.
I have a TableViewModel being displayed, when the user select the particular row and click delete i want that particular row to be deleted.
Any Suggestions How.
Thanks,
Emmanuel.If u want to delete single row, then set the property of TableView - selectionMode="SINGLESELECT". Select the radio button and click on delete button. In the main program, you can get the row value like...
public void onDeleteButtonClicked(Event event) throws PageException {
TableView table = (TableView) this.getComponentByName ("idTableView");
DefaultTableViewModel dmodel = myBean.beanModel;
String pid = "", row_selected;
// Get the first visible row
int firstVisibleRow = table.getVisibleFirstRow();
// Get the last visible row
int lastVisibleRow = table.getVisibleLastRow();
for (int i = firstVisibleRow; i <= lastVisibleRow; i++) {
if (table.isRowSelected(i)) {
row_selected = i;
pid = dmodel.getValueAt(i, 1).toString();
"i" will give you the row no, pid has the value of the row at first column.
Hope this helps.
Thanks,
Praveen -
How to delete a row of table in Word using powershell.
I want to search for a word which is present in Table. If that word is present than I want to delete that row from table.
Can anybody help me with that. The script I am using is:
$objWord = New-Object -ComObject word.application
$objWord.Visible = $True
$objDoc = $objWord.Documents.Open("C:\temp\Recipe.docx")
$FindText = "DP1"
$objSelection.Find.Execute($FindText)
$objWord.Table.Cells.EntireRow.Delete()
$objDoc.SaveAs("C:\Temp\P.docx")
$Doc.Close()Maybe try this:
$objWord = New-Object -ComObject word.application
$objWord.Visible = $True
$objWord.Documents.Open("C:\temp\Recipe.docx")
$FindText = "DP1"
$objWord.Selection.Find.Execute($FindText) | Out-Null
$objWord.Selection.SelectRow()
$objWord.Selection.Cells.Delete()
$objWord.Documents.SaveAs("C:\Temp\P.docx")
$objWord.Close()
$objWord.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$objWord) | Out-Null
This definitely assumes the text you're trying to find only exists in a table, per your specified requirements. If it exists anywhere else, or in multiple tables, the code above is inadequate.
I hope this post has helped! -
How to update duplicate row from table
Hi,
how to update duplicate row from table?
First to find duplicate row then update duplicate row with no to that duplicate row in oracle.
can you give me suggestion on it?
Thanks in advance.
your early response is appreciated...In order to find a duplicate row, see:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1224636375004
(or search this forum, your question has been asked before)
In order to update it, just create and use an Oracle sequence, have it start and increment at a value that doesn't exist in your table.
If that doesn't get you going, post some CREATE TABLE + INSERT INTO statements, and the results you want from them, in other words: a complete testcase. -
How To Delete a row from view object
Hi
I have a table whose data is populated based on the view object... and for each row i have a delete icon...
when i press on this delete icon i want to delete that particular row from the view object only..but not from the data
base..please help me in this issue
ThanksHi,
as per krishna priya says u can delete .
-----1st one thing let me know vo is eo based .???.
If not here is the sample code to delete a row not from the data base.:
public void Deleterow(OAPageContext pageContext, OAWebBean webBean,String prjid)
int idtodelete;
int fetchedrowcount;
Number prjojectid;
RowSetIterator deleteIter;
prjidtodelete=Integer.parseInt(prjid);
OADBTransaction tr = getOADBTransaction();
ProjectsVORowImpl row=null;
ProjectsVOImpl vo= getProjectsVO1();
fetchedrowcount=vo.getRowCount();
deleteIter = vo.createRowSetIterator("deleteIter");
deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedrowcount);
for(int i=0;i<fetchedrowcount;i++)
row= (ProjectsVORowImpl)deleteIter.getRowAtRangeIndex(i);
prjojectid=(Number)row.getAttribute("ProjectId");
if (prjojectid.compareTo(prjidtodelete)==0)
row.remove();
break;
deleteIter.closeRowSetIterator();
Regards
Meher Irk
Edited by: Meher Irk on Nov 2, 2010 12:42 AM -
HOW TO DELETE THE ROW FROM DATABASE
hI,
Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.
thanks
naveen
[email protected]
<%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,java.util.Vector,java.util.StringTokenizer" %>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Item Details</title>
<script>
function submitPage()
document.details.action = "itemdetails.jsp" ;
document.details.submit();
</script>
</head>
<body>
<form name="details" action="itemdetails.jsp" method="post">
<%
ConnectionPool pool;
Connection con = null;
Statement st;
ResultSet rs =null;
%>
<table border="0" cellpadding="0" cellspacing="0" width="328">
<tr>
<td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
<input type="submit" value="search" name="search" ></td>
</tr>
<tr>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item Code</b></font></td>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item No</b></font></td>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Amount </b></font></td>
<td width="80" bgcolor="#000099"> </td>
</tr>
<%
pool= new ConnectionPool();
Utils utils = new Utils();
double total =0.00;
String search =utils.returnString(request.getParameter("search"));
if(search.equals("search"))
try
String ref_no =utils.returnString(request.getParameter("txt_refno"));
String strSQL="select * from ref_table where refno='" + ref_no + "' ";
con = pool.getConnection();
st=con.createStatement();
rs = st.executeQuery(strSQL);
while(rs.next())
String itemcode=rs.getString(2);
int item_no=rs.getInt(3);
double amount= rs.getDouble(4);
total= total + amount;
%>
<tr>
<td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
<td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
<td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
<td width="80"><a href="delete</td>
</tr>
<%
}catch(Exception e){}
finally {
if (con != null) pool.returnConnection(con);
%>
<tr>
<td width="323" colspan="4">
<p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
</tr>
<tr>
<td width="323" colspan="4">
<input type="button" value="save" name="save"></td>
</tr>
</table>
</form>
</body>
</html>You mean when you click on the hyperlink you want that row to disappear from the page, but not delete the row from the database until a commit/submit button is pressed?
Personally, I think I'd prefer that you have a delete checkbox next to every row and NOT remove them from the display if I was a user. You give your users a chance to change their mind about their choice, and when they're done they can see exactly which rows will be deleted before they commit.
You know your problem, of course, so you might have a good reason for designing it this way. But I'd prefer not removing them from the display. JMO - MOD -
How to delete the row in table control with respect to one field in module pool programming?
Hi,
Can I know the way to delete the row in table control with respect to one field in module pool programming
Regards
Darshan MSHI,
I want to delete the row after the display of table control. I have created push button as delete row. If I click on this push button, the selected row should get deleted.
I have written this code,
module USER_COMMAND_9000 input.
DATA OK_CODE TYPE SY-UCOMM.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'DELETE'.
LOOP AT lt_source INTO ls_source WHERE mark = 'X'.
APPEND LS_SOURCE TO LT_RESTORE.
DELETE TABLE LT_SOURCE FROM LS_SOURCE.
SOURCE-LINES = SOURCE-LINES - 1.
ENDLOOP.
But I'm unable to delete the selected rows, It is getting deleted the last rows eventhough I select the other row.
So I thought of doing with respect to the field. -
How to "discard" a row from a view
It seems to me like a simple thing, but I can't find an answer:
I want to programmatically remove a row from an executed view's rowset, but I don't want the underlying entities removed?
[I don't want any pending updates to the entities affected either. It's basically a UI thing - the user does something and I want to make the current row vanish. I don't need or want to re-execute or alter the database as a result of this particular removal.]
Anyone know of a vo.removeRowWithoutAffectingEntities method?
Thanks,
Mike.Found an old thread myself.
How to remove a row from a rowset
Will have to give this "hack" a try, I guess. (Sung, has this API been introduced into an unreleased version yet?)
I had already tried overriding the updateable-entities' remove methods (which are called from row.remove()), but it seems that the view-row hangs around if the entities aren't actually removed. Found some "removeEntityReferences (i.e. set them to null)" method on a QueryCollection and was wondering if calling that followed by a row.remove() might do the trick, but the method's protected anyway. Might still see if I can call it somehow. Any comments on the viability of this, Sung? (Given that the previous work-around was "uncharted territory"....)
Anyway, I guess I'll give the original work-around a shot. (Or make application non-ideally commit and requery!)
Mike. -
can any one help me with the syntax for deleting a row from a table
C'mon, this has nothing to do with Java.
Learn SQL: http://www.google.com/search?q=sql+tutorial+site:w3schools.com -
How to delete a row from a SQL Server CE Table with multiple JOINs?
I want to delete a record from a SQL Server CE table.
There are 3 tables scripts, options and results. I would like to remove a record from the results table. The where clause contains dynamic information which retrieved via other queries to different tables in the same database. These queries work fine and deliver
the desired data.
The Compact server is a clone of a remote table created using the sync framework. The same query to the remote table works fine.
The error I get is:
There was an error parsing the query. [ Token line number = 1,Token line offset = 10,Token in error = from ]
The code that throws the exception is as follows:
Dim connLoc As SqlCeConnection = New SqlCeConnection(My.Settings.ConnectionString)connLoc.Open() Dim strDel As String = "Delete r from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = '" & ds1Loc.Tables(0).Rows(0)(1) & "' AND [Index] = '" & lstIndex & "'"Dim cmdDel As SqlCeCommand = New SqlCeCommandcmdDel.CommandText = strDelcmdDel.Connection = connLoccmdDel.ExecuteNonQuery()
The values held in ds1Loc.Tables(0).Rows(0)(1) and lstIndex are
correct so should not be the problem.
I also tried using parameterised queries
Dim strDel As String = "Delete r from [ResultsTable] r inner join [OptionsTable] o ON o.TestName=r.TestName inner join [ScriptTable] c ON r.TestName=c.TestName WHERE r.TestName = @TestName AND [Index] = @lstIndex"
Dim cmdDel As SqlCeCommand = New SqlCeCommand cmdDel.CommandText = strDel
With cmdDel.Parameters
.Add(New SqlCeParameter("@TestName", ds1Loc.Tables(0).Rows(0)(1)))
.Add(New SqlCeParameter("@lstIndex", lstIndex))
End With
cmdDel.Connection = connLoc cmdDel.ExecuteNonQuery()
I have tried replacing the "=" with "IN" in the the WHERE clause but this has not worked.
Is it the join that is causing the problem? I can do a select with the same search criteria and joins from the same database.
Also this query works with SQL Server. Is it perhaps that SQL CE does not support the Delete function the same as SQL Server 2008? I have been looking at this for a while now and cannot find the source of the error. Any help would be greatly appreciated.Hello,
In SQL Server Compact, we can use join in FROM clause. The DELETE statement fail may be caused by the FOREIGN KEY constraint.
Please refer to:
DELETE (SQL Server Compact)
FROM Clause (SQL Server Compact)
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
How to delete the row from the ADF table using popup box
Hi,
I have one requirement like need to delete a record from the table, but that time need to show one popup window for confirmation of the deletion. I am using Delete buttom from the vo operations. I am able to delete the row with out popup but when i used the popup that time deletion is not happening.
Can any one help me in this.
Regards,Issue was resolved.
-
How to delete single row from multiple
Hi:l
This is my query which provides duplicate rows in my table:
select count(*),CUSTMAST_REQUEST_SRNO,ACTIVITYMAST_SRNO,STATUSMAST_SRNO from REQUEST_TRANS having count(*)>1 group by CUSTMAST_REQUEST_SRNO,ACTIVITYMAST_SRNO,STATUSMAST_SRNO;
O/p:
2 |M984 | 74 |M6
2 |M985 | 74 |M6
2 |M987 | 74 |M6
2 |M992 | 74 |M6
2 |M995 | 74 |M6
2 |M998 | 74 |M6
Here output shows that CUSTMAST_REQUEST_SRNO M984 having two same rows. And now i want
to delete any one of row from that. So, how can i apply it for multiple rows ?
Can any body help-out me in that?
Thank You,
Anup Desai
Edited by: user11688398 on Feb 13, 2013 10:39 PMIf you want to delete all Duplicates and retain Only One row then Below:
delete from REQUEST_TRANS a
where rowid < ( select max(rowid) from REQUEST_TRANS b where a.CUSTMAST_REQUEST_SRNO = b.CUSTMAST_REQUEST_SRNO and a.ACTIVITYMAST_SRNO = b.ACTIVITYMAST_SRNO ... )
Maybe you are looking for
-
Cube not getting all the data from DSO
Hi experts , I have a scenario where i have 256 records in the DSO . I am loading the DSO data into Cube .but the cube is getting loaded with 200 records . Can any body help me in this regard ??? Samir
-
Product costing Cycle run for first time to complete backlog
Dear sir, In my Company we went live in April 2011 and since then we never did settlement of Product costing as process was not stream line , but now (in Aug-2011) it is stream-line and we wanted to do Proper costing Cycle run & settlement too. Can y
-
Problem while using module DynamicConfigurationBean
Hi experts I am doing a file-to-file bypass (<b>without any mapping involved</b>) scenario.My input file name is <comanycode>.<date>.<timestamp>.dat and I want output filename as <companycode>constant.<date><timestamp>.dat To achive this I
-
OBIEE only getting limited number of group membership records
Hey everyone, I'm seeing some strange behavior with the group membership functionality of OBIEE. Right now we're on version 10.1.3.2 and we've implemented SSO and we setup a query against LDAP (AD) to get user group information similar to the way Ven
-
I would embed a font in my css file. I have added fonts in my projects. But instead of refering to the fonts in the code, I would embed the fonts in the css. Is it possible ? Thanks, Pierre