How to check (programmatic) existence of a method in a class implementation

Hi
I need to check the existence of method in a class in a programmatic way and call it only when it is available otherwise proceed with subsequent steps in my ABAP OO Program. Is there way to do it? This is needed in a customer exit situation and each task is implemented with method and not all tasks would have methods implemented.
Any feedback is greatly appreciated.
Thanks

When you try to call the method dynamically and ifthe method doesn't exist, system would complain by raising the exception cx_sy_dyn_call_illegal_method. You can Catch this exception when you call the method.
CLASS lcl_test DEFINITION.
  PUBLIC SECTION.
    METHODS:
      check_exist.
ENDCLASS.                    "lcl_test DEFINITION
DATA: lo_test TYPE REF TO lcl_test.
DATA: lv_method TYPE char30.
lv_method = 'GET_DATA'.
CREATE OBJECT lo_test.
TRY.
    CALL METHOD lo_test->(lv_method).
  CATCH cx_sy_dyn_call_illegal_method.
ENDTRY.
CLASS lcl_test IMPLEMENTATION.
  METHOD check_exist.
  ENDMETHOD.                    "check_exist
ENDCLASS.
Regards,
Naimesh Patel

Similar Messages

  • How to check which is th best method to use in LSMw and the file

    Hi all,
    I am new to LSMW,
    Can know me when i get the file , how to check the which is the Best method ( Batch input, Direct input,BAPI, IDOC)  have to use in LSMW .
    How to check the input file is completely filled and how to check whether it is correct and also how to Prevalidation check has to be done fior the file before uploading.
    Can you provide any documents LSMW also Apprecited.
    Regards,
    Madhavi

    Hi Madhavi,
    To check Correctness & completeness of the file:
    1. The input file structure should be same as source structure what you defined whicle creating LSMW.
    2. Check the following steps to assure the field mapping is done correctly.
    a) Maintain field mapping & conversion rule
    b) Check 'Display Read data'
    c) Check ' Display Converted data''
    Please note LSMW is a tool, which will simply upload the data whatever you are providing. So you need to be careful while making your file and validate it outside SAP ( before upload start)
    Pradeep D

  • How to check the existence of DB400 library from java

    Hi all,
    I actunally need to validate a DB400 library via java. so is there any way to check the existence of DB400 library from java side.
    Thanks in advance.

    Hi Sarvan,
    You might not even need a function to tell you if a record exists or not.
    Here in below example i do a check with exists .you will find couple of other ways too..
    create table t as select * from emp where deptno=10now i set salary of every person present in table 'T' to 1111 in emp table.
    update emp e
    set sal=1111
    where exists
            (select 1
              from t
              where t.empno=e.empno) Remember that plain SQL will always outperform PLSQL.
    Hope it helps
    CKLP
    Edited by: CKLP on Sep 26, 2011 3:41 AM

  • How to check the existence of file without any error dialog?

    Hi everybody,
    I am trying update some labview programs from LV6.1 to LV7.1, I used the
    function "File/Dictionary Info" to check if the file
    exists or not (if the size=0 then file does not exist), and it ran well with
    LV6.1, but now it shows every time a labview error dialog
    about "LabView: file not found..." with 7.1, if this file dosn't exist.
    Sometimes I feel that it is really stupid to show the dialog, because I
    can write handling by myself, if the error should be handled, and
    I don't want all the process is interrupted because of such dialogs. Is
    there any way to shut the dialog down or check the existence of
    file smoothly?
    Thanks a lot!
    L.Wang

    Hello,
    The dialog is probably appearing because you have Auto Error Handling turned on.  This feature is turned on by default in LabVIEW 7.0.  You should go to VI Properties (Ctrl-I) > Execution and deselect "Enable automatic error handling".  Also you should go to Tools > Options > New and Changed in LabVIEW 7.x and deselect "Enable automatic error handling in new VIs".  If you never want to see one of those dialogs again, you can also deselect "Enaeble automatic error handling dialogs"...I wouldn't recommend this, however, as you would never know if one of your VIs had this setting enabled...you would only find out once somebody else tried to use your VI on another LabVIEW install.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How can I read the filter dependent values in abap class implementation ?

    Hi Experts,
    I need read the filter dependent values in my Z Class implementation but I don´t know how to do it.
    In classic badi was via FT_VAL parameter.
    Now how can I do it ?
    Regars,
    Bala

    Rogerio,
    In case of badis the field flt_val gets added automatically as an import parameter when you check FILTER DEPENDENT check box. This is to restrict which implementation of the badi should be executed, if there are more than one.
    There is no such concept when you are building a class.
    If you want one of your methods to be executed on in certain cases, you need add the required logic within the method.
    If you are referring to the FILTER check box in the pic below, that is used for a different purpose. It is used to filter what is displayed on the class builder screen. F1 on the field to know more about the same.
    Thanks,
    Vikram.M

  • How to check the existence of a file?

    Hi,
    I want to know how to use FileNotFoundException to check whether a text file exists in local directory.
    How should I do the code?
    Thanks
    gogo

    Like this:
    private File f = new File ("c:\\projects\\sutil\\err\\temp_err.txt");
       if (f.exists()) {
          f.delete();
       }

  • How to check the existence of a storeProcedure

    Hello everyone,
    today I discovered how to call an oracle store procedure with jdbc classes, and it's been easy with tutorials and reading posts on this forum.
    The problem I have is the following:
    if i try to execute a store procedure which does not exist on the oracle schema with this code:
    try{         
    con = DriverManager.getConnection(databaseurl,username,password);
    cstmt = con.prepareCall"{call procedure_that_not_exist(?,?,?)}";
    cstmt.setString(1, "try");
    cstmt.registerOutParameter( 2, Types.VARCHAR );
    cstmt.registerOutParameter( 3, Types.VARCHAR );
    cstmt.executeUpdate();
    catch(Exception e)
    e.printStackTrace();
    System.out.println(e.getMessage());
    I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'PROCEDURE_THAT_NOT_EXIST' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    how is it possible to check before getting this "not specific error" wheter the procedure exist on the database schema?
    Thank you!
    Gianni

    I mean the error PLS-00201 is not only related to the
    fact that the procedure does not exist, but more
    generally to "identifiers". (what are identifiers?)The 'name' of something. So, using your example code the following is an identifier....
    procedure_that_not_exist
    Other identifiers are variables in procs, table names, field names, constraint names, etc.

  • Check table existence method

    I have the following Java method that is suppose to determine whether a given table exists or not:
    public boolean tableExists(String table) {
    String defstmt = "select TABLE_NAME from ALL_TABLES where (TABLE_NAME = '" + table + "')";
    System.err.println("tableExists: stmt = " + defstmt);
    tc.executeSEL(defstmt);
    ResultSet rs = tc.getRS();
    String tname = new String();
    try {
    while (rs.next()) {
    rs.getString(tname);
    System.err.println("tableExists.try: tname = " + tname);
    rs.close();
    return true;
    catch (SQLException ex) {
    System.err.println("tableExists.catch: tname not found");
    try {
    rs.close();
    catch (SQLException ex1) {
    return false;
    Since this one didn't appear to work reliabily a friend suggested the following:
    public boolean tableExists(String table) {
    boolean exists = false;
    String defstmt = "select TABLE_NAME from ALL_TABLES where (TABLE_NAME = '" + table + "')";
    System.err.println("tableExists: stmt = " + defstmt);
    if (tc.executeSEL(defstmt)) {
    ResultSet rs = tc.getRS();
    try {
    exists = rs.first();
    // This returns false if the rs is empty
    // This should be sufficient if the query will return zero rows or one row.
    // If there's a possibility that the query could return more than one row
    // (for example if multiple schema data is in there and a table name
    // might be duplicated), then this section will need to be more picky.
    System.err.println("tableExists.try: tname found");
    catch (SQLException ex) {
    System.err.println("tableExists.catch: tname not found");
    try {
    rs.close();
    catch (SQLException ex1) {
    return exists;
    Bottom line; neither method seems to be able to determine whether the table exists. Someone out there got any suggestions?
    Thanks in advance
    RCulp

    The method "tc.executeSEL" is in a class "TableConnector" which I use to hold connection data and execute SQL statements. A new instance of the "TableConnector" class is created for each table prior to the check for existence. The method itself is boolean, returning true or false if the SQL runs successfully:
    public boolean executeSEL(String inpstmt) {
    rs = null;
    try {
    Connection conn = ConnectionData.getConnectionData().openConnection();
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery(inpstmt);
    return true;
    //debugdumpRS(rs);
    catch (SQLException ex) {
    System.err.println("SEL Statement = " + inpstmt);
    System.err.println("Error code = " + ex.getErrorCode());
    System.err.println("Error message = " + ex.getMessage());
    System.err.println("SQL state = " + ex.getSQLState());
    return false;
    /*FINALLY CAN NOT BE USED HERE; ERASES THE RESULT SET
    finally {
    if (stmt != null) {
    try {
    stmt.close();
    catch (SQLException ex) {
    System.err.println("Error code = " + ex.getErrorCode());
    System.err.println("Error message = " + ex.getMessage());
    The TableConnector class also has a get method for the ResultSet:
    public ResultSet getRS() {
    return rs;
    I'll try your suggestion and post the result.
    Thanks
    RCulp

  • BOR method "Returnparameter" on class

    Hi all,
    on the BOR object method, there is an option for "Resultparameter" so the method returns a value which can be used in the outgoing payments of a workflowtask.
    How can I achieve this using a method of a class?
    Regards
    Robert

    What about something like this?
    public interface Initializable
         public void initialize(byte[] data);
    public class Factory
         private final Map<Integer, Initializable> map = new HashMap<Integer, Initializable>();
            public void registerClass(int id, Class klass)
                    if (! Initializable.class.isAssignableFrom(klass))
                             // you may also want to ensure the class declares a parameterless constructor
                             throw new IllegalArgumentException("duff class");
                    if (this.map.keySet().contains(id))
                             throw new IllegalArgumentException("duff id");
              this.map.put(id, klass);
         public Initializable createInstance(int id, byte[] data)
                    // need some exception handling of course
              Initializable i = map.get(id).newInstance();
                    i.initialize(data);
                    return i;
    }

  • Programmatically check the existence of objects in the system

    Hi,
    Is there a way to programmatically check the existence of objects? The idea is I'll accept a list of names of objects and their object types and then programmatically check their existence in the system?
    Can you point me to a resource on how to do it?
    Thanks in advance.
    --Carl

    Hi.
    All custom objects (z, y) being referred to a program. May it be z or y table, data element, domain, sapscript form, function module/group.
    The goal is actually to be able to transport a program from a source machine to a target machine. The objects being referred to from the program must also be transported, of course, for it to run properly. Thus, the need to check the objects' existence.
    Thanks.
    --Carl

  • [svn:bz-trunk] 23143: Certain code needs to check the existence of the class validation validator  (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method .

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

  • How to check external file (logo) existence?

    Hello all,
    We use BIP 11.1.1.6 (build 5.12.110)
    In our rtf template, we use external logo with command :
    <fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/>That works perfectly.
    But, we would like to check existence of the logo file before printing it, and if the logofile doesn't exist then display a default logo.
    Is it possible to check file existence in this situation ?
    Thanks in advance,
    Olivier

    Hello AlexAnd,
    I tried to put together all what you said, but as soon as I used <image>, the engine sends this error below:
    Here is my code :
    <?xdoxslt:set_variable($_XDOCTX, 'OU', substring(IdReference/Description, 1, 4))?>
    OU:<?xdoxslt:get_variable($_XDOCTX, 'OU')?>
    <?xdoxslt:set_variable($_XDOCTX, 'LOGOFILE', concat( 'C:\GFS\images\', xdoxslt:get_variable($_XDOCTX, 'OU'),'.jpg'))?>
    LOGOFILE:<?xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')?>
    <?xdoxslt:set_variable($_XDOCTX, 'DEFAULTLOGO', concat( 'C:\GFS\images\', 'Default','.jpg'))?>
    DEFAULTLOGO:<?xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')?>
    <image><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'LOGOFILE')}')"/></image>
    <defaultimage><fo:external-graphic src="url('{xdoxslt:get_variable($_XDOCTX, 'DEFAULTLOGO')}')"/></defaultimage>The error comes before the 2 if commands.
    Here is the error detail:
    [052413_003637400][oracle.xdo.template.FOProcessor][EXCEPTION] oracle.xdo.XDOSAXException: org.xml.sax.SAXException: element image is not supported yet.
         at oracle.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:421)
         at oracle.xdo.template.FOProcessor.generate(FOProcessor.java:1218)
         at RTF2PDF2.runRTFto(RTF2PDF2.java:473)
         at RTF2PDF2.runXDO(RTF2PDF2.java:337)
         at RTF2PDF2.main(RTF2PDF2.java:230)
    Caused by: org.xml.sax.SAXException: element image is not supported yet.
         at oracle.xdo.template.fo.FOHandler.startElement(FOHandler.java:285)
         at oracle.xdo.common.xml.XSLTHandler$SEEntry.sendEvent(XSLTHandler.java:542)
         at oracle.xdo.common.xml.XSLTMerger.startElement(XSLTMerger.java:51)
         at oracle.xdo11g.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:182)
         at oracle.xdo11g.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1322)
         at oracle.xdo11g.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:366)
         at oracle.xdo11g.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:312)
         at oracle.xdo11g.parser.v2.XMLParser.parse(XMLParser.java:218)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at oracle.xdo.common.xml.XDOSAXParser.invokeParse(XDOSAXParser.java:166)
         at oracle.xdo.common.xml.XDOSAXParser.parse(XDOSAXParser.java:122)
         at oracle.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:407)
         ... 4 more
    [052413_003637402][oracle.xdo.template.FOProcessor][ERROR] End Memory: max=227MB, total=98MB, free=47MBI may not clearly translate what you suggested, I think about the setting of <image> and <defaultimage> with command fo:external-graphic, but this came as an immediate thought.
    Any suggestion ?
    Can you help ?
    Thanks,
    Olivier

  • How to check the table existence in JPA

    1) is there a way I can check for existence of the table using JPA, before I read the rows.
    2) If I want to create two tables with same columns (name, time), Should I create two entity objects to insert? is there a way to use one enity class and specify a table to insert ?
    thanks
    Vamshi

    Try this:
    function findNodes(vNode){
         if (vNode.className === "field"){
              if (vNode.isPropertySpecified("name")===true){
                   var myStateName=new RegExp(vNode.name);
                   var returnValue = GFL.search(myStateName);
                   if (returnValue!=-1){
                        this.ui.oneOfChild.border.fill.color.value="192,192,192";
                        this.access="readOnly";
                   else{  
                        this.ui.oneOfChild.border.fill.color.value="255,255,255";//whatever colour is open access
                        this.access="open";
         for (var a=0;a<vNode.nodes.length;a++){
              findNodes(vNode.nodes.item(a));
    findNodes(xfa.form);
    Kyle

  • Checking object existence

    I need help optimizing some code.
    Right now I have a conditional in my program. In one case a file object is created,
    else, the file object is not created. In each case I manually set a flag.
    boolean bfileCreated = true or false
    Whenever I go to access the file object I check the boolean.
    if (bfileCreated) {
    work with object
    However I think this is messy, I don't want to manually set a flag, and then have to check that flag
    all the time. Is there a way to just detect is an object exissts?
    Can I say something like
    if (objMyObject.exists()) {
    work with object
    Assuming that objMyObject is declared in the class, and it may or may have not been initialized.
    I guess that's what I want. Assuming all vars are declared, is there a way to test which
    ones have been initialized?
    // at global scope
    obj myObj;
    // sometimes myObj may get initialized
    if (specialCondition) {
    myObj = new whatever
    // sometimes it may not
    // later on in the class ...
    // I want to know if myObj is initialized
    if (myObj.hasValue())
    or something like that?
    How would I do it?
    What methods are inherited by all java objects that allow for checking this ?
    Thanks
    Josh

    Whats even stranger, is that is I just set a boolean, the compiler warns that
    the object "may not be initialized" the compiler is correct, in some cases
    the object will not be initialized. But why does the compiler care? I noticed that
    if the comipler spits out messages, my class files aren't generated, thus I need
    to keep the compiler from spitting out messages, so what I have to do is actually
    create the File object in all cases.
    See code
    public void SaveMyStuff(String strFilePath) {
                    int x, y;
                    boolean boolFileCreated = false; // declare a flag for checking stuff
                    File newFile; // declare a newFile var or type File, but dont initialize it yet
                    try {
                            if (strFilePath == "") { // If no file name was passed in then show Save As dialog
                                    JFileChooser fcSaveAs = new JFileChooser();
                                    fcSaveAs.addChoosableFileFilter(new CDBFileFilter());
                                    int returnVal = fcSaveAs.showSaveDialog(this);
                                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                                            newFile = fcSaveAs.getSelectedFile(); // newFile gets assigned
                                            boolFileCreated = true;
                                    } else {
                                            //initialize File object or compiler will complain unless I do this
                                            newFile = new File("save.tmp");
                                            newFile.delete();
                            } else {
                                    newFile = new File(strFilePath);
                                    newFile.delete();
                                    newFile.createNewFile();
                                    boolFileCreated = true;
                            if (boolFileCreated) { // This flag indicates if a file object has been created
                                         //do stuff that I wouldn't do if File object didn't exist
                                         //the compiler complains if I just create the object
                                         //and dont set it, so in the case where i don't want a
                                         //file I have to actually assign , and then delete the file
                                         //I created
                                         //too bad the File constructors all require to create a file
                    } catch (FileNotFoundException fnf) {
                            System.err.println("Unable to open file for writing: " + fnf.getMessage());
                    } catch (IOException ioe) {
                            System.err.println("unable to buffer write file: " + ioe.getMessage());
            }Let me know if you see a better way to do this.
    The file object can't be construvted without actually creating
    a file. Its a lot of overhead since I delete it immedidately/
    I would like to not even have to create the file or the boolean
    in the else case, and then just check for the existence of the
    object when I need to use it.
    Thanks
    Josh

  • How to check the include box on vendor import?

    I am importing vendors using the DTW into B1 2007.  There are 2 outgoing payments setup and I would like them both to have the include box checked on the payment system tab of the BP master.  Is this possible to do during the import?   I did not see a column in the template that address this. 
    I can get one of them checked if I set one as the default vendor payment method but I don't want to do this.  I need them both checked but without having a default.
    Thanks

    Hello,
    I am trying to use the DTW to update the include check box for the payment methods.  If I have two payment methods like "Incoming" and "Outgoing", how would I use the DTW to update those methods?  Do I need two .csv files to do this?  For example:
    Header File
    RecordKey     CardCode
    RecordKey     CardCode
    1                   10000
    Detail File
    RecordKey       LineNum               PaymentMethodCode
    RecordKey       LineNum               PaymentMethodCode
    1                   0                          Incoming 
    1                     1                      Outgoing
    In step 2 of the import wizard I selected my .csv header file for BusinessPartners and then select my detail .csv file for BPPaymentMethods.  I get the error:
    Status                         Key              Reason
    Update Failed              CardCode      Cannot find this object in B1 Application-defined or object-defined error65171
    Thank you.

Maybe you are looking for

  • How can i build a virtual network on mavericks please?

    I'd like to run mavericks and os x server on my mac mini and be able to connect them to simulate a network. I bought vmware fusion 6 for this and think i got it wrong. I can run both as separate virtual machines but i cant get them to connect to each

  • Exit CL_GUI_FRONTEND_SERVICES= FILE_OPEN_DIALOG once I get the file name

    Hi I have where I have a selection screen that finds the file, you can say where to get the file. After that I need to close that window. How do I close it??? Below is an example of my program. After I choose the file and execute the program, I have

  • Nokia PC Suite - Where are the Backup Files

    Hi. Where are the backup files store and what is the extension , I have tried to find them. I want to store them on my D: drive for safety Thanks. Nokia 5800 FW 21.0.025 Solved! Go to Solution.

  • Command to block a port in Vlan

    I have 3 switches interconnecting to each other. A PC in switch A wishes to ping to PC on Switch C. There are 2 paths leading to it, what command can i use to block one of the port so that there is only one path? Is it setting one of the switch as ro

  • How to connect Oracle Form Builder - Oracle Developer Suite 10g - Windows 7

    Hi brothers and sisters, Hope all you are fine. I have installed Oracle Developer Suite 10g on Windows 7 successfully and it is working properly. But when I connect to Oracle Form Builder using Connect window asking: a. User Name b. Password c. Datab