How to handle exception in select statement
eg:select empno into variable_1 from emp where empno=10 (Fails here the value of variable_1 should be 010)
select empno into variable_1 from emp where empno=102 (sucess)
in this statement i have to handle no_data_found exception
can u please suggest
emp table
empno ename sal
102 abc 1000
103 abcd 10002
In that case, don't use an implicit cursor, use an explicit cursor and do a fetch.
If you're going to use an implicit cursor, you will need to cater for no_data_found and (if the statement doesn't guarentee that only one row will be returned) too_many_rows (or you could leave them unhandled so they can raise an error back to the calling proc).
I would question why you don't want to use an exception block in this case, though.
Similar Messages
-
How to find for which select statement performance is more
hi gurus
can anyone suggest me
if we have 2 select statements than
how to find for which select statement performance is more
thanks®ards
kals.hi check this..
1 .the select statement in which the primary and secondary keys are used will gives the good performance .
2.if the select statement had select up to i row is good than the select single..
go to st05 and check the performance..
regards,
venkat -
How to convert simple SQL Select statements into Stored Procedures?
Hi,
How can I convert following SELECT statement into a Stored Procedure?
SELECT a.empno, b.deptno
FROM emp a, dept b
WHERE a.deptno=b.deptno;
Thanking in advance.
Wajidstored procedure is nothing but a named PL/SQL block
so you can do it like this see below example
SQL> create or replace procedure emp_details is
2 cursor c1 is SELECT a.empno, b.deptno
3 FROM scott.emp a, scott.dept b
4 WHERE a.deptno=b.deptno;
5 begin for c2 in c1
6 LOOP
7 dbms_output.put_line('name is '||c2.empno);
8 dbms_output.put_line('deptno is ' ||c2.deptno);
9 END LOOP;
10 END;
11 /
Procedure created.and to call it use like below
SQL> begin
2 emp_details;
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on;
SQL> /
empno is 7839
deptno is 10
empno is 7698
deptno is 30
empno is 7782
deptno is 10
empno is 7566
deptno is 20
empno is 7654
deptno is 30
empno is 7499
deptno is 30
empno is 7844
deptno is 30
empno is 7900
deptno is 30
empno is 7521
deptno is 30
empno is 7902
deptno is 20
empno is 7369
deptno is 20
empno is 7788
deptno is 20
empno is 7876
deptno is 20
empno is 7934
deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM -
How to utilize index in selection statement
hi
how to utilize index in selection statement and how is it reduces performance whether another alternative is there to reduce performance .
thanksHi Suresh,
For each SQL statement, the database optimizer determines the strategy for accessing data records. Access can be with database indexes (index access), or without database indexes (full table scan).The cost-based database optimizer determines the access strategy on the basis of:
*Conditions in the WHERE clause of the SQL statement
*Database indexes of the table(s) affected
*Selectivity of the table fields contained in the database indexes
*Size of the table(s) affected
*The table and index statistics supply information about the selectivity of table fields, the selectivity of combinations of table fields, and table size. Before a database access is performed, the database optimizer cannot calculate the exact cost of a database access. It uses the information described above to estimate the cost of the database access.The optimization calculation is the amount by which the data blocks to be read (logical read accesses) can be reduced. Data blocks show the level of detail in which data is written to the hard disk or read from the hard disk.
<b>Inroduction to Database Indexes</b>
When you create a database table in the ABAP Dictionary, you must specify the combination of fields that enable an entry within the table to be clearly identified. Position these fields at the top of the table field list, and define them as key fields.
After activating the table, an index is created (for Oracle, Informix, DB2) that consists of all key fields. This index is called a primary index. The primary index is unique by definition. As well as the primary index, you can define one or more secondary indexes for a table in the ABAP Dictionary, and create them on the database. Secondary indexes can be unique or non-unique. Index records and table records are organized in data blocks.
If you dispatch an SQL statement from an ABAP program to the database, the program searches for the data records requested either in the database table itself (full table scan) or by using an index (index unique scan or index range scan). If all fields requested are found in the index using an index scan, the table records do not need to be accessed.
A data block shows the level of detail in which data is written to the hard disk or read from the hard disk. Data blocks may contain multiple data records, but a single data record may be spread across several data blocks.
Data blocks can be index blocks or table blocks. The database organizes the index blocks in the form of a multi-level B* tree. There is a single index block at root level, which contains pointers to the index blocks at branch level. The branch blocks contain either some of the index fields and pointers to index blocks at leaf level, or all index fields and a pointer to the table records organized in table blocks. The index blocks at leaf level contain all index fields and pointers to the table records from the table blocks.
The pointer that identifies one or more table records has a specific name. It is called, for example, ROWID for Oracle databases. The ROWID consists of the number of the database file, the number of the table block, and the row number within the table block.
The index records are stored in the index tree and sorted according to index field. This enables accelerated access using the index. The table records in the table blocks are not sorted.
An index should not consist of too many fields. Having a few very selective fields increases the chance of reusability, and reduces the chance of the database optimizer selecting an unsuitable access path.
<b>Index Unique Scan</b>
If, for all fields in a unique index (primary index or unique secondary index), WHERE conditions are specified with '=' in the WHERE clause, the database optimizer selects the access strategy index unique scan.
For the index unique scan access strategy, the database usually needs to read a maximum of four data blocks (three index blocks and one table block) to access the table record.
<b><i>select * from VVBAK here vbeln = '00123' ......end select.</i></b>
In the SELECT statement shown above, the table VVBAK is accessed. The fields MANDT and VBELN form the primary key, and are specified with '=' in the WHERE clause. The database optimizer therefore selects the index unique scan access strategy, and only needs to read four data blocks to find the table record requested.
<b>Index Range Scan</b>
<b><i>select * from VVBAP here vbeln = '00123' ......end select.</i></b>
In the example above, not all fields in the primary index of the table VVBAP (key fields MANDT, VBELN, POSNR) are specified with '=' in the WHERE clause. The database optimizer checks a range of index records and deduces the table records from these index records. This access strategy is called an index range scan.
To execute the SQL statement, the DBMS first reads a root block (1) and a branch block (2). The branch block contains pointers to two leaf blocks (3 and 4). In order to find the index records that fulfill the criteria in the WHERE clause of the SQL statement, the DBMS searches through these leaf blocks sequentially. The index records found point to the table records within the table blocks (5 and 6).
If index records from different index blocks point to the same table block, this table block must be read more than once. In the example above, an index record from index block 3 and an index record from index block 4 point to table records in table block 5. This table block must therefore be read twice. In total, seven data blocks (four index blocks and three table blocks) are read.
The index search string is determined by the concatenation of the WHERE conditions for the fields contained in the index. To ensure that as few index blocks as possible are checked, the index search string should be specified starting from the left, without placeholders ('_' or %). Because the index is stored and sorted according to the index fields, a connected range of index records can be checked, and fewer index blocks need to be read.
All index blocks and table blocks read during an index range scan are stored in the data buffer at the top of a LRU (least recently used) list. This can lead to many other data blocks being forced out of the data buffer. Consequently, more physical read accesses become necessary when other SQL statements are executed
<b>DB Indexex :Concatenation</b>
In the concatenation access strategy, one index is reused. Therefore, various index search strings also exist. An index unique scan or an index range scan can be performed for the various index search strings. Duplicate entries in the results set are filtered out when the search results are concatenated.
<i><b>Select * from vvbap where vbeln in ('00123', '00133', '00134').
endselect.</b></i>
In the SQL statement above, a WHERE condition with an IN operation is specified over field VBELN. The fields MANDT and VBELN are shown on the left of the primary index. Various index search strings are created, and an index range scan is performed over the primary index for each index search string. Finally, the result is concatenated.
<b>Full Table Scan</b>
<b><i>select * from vvbap where matnr = '00015'.
endselect</i></b>
If the database optimizer selects the full table scan access strategy, the table is read sequentially. Index blocks do not need to be read.
For a full table scan, the read table blocks are added to the end of an LRU list. Therefore, no data blocks are forced out of the data buffer. As a result, in order to process a full table scan, comparatively little memory space is required within the data buffer.
The full table scan access strategy is very effective if a large part of a table (for example, 5% of all table records) needs to be read. In the example above, a full table scan is more efficient than access using the primary index.
<i><b>In Brief</b></i>
<i>Index unique scan:</i> The index selected is unique (primary index or unique secondary index) and fully specified. One or no table record is returned. This type of access is very effective, because a maximum of four data blocks needs to be read.
<i>Index range scan:</i> The index selected is unique or non-unique. For a non-unique index, this means that not all index fields are specified in the WHERE clause. A range of the index is read and checked. An index range scan may not be as effective as a full table scan. The table records returned can range from none to all.
<i>Full table scan:</i> The whole table is read sequentially. Each table block is read once. Since no index is used, no index blocks are read. The table records returned can range from none to all.
<i>Concatenation:</i> An index is used more than once. Various areas of the index are read and checked. To ensure that the application receives each table record only once, the search results are concatenated to eliminate duplicate entries. The table records returned can range from none to all.
Regards,
Balaji Reddy G
***Rewards if answers are helpful -
How to handle exceptions in web dyn pro
Hi Frndz....
Can any one kindly xplain how to handle exceptions in web dyn pro..like we hav exceptionhandling in java ....so is there any for NWDS
THANKS & REGARDS
RajeshHi,
Web Dynpro Java is basically java only.i.e You program in java. Hence exceptions are supported in the same way as in java i.e. via try,catch and finally block.
Additionally,
In 04/04s if you create a method in any controller in web dynpro you cann't specify exception that can be thrown in the method. This is now possible in new programming web dynpro model in CE.
Hence when creating a method you can also specify custom or core java (lib)excetions.
Regards,
Ashwani Kr Sharma -
How to handle exception thrown in standard bo method in the workflow design
Hi Experts
how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.@jrockman li
Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
a sample Snippet for understanding purpose
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = <path>
filetype = 'ASC'
IMPORTING
filelength = lv_len
TABLES
data_tab = l_txt_tab
EXCEPTIONS
file_write_error = 1 " If this Exception occurs
invalid_type = 2
no_authority = 3
unknown_error = 4
OTHERS = 10.
CASE sy-subrc.
WHEN 1. " SY-SUBRC value will be 1 then,
" Pass or set the value back to the workflow conatiner element
ENDCASE. -
How RMI handle exception in RMI kernel ?
hi everyone.
How RMI handle exception in RMI kernel ?
That is , when RMI catch an exception ,
what RMI should do to handle the exception?
best regards.it throws an exception (some derived class of RemoteException) which is transmitted to, rethrown at, and must be caught at, the client.
-
How to handle exceptions thrown by event
Hi all,
i have this slight problem, i'm trying to handle accessing a databse from a button click, i'm trying to simulate somebody logging on to a network. the code is as follows;
*@author James Taylor
*@version 30-11-2003
*Logon gui
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class LogonUI extends JFrame {
//instance variables
private JLabel userNameL;
private JPasswordField password;
private JButton logon;
ButtonHandler handler;
Connection con;
Statement stmt;
*Constructor initialises and creates UI, adds functionality to the button.
public LogonUI() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
super("Employee Logon");
Container c = getContentPane();
c.setLayout(new FlowLayout() );
//handles what happens when user presses the button
handler = new ButtonHandler();
userNameL = new JLabel("Please Enter Password:");
c.add(userNameL);
password = new JPasswordField(15);
c.add(password);
logon = new JButton( "Logon" );
//anonymous inner class that is created once the button is pressed.
//it connects to database to validate user
logon.addActionListener( handler );
c.add(logon);
c.setBackground( Color.pink );
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setSize(250,150);
setVisible(true);
*class that opens connection to validate user
private class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent ae)throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
try{
boolean isValidUser = false;
//Load mysql driver
Class.forName("com.mysql.jdbc.Driver").newInstance();
//make a connection
String url = "jdbc:mysql://localhost/flight";
con = DriverManager.getConnection(url)
//Create and instantiate a statement obj
stmt = con.createStatement();
//get a result set
ResultSet rs = stmt.executeQuery("SELECT Password FROM employees");
//Iterate through the result set
while ( rs.next() ){
String savedPassword = rs.getString("Password");
if (password.getText().equals(savedPassword) ){
isValidUser = true;
JOptionPane.showMessageDialog(null,"Yipeeeee");
if (isValidUser == false){
JOptionPane.showMessageDialog(null,"Invalid Password");
stmt.close();
con.close();
}catch(Exception e){ e.printStackTrace();}
public static void main (String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
LogonUI testAirApp = new LogonUI();
}When the user presses the button the app tries to validate the user.
I have not been able to test the code due to SQL Exceptions thrown in the handler class, and when i try and throw them up from here i get;
LogonUI.java:52: actionPerformed(java.awt.event.ActionEvent) in LogonUI.ButtonHandler cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; overridden method does not throw java.lang.InstantiationExceptionAny ideas on my code and how to handle these exceptions will be very appreciated. Regards, JamesTurn your checked exceptions into unchecked exceptions and retrieve the cause later:
RuntimeException unchecked = new RuntimeException(checked);
Throwable t = unchecked.getCause();Stephen -
How to handle exception CX_SY_REF_IS_INITIAL
hi experts,
im working on a test scenario for abap mapping in SAP XI im getting this error
An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause Dereferencing of the NULL reference
i understand that i need to catch this exception in the abap coding but i'm not familiar with oops concepts
can any one please suggest me how to handle this exception for the following code...
method IF_MAPPING~EXECUTE.
break x1149.
* initialize iXML
TYPE-POOLS: ixml.
class cl_ixml definition load.
** Instances & Variable declaration =======================
* instance main factory
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
* instance input stream factory
l_streamfactory TYPE REF TO if_ixml_stream_factory,
* instance input stream
l_istream TYPE REF TO if_ixml_istream,
* instance input document
l_document TYPE REF TO if_ixml_document,
* instance parse input document
l_parser TYPE REF TO if_ixml_parser,
* instance for elements within the nodes
node TYPE REF TO if_ixml_node,
*instance of nodemap
nodemap TYPE REF TO if_ixml_named_node_map,
* instance for iterator
iterator TYPE REF TO if_ixml_node_iterator,
name TYPE string,
value TYPE string,
* instance main factory
o_ixml TYPE REF TO if_ixml,
* instance output document
o_document TYPE REF TO if_ixml_document,
* instance output stream
o_istream TYPE REF TO if_ixml_ostream,
* instance parse output document
o_parser TYPE REF TO if_ixml_parser,
* instance fot renderer
renderer type ref to if_ixml_renderer,
irc type i,
l_xml_size TYPE i,
*ROOT ELEMENT
l_element_MT_DEMANDTEC_COST TYPE REF TO if_ixml_element,
*NEXT CHILD ELEMENT FROM THE ABOVE PARENT
l_element_DT_DEMANDTEC TYPE REF TO if_ixml_element,
*CHILDREN1 ELEMENT FOR DT_DEMANDTEC
l_element_DT_WHSE TYPE REF TO if_ixml_element,
*CHILDREN2 ELEMENT FOR DT_DEMANDTEC
l_element_DT_DC TYPE REF TO if_ixml_element,
*CHILDREN3 ELEMENT FOR DT_DEMANDTEC
l_element_DT_PLANT TYPE REF TO if_ixml_element,
*CHILDREN4 ELEMENT FOR DT_DEMANDTEC
l_element_DT_QTY TYPE REF TO if_ixml_element.
*saving the xml document
DATA: l_xml_table TYPE TABLE OF t_xml_line.
types: begin of t_source,
whse(5),
dc(4) ,
plant(4),
qty type i,
end of t_source.
types: tt_source TYPE STANDARD TABLE OF t_source.
data: wa_source type t_source.
data: it_source TYPE tt_source,
ivalue type string.
* Procedures and business logic =======================================
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
* create input stream
l_istream = l_streamfactory->create_istream_xstring( source ).
* initialize input document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* parse input document
l_parser->parse( ).
* Validate a document
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
* Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
refresh : it_source.
node ?= l_document.
CHECK NOT node IS INITIAL.
* create a node iterator
iterator = node->create_iterator( ).
* get current node
node = iterator->get_next( ).
* loop over all nodes
WHILE NOT node IS INITIAL.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
* element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WHEN if_ixml_node=>co_node_text.
* text node
value = node->get_value( ).
if name eq 'DT_WHSE'.
wa_source-whse = value.
ELSEIF name eq 'DT_DC'.
wa_source-DC = value.
ELSEIF name eq 'DT_PLANT'.
wa_source-PLANT = value.
ELSEIF name eq 'DT_QTY'.
wa_source-QTY = value.
COLLECT wa_source INto it_source.
CLEAR wa_source.
ENDIF.
endcase.
node = iterator->get_next( ).
endwhile.
ENDIF.
loop at it_source into wa_source .
at first.
* Creating a ixml factory
o_ixml = cl_ixml=>create( ).
* Creating the dom object model
o_document = l_ixml->create_document( ).
endat.
* Build and Fill root node MT_DEMANDTEC_COST
AT FIRST.
l_element_MT_DEMANDTEC_COST =
O_document->create_simple_element(
name = 'MT_DEMANDTEC_COST'
parent = o_document ).
ENDAT.
* Build and Fill Child node DT_DEMANDTEC for parent
* MT_DEMANDTEC_COST
l_element_DT_DEMANDTEC = O_document->create_simple_element(
name = 'DT_DEMANDTEC'
parent = l_element_MT_DEMANDTEC_COST ).
* Build and Fill Child node1 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-WHSE.
l_element_DT_WHSE = O_document->create_simple_element(
name = 'DT_WHSE'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node2 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-DC.
l_element_DT_DC = O_document->create_simple_element(
name = 'DT_DC'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node3 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-PLANT.
l_element_DT_PLANT = O_document->create_simple_element(
name = 'DT_PLANT'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node4 DT_QTY for parent DT_DEMANDTEC
ivalue = wa_source-QTY.
l_element_DT_QTY = O_document->create_simple_element(
name = 'DT_QTY'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
endloop.
* render document ======================================================
* create output stream
o_istream = l_streamfactory->create_ostream_xstring( result ).
* Connect internal XML table to stream factory
o_istream = l_streamfactory->create_ostream_itable( table =
l_xml_table ).
renderer = o_ixml->create_renderer( ostream = o_istream
document = o_document ).
irc = renderer->render( ).
* how do i catch the exception for type CX_SY_REF_IS_INITIAL ...?
endmethod.
full reward points for answers.
Thanks & Regards,
Uday Kumar.
Edited by: UDAY on May 6, 2008 9:32 PMHi Uday,
Its occurs because you're trying to access a objects with null reference. Or you forgot to create an instance or an error occurs during the instance creation. So You should put all your "Procedures and business logic" inside a Try/catch block. as follow.
" Define a class exception object to get error message......
DATA o_exception TYPE REF TO cx_sy_ref_is_initial.
"// Use the statment Try block to catch the error.
TRY.
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
* create input stream
l_istream = l_streamfactory->create_istream_xstring( source ).
* initialize input document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* parse input document
l_parser->parse( ).
* Validate a document
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
* Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
refresh : it_source.
node ?= l_document.
CHECK NOT node IS INITIAL.
* create a node iterator
iterator = node->create_iterator( ).
* get current node
node = iterator->get_next( ).
* loop over all nodes
WHILE NOT node IS INITIAL.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
* element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WHEN if_ixml_node=>co_node_text.
* text node
value = node->get_value( ).
if name eq 'DT_WHSE'.
wa_source-whse = value.
ELSEIF name eq 'DT_DC'.
wa_source-DC = value.
ELSEIF name eq 'DT_PLANT'.
wa_source-PLANT = value.
ELSEIF name eq 'DT_QTY'.
wa_source-QTY = value.
COLLECT wa_source INto it_source.
CLEAR wa_source.
ENDIF.
endcase.
node = iterator->get_next( ).
endwhile.
ENDIF.
loop at it_source into wa_source .
at first.
* Creating a ixml factory
o_ixml = cl_ixml=>create( ).
* Creating the dom object model
o_document = l_ixml->create_document( ).
endat.
* Build and Fill root node MT_DEMANDTEC_COST
AT FIRST.
l_element_MT_DEMANDTEC_COST =
O_document->create_simple_element(
name = 'MT_DEMANDTEC_COST'
parent = o_document ).
ENDAT.
* Build and Fill Child node DT_DEMANDTEC for parent
* MT_DEMANDTEC_COST
l_element_DT_DEMANDTEC = O_document->create_simple_element(
name = 'DT_DEMANDTEC'
parent = l_element_MT_DEMANDTEC_COST ).
* Build and Fill Child node1 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-WHSE.
l_element_DT_WHSE = O_document->create_simple_element(
name = 'DT_WHSE'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node2 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-DC.
l_element_DT_DC = O_document->create_simple_element(
name = 'DT_DC'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node3 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-PLANT.
l_element_DT_PLANT = O_document->create_simple_element(
name = 'DT_PLANT'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node4 DT_QTY for parent DT_DEMANDTEC
ivalue = wa_source-QTY.
l_element_DT_QTY = O_document->create_simple_element(
name = 'DT_QTY'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
endloop.
* render document ======================================================
* create output stream
o_istream = l_streamfactory->create_ostream_xstring( result ).
* Connect internal XML table to stream factory
o_istream = l_streamfactory->create_ostream_itable( table =
l_xml_table ).
renderer = o_ixml->create_renderer( ostream = o_istream
document = o_document ).
irc = renderer->render( ).
" The Statement CATCH define a block that catches the exceptions of the
" exception class cx_sy_ref_is_initial
CATCH cx_sy_ref_is_initial INTO o_exception.
" If you need to get the error message text do as follow
DATA errorMsg type string.
" Get the message text
errorMsg = o_exception->GET_TEXT( ).
" Display the error information
MESSAGE errorMsg TYPE 'I'.
ENDTRY.
The TRY block defines a guarded area whose class-based exceptions can be caught in the subsequent CATCH blocks. If no exception occurs in the TRY block and it reaches its end, the system continues the processing after ENDTRY. If a class-based exception occurs in the TRY block, the system searches for an exception handler in the same or an external TRY control structure.
Font: SAP Help
You can see a how to create and use an exception in this example [ ABAP Objects - Defining a Class-based exceptions|https://wiki.sdn.sap.com/wiki/x/19w] .
Best Regards.
Marcelo Ramos -
How to pass values in select statement as a parameter?
Hi,
Very simple query, how do I pass the values that i get in the cursor to a select statement. If table1 values are 1,2,3,4 etc , each time the cursor goes through , I will get one value in the variable - Offer
So I want to pass that value to the select statement.. how do i do it?
the one below does not work.
drop table L1;
create table L1
(col1 varchar(300) null) ;
insert into L1 (col1)
select filter_name from table1 ;
SET SERVEROUTPUT ON;
DECLARE
offer table1.col1%TYPE;
factor INTEGER := 0;
CURSOR c1 IS
SELECT col1 FROM table1;
BEGIN
OPEN c1; -- PL/SQL evaluates factor
LOOP
FETCH c1 INTO offer;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(offer);
select * from table1 f where f.filter_name =:offer ;
factor := factor + 1;
DBMS_OUTPUT.PUT_LINE(factor);
END LOOP;
CLOSE c1;
END;Hi User,
You are looking somethuing like this, as passing the values to the Cursor as a Paramter.
DECLARE
CURSOR CURR (V_DEPT IN NUMBER) --- Cursor Declaration which accepts the deptno as parameter.
IS
SELECT *
FROM EMP
WHERE DEPTNO = V_DEPT; --- The, Input V_DEPT is passed here.
L_EMP EMP%ROWTYPE;
BEGIN
OPEN CURR (30); -- Opening the Cursor to Process the Value for Department Number 30 and Processing it with a Loop below.
DBMS_OUTPUT.PUT_LINE ('Employee Details for Deptno:30');
LOOP
FETCH CURR INTO L_EMP;
EXIT WHEN CURR%NOTFOUND;
DBMS_OUTPUT.PUT ('EMPNO: ' || L_EMP.EMPNO || ' is ');
DBMS_OUTPUT.PUT_LINE (L_EMP.ENAME);
END LOOP;
CLOSE CURR;
DBMS_OUTPUT.PUT_LINE ('Employee Details for Deptno:20'); -- Opening the Cursor to Process the Value for Department Number 20
OPEN CURR (20);
LOOP
FETCH CURR INTO L_EMP;
EXIT WHEN CURR%NOTFOUND;
DBMS_OUTPUT.PUT ('EMPNO: ' || L_EMP.EMPNO || ' is ');
DBMS_OUTPUT.PUT_LINE (L_EMP.ENAME);
END LOOP;
CLOSE CURR;
END;Thanks,
Shankar -
How build where clause in select statement in FM for Virtual provider
Hi
I looking for example of FM for Virtual provider where I find code how assign to select statement "where" clause value from query variable.
In following code how build t_r_custtype range and how assign value to it.
CODE********************************
TYPE-POOLS: abap.
initialize
CLEAR: e_t_data, e_t_msg.
this is specific to infoprovider VIRTPROV
CHECK i_infoprov = 'VIRTPROV'.
FIELD-SYMBOLS: <l_s_sbook> TYPE sbook,
<l_s_data> TYPE ANY.
DATA: l_t_component TYPE abap_compdescr_tab,
l_t_sbook TYPE TABLE OF sbook.
initialize
CLEAR e_t_data.
Data selection / only Business Customer
SELECT * FROM sbook
INTO CORRESPONDING FIELDS OF TABLE l_t_sbook
WHERE custtype in t_r_custtype.
ENDCODE********************************
Thanks a lot
AdamHello,
Would you like fill the ranges in Customer exit for BEx..?
If Yes. please refer the attachment for the whole code...
"Sample code in Customer Exit in BEx"
IF i_step = 2.
CASE i_vnam.
WHEN 'ZDAY_CX'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDAY_IN'.
CLEAR: l_s_range.
ZT_DT1 = loc_var_range-low.
ZT_DT2 = loc_var_range-HIGH.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT1
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZFIDAY .
E_TT =
E_ULTKZ =
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT2
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZLSDAY.
E_TT =
E_ULTKZ =
l_s_range-low = ZFIDAY .
l_s_range-high = ZLSDAY .
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
*****************************************End*************************************
**To get the From date (For Text Variable) as per the user input date interval range**
WHEN 'ZR_S'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDAY_IN'.
CLEAR: l_s_range.
ZT_DT1 = loc_var_range-low.
ZT_DT2 = loc_var_range-HIGH.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = 0
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT1
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZFIDAY .
E_TT =
E_ULTKZ =
l_s_range-low0(2) = ZFIDAY6(2).
l_s_range-low+2(1) = '.'.
l_s_range-low3(2) = ZFIDAY4(2).
l_s_range-low+5(1) ='.'.
l_s_range-low6(4) = ZFIDAY0(4).
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
*****************************************End*************************************
Please let me know if any clarification required..
Rinku.. -
How to handle exceptions of rfc in web dydnpro
hi all,
i want to handle exceptions of Remote function module in webdynpro.how can we do that one.are there any variables in model class for those exceptions.
regards
NaiduHi,
Hope the following snippet answers ur query
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try{
wdContext.currentB_Quotation_Createfromdata_InpElement().modelObject().execute();
wdContext.nodeOutputQuotation().invalidate();
} catch(WDDynamicRFCExecuteException ce) {
manager.reportException(ce.getMessage(), false); -
How to handle exceptions in a Service
Hi,
I'm trying to get the new Service (background thread) stuff working and am close but I have a problem with handling exceptions that are thrown in my Task. Below is my code, does anyone know if I am doing something wrong, or is this just a flaw in the system at the moment:
Here is my service:
public class TestService extends Service<String>
protected Task<String> createTask()
return new Task<String>()
protected String call() throws Exception
System.out.println("About to throw exception from inside task");
throw new Exception("Test failure");
}Here is my code using this service:
public void doTest()
final TestService test = new TestService();
test.stateProperty().addListener(new ChangeListener<Worker.State>()
public void changed(ObservableValue<? extends Worker.State> source, Worker.State oldValue, Worker.State newValue)
System.out.println("State changed from " + oldValue + " to " + newValue);
test.start();
}When the task throws its exception I was hoping to get a state change to FAILED but the callback is never triggered. I've tried listening for invalidation of the state and also tried listening to all the other properties on Service (running, progress, exception, etc). There doesn't seem to be any feedback after the exception has been thrown.
Am I using this wrong, or is it a bug?
Cheers for you help,
zonskiHi,
This was working in the build #32. I updated the JavaFX to build #36 and it stopped working.
I checked in the latest build #37 as well which was released last week and this doesn't work here as well.
If the task is succeeding the state is getting changed to SUCCEEDED but in case of an exception there is no change in the state
Edited by: user12995677 on Aug 3, 2011 2:07 AM -
How to handle exceptions / errors in LiveCycle
Hello All ,
I want to handle some exception / errors that may arise while the user is filling the form so that the JavaScript console should not show any error rather we can simply show an alert / message .
Say I got a dynamic table where the user can add / delete row at run time . There is a minimum count for the no.of rows . Suppose the user clicks the delete button without adding a new row then the JavaScript console will show error . I know we can handle this by using if else statements where depending on the instance manager count the deletion of rows are permitted . I want to know is it possible here to write a code to handle exception considering this thing as an exception without using the If-else statement ?? Just a thought.
Thanks.
Bibhu.What you're looking for is the javascript:
try{
// code
} catch (err) {
// fail code
However, this is not the right way to solve your problem: Exception handling is for handling exceptions, and a scenario that you know can come to pass (such as the user clicking the removeInstance button when there are none to remove) is not an exception.
Don't misunderstand me - putting code inside try/catch is 'good developer manners' (I do it myself all the time), and I strongly encourage you to do the same. Although only for handling exception sprung from code that you think should work just as fine without them.
A better way of solving your particular problem is to remove the minus-button if there are no instances to remove. -
I have catch some exception ,but i don't know how to handle them. I means that if a caller call my method, the caller how to know exception .
This is my codes:
public byte[] encrypt(String algth,byte[] obj,Key key){
byte[] data=null;
try{
Cipher cipher = Cipher.getInstance(algth);//encrypted secretkey
cipher.init(Cipher.ENCRYPT_MODE,key);
data=cipher.doFinal(obj);
}catch(NoSuchAlgorithmException e){
}catch (NoSuchPaddingException e) {
}catch(InvalidKeyException e){
}catch(IllegalBlockSizeException e){
}catch(BadPaddingException e){
return data;
Can you tell me how to handle NoSuchAlgorithmException ,NoSuchPaddingException,InvalidKeyException and so onyou dont. you're stuffed. If there's 'NoSuchPadding' or NoSuchAlgorithm, or the encryption fails (the other 3), nothing you can do at that point will change that fact.
2 options.
return null, and check the return value every time you call the function
throw an exception, either the exception caught, or one of your own design with information pertinent to your application.
Maybe you are looking for
-
Running BOINC - Rosetta on an iMac G5 OS 10.4.7.
Can anyone solve the problem of running the above Application. At present I only receive 1/3 to 1/2 credit for work done. They say it is because BOINC 5.4.9 is not optimized for PPC's so the work output is much less than theoretically possible based
-
SOAP -Client Certificate Authentication in Receiver SOAP Adapter
Dear All, We are working on the below scenario SAP R/3 System -> XI/PI -> Proxy -> Customer In this, SAP R/3 System sends a IDOC and XI should give that XML Payload of IDOC to Customer. Cusomer gave us the WSDL file and also a Certificate for authen
-
I am getting the following message on my 4404 (running 4.2.61). We currently have 48 APs associated to it. We do not have aggressive load balancing enabled. I did a search on the error message below but I was not able to find much info about it on ci
-
Zcl_file_util= file_copy Issue
Hi, This is my first post here after some time I've been reading here, great community I must say (-: Let me apologize before I proceed to my question as I'm a PURE abap noob and trying my best to get the answers from former topics but it's not alway
-
Can we use two costing variants for standards cost estimate release.
Hi, We have 2 plants (plant 5100 and plant 5200) under company code 5000. We have run standard cost estimate(CK11N) for material 98001000027 at plant 5100 using costing variant ZG01 and at plant 5200 using costing variant ZG02. First, we released st