Assigning object of one class to object of another class.

Hi,
How will i assign an object of one class to an object of another class?
Ex:
ClassX A=some_method();
Now how will I assign the object A of class ClassX to the object 'B' of another class 'ClassY'.

In java you can only assign a object reference of one class into object reference of another class if the first class is the Second class (in other words the first class is a subclass of second class).
for example if this is a inheritance chart
Car ==========>Mercedes
"===========>Audi
then you can use
Audi a1 = new Audi();
Car c1 = a1;
or Mercedes m1 = new Mercedes();
Car c1 = m1;
but not
a1 = m1;
before assigning a variable into another variable of different class, use:
if(variable1 instanceOf ToBeAssignedIn Class){
variable2 = variable1;
example:
Audi a1;
Car c1;
if(a1 instanceOf Car){
c1 = a1;
Edited by: gaurav.suse on Apr 10, 2012 1:14 PM
Edited by: gaurav.suse on Apr 10, 2012 1:15 PM

Similar Messages

  • Re-Assigning Objects to another Package

    Hi,
    I have developed couple objects in a Z* Package. But my Client's asking me not to use that Z* Package and suggesting to use another Z* package. I am not sure, how to re-assign the package for the objects already created and assigned with a CTS. There are few CTS already released to QA System. Can any one please give me suggestion, how is it to be done?
    Thanks,
    Kannan

    If the released transports haven't been migrated to QA yet, you can ask your BASIS resource to delet them from the buffer.. You can then change the Package via SE80.. select the Object & then use the menu path Goto--> Object Directory Entry.. in the next pop-up click on the Display/Change (F6) icon and change the Package.. If your old request isn't released, the change will be saved to it, else, you will be prompted for a new tr req.
    Arya

  • Restrict 1 Charachteristic per class in assigned object

    Hi Gurus,
    I am using clasification system for reporting in vendors. I have created a class with class type 010 and assigned charachterictics to the class. When I assign this class to the object, i.e Vendor. I want the asignment of charachteristic value to be restricted one charachteristic and one value therein.
    I want to assign just one value of a characteristic, the we sholud be ablle to assin multiple charachterisitc pertaining to a specifc class. The end result should one valu from any one of the charachterisic of a specific class.
    Thanks and Regards,
    Abdul Kadir Rajbhoy

    Create multiple class with class type 010 and assign only one characteristics for each of the class.
    e.g:
    Class: CL1 - Assign Characteristics CHAR1
    Class: CL2 - Assign Characteristics CHAR2
    Class: CL3 - Assign Characteristics CHAR3
    Class: CL4 - Assign Characteristics CHAR3
    In the vendor class assignment, chhose one of the class and assign values to the characteristics.

  • Object Creation Of One class into another and vice versa

    Hello Everyone,
    My name is Prashant Sharma from Jaipur [Rajasthan]
    Can u people help me
    How to create of one class into another and vice versa
    Eg,
    I am having class A and class B
    I want to create object of class A into class B and vice versa
    Plz help me out of this problem as soon as possible....

    Read this: [Creating Objects|http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html]
    Then, do one of these three:
    1. Create an instance of the class
    2. Extend the class
    3. Access methods within the class
    Try it out. Post the problem code if you're having trouble.

  • How to assign one JSP request object to another JSP

    Hi,
    I want to assign one JSP request object (i.e., previous JSP Page request object) to another JSP (i.e., current JSP page request object).
    I don't want to use "<jsp:forward>" tag or "RequestDispatcher" obect here.
    Because i want to display one message in the current JSP page, before sending both JSP pages' request to a servlet. How to do this ?
    please help
    Thanks in advance
    Vishnu

    You cannot assign a request and response object of one jsp/servlet to another, every jsp or a servlet get is own fresh copy of request and response object with the request parameter data from the previous page.
    Unless u use request dispatcher or jsp:forward action, this solution that u r looking for by re-assigning the request and response object doesn't work

  • Maximum no'of Objects for one class

    Hello friends
    Please, tell me....Maximum no'of Obects for One Java class.
    Thanks & Regards
    S.Rajakrishna

    Is there any limit of creating the objects for One class?Instantiated objects go into the heap. There is only one heap for the whole JVM. There is no correlation between objects in the heap and the individual class files.
    100,000 objects may or may not fit into the heap. In general they probably will. If you don't, then yes, you'll get an Out Of Memory exception.
    Regardless there is no excuse for loading 100,000 objects just to render a JSP! You don't imagine your user is going read all of them do you? Restrict them to the number of objects that the user is actually going to be able to handle at any given time.
    You can do this by putting WHERE clauses on the hibernate query, and/or by setting limits (setFirstResult and setMaxResult) on the Query object before listing it.

  • How to pass the object of one class to the another class?

    Hello All,
    My problem is i am sending the object of serializable class from one class to another class but when i collection this class into another it is transfering null to that side even i filled that object into the class before transfer and the point is class is serializable
    code is below like
    one class contain the code where i collecting the object by calling this function of another class:-
    class
    lastindex and initIndex is starting and ending range
    SentenceStatusImpl tempSS[] = new SentenceStatusImpl[lastIndex-initIndex ];
    tempSS[i++] = engineLocal.CallParser(SS[initIndex],g_strUserName,g_strlanguage,g_strDomain);
    another class containg code where we transfering the object:-
    class
    public SentenceStatusImpl CallParser(SentenceStatusImpl senStatus, String strUserName, String strLanguage, String strDomain)
    *//here some code in try block*
    finally
    System.+out+.println("inside finally...........block......"+strfinaloutput.length);
    senStatus.setOutputSen(strfinaloutput);//strfinaloutput is stringbuffer array containg sentence
    fillSynonymMap(senStatus);
    senStatus.setTranslateStatus(*true*);
    return senStatus;
    Class of which object is serialized name sentenceStatusimpl class:-
    public class SentenceStatusImpl implements Serializable
    ///Added by pavan on 10/06/2008
    int strSourceSenNo;
    String strSourceSen = new String();
    String strTargetSen = new String();
    StringBuffer[] stroutputSen = null;
    HashMap senHashMap = new HashMap();
    HashMap dfaMarkedMap = new HashMap();
    boolean bTargetStatus = false;
    public SentenceStatusImpl(){
    public void setOutputSen(StringBuffer[] outputSen){
    stroutputSen = outputSen;
    public StringBuffer[] getOutputSen(){
    return stroutputSen;
    public void setTranslateStatus(*boolean* TargetStatus){
    bTargetStatus = TargetStatus;
    }//class

    ok,
    in class one
    we are calling one function (name callParser(object of sentenceStatusImpl class,.....argument.) it return object of sentenceStatusImple class containg some extra information ) and we collecting that object into same type of object.
    and that sentenceStatusImple classs implements by Serializable
    so it some cases it is returning null
    if you think it is not proper serialization is please replay me and suggest proper serialization so that my work is to be done properly (without NULL)
    hope you understand my problem

  • Assign Object to Class Type 026

    Dear Gurus,
    How can I assign objects to 026 type class ? because I tried CL2* transactions and all disallow me from accessing this 026 type class.
    Thank you.
    Best Regards,
    Kent.S

    Hi Kent,
    Class 026 is a reserved class for goods group ... look at Transaction WG21-Environment for hierarchy (we have a german system, so i don't know the correct items in the english menue).
    Best regards,
    Volker

  • Assign Object to class with characteristic values ?

    Hi All,
    I want to assign object to class with characteristic values. I found CL20N transaction for performing the same. Is there any BDC , BAPI to upload the same.
    Thanks & Regards,
    Navneeth K.

    Hi,
    try as below
        CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
          EXPORTING
            classtext            = 'X'
            classtype            = w_classtype  "Class type
            language             = sy-langu
            object               = w_object     "Object Matnr + Batch
            objecttable          = 'MARA'     "As requirement
            change_service_clf   = 'X'
            inherited_char       = ' '
            change_number        = ' '
          TABLES
            t_class              = t_class
            t_objectdata         = t_objectdata
            i_sel_characteristic = i_sel_characteristic
            t_no_auth_charact    = t_no_auth_charact.
        IF sy-subrc <> 0.
        ENDIF.
    *     Create with reference-----------------------
          w_objectkeynew = wa_inputfile-to_matnr.
          CALL FUNCTION 'BAPI_OBJCL_CREATE'
            EXPORTING
              objectkeynew    = w_objectkeynew
              objecttablenew  = 'MARA'
              classnumnew     = w_classnum
              classtypenew    = w_classtype
            TABLES
              allocvaluesnum  = t_allocvaluesnum
              allocvalueschar = t_allocvalueschar
              allocvaluescurr = t_allocvaluescurr
              return          = t_lreturn.
    "or
    BAPI_OBJCL_CHANGE              Classification BAPI: Change Assignment
    Prabhudas

  • Open and Close Posting Periods According to G/L Account Assignment Objects

    Hi,
    Can anybody please explain me how configurations related to " Open and Close Posting Periods According to G/L Account Assignment Objects " works in SAP FICO? I am confused about this config.
    Regards,
    Mandeep

    Hi Mandeep ,
    First i would like to tell about fiscal year
    fiscal year is nothing but a financial year of company in sap . it contain 12 normal periods and 4 special periods.In genaral we will call like month but that is sap that is a period. so 12 period for 12 months ok next special period will use in all companies for audit and tax adjustment purpose of previous year.
    coming to the open and close periods.in sap for security purpose we have to open one period like this month july so i opened july period only we cant post the pervious month (june)and we cant post future month lik in (Auguest)ok
    You can close and open periods by transaction ob52.
    In transaction ob52 there are account types
    + Valid for all account types
    A Assets
    D Customers
    K Vendors
    M Materials
    S G/L accounts
    V Contract accounts
    + means all types. if you want to open vendor then enter period from and to according to your fiscal year.
    you cant adjust items in closed period. if you want to then you have to open the period
    For your information.....
    posting periods also open user level tc S_ALR_87003642.
    customization levael OB52.
    Regards
    Kumar

  • Can i copy values from one object to another ?

    One more help..
    How do i compare the input values with the ones in an object of another class ?
    Can i copy values of one object of a class to different object of another class ?
    Thanks,
    Sanlearns

    How do i compare the input values with the ones in an
    object of another class ?By getting and comparing them?
    Can i copy values of one object of a class to
    different object of another class ?Yes, you can. But you shouldn't, as you're breaking encapsulation all over the place. You could use setter methods (if available) to set the values.

  • BDC selecting component - Assigning object dependencies

    Hi,
    I am facing a problem in developing a BDC program. In transaction CS02, for a configurable material there may be n number of components. The number of components may vary from material to material. My requirement is to assign object dependency Q & S to all the components for a given material.
    Through BDC program how can i pick the components one by one and assign object dependencies Q and S at runtime??? Dynamically on what basis do i have to pick the component? Any supporting code will be more helpfull. Very thankfull to you for solving the issue.
    Thanks,
    RAM

    I have a program which does exactly this.   What it does it excepts a flat comma-delimited file and uses this to chose the component and assign the obj dep.  Now that I'm looking at it, it looks that it will allow up to three obj dep to be added for a single component.  The file layout will need to have......
    material number
    plant
    item number
    component material lnumber
    object dep 1
    object dep 2
    object dep 3
    I can send you the code if you email me at the address on my business card.
    Regards
    Rich Heilman

  • The CO account assignment object belongs to company code 1000, not 1100

    Dear consultants,
    I am SAP - HR consultant.
    I have 4 company codes, under one controlling area & payroll area. I executed live Payroll & tried to run posting payroll results. System displayed folloewing error "You want to make a posting in company code 1100. At the same time, a CO account assignment object was specified that is assigned to company code 1000. This is account assignment object with object type CTR, and object key 1000/1010101400. "
    I have created similar accounts 1110101400, 1210101400 & 1310101400 for company codes 1100, 1200 & 1300.
    May I know what could be the reason?
    Regards,
    Bindumadhav

    "this is account assignment object with object type CTR, and object key 1000/1010101400" means; somethings is missing for cost center 1010101400 under the company code 1000. system tries to post and entry for company code 1100 to the cost center 1010101400 which falls under a different company code (1000).
    so it is not realted with GL accounts i believe
    you can go to KS02 and check the company code for the CCenter 1010101400 and change it to 1100.
    or you may change the cost center assigned to employer master and give a new ccenter which is under the company code 1100.
    but if i were you, before making any changes i would consult the a CO consultants first for this issue.

  • The CO account assignment object belongs to company code 2100, not 1100

    Hi All,
    My system has all different company codes assigned to one cotrolling area as a result one can change org unit and position cost center from one company code to another.
    I recently changed same position's cost center from co code 2000 to cost center in new  co code 1100 and created new personnel area to be linked to new Co code 1100. OM module doesn't moan however when I try and capture org-reassignment action to default same employee postion with new related cost center from new company code 1100 get the follwing error.
    'The CO account assignment object belongs to company code 2100, not 1100'.
    I see in IT0001 system defaults new personnel area linked to Co code 1100 however it still defaults old cost center linked to Co code 2000 instead of new cost center linked to Co code1100. How can I make the system default  new cost center?
    NB relationship for new cost center  from Co code 1100 to postion has been changed effective 01.04.2012 . The same date is used for or-reassignment action.

    Hi I had same problem can you explain me little bit more that how you will resolve this

  • FM Error: No assignment object determined for P100 / 457000

    Dear GURUS,
    we are facing the problem while changing the PO and system is giving the error message as CB item 00010: No assignment object determined for P100 / 457000
    we checked in FM9K and reconstructed in FMBV and run the report .
    pl suggest...
    Message no. BP748
    Diagnosis
    The budget structure for the combination funds center P100/commitment item 457000/fund  in line item 00010 does not contain a superior assignment object in the commitment budget.
    Also, if you have only assigned one assignment object in the commitment budget, you must create assignment objects in such a way that every assignable element has ONE assignment object in the upward path in the commitment budget.
    System Response
    Posting not made.
    Procedure
    1. Define a superior element in the budget structure or define the BS element itself as an assignment object in the commitment budget.
    2. Check your definition.
    3. Reconstruct the assigned values for the fund and year where you have changed the assignment object definition.
    Regards,
    Venkat

    Hi,
    Please check the Note 1080301
    Summary
    Symptom
    You receive the error message BP746 or any similar message (see below).
    Other terms
    BP 746 - BP746 - BP 747 - BP747 - BP745 - BP 745 - BP748 - BP 748
    Reason and Prerequisites
    You use the functionality of assignment objects in the budget structure for Former Budgeting
    Solution
    The functionality of the assignment object is not generally released for customers.
    Customers who want to use this functionality must first contact SAP consulting, if they are allowed to do so.
    If you do not need or know this functionality, then you must update the budget structure (transaction code FM9K) and remove the definition of all assignment objects. Sometimes, the corresponding columns are hidden in the transactions FM9L or FM9K. If this is the case, you should first activate them in the table control settings (right-upper button). The columns in FM9K and FM9L have the titles "CmA" and "PmA".
    If you use a complex budget structure, the easiest way to detect these assignment objects will to search in table BPCJ for entries with the field WRTTP equal to 72 or 46. As well you can use table BPCK which tells you whether assignment objects are used or not, by filtering entries with the field WRTTP equal to 72 or 46.
    After removing all combinations detected in tables BPCJ or BPCK using transaction code FM9K, you must reconstruct availability control, by means of transaction code FMBV.
    Note
    Problems with assignment objects are detected by the report BPCARRC0.
    Thanks & Regards,
    Shashi Kanth.

Maybe you are looking for

  • Product registration problem

    I purchased iLife06 a couple years ago but my hard drive crashed. When reinstalling my software I could not find my serial number. How can I get it? I do have the Software Coupons but the number is not there. How can I get a number from Apple? Also,

  • Problems connecting VNP ( cyber ghost ) on 8.1 over some public wifies

    help! I just brough a new labtop. it has windows 8.1. when i'm at the local library , which is faster then most free wifies in my area, and a few other free wifies i can't connect to my cyber ghost VNP service. when i had this problem on windows 7, i

  • Oracle EBS and SOX compliance

    Hello, I am new to Oracle EBS I would like to know what are the features of Oracle EBS to comply with SOX (Access to data and programs, change control, Operations) Thanks in advance

  • Conversion of Packaging item into Bulk....

    Dear All. The scenario is i used two type of items One is Bulk and other is packaging items.If i am doing the production of packaging item and if i want to convert into Bulk item then how can i do that.Can anyone please help me out. Regards

  • Error message on boot up - Revert to 1/1/2008

    My daughter is getting an error message when she boots up her Macbook Pro.  Something about reverting back to 1/1/2008.  The macbook does boot up, but all of her homework is gone and several of the applications will not work. Any Ideas?