Explicit return or Reference

Hi everyone,
I have a utility method to which i pass a List object. Within the utility method i update the value of each object in the list based upon some information passed in another parameter to the method.
What i am wondering is if i should now return the list as the return value from the method, or whether i let clients of the method assume that the value of the list they passed as a parameter into the method is automatically updated ( when objects are passed it is by reference and the value of the object can be altered within the destination method )
e.g should the method resemble
public void doSomthing( java.util.List aList, int aValue )
Iterator listIterator = aList.iterator();
while( listIterator.hasNext() )
MyObject anObject = ( MyObject ) listIterator.next();
anObject.setA( aValue );
or should it be
public List doSomthing( java.util.List aList, int aValue )
Iterator listIterator = aList.iterator();
while( listIterator.hasNext() )
MyObject anObject = ( MyObject ) listIterator.next();
anObject.setA( aValue );
return aList;
All help appreciated.......

but for convenience you could return the 1st parameter.
As Component::Container.add(Component) does in AWT.

Similar Messages

  • Inclusive Free Goods Return with Reference

    Hi Gurus!
    Could you help me with my question below
    We are tring to create a sales order return with reference to a billing document. This billing document has two items where one is a standard item and the other is a inclusive free goods item.
    Example:
    1            AAA

    Hi
    When you have creating the sales order  with reference to billing document the items will be copied into the return order without any changes
    You can check the controls in the copy control VTAF
    Regards
    Damu

  • ORDERS05 - Create a Return with reference to a Sales Order

    Hi all,
    I'm trying to create a return with reference to a sales order via IDOC ORDERS05. I'm indicating referenced Sales Order number into segment E1EDK02; indicating qualifier (QUALFR = 002) and Sales order number (BELNR). By this way, I create a Customer Return but without reference.
    Which fields or segment have to be filled in order to create it correctly?
    Thanks
    Marí

    Correct...
    You need something like:
    *Get the pricing cond number.
    select single knumv from vbak into cond
      where vbeln = '0000080347'.
    if sy-subrc = 0.
    Get the pricing record which are by line item.
      select * from konv into table konv_tbl where knumv = cond.
    Loop thru them one line at a time.
      loop at konv_tbl.
       bapi_cond-itm_number = '000010'.
        bapi_cond-cond_st_no = konv_tbl-stunr.
        bapi_cond-cond_count = konv_tbl-zaehk.
    CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
      EXPORTING
        RETURN_HEADER_IN               = bapi_hdr
       BUSINESS_OBJECT               = 'BUS2102'
        CONVERT                        = 'X'
      IMPORTING
        SALESDOCUMENT                 = bapi_salesdoc
       RETURN                        = BAPI_RET
      TABLES
        RETURN                        = bapi_ret_tbl
        RETURN_ITEMS_IN                = bapi_itm
        RETURN_ITEMS_INX               = bapi_itm_out
        RETURN_PARTNERS                = bapi_prtnr
        RETURN_SCHEDULES_IN            = bapi_schd_lin
        RETURN_CONDITIONS_IN           = bapi_cond.  "pricing
      ORDER_TEXT                    = bapi_text.

  • Returning remote reference

    Hi everybody, I'm having quite some trouble with RMI, everytime I try to return a reference to a Remote object on my server I get the usual "unmarshalling return" error. Problem is that my Object I'm trying to return actually implements the Remote interface:
    public interface Bank extends Remote {
         public Account create_account (String name) throws BankException, RemoteException;
    };the Implementation looks like this:
    public class BankImpl implements Bank {
         public Account create_account (String name) throws BankException {
              Account k = new AccountImpl(name);
              return k;
    }Again the interface and Implementation:
    public interface Account extends Remote {
        public Account(String name);
    public class AccountImpl implements Account, Remote  {
         private String name = null;
         AccountImpl(String name){
              this.name = name;
    };I'm quite stuck here, is there something I'm missing??? I thought that function whose return type is some implementation of the Remote interface will automatically get passed by reference with an automatically generated stub.

    It seems to me that having to actually extend the UnicastRemoteObject is quite a limitation.You don't have to. I gave you that as the simplest solution. If you don't extend UnicastRemoteObject, you have to export the object yourself with UnicastRemoteObject.exportObject(). Use the overload where you specify a port number, even if it's only zero (= any).
    And somehow I'm unable to cast the generated Proxies to my Interfaces.
    Actually I can only let my extend the "Remote" interface in my interfaces and them implement my Account interface and extend "UnicastRemoteObject" in the implementations and still it won't work.What happens? You'll have to show us the code ... btw is there something missing back there?
    Still think I'm missing something...For sure. RMI works.

  • Return by Reference/Return by Value

    Okay. I am suppose to create this accessor method that is not suppose to return by reference so as to protect the private variables.
    Firstly, I suppose for primitive data type I can :
    public int rtnInt() {
    int i = 0;
    int j;
    int j = i;//Primitive type creates new memory for variable
    return j; }
    Right? Or can I just return i? Will returning i result as a reference to i?
    Secondly, I am stumped on reference data type, example if I have :
    public String rtnstr() {
    String a = "a"
    String b;
    String b = a; //Can't do this right, it will just reference to the location of a?
    return b;
    So how do you actually copy a new a to and assign it to b? Oh ya, am I right to say arraycopy copies a new array and I don't have to worry about referencing?

    Noobie1987 wrote:
    Eh? So you mean to say I can just return or pass any variables, reference or primitive type, without fear of the original being modified?"Returning variables" does not pertain here, since when you return from a method, the variables are popped from from the stack and cease to exist. When you pass a variable to a method, a copy of that variable's value is used within the method. Changing the variable within the method does not affect the variable outside the method. Ever.
    But I thought 2 variables referencing the same memory location will affect each other if a change is made. AKA...
    String[] str = {0};
    String[] abc = str;
    abc[0] = 1;
    So str[0] will become 1?First, that example won't compile. Second, there is no passing of anything; just variable assignment.
    It is important to understand that variables do not contain objects. Read this: [http://www.javaranch.com/campfire/StoryPassBy.jsp]
    ~

  • Java returning the reference of the current class.

    Hi,
    I want to write a method in Java to return the reference of the current class in a static manner i.e, without instantiating the class. Please help as to how to go about it.
    Thanks.

    Come on, at least point out where the guy is wrong.
    user563329 wrote:
    I want to write a method in Java to return the reference of the current class in a static manner i.e, without instantiating the class.There is no concept of a "current class" but I guess you meant "the class where the code is defined that the current thread is running now".
    However, that means that class (code) has been instantiated so your question makes no sense.
    If you want the class of the "current running code" use Object#getClass().
    You can reference a class without instantiating it but it will still be loaded. For example:
    public class TestInit {
        public static void main(String[] args) {
            System.out.println(Init.class.getSimpleName());
    class Init {
        static { System.out.println("Init init"); }
    // running it with java -verbose:class show Init is loaded but the static initializer is not run
    // loading lots of class ending with
    [Loaded TestInit from file:/C:/Projects/Dump2/Output/]
    [Loaded java.lang.Void from shared objects file]
    [Loaded Init from file:/C:/Projects/Dump2/Output/]
    Init
    [Loaded java.lang.Shutdown from shared objects file]
    [Loaded java.lang.Shutdown$Lock from shared objects file]

  • Create return with reference to original sales order - partners

    Hi all
    I'm using the function SD_SALESDOCUMENT_CREATE to create a return order with reference to the original sales order. (Partially return works fine too).
    All the informationen from the original sales order (including partners). I'm reading with the function BAPISORDER_GETDETAILEDLIST. This works fine. I get all the correct datas from the sales order.
    The problem: when I create a return order with the SD_SALESDOCUMENT_CREATE it takes the partners from the standard defined partners table and not from the original sales order.
    For example, standard defined partners for Customer: 10101010:
    200010 Dealer 1
    300101 Subdealer 2
    501001 Salesman
    When I have in the sales order only this partner:
    200010 Dealer 1
    it takes into the Return still all the 3 partners. Also then, when I explicity delete these other partners in the partnertable (return_partners) before I leave to the Function: BAPI_CUSTOMERRETURN_CREATE.
    Can anyone help me?
    Thank you so much!!
    Petra

    Hi Petra
      Can you check how itz behaving when you create using
    VA01 with reference document for the same case.
    Kind Regards
    Eswar

  • Goods return without reference to a Material Document or delivery note

    Hi
    Is there a way to do Goods return without a material document. Please suggest.
    The situation is that a material will go to the field (material is being maintained against a serial number profile) and let suppose that it is returned after a few years of use. Then in such a situation I need to take it back into the stock through a return delivery. But it may not be possible to track the material documnet against which GI was done few years back. SO i need to have a provision that either goods be returned with a reference of a material Document OR I should be able to track the material document in the system (through a report) using the serial number. Request you to please suggest on these two cases.
    Also we are not having procurement process in our organization. we do GR and GI only in regard to inventory movement.
    Thanks,

    Check
    Customer returns without billing reference

  • Create sales order (return) with reference - PO number not copied

    Hello all,
    I have a question regarding creating a sales order (return, VA01) with the option "create with reference" where a sales order number can be added as reference.
    The system will copy values from the sales order into the return document like the item, the sold-to-party etc.
    The PO Number (customer PO number) is not being copied in our system, so I was wondering if there is a way to tell the system to copy the PO number from the sales order?
    Thanks,
    Anne

    Hi,
    In the transaction code VTAA, select the target and source document types (return order <- sales order) and click on the details button. Check the data transfer routine (the first one for VBAK) assigned here. You may need to clone this routine (in transaction VOFM -> Data transfers -> orders) and create a new routine to add field VBAK-BSTNK into it.
    Check with an ABAP'er for further details.
    Regards,

  • Create return with reference to original sales order - pricing

    Hi
    I am using the function SD_SALESDOCUMENT_CREATE to create a return order with reference to the original sales order.
    All the information from the original sales order (including pricing conditions) I've read with the function BAPISDORDER_GETDETAILEDLIST.
    The problem : the pricing conditions. I need to copy the conditions from the original order and it is not working correctly.
    Any ideas?
    Thanks.
    Anca

    Correct...
    You need something like:
    *Get the pricing cond number.
    select single knumv from vbak into cond
      where vbeln = '0000080347'.
    if sy-subrc = 0.
    Get the pricing record which are by line item.
      select * from konv into table konv_tbl where knumv = cond.
    Loop thru them one line at a time.
      loop at konv_tbl.
       bapi_cond-itm_number = '000010'.
        bapi_cond-cond_st_no = konv_tbl-stunr.
        bapi_cond-cond_count = konv_tbl-zaehk.
    CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
      EXPORTING
        RETURN_HEADER_IN               = bapi_hdr
       BUSINESS_OBJECT               = 'BUS2102'
        CONVERT                        = 'X'
      IMPORTING
        SALESDOCUMENT                 = bapi_salesdoc
       RETURN                        = BAPI_RET
      TABLES
        RETURN                        = bapi_ret_tbl
        RETURN_ITEMS_IN                = bapi_itm
        RETURN_ITEMS_INX               = bapi_itm_out
        RETURN_PARTNERS                = bapi_prtnr
        RETURN_SCHEDULES_IN            = bapi_schd_lin
        RETURN_CONDITIONS_IN           = bapi_cond.  "pricing
      ORDER_TEXT                    = bapi_text.

  • Returns with reference to Billing Document (F2-RE)

    Dear all,
    I want to understand what are the data transfer routines I need to consider while copy control of the Billing Doc(F2) to Returns Doc (RE)
    For your reference I have considered the following,
    At Header Level,
    Data T - 052 (Billing Doc Header)
    DataT      104 (Bill Bus Item Data)     
    DataT      003 (Bill Header Partner)
    Copying Requirements - 001 (Header same customer)
    Copy Item Number (Checked)
    At the Item LEvel,
    DataT 153 Item from bill.doc.
    DataT 102 (Bus.data/item compl).                            
    DataT 002 (Partner item)             
    Copying requirements 303 (Always an item)
    Now when I do returns order with reference to the Bill Doc, I'm not able to save the order because of Pay Terms, Incoterms, & Pricing Date Incompletion.
    Kindly Suggest.

    hi
    copy controls tells us how the data has to be transfered from one document to other document
    as we know sales document is divided in to 3 parts
    header
    item
    scheduline
    but a billing doc will have only 2 levels
    header
    item
    in the header we wil have info abt partners
    at item we will have info abt materials
    when refering a doc to create other,,when there is no control how the data has to be copied there is no meaning
    copy controls does exactly that....
    it controls how the data has to be copied from one doc to other
    Example:
    customer 'A' has ordered a material..diliveriy and billing was also done...
    when he wants to return that material back,,is there any meaning when customer 'B' is entered in the place of Customer'A'
    routines checks whether certain requirement is met when a data transfer takes place between two doc's
    i dont understand one thing
    you dont have to enter the business data ( Payment terms,  incoterms)
    while creating a returns doc
    they already exist in the bill doc
    if the information is not there from the beginning itself
    i cant undersdatna how u saved the billing doc for the first time
    if ur able to create a bill doc that it self means the doc is complete
    regards'
    ravi
    reward if help ful
    Edited by: ravi chandra on Mar 31, 2008 11:35 AM

  • Returning local references from an EJB

    Hi,
    Is it possible to return a local object reference (of bean X) from the business method of another entity bean(Y)?
    Thanks in advance,
    Albert.

    Hey Nikola,
    Thanks for the reply.
    That is what looked so obvious to me too. My EJB is only using the local interfaces. Actually, here i am trying to use bean managed relationships. The EJB just doesn't seem to be getting deployed. Whenever i change all the references type of the specific local object to "Object" class, deployment goes thru successfully. My problem is compounded by the fact that oracle doesn't even give out any sensible error message. So i was wondering whether returning of the reference is allowed.
    Thanks,
    Albert.

  • SALES RETURN WITH REFERENCE GL accounts

    Hello SAP Gurus
    when we do salesreturn with reference it will pick the same pricing procedure in returns and the accounting document in credit memo will be a reverse to same gl as in normal pricing procedure
    eg customer dr    123
         sales ac                 cr   222
         bed                        cr   333
         ecess                    cr    444
         sheces                  cr    555
         vat                         cr    666
    In returns with refernce the same entry will get reversed
    eg customer cr   123
         sales ac                 dr   222
         bed                        dr   333
         ecess                    dr    444
         sheces                  dr    555
         vat                         dr    666
    But my client requremnt is instead of sales ac 222  he wants a new sale return ac to be debited with new GL 232 but in scenario sales return with refernce its looking impossible to me
    Can any one guide me on this is there ne other way out HERE I AM ONLY ADDRESSING SALES RETURN WITH REFERENCE

    Hi - try this out -
    copy your existing pricing procedure to new one
    (eg pric proc zvva01 to zvret01)
    for zvret01, assign new gl account determination as required
    assign zret01 to billing type for returns
    try it out and see if yoiu can make it work
    cheers
    nandu

  • Splitting out string, using the results to lookup reference, then returning the reference name as a string?

    I have a field that contains a comma separated string of sys_id’s that relate to another table.
    I am trying to write a query that returns the name value from the reference table, so that the result is a comma separated string of the name field.
    Can anyone help with the SQL required to split out the sys_id’s, do the look-up and return the names back into a string?
    Table1
    Number
    Category
    1001
    Sys_id1, Sys_id3, Sys_id9
    1002
    Sys_id3
    1003
    Sys_id4,Sys_3
    1004
    Sys_id1, Sys_id9, Sys_id10, Sys_id6
    Category Reference Table
    Category Sys_id
    Category_Name
    Sys_id1
    Consulting
    Sys_id3
    Negotiate
    Sys_id4
    Planning
    Sys_id6
    Building
    Sys_id9
    Receipt
    Sys_id10
    Complete
    The result I am looking for would be.
    Number
    Category
    1001
    Consulting, Negotiate, Receipt
    1002
    Negotiate
    1003
    Planning, Negotiate
    1004
    Consulting, Receipt, Complete, Building

    I am not going to arguee regarding your model, but you should consider normalizing it.
    The idea is to have a function to split the string and return a row for each element in the list. Dump the result into a table and then use FOR XML PATH to do the string aggregation.
    To learn about different methods you could use to create the split function refer to this article.
    Arrays and Lists in SQL Server
    http://www.sommarskog.se/arrays-in-sql.html
    Here is an example using XML methods. This is just an example and it doesn't deal with proper indexing, weird characters as part of the list that can't be translated as xml, etc.
    SET NOCOUNT ON;
    USE tempdb;
    GO
    DECLARE @T TABLE (
    Number int,
    Category varchar(50)
    INSERT INTO @T (Number, Category)
    VALUES
    (1001, 'Sys_id1, Sys_id3, Sys_id9'),
    (1002, 'Sys_id3'),
    (1003, 'Sys_id4, Sys_id3'),
    (1004, 'Sys_id1, Sys_id9, Sys_id10, Sys_id6');
    DECLARE @R TABLE (
    Sys_id varchar(15),
    Category_Name varchar(35)
    INSERT INTO @R (Sys_id, Category_Name)
    VALUES
    ('Sys_id1', 'Consulting'),
    ('Sys_id3', 'Negotiate'),
    ('Sys_id4', 'Planning'),
    ('Sys_id6', 'Building'),
    ('Sys_id9', 'Receipt'),
    ('Sys_id10', ' Complete');
    DECLARE @W TABLE (
    Number int,
    pos int,
    Sys_id varchar(15),
    PRIMARY KEY (Number, Sys_id)
    INSERT INTO @W (Number, pos, Sys_id)
    SELECT
    A.Number,
    ROW_NUMBER() OVER(PARTITION BY A.Number ORDER BY N.x) AS pos,
    N.x.value('(text())[1]', 'varchar(15)') AS Sys_id
    FROM
    @T AS A
    CROSS APPLY
    (SELECT A.Category AS [text()] FOR XML PATH('')) AS B(c)
    CROSS APPLY
    (SELECT CAST('<l>' + REPLACE(B.c, ', ', '</l><l>') + '</l>' AS xml)) AS C(x)
    CROSS APPLY
    C.x.nodes('/l') AS N(x);
    SELECT
    A.Number,
    STUFF(
    SELECT
    ', ' + C.Category_Name
    FROM
    @W AS B
    INNER JOIN
    @R AS C
    ON C.Sys_id = B.Sys_id
    WHERE
    B.Number = A.Number
    ORDER BY
    B.pos
    FOR XML PATH(''), TYPE
    ).value('(text())[1]', 'varchar(MAX)'), 1, 2, '') AS Category
    FROM
    @T AS A;
    GO
    AMB
    Some guidelines for posting questions...

  • Returning VI reference from control object reference

    Dear All
    I was wondering if there is anything that acts like inverse of "To more specific class" ? I mean it returns the VI reference from a reference to one of its control object? I think it is like moving upward in the hierarchy!!
    Is there any way to implement that?
    Best ragards
    Afshin
    Solved!
    Go to Solution.

    The property OWNER allows you to climb up the tree.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for