Constructor question - dealing with protected methods

Hi all, I'm trying to run a protected method, got somewhere by making the class a subclass - but not too sure about where to put the constructor for a class I'm trying to use (IQRegister). Can anyone help and point me in the right direction as to what I did wrong?
public class Registration extends IQRegister {
//Create new instance of ConnectionBean
ConnectionBean conBean = new ConnectionBean();
InfoQueryBuilder iqb = new InfoQueryBuilder();
InfoQuery iq;
//IQRegisterBuilder iqRegb = new IQRegisterBuilder();
public Registration( IQRegisterBuilder iqRegb ) {
super( iqRegb );
//This constructor needs to go somewhere that will work>>>>>>>>>>>>>>
IQRegister iqReg = new IQRegister( iqRegb );
public void regUser() {
String server = JOptionPane.showInputDialog( "Enter Server address" );
InetAddress inetaddress;
try {
conBean.connect( inetaddress = InetAddress.getByName( server ));
catch( UnknownHostException unknownhostexception ) {
Object aobj[] = {
"Cancel", "OK"
int i = JOptionPane.showOptionDialog(null, "Retry Server?", server +
": Not Responding", -1, 2, null, aobj, aobj[1]);
if( i == 1 )
regUser();
System.out.println( "Cannot resolve " + server + ":" + unknownhostexception.toString ());
return;
catch( IOException ioexception ) {
Object aobj1[] = {
"Cancel", "OK"
int j = JOptionPane.showOptionDialog( null, "Cannot Connect to:",
server,-1, 2, null, aobj1, aobj1[1] );
if( j == 1 )
regUser();
System.out.println( "Cannot connect " + server);
return;
System.out.println( "Registering User" );
registrationProcess();
public void registrationProcess () {
try {
//Need to getXMLNS packet method getXMLNS() is protected
iqReg.getXMLNS();
catch ( InstantiationException e ) {
System.out.println( "Error in building Registration packet" );
String username = JOptionPane.showInputDialog( "Enter: Username" );
String password = JOptionPane.showInputDialog( "Enter: Password" );
ERROR:
Registration.java:108: cannot resolve symbol
symbol : variable iqReg
location: class Registration
iqReg.getXMLNS();
^
1 error
Thanks again :)

Made some changes to code but getting some varied error here:
Registration.java:31: <identifier> expected
iqReg = new IQRegister( iqRegb );
^
Registration.java:31: cannot resolve symbol
symbol : class iqReg
location: class Registration
iqReg = new IQRegister( iqRegb );
^
Registration.java:104: cannot resolve symbol
symbol : variable iqReg
location: class Registration
iqReg.getXMLNS();
^
3 errors
CODE:
public class Registration extends IQRegister {
//Create new instance of ConnectionBean
ConnectionBean conBean = new ConnectionBean();
InfoQueryBuilder iqb = new InfoQueryBuilder();
InfoQuery iq;
//IQRegisterBuilder iqRegb = new IQRegisterBuilder();
//This constructor problem here>>>>>>>>>>>>
iqReg = new IQRegister( iqRegb );
public Registration( IQRegisterBuilder iqRegb ) {
super( iqRegb );
.......same code..... as above....
Thank you so much for the guidance..

Similar Messages

  • 24p question dealing with capturing

    friend shoots movie in 24P.
    I get to edit movie.
    as far as I know, 24P should be captured at 29.97 and FCP makes the adjustments.
    so.
    when I capture, I get some firece tracers/zebra stripes on the video. I've tried it 3 different ways and everytime, I output a DVD (uncompressed quicktime) and it looks like rubbish.
    help me FCP people! Make me a believer (I'm an AVID guy)

    Welcome to the discussions, Baldy! I was an Avid guy for 10 years before I started using FCP 3 years ago. I haven't looked back.
    Do you have the "zebra stripse" on your TV/video monitor? Were you watching the DVD on TV or on the computer?
    24P already has the pulldown inserted. Just like film shot at 24 and telecined to tape. You may be seeing the pulldown frames. Which is normal. There is also no need to export uncompressed to burn a DVD. Edit in the native format DV. Export Quicktime Movie... with current settings. You gain nothing by "up-rezing" to uncompressed before burning to DVD.
    Patrick

  • Object within Constructor with a method?

    Hi,
    Just trying to understand java code example and its various parts. i.e fields, constructor, methods etc. It is a Blackberry application.
    I am mainly wondering about the part with the " HorizontalFieldManager(USE_ALL_WIDTH )". This has a method attached to it. So if this is the case it is an 'Object' within the UserInterface 'Constructor' that has a 'Method'?
    And the semicolon at the end is not normally present on Methods is it?
    Thanks.
    //// EXAMPLE CODE ///
    public class UserInterface extends UiApplication {
    public static void main(String[] args) {
    UserInterface theApp = new UserInterface();
    theApp.enterEventDispatcher();
    //constructor for UserInterface?
    public UserInterface() {
    pushScreen(new UserInterfaceScreen());
    //UserInterfaceScreen class
    final class UserInterfaceScreen extends MainScreen {
    //fields or variables
    HorizontalFieldManager _fieldManagerTop;
    String _exchange, _convertedStr, _euroStr;
    double _euros, _pounds, _converted;
    int displayed = 0;
    //constructor?
    public UserInterfaceScreen() {
    super();
    LabelField title = new LabelField("Euro Calc",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle(title);
    _fieldManagerTop = new HorizontalFieldManager();
    // An object with a method?
    _fieldManagerGround = new HorizontalFieldManager(USE_ALL_WIDTH ) {
    protected void paintBackground(Graphics graphics)
    graphics.setBackgroundColor(0x00382B79);
    graphics.clear();
    super.paint(graphics);
    };Edited by: duxbuz on Jul 9, 2009 3:20 AM

    Hi,
    this is a way to override the HorizontalFieldManager.paintBackground method whithout declaring a subclass inheriting from HorizontalFieldManager. See ANONYMOUS CLASSES in the following Link.
    Jack

  • How to deal with often ask doc questions in Oracle forums?

    All,
    Lately the number of doc questions in the Database General forum and the SQL and PL/SQL forum seems to increase exponentially.
    Also almost all posters never look up error messages in the on-line documentation, nor do they anything to resolve their own problem.
    Need I to mention ORA-12154? Probably not.
    While the Forums Etiquette post is clear you should be looking up, no one is actually doing that.
    Also apparently no one reads the Forum Etiquette post.
    The result of this is the Search Forum button has become fully useless and almost always turns up 1000s of non-relevant posts.
    Which results in .... people asking that question again
    I am quite aware the situation on http://asktom.oracle.com and many other sites is hardly better.
    I am also aware Jives might be incapable of addressing this properly.
    But can't something be done?
    Eg: Jives automatically consults the on-line documentation or automatically consults Google or even Wikipedia?
    I try to avoid answering doc questions as much as possible, but that doesn't work.
    If I could, I would kick the poster, as this kind of laziness really annoys me.
    When I started my career the Internet didn't exist. The only things available were manuals and the phone to call support, and it wasn't outsourced to Asia.
    Regards
    Sybrand Bakker
    Senior Oracle DBA

    sybrand_b wrote:
    All,
    Lately the number of doc questions in the Database General forum and the SQL and PL/SQL forum seems to increase exponentially.
    Also almost all posters never look up error messages in the on-line documentation, nor do they anything to resolve their own problem.
    Need I to mention ORA-12154? Probably not.
    While the Forums Etiquette post is clear you should be looking up, no one is actually doing that.
    Also apparently no one reads the Forum Etiquette post.gang-faq 'em!
    >
    The result of this is the Search Forum button has become fully useless and almost always turns up 1000s of non-relevant posts.
    Which results in .... people asking that question again
    I am quite aware the situation on http://asktom.oracle.com and many other sites is hardly better.
    I am also aware Jives might be incapable of addressing this properly.
    But can't something be done?
    Eg: Jives automatically consults the on-line documentation or automatically consults Google or even Wikipedia?When I've seen this (as in metalink), it has been more a waste of time than random guessing answers by newbies. Even the best neural network software would be stumped by the range of experience it would have to deal with.
    >
    I try to avoid answering doc questions as much as possible, but that doesn't work.
    If I could, I would kick the poster, as this kind of laziness really annoys me.
    When I started my career the Internet didn't exist. The only things available were manuals and the phone to call support, and it wasn't outsourced to Asia.You are making the same mistake so many newbie user interface designers make: You have to deal with the wide range of experience and expectations of the user population, not a small homogenous group of Dutch programmers who will follow arbitrary rules.
    http://imgs.xkcd.com/comics/duty_calls.png

  • How do I deal with a Java method which returns a class object?

    Hi, I am using JNI to talk to some Java code from c++;
    I have a java method in class B that is defined as
    class B{
    A[] As;
    A getA(int i){
    return As(i);
    where A is one of my classes.
    I would like to know the code to deal with a returned object of type A and then how to access the variables in A from c++.
    I have defined my method pointer as :
    env->GetMethodID(B, "getA", "(I)A;");and have the jclass object of type A.
    Would I do something like jclass A_CLASS = env->FindClass("A");
    jobject A_OBJECT = (A_CLASS)env->CallObjectMethod(B,getA, i) ; If so, how do I then access the fields in A_OBJECT? Please let me know, thanks.

    ilganeli wrote:
    Thanks but this doesn't really help. I know how this is done in Java (see below).Presumably you also understand how that code will fail. At least based on what you have posted here.
    I do not understand the syntax to do the equivalent thing in JNI, specifically, how to cast the returned object from the CallObjectMethod function to be of the appropriate type, namely A, and then how to access those fields. You don't cast it. Didn't do so in your java code either.
    But you define how you are going to attempt to access any object in JNI. If you mess up it fails.

  • ECATT: How to access a protected method of a class with eCATT?

    Hi,
    These is a class with a protected method. now i am willing to automate the scenario with eCATT. Since the method is Protected i am unable to use createobj and use callmethod. Could anyone suggest me a work around for this ?
    Regards
    Amit
    Edited by: Amit Kumar on Jan 10, 2012 9:53 AM

    Hello Anil,
    You can write ABAP Code to do that inside eCATT Command.
    ABAP.
    ENDABAP.
    Limitation of doing that is you can only use local variable inside ABAP.... ENDABAP. bracket.
    Regards,
    Bhavesh

  • HT1848 How to transfer Ipad music NOT purchased from Apple to Macbook Air. Answers found in the Community does not seem to deal with the questions some members already ask.

    how to transfer Ipad music NOT purchased from Apple to MacBook Air.  Answers found in the Community does not seem to deal with similar questions posted to the Community.

    You can only transfer purchases from iTunes on the iPad into iTunes on your computer. If you bought the music from another source, you need to use the source app to transfer the music, or you need a third party app to transfer the music.
    http://www.wideanglesoftware.com/touchcopy/

  • How to use enumeration method deal with sets?

    hi,
    friends, i have some troubles to compile my program on deal with Set.
    here is the problem:
    A:\>javac Set.java
    Set.java:145: Reference to variable set2 in class Set as if it were a method.
    if (set1.contains(elem) != set2(elem))
    ^
    Set.java:189: Wrong number of arguments in method.
    loadResult(set1.complement(set2));
    ^
    Set.java:191: Wrong number of arguments in method.
    loadResult(set1.symmetricComplement(set2));
    ^
    3 errors
    i marked the related part with ???. please help.
    thank you very much.
    my program as following:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    import java.io.*;
    public class Set extends Applet implements ActionListener,                               ItemListener{
    Button add, union, intersect, clear, complement,symmetricComplement;
         List set1List, set2List, activeList, resultList;
         Checkbox set1Selector, set2Selector;
         CheckboxGroup selectorGroup;
         TextField value;
         Set set1, set2, activeSet;
         Vector vector;
         private Button makeButton(String label, Color color) {
              Button b = new Button(label);
              b.setBackground(color);
              b.setFont(new Font("Courier", Font.BOLD, 10));
              return b;
         private Panel makePanel(LayoutManager lm, Color c) {
              Panel p = new Panel();
              p.setLayout(lm);
              p.setBackground(c);
              return p;
         public void init () {
         set1 = new Set();
         set2 = new Set();     //componets
         setLayout(new BorderLayout());
                        //checkboxes
         set1Selector = new Checkbox("Set 1");
         set1Selector.addItemListener(this);
         set2Selector = new Checkbox("Set 2");
         set2Selector.addItemListener(this);
         selectorGroup = new CheckboxGroup();
         set1Selector.setCheckboxGroup(selectorGroup);
         set2Selector.setCheckboxGroup(selectorGroup);
         Panel p = new Panel();
         p.add(set1Selector);
         p.add(set2Selector);
         add("North", p);
                        //Lists
         set1List = new List();
         set1List.setBackground(Color.white);
         set2List = new List();
         set2List.setBackground(Color.white);
         resultList = new List();
         resultList.setBackground(Color.white);
         p = new Panel();
         p.add(new Label("Set1"));
         p.add(set1List);
         p.add(new Label("Set2"));
         p.add(set2List);
         p.add(new Label("Result"));
         p.add(resultList);
         add("Center", p);
                        //Buttons
         add = new Button("Add:");
         add.addActionListener(this);
         value = new TextField(5);
         clear = new Button("Clear");
         clear.addActionListener(this);
         union = new Button("Union");
         union.addActionListener(this);
         intersect = new Button("Intersect");
         intersect.addActionListener(this);
         complement = new Button("Complement");
         complement.addActionListener(this);
         symmetricComplement = new Button("SymmetricComplement");
         symmetricComplement.addActionListener(this);
         p = new Panel();
         p.add(add);
         p.add(value);
         p.add(clear);
         p.add(union);
         p.add(intersect);
         p.add(complement);
         p.add(symmetricComplement);
         add("South", p);
                   //set active checkbox
         selectorGroup.setSelectedCheckbox(set1Selector);
         setActive();
         public Set() {
              vector = new Vector();
         public boolean isEmpty() {
         return vector.isEmpty();
         //public size() {
         //return vector.size();
         public boolean contains(Object o) {
         Enumeration enum = vector.elements();
         while (enum.hasMoreElements()) {
         Object elem = enum.nextElement();
         if (elem.equals(o))
         return true;
         return false;
         public void addElement(Object o) {
              if (!contains(o))
                   vector.addElement(o);
         public Object copy() {
              Set destSet = new Set();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   destSet.addElement(enum.nextElement());
              return destSet;
         public Set union(Set s) {
              Set unionSet = (Set)s.copy();
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements())
                   unionSet.addElement(enum.nextElement());
                   return unionSet;
         public Set intersection(Set s) {
              Set interSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
                   if (s.contains(elem))
                   interSet.addElement(elem);
              return interSet;
         public Set complement (Set set1, Set set2) {     //???
              Set complementSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
                   Object elem = enum.nextElement();
              if (set1.contains(elem) != set2(elem))
                   complementSet.addElement(elem);
              return complementSet;
         public Set symmetricComplement (Set set1, Set set2) { //???
              Set symmetricComplementSet = new Set();
              Enumeration enum = this.vector.elements();
         while (enum.hasMoreElements()) {
              Object elem = enum.nextElement();
              if (elem != set1.set2)
              symmetricComplementSet.addElement(elem);
              return symmetricComplementSet;
         void removeAllElements() {
         vector.removeAllElements();          //differ
         Enumeration elements() {
         return vector.elements();
         public void print(PrintStream ps) {
              String PrintStream;
              Enumeration enum = vector.elements();
              while (enum.hasMoreElements()) {
                   ps.print(enum.nextElement().toString());
                   ps.print(" ");
              //handles action events generated by the buttons
         public void actionPerformed(ActionEvent ae){
              if (ae.getSource() == add) {
              addElement();
              repaint();
              else if (ae.getSource() == union)          
              loadResult(set1.union(set2));
              else if (ae.getSource() == intersect)
              loadResult(set1.intersection(set2));
              else if (ae.getSource() == complement)
              loadResult(set1.complement(set2));     //???
              else if (ae.getSource() == symmetricComplement)
              loadResult(set1.symmetricComplement(set2)); //???
              else if (ae.getSource() == clear) {
              activeSet.removeAllElements();
              activeList.removeAll();
              //handles item events generated by the Checkboxes
         public void itemStateChanged(ItemEvent ie) {
              setActive();
         private void addElement() {
              int i = Integer.parseInt (value.getText());
              activeSet.addElement (new Integer(i));
              activeList.addItem (Integer.toString(i));
         private void setActive() {
              List newActiveList;
              if (selectorGroup.getSelectedCheckbox() ==                               set1Selector){
                   activeList = set1List;
                   activeSet = set1;
              else {
                   activeList = set2List;
                   activeSet = set2;
         private void loadResult(Set resultSet){
              resultList.removeAll();
              Enumeration enum = resultSet.elements();
              while (enum.hasMoreElements())
              resultList.addItem (enum.nextElement().toString());
              repaint();

    public Set complement (Set set1, Set set2) {
       Set complementSet = new Set();
       Enumeration enum = this.vector.elements();
       while (enum.hasMoreElements()) {
          Object elem = enum.nextElement();
          if (set1.contains(elem) != set2(elem))
             complementSet.addElement(elem);
       return complementSet;
    }I'm not sure what you think you are doing with the set2(elem) call. You are treating a variable as if it were a method.
    All you have to do is change set2(elem) to set2.contains(elem) and things would be fine. This is especially weird since you knew that for set1.

  • How to deal with bigdecimal in DataProvider getValue method

    Dear Sir/Madam
    Trying
    employeeDataProvider.getValue("EMPLOYEE.NUMBER0")
    gives an error .
    My Database is Oracle. EMPLOYEE.NUMBER0 is NUMBER(5).
    Databound shows EMPLOYEE.NUMBER0 to be bigdecimal.
    please advise how to deal with bigdecimal to be able to execute
    employeeDataProvider.getValue successfully.
    Thanks a lot for your kind assistance
    Salah Beidas

    employeeDataProvider.getValue("EMPLOYEE.NUMBER0")
    gives an error .What is the error? Does red x appears in the margin in the Java source editor? If so, when you place the curson over the red x, the tooltip shows the error. What does it say.
    Is it a runtime error? Does a page show with a stacktrace? If so, what is the error? When you look at the stack trace do you find your page mentioned anywhere. If so, it shows a line number. What does that code look like (that is pointed to by the line number)?

  • Protected methods in abstract classes

    Hello All
    I have some problem which I cannot find a workaround for.
    I have three classes:
    package my.one;
    public abstract class First {
      protected void do();
      protected void now();
    package my.one;
    public class NotWantToHave extends First {
      protected First obj;
      public NotWantToHave(First O) { obj = O; }
      public void do() { obj.do(); }
      public void now() { obj.now(); }
    package my.two;
    public class Second extends my.one.First {
      protected void do() { System.out.println("Second does"); }
      protected void now() { System.out.println("Second does now"); }
    package my.three;
    public class Three extends my.one.First {
      protected my.one.First obj;
      public Three(my.one.First O) { obj = O; }
      protected void do() { System.out.println("Doing"); }
      protected void now() { obj.now(); } // Not possible, see later text
    Problem is, as one can read in http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html , it says that you cannot access protected members and methods from classes if they are in a different package. However, since my class Three should not concern about the method now() but should use from some other class that implements (i.e. class Second), the question I have is how to do?
    One way would be to implement a class that simply make a forward call to any protected method in the same package the abstract class is in like in class NotWantToHave and pass it to the constructor of class Third while this class was created with an instance of class Second. However, such a call would look very clumsy (new my.three.Third(new my.one.NotWantToHave(new my.two.Second()));). Furthermore, everyone could create an instance of class NotWantToHave and can invoke the methods defined as protected in class First, so the access restriction would be quite useless.
    Does anyone has a good idea how to do?

    Hi
    One way I found is to have a nested, protected static final class in my super-class First and provide a protected static final method that returns a class where all methods of the super-class are made public and thus accessible from sub-classes at will. The only requirement is that a sub-class must invoke this method to encapsulate other implementations of the super-class and never publish the wrapper class instance. This will look as follows:
    package my.one;
    public abstract class First {
      protected final static class Wrap extends First { // extend First to make sure not to forget any abstract method
        protected First F;
        public void do() { F.do(); }
        public void now() { F.now(); }
        protected Wrap(First Obj) { F = Obj; }
      } // end Wrap
      protected final static First.Wrap wrap(First Obj) { return new First.Wrap(Obj); }
      protected abstract void do();
      protected abstract void now();
    } // end First*******
    package my.two;
    public class Second extends my.one.First {
      protected void do() { System.out.println("Second does"); }
      protected void now() { System.out.println("Second does now"); }
    } // end Second*******
    package my.three;
    public class Three extends my.one.First {
      protected my.one.First.Wrap obj;
      public Three(my.one.First O) { obj = my.one.First.wrap(O); }
      protected void do() { System.out.println("Doing"); }
      protected void now() { obj.now(); } // Not possible, see later text
    } // end Third*******
    In this way, I can access all methods in the abstract super class since the Wrap class makes them public while the methods are not accessible from outside the package to i.e. a GUI that uses the protocol.
    However, it still looks clumsy and I would appreciate very much if someone knows a more clear solution.
    And, please, do not tell me that I stand on my rope and wonder why I fall down. I hope I know what I am doing and of course, I know the specification (why else I should mention about the link to the specification and refer to it?). But I am quite sure that I am not the first person facing this problem and I hope someone out there could tell me about their solution.
    My requirements are to access protected methods on sub-classes of a super-class that are not known yet (because they are developed in the far, far future ...) in other sub-classes of the same super-class without make those methods public to not inveigle their usage where they should not be used.
    Thanks

  • Dealing with DB table-entries in ABAP OO

    Hi everybody,
    in ABAP-Reports (normally) we have deal a lot with DB table entries.
    Is there a "state of the art" for doing this with ABAP OO?
    An easy example:
    Asuming I want to select table  entries into an
    internal table from BUT000.And than I want to write: the entries.
    How would this look like in ABAP OO?
    show the internal ZTable be my object?
    or should every BUT000-Table-record be my object?
    Regards Mario
    null
    Message was edited by:
            Mario Müller

    Hello Mario,
    A very good question. This is what is called as modeling.
    I shall give you an approach into this. There is no right and wrong way of doing it. Probably, only a more desriable or better way !!
    How you model it depends on what your object is.
    If you have an internal table of sales orders, still in real world the services or methods are on a single sales order. So the object here is a single sales order.
    => I would model the class to deal with one sales order. (this more or less answers your question)
    2. Just to take this a little further.
    What I would do is have 3 different layers of abstraction.
    A UI class, a business layer class and a DB class.
    UI class can only talk to business class, business can talk to DB class. And the DB class is a static class.
    The UI class is only responsbile to do the display job.
    The UI will display multiple sales orders for eg, so u have an internal table of instances to the business layer.
    The business layer itself does validation, processing for each sales order.
    The business layer can also have soem static methods (or class methods) to select multiple records from Database. This is static, as it is not acting on one sales order, but you are returning multiple. This method should simply call a method of the DB layer.
    The DB layer is meant only to read from DB and write to DB.
    Hope this helps. Remember to reward points, if it does.
    For more highlights into this, refer to some material on design approach or design pattern.
    Best Rgds,
    Prashanth.
    SAP.

  • ALV - access to protected method

    Hello,
    I have a object from class "CL_GUI_ALV_GRID" and want to change the protected attribute "EVT_DELAYED_CHANGE_SELECTION     Constant     Protected" with the method
        CALL METHOD alv_grid->SET_DELAY_CHANGE_SELECTION
          EXPORTING
            time = lv_delay.
    How can I access this protected attribute?
    Thanks in advance,
    Holger

    This will do what you want
    Trick is to define a sub class inheriting the super class where the protected attributes and methods exist in - then you can access the protected methods and attributes.
    If you do this don't forget to call  the SUPER CONSTRUCTOR (of the class you are inheriting from) in your constructor method. Code example shown below.
    Here I want the original and modified table of an alv grid but you can adapt this code to whatever you need.
    Hope it helps.
    create blank screen (100) with a custom container CCONTAINER1 and the following scren logic in it
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    now look at the code here. Note text in Bold
    PROGRAM zdynfieldcat.
    class zcltest definition  deferred.  "For field symbol reference.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    Table structure obtained via new RTTI functionality
    use ALV grid to display and edit.
    Create a blank screen 100 with a custom container called CCONTAINER1.
    James Hawthorne
    Define field symbols as these can't be defined in classes
    field-symbols: <dyn_table> type standard table,
                   <g2> type ref to zcltest,
                   <g1> type ref to cl_gui_custom_container,
                   <actual_tab> type standard table,
                   <outtab> type table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE,
                   <fs3> type table,
                   <fs4> type table,
                   <fs5> type  table.
    <b>class zcltest definition inheriting from cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid</b>
      public section.
        types:  g4 type ref to cl_gui_custom_container.
        types:  g3  type ref to cl_alv_changed_data_protocol.
        data:   i_parent type g4,
                lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
        zog like line of lr_rtti_struc->components. "RTTI
        types: struc like zog.
        types: struc1 type table of struc.
        methods:
           constructor
               importing i_parent type g4,
           disp_tab
               importing  p_er_data_changed type g3,
           create_dynamic_fcat
               importing zogt type struc1
               exporting it_fldcat type lvc_t_fcat.
    Protected section.
       data: stab type ref to data,
            wa_it_fldcat type lvc_s_fcat,
            c_index type sy-index.
    endclass.
    <b>class zcltest implementation.
      METHOD constructor.
        CALL METHOD super->constructor
          EXPORTING
            i_appl_events = 'X'
            i_parent      = i_parent.
          endmethod
    method disp_tab.
    *mt_outtab is the data table held as a protected attribute
    in class cl_gui_alv_grid.
        assign me->mt_outtab->* TO <outtab>. "Original data
        assign p_er_data_changed->mp_mod_rows TO <FS1>.
        stab = p_er_data_changed->mp_mod_rows.
        assign p_er_data_changed->mt_inserted_rows to <fs3>.
        assign p_er_data_changed->mt_deleted_rows to <fs4>.
        assign p_er_data_changed->mt_mod_cells to <fs5>.
        assign stab->* TO <fs2>.
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained already by
    call to form check_data USING P_ER_DATA_CHANGED
    TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2> validate / update / merge etc
      endmethod.</b>
      method create_dynamic_fcat.
        loop at zogt into zog.
          c_index = c_index + 1.
          clear wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          if c_index eq 2.
            wa_it_fldcat-emphasize = 'C411'.
          endif.
          if c_index eq 3.
            wa_it_fldcat-emphasize = 'C511'.
          endif.
          append wa_it_fldcat to it_fldcat .
        endloop.
      endmethod.                    "create_dynamic_fcat
    endclass.                    "zcltest IMPLEMENTATION
    class lcl_grid_event_receiver definition.
      public section.
    methods:
        handle_data_changed
             for event data_changed of zcltest
            for event data_changed of cl_gui_alv_grid
             importing  er_data_changed,
        toolbar
             for event toolbar of zcltest
             importing e_object
             e_interactive,
        user_command
             for event user_command of zcltest
             importing e_ucomm.
    endclass.
    class lcl_grid_event_receiver implementation.
      method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
        call method <g2>->disp_tab
          EXPORTING
            p_er_data_changed = er_data_changed.
      endmethod.                    "handle_data_changed
      method toolbar.
        data : ls_toolbar type stb_button.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.                    "toolbar
      method user_command.
        case e_ucomm .
          when 'EDIT'. "From Tool bar
            perform set_input.
            perform init_grid.
          when 'UPDA'. "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'. "From Tool bar
            leave program.
        endcase.
      endmethod.                    "user_command
    endclass.                    "lcl_grid_event_receiver IMPLEMENTATION
    program data
    include <icon>.
    define any old internal structure NOT in DDIC
    types: begin of s_elements,
    anyfield1(20) type c,
    anyfield2(20) type c,
    anyfield3(20) type c,
    anyfield4(20) type c,
    anyfield5(11) type n,
    end of s_elements.
    data: wa_element type s_elements,
    wa_data type s_elements.
    Note new RTTI functionality allows field detail retrieval
    at runtime for dynamic tables.
    data:
            grid1 type ref to zcltest,
            grid_handler type ref to lcl_grid_event_receiver,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp, "RTTI
            zog like line of lr_rtti_struc->components,  "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid type c,
            new_table type ref to data.
            types: struc like zog.
    data:  zogt type table of struc,
            grid_container1 type ref to cl_gui_custom_container,
            g_event_receiver type ref to lcl_grid_event_receiver,
            ok_code like sy-ucomm,
            i4 type int4.
    start-of-selection.
      call screen 100.
    module status_0100 output.
      if grid_container1 is initial.
        create object grid_container1
        exporting
        container_name = 'CCONTAINER1'.
        assign grid_container1 to <g1>.
        create object grid1
         exporting i_parent = grid_container1.
    we need reference to this instance so we can use
    Methods etc of zcltest class and alv (superclass)
    in our event receiver class.
         assign grid1 to <g2>.
        create object grid_handler.
        set handler:
        grid_handler->user_command for grid1,
        grid_handler->toolbar for grid1,
        grid_handler->handle_data_changed for grid1.
    Get the Internal table structure
        lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
        zogt[] = lr_rtti_struc->components.
          call method grid1->create_dynamic_fcat
          EXPORTING
            zogt      = zogt
          IMPORTING
            it_fldcat = it_fldcat.
    Create dynamic internal table and assign to field symbol.
    Use dynamic field catalog just built.
      call method cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = new_table.
      assign new_table->* to <dyn_table>.
        perform populate_dynamic_itab.
        perform init_grid.
        perform register_enter_event.
    set off ready for input initially
        i4 = 0.
        call method grid1->set_ready_for_input
          EXPORTING
            i_ready_for_input = i4.
      endif.
    endmodule.                    "status_0100 OUTPUT
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands are handled as events
    *in method user_command.
    *we can also get control if the Data entered and the ENTER is pressed by
    *raising an event.
    Control then returns to method handle_data_changed.
    endmodule.                    "user_command_0100 INPUT
    form populate_dynamic_itab.
    load up a line of the dynamic table
      c_dec2 = c_dec2 + 11.
      wa_element-anyfield1 = 'Tabbies'.
      wa_element-anyfield2 = 'ger.shepards'.
      wa_element-anyfield3 = 'White mice'.
      wa_element-anyfield4 = 'Any old text'.
      wa_element-anyfield5 = c_dec2.
      append wa_element to <dyn_table>.
    endform.                    "populate_dynamic_itab
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.                    "exit_program
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.                    "refresh_disp
    form update_table.
    The dynamic table here is the changed table read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
      loop at <dyn_table> into wa_element.
    do what you want with the data here
      endloop.
    switch off edit mode again for next function
      i4 = 0.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "update_table
    form set_input.
      i4 = 1.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "set_input
    form switch_input.
      if i4 = 1.
        i4 = 0.
      else.
        i4 = 1.
      endif.
      call method grid1->set_ready_for_input
        EXPORTING
          i_ready_for_input = i4.
    endform.                    "switch_input
    form init_grid.
    Enabling the grid to edit mode,
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Jimbos Test'.
       call method grid1->set_table_for_first_display
        EXPORTING
          is_layout       = struct_grid_lset
        CHANGING
          it_outtab       = <dyn_table>
          it_fieldcatalog = it_fldcat.
    endform.                    "init_grid
    form register_enter_event.
      call method grid1->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
      create object g_event_receiver.
      set handler g_event_receiver->handle_data_changed for grid1.
    endform.                    "register_enter_event

  • Dealing with 1Million of records

    i'm connecting to DB2 via JDBC. the DB i'm using is quite large. my question is will i get OutOfMemoryError if i just do a simple select such as
    "select * from bigTable"
    since this table contain 1Million records.
    or is JDBC smart enough not to hold every record in the memory but fetching the record as they are used(after calling resultset.next())?
    i see method Statement.setFetchSize(int size). what does it do?
    if JDBC is not smart as i thought then the only way i can prevent OutOfMemoryError is to select a batch of records(i.e. 100/batch)?
    any suggestions?

    Hi,
    Basically, I suggest that partition that big table properly.
    one million records in one table might cost lots of resources
    while database operate that table. It is possible to degrade
    the performance of that table operation as well. Database is
    good for us to deal with the large amount of data. But it needs
    to be well controlled for the best performance.
    good luck,
    Alfred Wu

  • Not sure how to use protected method in arraylisy

    Hi,
    Im wondering how to use the removeRange method in java arraylist, its a protected method which returns void.
    http://java.sun.com/j2se/1.3/docs/api/java/util/ArrayList.html#removeRange(int,%20int)
    So if my class extends Arraylist i should be able to call the method but the compiler states that it still has protected access in arraylist. Does this mean im still overriding the method in arraylist ? A little explanation of whats happeneing would be appreciated as much as an answer
    thanks

    In this codefinal class myClass extends java.util.ArrayList {
        private ArrayList array = new ArrayList();
        public myClass(ArrayList ary){
            for(int i=0;i<7;i++) {
                array.add(ary.get(i));
            ary.removeRange(0,7)
    }You are defining a class called myClass which extends ArrayList.
    You have a member variable called array which is an ArrayList
    You have a constructor which takes a parameter called ary which is an ArrayList
    Since ary is an ArrayList, you cannot call it's removeRange() method unless myClass is in the java.util package. Do not put your class in the java.util package.
    It seems like what you want to do is to move the items in one ArrayList to another ArrayList rather than copying them. I wrote a program to do this. Here it isimport java.util.*;
    public class Test3 {
      public static void main(String[] args) {
        MyClass myClass = new MyClass();
        for (int i=0; i<5; i++) myClass.add("Item-"+i);
        System.out.println("------ myClass loaded -------");
        for (int i=0; i<myClass.size(); i++) System.out.println(myClass.get(i));
        MyClass newClass = new MyClass(myClass);
        System.out.println("------ newClass created -------");
        for (int i=0; i<newClass.size(); i++) System.out.println(newClass.get(i));
        System.out.println("------ myClass now contains -------");
        for (int i=0; i<myClass.size(); i++) System.out.println(myClass.get(i));
    class MyClass extends java.util.ArrayList {
        public MyClass() {}
        public MyClass(MyClass ary){
            for(int i=0;i<ary.size();i++) add(ary.get(i));
            ary.removeRange(0,ary.size());
    }You should notice now that I don't create an ArrayList anywhere. Everything is a MyClass. By the way, class names are normally capitalized, variable names are not. Hence this line
    MyClass myClass = new MyClass();
    In the code above I create an empty MyClass and then populate it with 5 items and then print that list. Then I create a new MyClass using the constructor which takes a MyClass parameter. This copies the items from the parameter list into the newly created MyClass (which is an ArrayList) and then removes the items from the MyClass passed as a parameter. Back in the main() method, I then print the contents of the two MyClass objects.
    One thing which may be a little confusing is this line.
    for(int i=0;i<ary.size();i++) add(ary.get(i));
    the add() call doesn't refer to anything. What it really refers to is the newly created MyClass object which this constructor is building. This newly created object is the 'this' object. So the line above could be rewritten as
    for(int i=0;i<ary.size();i++) this.add(ary.get(i));
    Hopefully this helps a little. The problems you seem to be having are associated with object oriented concepts. You might try reading this
    http://sepwww.stanford.edu/sep/josman/oop/oop1.htm

  • Problem with protected access

    I'm studying for the JCP exam. I've come across a question:
    True or false: If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y.
    A. True
    B. False
    And the answer:
    B. An object that inherits a protected method from a superclass in a different package may call that method on itself but not on other instances of the same class.
    However, I wrote such piece of code:
    File Foo.java in foo package:
    package foo;
    public class Foo {
        protected void fun() {};
    }File Main.java in package test:
    package test;
    import foo.Foo;
    class Main extends Foo {
        void test() {
            fun();  //this is supposed to work
            Main m = new Main();
            m.fun();    //but this is not - but it works!
        public static void main(String args[]) {}
    }So, could anybody explain this to me? Is there a bug in the book I am using or is it me who doesn't understand everything?
    The book: Sybex, Complete Java� 2 Certification: Study Guide, Fifth Edition

    That Sybex book is full of errors. This is only one of them. For example, it tells me that the classpath I specify with -cp MERGES with the system classpath -- anyone who has basic experience with it knows that this is crap.
    Also, there are not just errors, but omissions. For example, it leaves out the whole section about the shift operators (<<, >>, >>>), but there are questions in the book about them. It explains <? extends A>, but not <? super A>.
    Or it tells that you can use the class lock in the body of static methods, but does not explains how! The simplest I could come up with is synchronized(Class.forName("myPackage.myClass")); yes, in a try-catch construct.
    The exam questions are also strange. For example, there is a question about void callMe(String? names). According to the book, the correct answer is "names is an array of Strings in the method". That COULD be true, if it compiled. But it does not...
    I would suggest to learn from another book. Unfortunately I don't know if there are other books for Java 5 yet.

Maybe you are looking for

  • Lightroom 5.7 in Windows 8.1 and MIDI controlers

    Hi, I am looking for a plug-in or other option with what I can use for example the Novation Nocturn in the develop module in LR. But for Windows there is probably no solution aviable There is "Paddy", but that is outdated and not working.. Actually I

  • Developement Mode extensions are not loaded by Photoshop CC after 14.2 update

    I keep my HTML5 extensions in /Users/myaccount/Library/Application Support/Adobe/CEPServiceManager4/extensions. I do have Debug Mode enabled using cli tool: https://github.com/davidderaedt/CCEXTCLI/blob/master/setdebugmode.sh In manifest.xml I have "

  • Why is the latest version of Itunes causing my firefox 9 to crash?

    My firefox 9, which i love btw, started randomly crashing on me very often. I read in a thread online that ppl have fixed this problem by ininstalling Quicktunes or Itunes. I did just that (uninstalled the latest Itunes update version 10.5.02) and my

  • X200 VGA Display Issues

    Ok so I'll try to be as specific as possible.  I have an X200 2024-B27 and I am running windows 8.1. I just recently attempted to hook up a second monitor to it.  Once it is hooked up it works but cuts on and off every 5-10 seconds.  Once it cuts off

  • How to user plsql in apache server

    i have a web used ows 3.0 web server and oracle 8.0 database. now i want to migrate it to linux useing apache web server.but the plsql produce doesn't work , i konw it can use oas 4.0 , but i want use apache server. how can i do???