Instantiation and Encapsulation

Hi
Can any one explain me about instantiation and Encasulation with example, i am new to ABAP Objects.
Please dont send any links.
Arun Joseph

Hi,
First let me give small introduction to OO ABAP programing.
Object-oriented programming is a method of implementation in which programs are organized      as cooperative collections of objects, each of which represents  an instance of some class...?
A class is a set of objects that share a common
structure and a common behavior
A class will have attributes ( i.e data definition) and methods ( nothing but functions )
We can also call  object as Instance of the class.
Lets see a simple demo class to calcualte SUM of 2 numbers.
define 2 variables a and b of type i. (Attributes)
SUM is the method name. this will have the logic to do the sum.
2 importing paramers and an exporting parameter res for the method.
Note: you can either create a class either globally or locally..
Goto SE24 to create Global class, this class will be avaialable for use in all the programs, this is like class library with all global classes.
Local class is the one which you create in SE38 i.e; your own program,
by this it is understood that it's scope is only upto that program
SO let us discuss the example with SE24(global class)
give a class name, description,
In the attributes tab, define a and b of type i, level as instance attribute and
visibility as public That means these attributes are available outside this class also. we will come to this later.
in the methods tab give name, level as instance, visibilty as pubilc again.
now double click on the method name, it will take to you to write the code.
(method implementation)
just wirte between the method ---endmethod,
res = num1 + num2.
come back to methods tab, click on parameters button, to define exporting, importing etc.. paramters for your method,
define 'res' as an exporting parameter, 2 variables num1 and num2 as importing parameters.Activate the class.
now you have defined a class.
whenever you want the logic to sum 2 variables, in all those cases you can make use of the SUM method in this class. This is what Reusability is.A very imp. feature of OO ABAP.
So now comes Instantiation.
you can't directly access a class.
You have to create a reference variable of the type of the class, then create an object with the reference variable. (memory allocation).
This step is called Instantiation or Instantiating the class
For this go to se38, in which ever program you want to instatantiate the above class.
do as below.
data: obj type ref to zsow_cl1.
start-of-selection.
create object obj.
Now object of the above class is ready for you.
Now all the contents i.e either attributes or methods etc of the class can be accessed with this object
now you have to call the method 'sum' of the above class using the above object in your program for the sum functionalty.
for that click on Pattern button select 'Abap Object Patterns' press enter
select 'Call method' radio button, give your object name ('OBJ')
class name  ( ZSOW_CL1)
give the method name (SUM)
class and method names can be selected from the F4
press enter.
you will get the below line in your program
CALL METHOD OBJ->SUM
  EXPORTING
    NUM1   =
    NUM2   =
*  IMPORTING
*    RES    =
now define 2 variables of type i to pass the inputs to the method and one more vairable to hold the output coming from the FM
on the whole code in your se38 is as follows.
DATA: OBJ TYPE REF TO ZSOW_CL1,
      X TYPE I,
      Y TYPE I,
      Z TYPE I.
START-OF-SELECTION.
  CREATE OBJECT OBJ.
  X = 10.
  Y = 10.
  CALL METHOD OBJ->SUM
    EXPORTING
      NUM1 = X
      NUM2 = Y
    IMPORTING
      RES  = Z.
  WRITE: Z.
so Z will give the output.
Next is Encapsulation
while defining the method i asked you to give the visibility as Public.
Visibility can be of 3 types:
              Public
              Protected
              Private
public means as i said above the method or varaibles can be used outside the class also.as you did above outside the class you have created an object to the class and
accessed the method.
private means the attributes/methods that you define in the class can only be accessed in/by the method of the same class, they cannot be accessed anywhere else and outside.
change your 'a' parameter visibilty to private and try the below code in se38.
obj->b = 10.
obj->a = 10.
1st line doesn't give error, since 'b' is public attribte,
2nd line will give error since 'a' is now private.
you can use 'a' in the 'SUM' method if you want.
Protected means it can't be accessed outside of the class like with the help of object, but can be accessed in  the child class if defined to the above class.
just post if you have any other doubts after trying this example.
Do reward points if it helps you.
Regards,
Sowjanya

Similar Messages

  • What is difference between abstraction and encapsulation ?

    Hi,
    I am trying to figure out the difference between abstraction and encapsulation but confused.
    Both are used for data hiding then what is the exact difference ?
    Thanks.

    Tushar-Patel wrote:
    I am trying to figure out the difference between abstraction and encapsulation but confused.
    Both are used for data hiding then what is the exact difference ?This is the picture I have:
    When you encapsulate something you get an inside and an outside. The outside is the abstraction. It describes how the encapsulated entity behaves viewed from the outside. This is also called the type. Hidden inside is the implementation. It holds detail information about how the type's behaviour is accomplished.
    It's a very simplified picture but I think it's quite accurate and it works for me.

  • What kind of classes can be instantiated and how it can be done?

    Dear All,
    What kind of classes can be instantiated and how it can be done?
    Can you please explain me in brief and provide sample code for it?
    Thanks,
    Anup Garg

    Hi Anup,
    You can create instances of a Final class...its just that you cannot override its behaviour...
    btw...If you are coding the whole class, you can define a class as Final as below
    CLASS CLASS_NAME DEFINITION FINAL
    ENDCLASS
    Else, if you use the class builder (SE24), you just need to check the Final checkbox available in the Properties section of the class.
    ~ Piyush Patil

  • Abstraction and Encapsulation i.e basic oops concepts gist and their unders

    I have gone to many sites and everywhere got some difference in defintion of abstraction and encapsulation.
    Below i tried to summarize the findings of both and have some questions which are inline with understanding.
    Encapsulation:-
    Hiding internal state and requiring all interaction to be performed through an object's methods is known
    as data encapsulation — a fundamental principle of object-oriented programming.
    Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.
    Question1:- Agreed that we are hiding the instance variable details but again we do expose them with getter and setter
    methods. Is it not the violation of encapsulation? What advantage it provides exposing the internal state thru methods
    (like getter and setter) but not declaring stae with public modifier.?
    Question2:- If class does not have any state variable and has some just simple methods printing hello world.
    Can we still say it is encapsulation?
    Abstraction:-Abstraction in Java allows the user to hide non-essential details relevant to user.
    Question1:- so we can say Encapsulation is also a feature of abstraction because in ecapsulation also we hide data(state) of object. Right?
    Question2:-Say a class has 10 methods . Out of these 10 , only two are exposed for outside world with public modifier.Can we say this is the example of abstraction?
    Question3:- Can we say interface/abstract class are the baset examples of abstraction as they just expose the masic details i.e signature of method to outside world?

    JavaFunda wrote:
    Hi jverd whats your take on original post?Question1:- Agreed that we are hiding the instance variable details but again we do expose them with getter and setter
    methods. Is it not the violation of encapsulation? What advantage it provides exposing the internal state thru methods
    (like getter and setter) but not declaring stae with public modifier.?
    >
    I don't think you can say whether an individual get/set "violates encapsulation" without more context. If you're just blindly providing direct get/set for every member variable, then it's likely you don't understand encapsulation. There's still some encapsulation there, however, because the caller can't directly see or modify the state.
    Sure, a programmer familiar with coding conventions and possessing some common sense could infer that those get/set methods correspond directly to member variables of the same names, but so what? He still has to go through the methods to see or modify the state, and there could be other stuff going on there. The fact that going through the method makes it a black box to him is why I say there's some level of encapsulation. There's a continuum of how "direct" the access to the internal state is, and I don't think there's a clear delineation between "encapsulated" and "not encapsulated."
    For example:
    As direct as can be: setX() is simply this.x = x and getX() is simply return x.
    Somewhat less direct: getFullName() returns firstname + " " + lastName. There's no member variable called "fullName", and the result is composed by operating on multiple pieces of the object's state.
    Still less direct: ArrayList's toString() is "[", followed by the results of each of its elements' toString() methods, separated by commas, followed by "]"
    Very indirect: Map.put(). We know that it modifies the state of the Map by adding the key/value pair we specify, and we can infer some things about how it's implemented based on the type of Map. But that abstraction is so far separated from the specific state that represents it, that we would probably say that there's a high level of encapsulation there.
    And of course there are other scenarios in between these, and further toward the "encapsulated" end of the spectrum than the Map example. Where do you draw the line between "not encapsulated" and "encapsulated"?
    I think a reasonable criterion to use is whether the exposed stated has been exposed because it's a natural part of the behavior of the class.
    For instance, Colleciton.size(). It makes sense that as part of a Colleciton's behavior, you'd want it to be able to tell you how many items it holds. In an ArrayList, you would probably have a size variable that gets updated each time an element is added or removed. However, in a ConcurrentSkipListSet, there is no size variable. You have to traverse the Set and count the elements. So is size encapsulated here? Is it in one but not the other? Why? I would say it is in both cases, because part of the natural behavior of a Collection is to tell us its size, so the fact that in some collections that can be done simply be returning the value of a member variable doesn't "violate" encapsulation.
    But, after having said all that, my real answer is: I don't care. The answer to "Do get/set violate encapsulation?" doesn't matter to me in the least in how I write my code.
    >
    Question2:- If class does not have any state variable and has some just simple methods printing hello world.
    Can we still say it is encapsulation?
    >
    I would say no, since there's no state to be encapsulated. However, I supposed one could say that the behavior is encapsulated. It could be implemented any number of different ways, some of which would involve state and some wouldn't, and all we'd see is the public interface and the behavior it provides. I don't know that anybody actual does view it that way though.
    And, again, this sort of nitpickery is not actually relevant to anything, IMHO.
    >
    Question1:- so we can say Encapsulation is also a feature of abstraction because in ecapsulation also we hide data(state) of object. Right?
    >
    More silly semantics. I wouldn't say that encapsulation is a "feature" of abstraction. I think the two often work together, and there's some overlap in their definitions, or at least in how they're realized in code. (Which can be seen in my long-winded answer to the first quetsion.)
    >
    Question2:-Say a class has 10 methods . Out of these 10 , only two are exposed for outside world with public modifier.Can we say this is the example of abstraction?
    >
    Don't know, don't care.
    >
    Question3:- Can we say interface/abstract class are the baset examples of abstraction as they just expose the masic details i.e signature of method to outside world?
    >
    No idea what you're saying here, but I expect my answer will again be: "don't know, don't care".
    Edited by: jverd on Aug 3, 2011 10:22 AM
    Edited by: jverd on Aug 3, 2011 10:22 AM

  • Instantiation and start_scn of capture process

    Hi,
    We are working on stream replication, and I have one doubt abt the behavior of the stream.
    During set up, we have to instantiate the database objects whose data will be transferrd during the process. This instantiation process, will create the object at the destination db and set scn value beyond which changes from the source db will be accepted. Now, during creation of capture process, capture process will be assigned a specific start_scn value. Capture process will start capturing the changes beyond this value and will put in capture queue. If in between capture process get aborted, and we have no alternative other than re-creation of capture process, what will happen with the data which will get created during that dropping / recreation procedure of capture process. Do I need to physically get the data and import at the destination db. When at destination db, we have instantiated objects, why not we have some kind of mechanism by which new capture process will start capturing the changes from the least instantiated scn among all instantiated tables ? Is there any other work around than exp/imp when both db (schema) are not sync at source / destination b'coz of failure of capture process. We did face this problem, and could find only one work around of exp/imp of data.
    thanx,

    Thanks Mr SK.
    The foll. query gives some kind of confirmation
    source DB
    SELECT SID, SERIAL#, CAPTURE#,CAPTURE_MESSAGE_NUMBER, ENQUEUE_MESSAGE_NUMBER, APPLY_NAME, APPLY_MESSAGES_SENT FROM V$STREAMS_CAPTURE
    target DB
    SELECT SID, SERIAL#, APPLY#, STATE,DEQUEUED_MESSAGE_NUMBER, OLDEST_SCN_NUM FROM V$STREAMS_APPLY_READER
    One more question :
    Is there any maximum limit in no. of DBs involved in Oracle Streams.
    Ths
    SM.Kumar

  • Constant values and encapsulation

    Hi All,
    lookat the code below:
    class Test{
    public static final int flag = 10;
    Public static void main(String args[])
    System.out.println(i);
    }here the constant value i is used inside the same class.
    Now generally, we use to make separate java file for all constant values and get the values:
    For example:
    class UIConstants{
    public static final int flag = 10;
    }and call this constants values where ever neccessary:
    class Test{
    Public static void main(String args[])
    System.out.println(UIConstants.flag);
    }In most of the the time, i have seen second case is used, but it avoids the encapsulation concepts, since making variable private to public.
    What is the advantages of making in this way?or is there any other reason for using this way?

    Are they thread-safe? No! Not by default anyway.Anything immutable and final is thread safeAs long as the immutable object really is internally
    immutable and has no operations that have
    side-effects on objects outside of the object.
    COuld you shed some light on this.
    For example even a final immutable PrintStream (which
    system.out and system.err are not... see
    System.setOut()) is not necessarily threadsafe
    because two threads could be writing to the same
    stream at the same time.I didnot know PrintStreams were immutable

  • Instantiation and communication

    Hi there
    I'm having problems with communication between classes within an application. I am instantiating objects of one class from within a main class, but these objects need to use methods located in the main class so the objects need to know where the main class is and the main class needs to know which of the objects is using the method so it can communicate back. I think I understand the theory, but I can't make it work. Here are the relevent bits of the code (the rest of the programme is long and boring) - can anyone help?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.lang.*;
    public class Machine
         private JFrame cbFr = new JFrame();
         private JLabel labCb = new JLabel();                    
         public Machine()
                   Kam k1 = new Kam();
         public static void main(String [] args)
                   Machine m1 = new Machine();
    class Kam implements ActionListener, ItemListener //this the main class
              public Kam()                         
                        Cb a = new Cb(this);
                        cbFr.setLocation(20,230);
                        labcb = new JLabel("CbA ");
                        cbFr = new JFrame("CbA");
                        Cb b = new Cb(this);
                        cbFr.setLocation(20,230);
                        labcb = new JLabel("CbB ");
                        cbFr = new JFrame("CbB");                              Cb c = new Cb(this);
                        cbFr.setLocation(20,230);
                        labcb = new JLabel("CbC ");
                        cbFr = new JFrame("CbC");
    class Cb implements ActionListener //class that builds the cb obj above
    private String location;
              private Object empty, name, k1;
              public Cb(Kam k1) //trying to hold the location of
    the main class
                        k1 = (String)kMachine;
                        drawCbDisplay( );
              public Object getName() //trying to hold the identity
    of the objects
                        name = (Object)location;
                        return name;
              public void actionPerformed(ActionEvent ae)                     {     
                   if (ae.getSource() == butE)
                   k1.validation(); //a main
    class method
    }          

    If you want Kam to call methods from Machine, construct it like this:
    Kam k1 = new Kam(this);And change the constructor to this:
    public Kam(Machine m)Is that what you meant?
    Cheers,
    Radish21

  • Template instantiation and multiple binaries in same directory

    Forte C++ 5.3
    Solaris 8 w/Recommended Patch Cluster: Mar 20/03
    Several ACE [see http://www.cs.wustl.edu/~schmidt/ACE.html] Makefiles direct the creation of multiple binary executables in the same directory. My build [i.e. GNU make] of ACE test programs results in successful creation of only the first of the multiple binaries. All binaries after the first have link errors. The link errors seem to be caused by the linker's failure to pick up template instantiations the were already created when the first binary was compiled and linked.
    The $64000 question seems to be: Why does Forte's link line include the appropriate file from the template repository in the first case but not in subsequent cases? The first of the executables, MCast_Fragment_Test, links correctly because the linker picks up the singleton_ instantiation from the template repository - you can see this with the "-verbose=template" switch. However, the second of the test executables, RMCast_Reassembly_Test, fails to link because the same singleton_ instantiation [i.e. the same file] is not picked up:
    % export ACE_ROOT=/tools/pkg/ace/ace5.3.1-sunc++/ACE_wrappers
    % cd $ACE_ROOT/tests/RMCast
    % gmake CCFLAGS="-verbose=template -fast -O3" exceptions=1
    shared_libs=1 static_libs=1 threads=1 distrib=1
    CC -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I/tools/pkg/ace/ace5.3.1-sunc++/ACE_wrappers
    -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ -c
    -o .obj/RMCast_Fragment_Test.o RMCast_Fragment_Test.cpp
    o o o
    "../test_config.h", line 314: Information: Instantiating
    ACE_Singleton<ACE_Test_Output, ACE_Null_Mutex>::singleton_.
    ccfe: Information: Invoking:
    "/tools/forte_c++/SUNWspro/bin/../WS6U2/bin/CC
    -ptd/tmp/03764.TEMPLATE_FILE.s
    -ptc/tmp/03764.TEMPLATE_FILE.ir
    -o $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_z/\
    temp.shuriken.3767.zr7WQNsTBFiWx9j3KXv3.o
    -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION -I$ACE_ROOT
    -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ -c ".
    o o o
    CC -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I$ACE_ROOT -DACE_HAS_EXCEPTIONS -D__ACE_INLINE
    -mt -xildoff -L$ACE_ROOT/ace -L./
    -o RMCast_Fragment_Test .obj/RMCast_Fragment_Test.o
    -lACE_RMCast -lACE -lsocket -ldl -lnsl -lgen -lposix4
    CClink: Information: Invoking:
    "/tools/forte_c++/SUNWspro/bin/../WS6U2/bin/CC
    -ptl -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I/tools/pkg/ace/ace5.3.1-sunc++/ACE_wrappers
    -DACE_HAS_EXCEPTIONS
    -D__ACE_INLINE__ -mt -xildoff
    -L/tools/pkg/ace/ace5.3.1-sunc++/ACE_wrappers/ace
    -L./
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_N/ND6YV9mCPjF6W_mdb9HD.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_W/Wo599T9ON0ragDRfBzx1.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_0/0K1qNfk0TfJC_d7Uf0Iy.o
    ### SUCCESS: The following object file contains the 'singleton_'
    ### definition. Look for blahblah.zr7WQNsTBFiWx9j3KXv3.o, above.
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_z/zr7WQNsTBFiWx9j3KXv3.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_L/LLYlbLynG-qBErnxnavz.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_2/2nXCDDGsUTu5P0ypRsj6.o
    .obj/RMCast_Fragment_Test.o -lACE_RMCast -lACE -lsocket -ldl -lnsl
    -lgen -lposix4 -o RMCast_Fragment_Test ".
    CC -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I$ACE_ROOT -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__
    -c -o .obj/RMCast_Reassembly_Test.o RMCast_Reassembly_Test.cpp
    CC -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I$ACE_ROOT -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ -mt -xildoff
    -L$ACE_ROOT/ace -L./
    -o RMCast_Reassembly_Test .obj/RMCast_Reassembly_Test.o
    -lACE_RMCast -lACE -lsocket -ldl -lnsl -lgen -lposix4
    CClink: Information:
    Invoking: "/tools/forte_c++/SUNWspro/bin/../WS6U2/bin/CC -ptl
    -verbose=template -fast -O3 -I..
    -DACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
    -I$ACE_ROOT -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ -mt -xildoff
    -L$ACE_ROOT/ace -L./
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_N/ND6YV9mCPjF6W_mdb9HD.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_W/Wo599T9ON0ragDRfBzx1.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_0/0K1qNfk0TfJC_d7Uf0Iy.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_L/LLYlbLynG-qBErnxnavz.o
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_2/2nXCDDGsUTu5P0ypRsj6.o
    ### FAILURE: No blahblah/CC_obj_z/zr7WQNsTBFiWx9j3KXv3.o among the
    ### above object files pulled from the template repository.
    .obj/RMCast_Reassembly_Test.o -lACE_RMCast -lACE -lsocket -ldl -lnsl
    -lgen -lposix4 -o RMCast_Reassembly_Test ".
    Undefined first referenced
    symbol in file
    ACE_Singleton<ACE_Test_Output,ACE_Null_Mutex>::singleton_
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_L/LLYlbLynG-
    qBErnxnavz.o
    [Hint: static member
    ACE_Singleton<ACE_Test_Output,ACE_Null_Mutex>::singleton_ must be
    defined in the program]
    ld: fatal: Symbol referencing errors. No output written to
    RMCast_Reassembly_Test
    gmake: *** [RMCast_Reassembly_Test] Error 1
    FYI - A manual relink of RMCast_Reassembly_Test while explicitly
    specifying
    $ACE_ROOT/tests/RMCast/.obj/SunWS_cache/CC_obj_z/zr7WQNsTBFiWx9j3KXv3.
    o successfully created the executable.
    Additional Info: If I swap RMCast_Fragment_Test with RMCast_Reassembly_Test in the build order, i.e.:
    BIN = RMCast_Fragment_Test \
    RMCast_Reassembly_Test \
    becomes
    BIN = RMCast_Reassembly_Test \
    RMCast_Fragment_Test \
    then RMCast_Reassembly_Test links correctly, but RMCast_Fragment_Test
    doesn't.
    Generalization: In all cases, the first binary links successfully
    while subsequent binaries fail to link successfully.
    Regards,
    ... Dave

    Thank you for your reply, but it raises some questions:
    (1) There are people doing regular builds of ACE [see http://tao.doc.wustl.edu/scoreboard/ace.html] using Solaris-8/Forte, but my particular issue is not one that they see. They use the same Makefiles, so why do they not experience the same problem?
    (2) You acknowledge that my observations are consistent with expected behaviour, but who expects that behaviour? Does Sun not accept that this behaviour amounts to a bug?
    (3) Your suggested workarounds are appreciated, but there may be additional options. The more I know about the template related mechanisms employed by the compiler and linker, the better I am able to identify alternative workarounds. For example, after linking a binary, could I touch(1) one or more files in the template repository to positively effect the outcome for building the next binary?
    Regards,
    ... Dave

  • Regular Expression with comma and encapsulated charaters

    Would appreciate some help. Looking for a regular expression to remove comma's from encapsulated text as follows
    For example
    - Input
    1,"This is a string, need to remove the comma",Another text string,10
    - Required output
    1,"This is a string; need to remove the comma",Another text string,10
    Have tried to use the REGEXP_REPLACE but could not grasp the pattern matching.
    Thanks John

    John Heaton wrote:
    Thanks for the solution,this works great for a single field encapsulated by " and containing ,. I am parsing several different file definitions so it would need to cascade through the string for a undetermined number of times and replace all occurrences. Then try (performance-wise) MODEL solution:
    {code}
    with t as (
    select '1,"This is a string, need to remove the comma",Another text string,10' txt from dual union all
    select '1,"remove this comma,",Another text string,10,"remove this comma,",xxx,"remove this comma,",11' txt from dual
    select txt_original,
    txt
    from t
    model
    partition by(row_number() over(order by 1) p)
    dimension by(1 rn)
    measures(txt txt_original,txt,0 quote)
    rules
    iterate(
    1e9
    until(
    iteration_number + 1 = length(txt[1])
    quote[1] = case substr(txt[1],iteration_number + 1,1)
    when '"' then quote[1] + 1
    else quote[1]
    end,
    txt[1] = case substr(txt[1],iteration_number + 1,1)
    when ',' then case mod(quote[1],2)
    when 1 then substr(txt[1],1,iteration_number) || ';' || substr(txt[1],iteration_number + 2)
    else txt[1]
    end
    else txt[1]
    end
    TXT_ORIGINAL TXT
    1,"This is a string, need to remove the comma",Another text string,10 1,"This is a string; need to remove the comma",Another text string,10
    1,"remove this comma,",Another text string,10,"remove this comma,",xxx,"remove this comma,",11 1,"remove this comma;",Another text string,10,"remove this comma;",xxx,"remove this comma;",11
    SQL>
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Abstraction and Encapsulation

    Hi,
    Can I have the difference between Encapsulation and Abstraction with Jave Program Example ..
    Regards,
    Rani.

    That's the ironic thing about these interview questions. The people who know the answers have heard the question so many times that it's pure annoyance. The only people who find the question interesting are the ones who are at about the same level of understanding as the OP, which means the answers tend to be useless, if not dead wrong. (Or, as in this case, they don't know enough to realize that the question makes no sense.) When we tell you to google for the answers, we aren't just being arseholes; that really is the best advice anyone can give you.

  • Class instantiation - and is this a pattern?

    Firstly, my apologies if my goal here is unclear. I am still learning the concepts and may perhaps have a lack of words for the appropriate terms or processes. Hopefully I can convey my meaning enough to get some feedback.
    I have a group of classes, all inheriting from a base class. My task is to add the functionality in these classes to another set of derived classes by simply creating instances of them in these classes constructor methods. To my knowledge this means the instance must take the class it's written in or (this) as it's parameter. My question is then really how should my external helper classes be written so they can be instanced in this way and is there a pattern that this idea conforms to and if so could someone explain this to me. My thanks in advance for any help, tips or directions to a good reference on this topic.

    It sounds a bit like the Strategy pattern.
    Your "helper" classes are providing various ways of performing a task on behalf of another class.
    AWT LayoutManagers implement strategies for laying out the Components in a Container. Have a look through that to see how it's done there.
    Whether your strategy classes need to take the "container" class in their constructor will depend on the functionality they provide. If their behaviour does not need to be cached then they could take a reference to the wrapper in each method call like LayoutManagers do.
    Hope this helps.

  • How about a little help working with Gbps Ethernet I/O (embedded and instantiated) and the Zynq SoC?

    A new Xilinx TechTip gives you some basics for working with the embedded Gbps Ethernet ports on all Zynq SoCs. This TechTip also applies to additional Gbps Ethernet ports you might instantiate in the Zynq SoC’s programmable logic. (More than one, if you like.) If you’re not familiar with basic Ethernet tools including the Wireshark protocol analyzer and the NetPerf benchmarking utility for Linux, give this one a read.
     

    kglad wrote:
    that code should be attached to the first keyframe that contains your flvplayback component.
    if you have more than one, you'll need to assign each a different instance name and adjust the code accordingly.
    the trace() should be added to your button listener function (openurl).
    All right, I think its going to be easy to explain if you please check my image here http://thenewmediastudio.com/roland/example.png
    I'm placing the code in the first frame, however, the movie is located in the 2nd frame but is not working, not sure where exactly I should place the code.
    And sorry but, that other thing about the trace, didn't understood that one.
    Thanks so much!

  • Instantiating and Deleting a Component Usage

    Hi,
    I want to delete a component and create the same component again.
    But when I create the same coponent again the method "WDDOMODIFYVIEW" is not called.
    I need to do this because the code in IF first_time = abap_true. in "WDDOMODIFYVIEW" must be executed every time.
    I have the following code:
    lo_cmp_usage = wd_this->wd_cpuse_invoice_lines( ).
          IF lo_cmp_usage->has_active_component( ) IS INITIAL.
            lo_cmp_usage->create_component( ).
          ELSE.
            lo_cmp_usage->delete_component( ).
            lo_cmp_usage->create_component( ).
          ENDIF.
    Thanks,
    Morten

    Hi,
    You need to check the component is initial or not in the 'ELSE' part also, only then delete the component and create it again.
    Before deleting the component Invalidate the Node 'DATA' of the component usage.
    Regards,
    Lekha

  • Dynamic enum instantiation and access

    Here's what I would like to do, but I'm not sure if/how it can be done.
    Given a set of enum's e1, e2, e3;
    1. Specify at runtime the enum I'm interested in as a string "e1".
    2. Dynamically create an object of that type.
    3. Access the values() method at runtime to see what the constants of e1 are.
    I can get this far:
    String className = new String("e1");
    Class c = Class.forName(className);
    Object o = c.newInstance();Step #3 is the issue. I don't know how to cast the object in order to get access to the values() method. The Enum class does not include that method. Anyone know what does that I can cast my object to?
    Thanks,
    Mark

    import java.util.EnumSet;
    * @since October 10, 2006, 12:41 PM
    * @author Ian Schneider
    public enum DynamicEnumAccess {
        A,B,C,D,E,F,G;
        public static void main(String[] args) throws Exception {
            Class<? extends Enum> e = (Class<? extends Enum>) Class.forName("DynamicEnumAccess");
            EnumSet allOf = EnumSet.allOf(e);
            System.out.println(allOf);
    }

  • Why use setters and getters?

    Hi.
    I've been wondering woudn't a function with return do the same thing as a get function with return?
    Ex:
    var age:Number = 16;
    function get Age() {
         return age;
    isn't the same as:
    function Age() {
         return age;
    Thanks.

    I respectfully disagree with the statements that it is a matter of nomenclature. Although there are a lot of cases when accessors (getters/setters) are overused, they are definitely extremely useful features of any OO language. In some case code would be much longer and more cumbersome without accessors. I must say that with code written on timeline accessors are less useful (although I can see plenty of cases one can utilize them). When code is written in classes - accessors are indispensable.
    With your age example it is really a matter of preference. But if you need to do more with age - you would definitely appreciate getters/setters.
    For example:
    Say you have a class Person and it has property age:
    public var age:int = 0;
    Somewhere we instantiate this class:
    var myPerson:Person = new Person();
    Now we set age:
    myPerson.age = 23;
    trace(myPerson.age); // returns 23
    Just imagine you instantiate this variable in 100 of places.
    When you think you are done, your boss comes to you and says: “I want you when they set the age also to evaluate what age group person belongs to.”
    If there were no getters/setters – you would have a very hard time chasing all 100 instances in your program and changing your Person class architecture. With accessors you will spend a few minutes only. You can do the following:
    // change the variable to private
    private var _age:int = 0;
    // create accessors
    public function set age(a:int):void{
         _age = a;
         // here you evaluate age
         if (_age < 10) {
              trace("child");
         else if (_age > 10 && _age < 20) {
              trace("teenager");
         else if (_age > 20 && _age < 30) {
              trace("young");
         else {
              trace("too old to bare :-(");
    public function get age():int{
         return _age;
    As you can see you changed the code in one place and while not doing a thing in any of 100 places you instantiated the Person class.
    Again, your boss can come back and ask to restrict the age to people older than 20.
    So may write:
    public function set age(a:int):void {
         if (a > 20) {
              _age = a;
    Again, you met requirements and did not change any code anywhere else.
    One more request from the boss. Say, he wants you to count how many times age was changed. You can use setter to do that:
    private var getterCounter:int = 0;
    public function get age():int {
         getterCounter++;
         return _age;
    You wouldn’t be able to do all these things if there were not accessors.
    Still the use of age variable will stay the same:
    var myPerson:Person = new Person();
    myPerson.age = 34;
    trace(myPerson.age);
    Welcome to scalability and encapsulation. It doesn’t matter what you do when age is set inside Person class – it will not break code anywhere else.
    There are millions more useful cases when getters/setters come handy.

Maybe you are looking for

  • To complete multiple tasks in a single window without closing individual

    Hi Folks, How much it is possible to complete multiple BPM activities in a single window? Suppose i have a BPM process which contain 2 swimlanes and 4 steps. First 2 and 4th step is assigned to swimlane A and step3 is assigned to Swimlane B. Two user

  • Can I put a solid state hard drive in my older MacBook Pro?

    Can this Macbook pro 2.2GHz MacBook Pro (MC723LL/A) be upgraded to a solid state hard drive?

  • Order units differ

    Hi, We are working on MM-SUS Scenario. Created PO in ECC and got transferred to SUS, we have created Purchase Order Response in SUS. From SUS end it is sucess. But at the ECC we are getting the below error in Inbound IDOC. Error Details Order units d

  • Transport controls won't work with mouse....

    Hi Having been a long term Mac user with Avid and FCP I have now decided to move to Premiere on a PC. I've just installed the Creative Cloud version and it all looks good. However, the mouse will not activate any of the device controls. (play, mark i

  • •Error Code: 502 Proxy Error. The directory name is invalid. (267)

    Hi..my name is Fajar.. I facing same situation getting an error cannot access www.pajak.go.id. I have followed up soulution  to restart firewall services its resolved only one day, once I get back to the office cannot access again. btw sometimes afte