How BAPI Tables parameters are passed by reference

Hi Gurus,
                 I have a genuine doubt regarding BAPI parameters. I would like to point out the genreal rules of bapi like,
1. BAPI parameters should be passed by value. (Because they are rfc fm's. So both systems will be in different servers. This is the normal scenario.)
2. But the tables parameters in BAPI can't be passed by value. Instead they are passed by reference.
3. I know they use some kind of delta mechanism to transfer tables parameters to remote servers.
So gurus I would like to know what exactly happens when a tables parameter is passed. And also I didn't understand the delta mechanism. Kindly guide me.
Thanks in advance,
Jerry Jerome

You'll see in [SAP Library - RFC - Parameter Handling in Remote Calls|http://help.sap.com/saphelp_nw04s/helpdata/en/22/042551488911d189490000e829fbbd/frameset.htm] that tables are not passed by reference when you use RFC. It also explains the delta.
When you make a remote function call, the system handles parameter transfer differently than it does with local calls.
TABLES parameters
The actual table is transferred, but not the table header. If a table parameter is not specified, an empty table is used in the called function.
The RFC uses a delta managing mechanism to minimize network load during parameter and result passing. Internal ABAP tables can be used as parameters for function module calls. When a function module is called locally, a parameter tables is transferred u201Cby reference". This means that you do not have to create a new local copy. RFC does not support transfer u201Cby referenceu201D. Therefore, the entire table must be transferred back and forth between the RFC client and the RFC server. When the RFC server receives the table entries, it creates a local copy of the internal table. Then only delta information is returned to the RFC client. This information is not returned to the RFC client every time a table operation occurs, however; instead, all collected delta information is passed on at once when the function returns to the client.
The first time a table is passed, it is given an object-ID and registered as a "virtual global table" in the calling system. This registration is kept alive as long as call-backs are possible between calling and called systems. Thus, if multiple call-backs occur, the change-log can be passed back and forth to update the local copy, but the table itself need only be copied once (the first time).

Similar Messages

  • How to Identify the count , If multiple parameters are passed using Pipe Delimited string

    Hi,
    We are passing Pipe delimited string to the parameter and I want to know how many values we are passing to the parameter.
    Here is the example
    Parameter.Grant: 24|34|54|67
    I am using below expression, but it is not giving the right values. Please let me know if  I am missing anything or is it possible.
    =iif(parameters!Grant.Count>1,"Multiple value selected",parameters!Grant.Value)

    Hi NaveenCR,
    According to your description, you used pipe delimited multi-value parameter in the report, you want to know how many values passed to the parameter. If that is the case, please refer to the following steps:
    In Design view, click Text Box in the Toolbox.
    On the design surface, click and then drag a box to the desired size of the text box.
    Right-click inside of the text box, then click Expression.
    In Expression text box, type the expression like below:
    =iif(split(Parameters! Grant.Value,"|").Length>1," Multiple value selected",Parameters!Grant.Value)
    The following screenshots are for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • New in NW04s: FL069 TABLES parameters are obsolete (in function modules)

    Can somebody explain what is the fundamental reason for this behaviour in NW04s?
    In Netweaver 2004s system (like ERP2005 ) you get a warning message in SE37:
    FL069 TABLES parameters are obsolete! when defining quite ordinary tables parameter using LIKE and reference to a structure in ddic.
    I now speak normal function modules, not RFC enabled.
    This example of tables parameter definition will cause the warning message:
    return LIKE BAPIRET2
    I of course looked the additional help provided by this message FL069. I understood it as following:
    you should stop using TABLES parameter and more often use CHANGING parameter by referring a TABLE TYPE defined in dictionary.
    if using CHANGING parameter and still want to pass the header line of your internal table you should use a separate parameter (EXPORT or CHANGING parameter)
    Developers have too much used TABLES parameters for passing internal tables for reading (by value) rather than to be modified (by reference). As a consequence, fm could have change the header line without caller to know it.
    in my opinion the message help is missleadingly telling that header line is no longer passed to function module if TABLES parameter is used. I made a small test program and fm (with TABLES paramerer), and everything worked as before.
    The warning message can be ignored by pressing Enter a few times and your fm with TABLES parameter works as it had in older versions of Netweaver.
    SAP is still using a lot of TABLES parameters in their own function modules. For example SD_SALES_HEADER_MAINTAIN.
    So what is the point of this warning message while everything still works as it used to be and SAP uses this same "OBSOLETE" feature itself? Is there anything more fundamental behind this message? Like TABLES paremeters will no longer work in future versions of ABAP (or header line passing will be ignored in future versions) and therefore developers should switch to CHANGING/EXPORT parameters with TABLE TYPES as soon as possible??
    Please understand that I don't need any assistance how to avoid this message, just interested to share your opinions what is the purpose of this warning message.
    That is why I did not marked this thread as a question.
    Br: Kimmo

    Hello,
    This is the view under Tables tab in my function builder:
    I_T_SELECT     TYPE     SRSC_S_IF_SIMPLE-T_SELECT
    I_T_FIELDS     TYPE     SRSC_S_IF_SIMPLE-T_FIELDS
    E_T_DATA     LIKE     SFLIGHT (which I change to YBWxxxx)
    The moment I change to YBWxxxxx it gives me that error '"TABLES parameters are obsolete! "'
    and unfortunately hitting enter several times is not helping  either
    Thanks!

  • Tables parameters are obsolete

    hi,
          i am trying to create one function module in ecc6.0 version. And after declaration under tables table like "errortable like bapiret2" i am getting the warning "tables parameters are obsolete". please help me to solve this problem.
                                                                        Thanks&Regards,
                                                                         chakradhar.M.

    Hi,
    It just a warning message..Press enter to continue..
    OR
    create a table type in the DDIC for the structure and use that table type in the EXPORTING parameter...
    Thanks
    Naren

  • Strings are passed by Reference

    Since strings are objects, they are passed by reference. I tested this out:
    1.in main(): String str="in main"; creates a new string "in main" and has str point to it.
    2.Passed str into changeStr(String str2)
    3.in changeStr: str2="in changeStr", since str2 is a reference, it should redirect str to point to the new string "changeStr".
    4.Back in main I print out str and get "in main".
    Why?

    (When you post source code, please put it in CODE tags; there's a button for that above the textarea.)
    Don't think of references as memory addresses; that makes them sound like C pointers, when in fact they're fundamentally different: a pointer points to a memory location, while a reference points to an Object. C lets you dereference a pointer and replace the data at that memory location with something else. Afterward, any existing variable that referred to the data in that section of memory, will see the new value.
    A Java reference lets you access the object to call its methods, examine its variables, and so on. If the object is mutable, you can change itss contents, and all existing variables that refer to that object will see those changes. But you can't replace the whole object with something else. Reassigning the variable that was passed into the method has no effect on the original object or on any other variables that pointed to it.
    So stop thinking of references as memory addresses. In fact, stop thinking about memory addresses, period. You never need that information in Java, and for that you should be eternally grateful. The absence of C pointers was one of Java's biggest selling points, way back when.
    Edited by: uncle_alice on Feb 27, 2008 7:55 AM
    Oh well. :-/ At least I may have done some good by asking the OP to use CODE tags.

  • RFC Lookup - BAPI-TABLE Parameters problem

    Hello All,
    I had a scenario where i need to export parameters and am supposed to get import parameters from BAPI between source and target structures.
    like -
    source --> BAPI execution = result --> target
    We had succeeded in getting those but the only problem is with TABLE parameters in that BAPI.
    How can we achieve it.
    Faster reply would be appreciated.
    Thanks & regards
    Reddy

    Hi VJ,
    Its not a simple source-target mapping .
    For Ex :
    Source-Bapi-Idoc
    Source will send some parameters to BAPI and bapi will execute it and respond with values in table parameter of the bapi and result would be assigned to idoc-field.
    For this i am using RFC Look up with sample code as :
    String rfcxml ="<ns0:Z_BAPI xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">" +
    "     <A>" + A + "</A>" +       --- Export parameters
    "     <B>" + B + "</B>" +       --- Export parameters
    //"                       <TABLE><FIELD1>" + FIELD2 + "</FIELD1></TABLE>" +
    //"                       <TABLE><FIELD2>" + FIELD2 + "</FIELD2></TABLE>" +
    //"                       <TABLE><FIELD3>" + KDMAT+ "</FIELD3></TABLE>" +
    //          "<FIELD1>" + FIELD1 + "</FIELD1>" +
    "</ns0:Z_BAPI> "  ;
    Passing A & B as export parameters and getting TABLE-FIELD1&2&3 as response.
    I hope some problem in the syntax.
    Regards,
    HP

  • Arrays are passed by reference or value ?

    Hi peoples,
    I have something interesting here which I need to know. Look into the following classes :
         public class example1 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         i[0] = 2;
         i[0] *= 2;
         public class example2 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         int j[] = {2};
         i = j;
    Among the above classes, the class named 'example1' returns the value 4 whereas, the class named 'example2' returns the value 1.
    Any explanations to this one please....
    Cheers,
    Rasmeet

    minglu, you are not doing right.
    i just don't get it why you have i[] as instance variable but never use it ( i[] is declared in every method so each i you refer to in the method is a local varable not member variable that can be shared for the object ).
    your first solution work. but that i = j line is not needed because it has no effect you still cannot change the referrence of i to other int[]. your first soultion just need to be
    public static int[] change_i(int i[]) {
    int j[] = {2};
    return j;
    }anyway, using this solution, the method name will be misleading because the method didnot change i in anyway. i is changed because you assign the return array (j) to i.
    for that second solution also, you didn't use your member variable i at all. what you change is the content of i you pass so the result is correct. but then how is this method different from the first method the original poster posted?
    moreover, java never pass argument to the method by reference it ALWAYS pass by copy.i suppose you define passing by reference in the same way C++ does. all object variable in java is a refernce to Object so passing the variable to method is surely passing the reference to the method but that's not passing by reference. it's passing by copy because what is passed is the copy of the reference to the object, not the reference to the reference to Object. if it is really passing by refernce, then you will be able to change your reference to object to point anywhere because you have the access the address of the reference. but since you don't (you only know where the passed reference is pointing to (you have the COPY of value of reference) but you don't know where the refernce store its value) you can only change the content of the pointed object but not changing the pointed object.
    let me restate this, java always pass by reference.

  • BPEL to JDE 811, parameters are passed as zero

    Hi,
    We have finished all configuration from Adapter Installation guide as well as from User's guide.
    When we are making a call from our BPEL to JDE 811 functions,
    1) For the functions that are not having any parameters (e.g. GetAuditInfo), are returning correct outputs or say valid response. but
    2) When we make a call to function that are having parameters (e.g. GetYearDescription, GetEffectiveAddress), the values of the parameters are being passed as zero. Or JDE is sending responses like the parameters we passed were absolute zero.
    like for GetYearDescription, i'm giving following XML as input,
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/JDE_SERVICE2">
    <ns1:jdeRequest type="callmethod">
    <callMethod name="GetYearDescription" runOnError="no">
    <params>
    <param name="mnCalendarYear">95</param>
    </params>
    <onError abort="yes"/>
    </callMethod>
    </ns1:jdeRequest>
    </soap:Body>
    </soap:Envelope>
    But instead of 1995, we are getting response as 2000 as parameter values is somehow passed as zero.
    We have checked on JDE side and tested above functions are working OK.
    Can anybody help us and say why the values are being treated as zero.
    Thanks,
    Nirav

    Hi,
    Thanks for the response, but I'm still facing the issue.
    As you suggested, I configured my Application Explorer for Attribute Style and get connected. I generated the WSDL and Schema for GetYearDescription. I created the BPEL process and again gave the input as I mentioned above, but it is still giving me 2000 as output. Am'I following the correct process ?
    Invoke Audit Trail from BPELConsole for after running the process is as below :
    <messages><Invoke_1_GetYearDescription_InputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="input_GetYearDescription"><jdeRequest type="callmethod" session="" xmlns="urn:iwaysoftware:jde/services/JDEJAVA_CMFGBASE/B3000260/GetYearDescription">
    <callMethod name="GetYearDescription" runOnError="no" xmlns="">
    <params>
    <param name="mnCalendarYear">95</param>
    </params>
    <onError abort="yes"/>
    </callMethod>
    </jdeRequest>
    </part></Invoke_1_GetYearDescription_InputVariable><Invoke_1_GetYearDescription_OutputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="response-headers">[]</part><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="output_GetYearDescription"><jdeResponse xmlns="urn:iwaysoftware:jde/services/JDEJAVA_CMFGBASE/B3000260/GetYearDescription" user="PSFT" type="callmethod" session="6656.1211956064.15" environment="DV811" role="*ALL">
    <callMethod name="GetYearDescription" runOnError="no">
    <returnCode code="0"/>
    <params>
    <szYearDescription>2000</szYearDescription>
    </params>
    </callMethod>
    </jdeResponse>
    </part></Invoke_1_GetYearDescription_OutputVariable></messages>
    And here is my WSDL which I generated with Attribute_Style JDE Connection from Application Explorer :
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="GetYearDescription"
    targetNamespace="http://xmlns.oracle.com/pcbpel/iWay/wsdl/JDEdwards/JDEOne/GetYearDescription"
    xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
    xmlns:iWay="http://xmlns.oracle.com/pcbpel/adapter/iWay/"
    xmlns:GetYearDescription="http://xmlns.oracle.com/pcbpel/iWay/wsdl/JDEdwards/JDEOne/GetYearDescription"
    xmlns:pc="http://xmlns.oracle.com/pcbpel/"
    xmlns:iWayRequest="urn:iwaysoftware:jde/services/JDEJAVA_CMFGBASE/B3000260/GetYearDescription" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:iwaysoftware:jde/services/JDEJAVA_CMFGBASE/B3000260/GetYearDescription"
    xmlns:ns="urn:iwaysoftware:jde/services/JDEJAVA_CMFGBASE/B3000260/GetYearDescription" elementFormDefault="qualified">
    <xsd:element name="jdeRequest">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="callMethod">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="params">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="param" minOccurs="0" maxOccurs="2">
    <xsd:complexType>
    <xsd:simpleContent>
    <xsd:extension base="xsd:string">
    <xsd:attribute name="name" use="required">
    <xsd:simpleType>
    <xsd:restriction base="xsd:NMTOKEN">
    <xsd:enumeration value="mnCalendarYear"/>
    <xsd:enumeration value="szYearDescription"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    </xsd:extension>
    </xsd:simpleContent>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="onError" minOccurs="0">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:any minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="abort" use="required">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="yes"/>
    <xsd:enumeration value="no"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    <xsd:attribute name="name" use="required">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="GetYearDescription"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    <xsd:attribute name="app" type="xsd:string" use="optional"/>
    <xsd:attribute name="runOnError" use="optional">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="yes"/>
    <xsd:enumeration value="no"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    <xsd:attribute name="returnNullData" use="optional">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="yes"/>
    <xsd:enumeration value="no"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    <xsd:attribute name="trans" type="xsd:string" use="optional"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    <xsd:attribute name="type" use="required">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="callmethod"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:attribute>
    <xsd:attribute name="session" type="xsd:string" use="optional"/>
    <xsd:attribute name="sessionidle" type="xsd:string" use="optional"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    ...Response Schema ...
    Can you tell me that what exactly should be my input XML. soap:Envelope and soap:Body are required right ?
    Thanks,
    Nirav

  • BAPI Table Input not passing to R/3 Backend

    Hello Experts,
    I am having trouble populating a Table input in my Web Dynpro Java application.  I have tried researching this issue on SDN and have attemped many of the solutions with no luck.  Here is my code:
              Bapi_Order_Input NewOrder = new Bapi_Order_Input();
              wdContext.nodeBapi_Order_Input().bind(NewOrder);
              Bapisdhd1 OrderHead = new Bapisdhd1(); - <i>(This is part of the Input Paramter, values are successfully passed)</i>
              OrderHead.setDoc_Type("ZOR");
              OrderHead.setSales_Org("2000");
              OrderHead.setDistr_Chan("40");
              NewOrder.setOrder_Header_In(OrderHead);                    
              Bapiparnr Partner = new Bapiparnr(); - <i>(This is a table parameter, values are not being passed to the backend)</i>
              Partner.setPartn_Role("SP");
              Partner.setPartn_Numb("20010");
              Partner.setItm_Number("000000");     
              NewOrder.addOrder_Partners(Partner);
              wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();
    I cannot use "NewOrder.setOrder_Partners(Partner)" because Order_Partners is an AbstactList.  I have attempted to create this abstract list below but it will not syntactically check:  
    AbstractList PartnerList = new Bapiparnr.Bapiparnr_List();
    If I test these same input values above in R/3, the BAPI executes fine.  When I test the BAPI from WD, I get the return message " Please enter a Sold-To or ShipTo Party".  I can replicate this same message in R/3 if I do not populate the Partner table.
    I am also able to see the Partner values I enter when I create a Table is display them in Web Dynpro.
    This is frusterating me a great deal and I would greatly appreciate, and rewards, any suggestions or recomendations.
    Thank you for your help,
    Matt

    Hi Everyone,
    Well, I was finally able to resolve my issue.  After debugging the Web Dynpro Application from the ECC BAPI side, I was able to see that the Partner values were failing to be passed to the back-end SAP system.  After I restarted the J2EE engine, I was able to create the sales order.
    I noticed a couple of interesting things as well:
    -You need to fill in the leading zeros for Customer Number (KUNNR) before passing of this value
    -The ECC BAPI automatically (atleast in my case) changed the input value of Partner-PartnerRole from "SP" to "AG".  This change occurs before the first step in the Debugger is performed.  This change, however, does not occur when the BAPI is called from Web Dynpro.  Once I edited the Web Dynpro Partner Role input to "AG", I was able to create the sales order.
    I have list my code below, thank you all for your help.
    Regards,
    Matt
         Bapi_Salesorder_Createfromdat2_Input SO = new Bapi_Salesorder_Createfromdat2_Input();
         Bapi_Transaction_Commit_Input Commit = new Bapi_Transaction_Commit_Input();
         Bapisdhd1 OrderHeader = new Bapisdhd1();
         OrderHeader.setSales_Off("0000");
         OrderHeader.setDoc_Type("ZOR");
         OrderHeader.setPo_Meth_S("CU01");
         SO.setOrder_Header_In(OrderHeader);
         Bapiparnr Partner = new Bapiparnr();
         Bapiparnr.Bapiparnr_List PartnerList = new Bapiparnr.Bapiparnr_List();     
         Partner.setPartn_Numb(PartnerNumber);
         Partner.setPartn_Role("AG");
         PartnerList.addBapiparnr(Partner);
         SO.setOrder_Partners(PartnerList);
         int size = wdContext.nodeShoppingCart().size();
         BigDecimal Qty;
         Bapisditm.Bapisditm_List ItemsList = new Bapisditm.Bapisditm_List();
         Bapisditm Items;
         IPublicUserAccount.IShoppingCartElement CartItem = wdContext.currentShoppingCartElement();
         for (int i=0; i < size; i++){     
              Items = new Bapisditm();
              Qty = new BigDecimal(BigInteger.ZERO);
              CartItem = wdContext.nodeShoppingCart().getShoppingCartElementAt(i);
              Qty = Qty.add(BigDecimal.valueOf(CartItem.getQuantity()));                              
              Items.setTarget_Qty(Qty);
              Items.setTarget_Qu("EA");
              Items.setMaterial(CartItem.getMaterial_number());          
              ItemsList.add(Items);
         SO.setOrder_Items_In(ItemsList);     
         wdContext.nodeBapi_Salesorder_Createfromdat2_Input().bind(SO);
         wdContext.nodeBapi_Transaction_Commit_Input().bind(Commit);
    catch(Exception ex) {
         IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
         msgMgr.reportException(ex.getLocalizedMessage()+ " Create SO Failed!", true);
         try {
              wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();
              wdContext.currentBapi_Transaction_Commit_InputElement().modelObject().execute();
         catch (Exception ex){
              IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
              msgMgr.reportException(ex.getLocalizedMessage()+ " Retrieve Cart Failed!", true);

  • How to change parameters of Static VI Reference

    Can anyone let me know how to change the parameters of a static vi reference please? right now when I right click on it, just says "Strictly Typed VI". I don't know how to add/delete/change the parameters of it.
    Thanks,
    Solved!
    Go to Solution.

    Hello Triple H,
    This is Andrew Brown, an Applications Engineer with National Instruments. You will need to go through the process to create a new strictly typed VI reference in order to update the parameters of your Call by Reference Node. An article that details this process is Creating a Strictly Typed VI Reference That Calls VIs Dynamically. 
    Please let me know if you have additional questions or issues in this area.
    Regards,
    Andrew Brown
    Applications Engineer
    National Instruments

  • Table Parameters are obsolete in ECC 6.0

    hello All,
    I have created a function module in ECC6.0 and I need an internal table as a parameter but SAP will not allow it to be created as a tables parameter only as a changing parameter. How do you do this as a changing parameter. I am using structure type MMPUR_TEXTLINES.
    Thanks

    Use tables tab instead of changing.
    then use
    MMPUR_TEXTLINES     LIKE    MMPUR_T_TEXTLINES

  • Pass by reference and String

    public class Test {
        static void method(String str) {
            str = "String Changed";
        public static void main(String[] args) {
            String str = new String("My String");
            System.out.println(str);
            method(str);
            System.out.println(str);
    }The output is
    My String
    My String
    How this is possible when objects are passed by reference ?

    > How this is possible when objects are passed by reference ?
    All parameters to methods are passed "by value." In other words, values of parameter variables in a method are copies of the values the invoker specified as arguments. If you pass a double to a method, its parameter is a copy of whatever value was being passed as an argument, and the method can change its parameter's value without affecting values in the code that invoked the method. For example:
    class PassByValue {
        public static void main(String[] args) {
            double one = 1.0;
            System.out.println("before: one = " + one);
            halveIt(one);
            System.out.println("after: one = " + one);
        public static void halveIt(double arg) {
            arg /= 2.0;     // divide arg by two
            System.out.println("halved: arg = " + arg);
    }The following output illustrates that the value of arg inside halveIt is divided by two without affecting the value of the variable one in main:before: one = 1.0
    halved: arg = 0.5
    after: one = 1.0You should note that when the parameter is an object reference, the object reference -- not the object itself -- is what is passed "by value." Thus, you can change which object a parameter refers to inside the method without affecting the reference that was passed. But if you change any fields of the object or invoke methods that change the object's state, the object is changed for every part of the program that holds a reference to it. Here is an example to show the distinction:
    class PassRef {
        public static void main(String[] args) {
            Body sirius = new Body("Sirius", null);
            System.out.println("before: " + sirius);
            commonName(sirius);
            System.out.println("after:  " + sirius);
        public static void commonName(Body bodyRef) {
            bodyRef.name = "Dog Star";
            bodyRef = null;
    }This program produces the following output: before: 0 (Sirius)
    after:  0 (Dog Star)Notice that the contents of the object have been modified with a name change, while the variable sirius still refers to the Body object even though the method commonName changed the value of its bodyRef parameter variable to null. This requires some explanation.
    The following diagram shows the state of the variables just after main invokes commonName:
    main()            |              |
        sirius------->| idNum: 0     |
                      | name --------+------>"Sirius"       
    commonName()----->| orbits: null |
        bodyRef       |______________|At this point, the two variables sirius (in main) and bodyRef (in commonName) both refer to the same underlying object. When commonName changes the field bodyRef.name, the name is changed in the underlying object that the two variables share. When commonName changes the value of bodyRef to null, only the value of the bodyRef variable is changed; the value of sirius remains unchanged because the parameter bodyRef is a pass-by-value copy of sirius. Inside the method commonName, all you are changing is the value in the parameter variable bodyRef, just as all you changed in halveIt was the value in the parameter variable arg. If changing bodyRef affected the value of sirius in main, the "after" line would say "null". However, the variable bodyRef in commonName and the variable sirius in main both refer to the same underlying object, so the change made inside commonName is visible through the reference sirius.
    Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory. If the Java programming language actually had pass-by-reference parameters, there would be a way to declare halveIt so that the preceding code would modify the value of one, or so that commonName could change the variable sirius to null. This is not possible. The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
    -- Arnold, K., Gosling J., Holmes D. (2006). The Java� Programming Language Fourth Edition. Boston: Addison-Wesley.
    ~

  • Subroutine Pass by Value, Pass by Reference using xstring

    Hi,
      I am trying to check the difference between pass by value, pass by reference, pass by return value to a subroutine. When I tried integers as parameters the following functionality worked. When I am using xstring as parameters I am not getting desired results.
      Some one please explain me how the xstring's are passed to a subroutine.
    Here I am giving the code and output of the code.
    data : s_passbyref    type xstring,
           s_passbyval    type xstring,
           s_passbyretval type xstring.
    * Pass by Value, Pass by Reference, Pass by return value - STRINGS
    s_passbyref     = 'ABCD'.
    s_passbyval     = 'ABCD'.
    s_passbyretval  = 'ABCD'.
    write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', s_passbyretval.
    perform call_str_sub using s_passbyref s_passbyval changing s_passbyretval.
    write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', s_passbyretval.
    form call_str_sub using ps_passbyref value(ps_passbyval) changing value(ps_passbyretval).
      ps_passbyretval = 'XYZ'.
      ps_passbyref    = 'XYZ'.
      ps_passbyval    = 'XYZ'.
    endform.
    OUTPUT
    ByRef  :  ABCD    By Val : ABCD    By Return Value : ABCD
    ByRef  :               By Val : ABCD    By Return Value :
    Thanks in advance
    Naveen

    try this
    write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', ps_passbyretval.

  • Tables parameters obsolete

    Hi all,
    In ecc6.0 i have been trying to use tables parameters while designing function modules and it says tables parameters are obsolete, what should be used here and how?
    Regards,
    C.A

    Hi,
    Create a table type in Se11 of the type internal table.
    Now when you are decalring the internal table in Changing parameter give the reference of that table type.
    Create another work area in the source code of function module.
    now loop the Internal table sa usual.
    regards,
    Sujit

  • BAPI FM Parameters problem

    Hi,
    I have  created BAPI using the Zfunction Module. Now this is working fine.
    Now i have changed the parameteres in Z FM. When I executed the BAPI. It is giving error. So, i have re generated the BAPI. But new parameters are not coming in BAPI.
    My doubt is, after changes in FM, in BAPI What steps i have to do. is re generate enough? or any thing i have to do?
    Regards,
    Balu

    Hi,
    Check the source code of the BAPI if it matches with the changed parameters of the Z Function Module. If it was working fine  before, the problem must lie in the source code of the BAPI where the Z Function Module parameters are passed.
    Regards,
    Vik

Maybe you are looking for

  • Autofill on SMS is very annoying. How can I shut it off?

    I have to send a lot of text to my work partner through short code/etc, but the autofill predicts the wrong words and makes me either have to go back and delete, or sends 'interpreted' gibberish. Is there a simple way to switch this unnecessary fucti

  • Curious question about Lightroom previews and Camera Raw Cache

    Posted in the Flickr Lightroom Group as well: I have noticed something about the Lightroom (3.6) previews and Camera Raw cache that have me puzzled. I create a brand new empty catalog and purge the Camera Raw Cache. Then I import ONE Nikon RAW (NEF)

  • Merging iPhoto Libraries from two Macs

    Does anyone have a way of physically combining (not just sharing) iPhoto libraries from two macs? I'm hoping there's an easier, smarter way of doing it than just exporting all of the photos from one and importing them into the other and then just doi

  • Element Creation for STD Sick Pay

    I am looking for information pertaining to the element set up requirements (including balance feeds) for the use with STD Sick Pay. All our STD sick pay payments are made by a contracted insurance company. The insurance company withholds only EE FICA

  • Select last 50 records

    I have 230 records in a table. How to select last 50 records?