How to access specific row of a database table.
hi all,
i am saving all the hr tables in a internal table.
say, mtable = 'pa0002' is the content of mtable on looping above internal table.
LOOP AT i_itf_list INTO wa_list. "wa_list contains list of hr tables.
mtable = wa_list-tabname.
LOOP AT persno. "persno contains list of personal numbers.
"how to acess particular row of (mtable) dynamically where pernr = persno-pernr."
ENDLOOP.
ENDLOOP.
thanks.
Hi,
Use below code for your reference.
data : ref_table_des type ref to cl_abap_structdescr,
dref type ref to data.
field-symbols : <itab> type standard table,
<wtab> type any.
data : mtable type tabname.
LOOP AT i_itf_list INTO wa_list. "wa_list contains list of hr tables.
clear mtable.
mtable = wa_list-tabname.
LOOP AT persno. "persno contains list of personal numbers.
ref_table_des ?= cl_abap_typedescr=>describe_by_name( mtable ).
create data dref type handle ref_table_des.
assign dref->* to <wtab>.
create data dref like standard table of <wtab>.
assign dref->* to <itab>.
***if you want to select multople rows use below select***********
select * from (mtable)
into table <itab>
where pernr = persno-pernr.
********if you want to select single row use below select************
select single * from (mtable)
into <wtab>
where pernr = persno-pernr.
ENDLOOP.
ENDLOOP.
Vijay
Similar Messages
-
How to access the Mobile Time & Travel database tables?
How can I access the database tables stored in SAPMobileEngine\webapps\me\WEB-INF\wwwroot\te_data\customer\database_2_0\<name_of_declared_table> ??
Formerly the tables were stored in ...\database as XML files and could be viewed with a standard texteditor. Now the files are stored in ...\database_2_0 as DAT files in a special format. How can I get access to the tables? (like longtext.dat or CATS_MY_TABLE_*.DAT)Michael,
Are you running MTT 1.6 SR2 Patch 03?
The database is in serialized format and you will have unserialized them by using Eclipse IDE (or NW Development Studio). This will convert it to xml format. But I think the application itself will need it to be serialized format.
Peter -
How to insert multiple rows in the database table with the high performance
Hello everybody,
I am using the struts,jsp and spring framework. In my application there are 100s of rows i have to insert into the database 1 by 1. I am using usertransaction all other things are working right but i am not getting the real time performance.
Can anyone tell me the proper method to insert multiple records and also with fast speedI don't know much about Spring etc, but if the jdbc Statemenet.addBatch(), Statement.executeBatch() statements let you bundle a whole lot of sql commands into one lump to execute.
Might help a bit... -
How to find interchanged rows in a database table.
Hi All,
Today I encountered a strange problem and as I'm not very good at SQL I'm unable to fix it. So please help me out in fixing this issue.
The issue goes like this. I had a table with two columns say x and y. It should allow only values of one pair only i.e, if a,b is entered b,a cannot be entered. I had already some data in the table and would like to identify such columns where data got interchanged. So can anyone help me out in fixing it.
Any help is appreciated.
Thanks and Regards,
V.Venkateswara Rao.create table no_cons ( x number, y number );
insert into no_cons values ( 1, 2 );
insert into no_cons values ( 2, 1 );
create table has_cons (x number, y number );
create unique index has_cons_uq on has_cons ( to_char(least(x,y)) ||'.'|| to_char(greatest(x,y)) );
begin
for i in ( select * from no_cons ) loop
begin
insert into has_cons values ( i.x,i.y );
exception
when dup_val_on_index then
null;
end;
end loop;
end;
select * from no_cons;
X Y
1 2
2 1
select * from has_cons;
X Y
1 2
select * from no_cons
minus
select * from has_cons;
X Y
2 1 -
How can i count no rows in my database table
plz tell me how can i count no of rows in my database table with[b] ResultSet object
Hi ! hope this code helps you .
We can use the count(*) to get the total no of records in the table ad then access it through the getString method .
import java.sql.*;
public class JdbcTest
public static void main(String [] args ) throws Exception
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String DBURL = "jdbc:odbc:mydsn" ;
Connection conn = DriverManager.getConnection(DBURL);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select count(*) from table1");
rs.next();
System.out.println("total rec = " + rs.getString(1));
Cheers ! -
How to get the last row of a database table.
HI ,
I want to get record exactly from the last row of a database table.
How is that possible?Hi,
To fetch last record from an internal table, just do find the number of records in it and read using index.
DESCRIBE TABLE ITAB LINES L_LINES.
READ TABLE ITAB INDEX L_LINES.
You can also use LOOP .. ENDLOOP but the above method is better (performance wise).
using LOOP .. ENDLOOP.
LOOP AT ITAB.
**do nothing
ENDLOOP.
**process ITAB (Header record of ITAB).
**after ENLOOP, ITAB will have the last record of the internal table.
[here ITAB is internal table as well as header record.]
But what is the requirement?
If you are looking for the current record of an employee then you can use ENDDA = HIGH_DATE.
My advice is to review your requirement again and try to fetch only that record which you need.
Mubeen -
How to access specific camera attributes tree (camera controls) located in MAX with Labview?
I want to be able to access frame, trigger and grab properties. Does anyone know?
Thanks.
/PeterPlease see this related thread http://forums.ni.com/t5/LabVIEW/IMAQdr-Property-Node/m-p/1642950/highlight/false#M590168
Matt
Product Owner - NI Community
National Instruments -
How to access the LOB objects through database links??????????????
Hi
See:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:52297289480186
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5322964030684
And you also might want to get a new keyboard, your '?' seems to be stucked.... -
Programmatically refresh components inside a specific row of an af:table
How to programmatically refresh components inside a specific row of an af:table without refreshing the whole table ?_
I have an af:table displaying a read-only view object. There is an edit button inside the table calling an af:popup, where the user can update some informations and click a submit button to validate his changes.
The action property of this button is a method in a backing been where
- 1 : A stored procedure is called to update several tables (related to my read-only VO).
- 2 : The VO is re-queried (VO. refreshQueryKeepingCurrentRow() )
- 3 : The whole table is refreshed (AdfFacesContext.getCurrentInstance().addPartialTarget(myTable) )
Is it possible to programmatically refresh some components of the current row of the table without refreshing the whole table (point 3)?
I’ve tried to play with the “partialTrigger” property of af:outputText (table:column:outputText), without success.
Thanks
Nicolas"+do you happen to want to refresh following an action on the row? Like a link/button click?+" : NO
There is a table on my page. The user select a row and click on an edit button. This edit button call a popup where the user can modify some information (not directly on the viewObject. All fields in the popup are dummy fields bind to attributes in my backing bean) and then he click on a submit button.
The submit button action execute a method "submitInformation" in a backing been.
public String submitInformation(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pManNo", xManNo.getValue()); //xManNo is an attribute of the backing bean
params.put("pDate", xPeriod.getValue()); //xPeriod is an attribute of the backing bean
// Execute Operation
OperationBinding oper = ADFUtils.findOperation("serviceSubmitInfo");
oper.getParamsMap().putAll(params);
String results = (String)oper.execute();
// Close Popup & Refresh Row if OK
if(!StringUtils.isStringEmpty(results) && results.equals("TRUE")){
closePopup("pt1:popAbs");
refreshMyCol();
}The serviceSubmitInfo method is defined in my serviceImpl
public String serviceSubmitInfo (String pManNo, String pPeriod, ......){
String results =
callStoredFunction("? :=myDatabaseFunction(?, ?, ?, ?)",
new Object[] { pManNo, pPeriod, ...... });
// Commit
getDBTransaction().commit();
// Refresh VO (re-query & set currentRow)
getMyVO().refreshQueryKeepingCurrentRow();
return results; // TRUE if ok
}I want the " refreshMyCol()" method to refresh only the current row and not the whole table...
Regards
Nicolas -
How to select alternate entries from the database table
Hi Experts,
can u help me, how to select alternate entries from the database table.
ThanksAs there is no concept of sequence (unless there is a field specifically included for the purpose), there is no meaning to "alternate" records.
What table do you have in mind, what data does it hold, and why do you want alternate records?
matt -
How to increase the row height of the table in the smartform
Hi,
Can any one say,
How to increase the row height of the table in the smartform.
It is presently show the row width very small, i want to increase the row with of the table in the smartform.
Plase say how can we increase the row height in the smartform.Hi Ravi,
In Smartforms , Select the Table and you can adjust the cell hieghts in OUTPUT OPTIONs TAB.
Reward points if that Helps.
Manish -
How to get selected row index of a Table ?
hi gurus,I'm new to Webdynpro for abap
I'm displaying just Flight details in a Table so
how to get selected row index of a Table and need to be display in Message manager.Hi,
For getting the row index use the following code.
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA index TYPE i.
* navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
lo_el_node = lo_nd_node->get_lead_selection( ).
index = lo_el_node->get_index( ).
node is the name of the node which is binded to the table.
For printing the message u can use code wizard.
Press ctrl-F7. Now Select generate message.
IN this select the method REPORT_SUCCESS
In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
Write the whole code in onLeadSelect of the table.
Regards,
Pankaj Aggarwal -
How to update field values in a database table using module pool prg?
hi
how to update field values in a database table using module pool prg?
we created a customized table, and we put 2 push buttons in screen painter update and display.
but update is not working?
data is enter into screen fields and to internal table, but it is not updated in database table.
thanks in adv
vidyaHI,
we already used the update statement. but its not working.
plz check this.
*& Module Pool ZCUST_CALL_REC
PROGRAM ZCUST_CALL_REC.
TABLES: ZCUST_CALL_REC,ZREMARKS.
data: v_kun_low like ZCUST_CALL_REC-kunnr ,
v_kun_high like ZCUST_CALL_REC-kunnr,
v_bud_low like ZCUST_CALL_REC-budat,
v_bud_high like ZCUST_CALL_REC-budat.
ranges r_kunnr for ZCUST_CALL_REC-kunnr .
ranges r_budat for zcust_call_rec-budat.
DATA: ITAB TYPE STANDARD TABLE OF ZCUST_CALL_REC WITH HEADER LINE,
JTAB TYPE STANDARD TABLE OF ZREMARKS WITH HEADER LINE.
*data:begin of itab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of itab.
*data:begin of Jtab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of Jtab.
CONTROLS:vcontrol TYPE TABLEVIEW USING SCREEN '9001'.
CONTROLS:vcontrol1 TYPE TABLEVIEW USING SCREEN '9002'.
*start-of-selection.
*& Module USER_COMMAND_9000 INPUT
text
MODULE USER_COMMAND_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'ENQUIRY'.
perform multiple_selection.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9001'.
WHEN 'UPDATE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
perform update on commit.
WHEN 'DELETE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*& Module STATUS_9000 OUTPUT
text
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE USER_COMMAND_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
endcase.
ENDMODULE. " USER_COMMAND_9001 INPUT
*& Module STATUS_9001 OUTPUT
text
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9002 INPUT
text
module USER_COMMAND_9002 input.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'UPDATE'.
perform move_data.
UPDATE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE UPDATED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT UPDATED'.
ENDIF.
WHEN 'DELETE'.
perform move_data.
DELETE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE DELETED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT DELETED'.
ENDIF.
endcase.
endmodule. " USER_COMMAND_9002 INPUT
*& Module STATUS_9002 OUTPUT
text
module STATUS_9002 output.
SET PF-STATUS 'ZCUSTOMER1'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_9002 OUTPUT
*& Module update_table OUTPUT
text
module update_table output.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
endmodule. " update_table OUTPUT
***Selection Data
FORM SELECT_DATA.
SELECT mandt kunnr budat code remarks FROM zcust_call_rec INTO
table itab
WHERE kunnr IN r_kunnr AND BUDAT IN R_BUDAT.
ENDFORM.
****append vendor code
FORM APPEND_CUSTOMER_CODE.
clear r_kunnr.
clear itab.
clear r_budat.
refresh r_kunnr.
refresh itab.
refresh r_kunnr.
IF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_high
IMPORTING
OUTPUT = r_kunnr-high.
r_kunnr-option = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I003(0) WITH 'ENTER CUSTOMER NUMBER'.
CALL SCREEN '9000'.
ENDIF.
PERFORM V_BUDAT.
ENDIF.
ENDFORM.
FORM V_BUDAT.
IF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'BT'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-HIGH = v_bud_HIGH.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I002(0) WITH 'ENTER POSTING DATE'.
CALL SCREEN '9000'.
r_budat-low = ''.
r_budat-option = ''.
r_budat-sign = ''.
ENDIF.
ENDIF.
ENDFORM.
*& Form update
text
--> p1 text
<-- p2 text
form update .
commit work.
endform. " update
*& Form move_data
text
--> p1 text
<-- p2 text
form move_data .
clear itab.
refresh itab.
move-corresponding zcust_call_rec to itab.
MOVE ZCUST_CALL_REC-MANDT TO ITAB-MANDT.
MOVE ZCUST_CALL_REC-KUNNR TO ITAB-KUNNR.
MOVE ZCUST_CALL_REC-BUDAT TO ITAB-BUDAT.
MOVE ZCUST_CALL_REC-CODE TO ITAB-CODE.
MOVE ZCUST_CALL_REC-REMARKS TO ITAB-REMARKS.
APPEND ITAB.
delete itab where kunnr is initial.
endform. " move_data
thanks in adv
vidya -
How to tracke the new entries in database table ?
Hi,
How to tracke the new entries in database table ? is there any FM or report is there to check it ?
regards
vishnuHi Vishnu,
u can write a report program for this and in that use the event :
AT NEW <field-name> ( use primary key)
your statements
ENDAT
for eg.
loop at itab ( herfe itab must be of type of table for which u want to track new entries)
at new matnr
write:/ new record
endat
endloop.
schedule this report in background to run in every 5 or 10 mins as per your requirement and hence changes can be tracked.
regards
Vinod -
Randomly selecting some rows from the database table
Hi can some one help me in selecting some rows from a database table which has around 90,000 rows.
Thanks.One thing you might try is the "sample" clause if you have 8i which is supposed to return a random percentage of the table. Say for example, you have a sequence number on your table as the pkey. Then you might try:
select * from <table_name> where pkey in(select pkey from <table_name> sample(10));
This should give you a random 10 percent of the rows in the table but I tried this once and the results seemed unpredictable. For example it returned a different number of rows each time even though the number of rows in the table didn't change.
Hope this works for you.
Maybe you are looking for
-
Using Thunderbird 24.5.0, W7, up-to-date in fixes The delete key and the right click delete suddenly don't delete a messsage. Restarting Thunderbird and then they both work. What should I be looking for?
-
QuadCore i5, 2 hours old, AirPort dropping
Brought it home, turned it on, registered and it connected initially via AirPort without a problem. Did iDisk to repair permissions. A new computer, I went to the Apple/ Software Update/ and it started loading some things that it said needed updated.
-
Hi There, Is there a way to influence the expiration date header for - The apex generated page itself (not that useful, if set to a long time) - For uploaded workspace/application files ? (really useful for large javascripts) I know, you can use 'Exp
-
Content Management / Repository Managers
Hi, I must write IView for selecting Entry Points (Knowledge Management -> Content Management -> Repository Managers). Logical way need I first all Entripoints. Which class gives me the whole list of the Entry Points in the portal? Regards, Raissa
-
Hi Sir, When I retrieve 10 records, I would have a non-database column on form to show the record number from 1..10. When I delete one of the record in the middle of the 10 records, say record 5, all the other record number should be reflected correc