References, objects, passing by value, etc.

This question is more for peace of mind than trying to fix a program. I am trying to understand Java more.
Some simple code:
LinkedList<String> L1;
void myMethod()
   String S1 = "";
   L1.add(S1);
}So I have a LinkedList<String> called L1. I also have a method myMethod(), in which I initialize a String object, S1. I want to call the add() function to add S1 to L1. What happens to the String?
When myMethod exits, the reference S1 is destroyed. Since S1 was copied as a parameter to add(), L1 now has its own reference to the String that was pointed to by S1. So is the String itself destroyed when myMethod exits, thus making LinkedList<String> a totally useless class? Apparently not. That means an object survives as long as there is a reference to it, even if the method in which it was created has exited. Correct?
I have another question, but String is an immutable object so I am thinking what I can use instead... let's use Point.
LinkedList<Point> L1;
Point myMethod()
   Point P1 = new Point(2, 3);
   L1.add(P1);
   return P1;
P1.set(3,4);
System.out.println(L1.getLast());
What does it print?
Many thanks,
daarklord

daarklord wrote:
That means an object survives as long as there is a reference to it, even if the method in which it was created has exited. Correct?Yes. As long as an object has at least one reference to it, it cannot be GC.
LinkedList<Point> L1;
Point myMethod() {
    Point P1 = new Point(2, 3);
    L1.add(P1);
    return P1;
P1.set(3,4);
System.out.println(L1.getLast());For starters this will generate an error since the P1 variable is declared inside the method and is not available outside the method. However if we ignore this fact then since the P1 variable and the List both hold a reference to the same object, if you make a change then both references will reflect that change.

Similar Messages

  • In a single JVM the objects can pass-by-value ?

    what happen when a bean call to another bean which already deployed in the same container?
    how many JVMs in a container?

    "I thought parameters were all pasted by value because Java doesn't support pointers?"
    Incorrect assumption.
    Java doesn't let you fiddle with pointers, but effectively all object variable references are pointers (not exactly though). If you are working in a single JVM all params are passed by value, but when you think you are passing objects you are really passing object references, so it is they (the object references) that are passed by value.
    Within the scope of EJB, objects (not the references) are passed by value because we are talking about remote method calls. Since calls are assumed to be between separate JVMs the object state must be copied across the wire.
    In the case of an EJB calling another within the same JVM, the parameters passed must still be passed by value since the receiving code may rightfully assume there is no shared object state (the implementation could be pass-by-ref as long as the container could somehow support the above assumption, not very likely).

  • Confused about passing by reference and passing by valule

    Hi,
    I am confuse about passing by reference and passing by value. I though objects are always passed by reference. But I find out that its true for java.sql.PreparedStatement but not for java.lang.String. How come when both are objects?
    Thanks

    Hi,
    I am confuse about passing by reference and passing
    by value. I though objects are always passed by
    reference. But I find out that its true for
    java.sql.PreparedStatement but not for
    java.lang.String. How come when both are objects?
    ThanksPass by value implies that the actual parameter is copied and that copy is used as the formal parameter (that is, the method is operating on a copy of what was passed in)
    Pass by reference means that the actual parameter is the formal parameter (that is, the method is operating on the thing which is passed in).
    In Java, you never, ever deal with objects - only references to objects. And Java always, always makes a copy of the actual parameter and uses that as the formal parameter, so Java is always, always pass by value using the standard definition of the term. However, since manipulating an object's state via any reference that refers to that object produces the same effect, changes to the object's state via the copied reference are visible to the calling code, which is what leads some folk to think of java as passing objects by reference, even though a) java doesn't pass objects at all and b) java doesn't do pass by reference. It passes object references by value.
    I've no idea what you're talking about wrt PreparedStatement, but String is immutable, so you can't change its state at all, so maybe that's what's tripping you up?
    Good Luck
    Lee
    PS: I will venture a guess that this is the 3rd reply. Let's see...
    Ok, second. Close enough.
    Yeah, good on yer mlk, At least I beat Jos.
    Message was edited by:
    tsith

  • Passing by value

    Hi all,
    Can anyone please tell me how can we achieve passing by value in objective-c?
    I am using:
    NSMutableString *fileNames;
    //do some operation on fileNames
    \[self printData:fileNames\];
    -(void)printData: (NSString*)dataToPrint
    //some code
    Is this passing by reference or passing by value??
    If it is passing by reference then how can we achieve passing by value??
    Thanks and Regards,
    $hr!k@nt

    In Objective-C, objects are ALWAYS treated as "reference to an object", so passing an objects by value like in C++ is "impossible" in Objective-C, like in Java and C# (which have adopted that system from Objective-C).
    The compiler won't accept that you pass the object by value, that means you can't take the star "*" off to remove the reference.
    The bycopy keyword is a different matter, it's here for remote messaging optimization. When you do not need a passed object to be modified by the callee you pass it "bycopy" to tell the compiler that the new object value needs not to be sent back to the caller.
    However, if you really need an object passed by value there's a hack using C-structures.
    If you're using Objective-C 1.0 (pre-Leopard) you can use the @defs directive like that :
    typedef struct MyClassStruct {
    @defs(MyClass);
    } MyClassStruct;
    MyClass *obj = [[MyClass alloc] init];
    MyClassStruct myObj = *(MyClassStruct *)obj;
    That's not valid in Objective-C 2.0 (Leopard and later) because @defs is deprecated.
    However, you can do manually what @defs do automatically but that's not portable. You just need to define a struct with all the instance variable of the class and its super classes in the same order, for example :
    @interface MyClass : NSObject {
    int value;
    char *string;
    @end
    typedef struct MyClassStruct {
    Class isa;
    int value;
    char *string;
    } MyClassStruct;
    After all of that, you just need to put your struct type as the argument type. And you can then pass the objects "by value"... But that's an horrible, completely anti-OOP, non-portable hack which shouldn't be used.

  • RFC parameters (pass by value)

    I believe Iam missing something in the concept of passing by value and reference in a RFC FM.
    the question/s  is/are:
    we always have to check <b>'pass value'</b> for parameters(we get a syntax unless), but what value will be passed to the input parameters of the rfc,are they initial values based on type?
    and do we still have to give reference when it doesn't make sense in a  network?(or once the call is made from an outside system )
    RFC:
    <b>parameter/ ref / pass value</b>
    v_vbeln /like /vbak-vbeln / check
    hope i make sense.
    i would greatly appreciate any answers.
    thanks

    More F1 Help...
    <i>
    There are two types of parameter passing: pass by reference and pass by value.
    Pass by reference shows the formal parameter directly on the actual parameter so that changes to the formal parameter immediately affect the actual parameter.
    Pass by value creates the formal parameter either as a copy of the actual parameter when the function module is called (at IMPORTING value and CHANGING value parameters) or creates it initially on the stack (at EXPORTING value parameters). At CHANGING value and EXPORTING value parameters the formal parameter is copied onto the actual parameter when it returns from the function module call.
    </i>
    Regards,
    Rich Heilman

  • To pass parameter values to the object reference of action step in sequence file of teststand programatically using C#.

    //Initialize the Engine
                EngineClass myEngine = new EngineClass();
                myEngine.LoadTypePaletteFilesEx(TypeConflictHandlerTypes.ConflictHandler_Prompt, 0);
                Step myStep = myEngine.NewStep(AdapterKeyNames.DotNetAdapterKeyname,StepTypes.StepType_Action);
                myStep.Name = "object";
                DotNetModule dotnetmodule = myStep.Module as DotNetModule;
                dotnetmodule.SetAssembly(DotNetModuleAssemblyLocations.DotNetModule_AssemblyLocation_File,@"C:sequence.dll");
                dotnetmodule.ClassName = "CN";
                dotnetmodule.MemberType = DotNetModuleMemberTypes.DotNetMember_GetProperty;
                dotnetmodule.MemberName = "ISI";  
    mySequence.Locals.NewSubProperty("object", PropertyValueTypes.PropValType_Reference, false, "", 0);        
    Sequence mySequence = myEngine.NewSequence();
                mySequence.Locals.NewSubProperty(varName, PropertyValueTypes.PropValType_Reference, false, String.Empty, 0);
    mySequence.InsertStep(myStep, 0, StepGroups.StepGroup_Main);
                SequenceFile seqFile = myEngine.NewSequenceFile();
                seqFile.InsertSequence(mySequence);
    seqFile.Save("C:\\mySeq.seq");
    I have done this,dynamically creating a sequence file in teststand programatically through c#.
    Problem is
    1.I created an action step and object Reference variable for the step, but i am not able to pass  parameter values to the objectReference 
    2.I am not able to load the sequence in to the main Sequence of the sequence file in the teststand. How can I do these two things.

    Hi,
    have you ever followed on my Links ?!?!?
    If not please jump to this one
    http://forums.ni.com/ni/board/message?board.id=330&thread.id=26880 
    and read the the answer from Mannoch
    starting with this words:
    Anthony -
    Currently, functionality for retrieving the Metadata Token for a class constructor or member is not fully provided in the TestStand .NET Adapter API. The DotNetModule.GetConstructorMetadataToken() and DotNetModule.GetMetadataToken() methods only return the correct Metadata Token when the member/constructor prototypes have already been loaded. Thus, in the case of your code, when you call DotNetModule.GetMetadataToken(), the method is returning -1 because the member prototype for the Step you are referring to has not yet been loaded.
    That means have to do a workaround for your stuff.
    Juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

  • Objects - Pass by refrence or pass by value ----Confusion

    Hii Javaties
    I have confuison regardhing whether objects are passed by value or refernce -----------------------------------------------------
    i have a function ( test() ) that calls
    another function ( change(Test_Bean) ) which takes a bean as a parameter.
    If in this calling function i change the value of the bean , then the value of bean is actually altered in calling function .
    function change(Test_Bean)
         test_bean.setName("Peter");
    function test()
          Test_Bean test_bean=new Test_Bean();
           test_bean.setName("Tom");
           change(test_bean);
           System.out.println("Name ="+ test_bean.getName());
           /* Name = Peter is printed */
    }Can anybody tell me why is this so ?

    Your code demonstrates the proper functioning of pass
    by value. You altered the state of an object by using
    the correct method. That has nothing to do with
    attempting to reassign the reference which would be
    pass by reference and you can't do.If this is pass be value , then how can i change the value of original copy ?
    If i am using the correct method to alter the state , then it sould alter the state of the local copy not the of original object.
    I am still confused .......

  • Parameter passing by value or by reference in function module

    hi everybody:
    Im a beginner for abap.
    Below description is described in online help.
    In function module, the CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.
    I understand parameters passing by value means values carried by parameters are transferred, but I do not understand what is "by reference".
    Please kindly give me a explanation.
    Regards.
    Andy

    hi,
    Function modules are modular units with interfaces. The interface can contain the following elements:
    Import parameters are parameters passed to the function module. In general, these are assigned
    standard ABAP Dictionary types. Import parameters can also be characterized as optional.
    Export parameters are passed from the function module to the calling program. Export parameters
    are always optional and for that reason do not need to be accepted by the calling program.
    Changing parameters are passed to the function module and can be changed by it. The result is
    returned to the calling program after the function module has executed.
    Exceptions are used to intercept errors. If an error triggers an exception in a function module, the
    function module stops. You can assign exceptions to numbers in the calling program, which sets the
    system field SY-SUBRC to that value. This return code can then be handled by the program.
    By reference Passes a pointer to the original memory location.  Very efficient
    By value Allocates a new memory location for use within the subroutine. The memory is freed when the subroutine ends.  Prevents changes to passed variable
    By value and result Similar to pass by value, but the contents of the new memory is copied back into the original memory before returning.  Allows changes and allows a rollback
    When you pass a parameter by reference, new memory is not allocated for the value. Instead, a pointer to the original memory location is passed. All references to the parameter are references to the original memory location. Changes to the variable within the subroutine update the original memory location immediately.
    1  report ztx1804.
    2  data f1 value 'A'.
    3
    4  perform s1 using f1.
    5  write / f1.
    6
    7  form s1 using p1.
    8      p1 = 'X'.
    9      endform.
    The code in Listing produces the following output:
    X
    Hope this helps, Do reward.

  • 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.

  • Passing array values to methods & Classes

    Hi,
    I have written the following two classes, I want to pass the value from one class - insersortest to the other class what kind of return statement do I do ? I am not sure what does this Comparable object do in this program ? I am trying the program (algorithm specfieid) from one of the Data Structure book.
    import java.io.*;
    import java.lang.*;
    public class Insersortest
    public static void main(String args[]) throws IOException
    Insersort ghl = new Insersort();
              Comparable a[] = {1, 3, 5, 9, 1};          
                   System.out.println("Detecting duplicates"+ ghl.insertA(a));               
    -=-=-=-
    class Insersort
    public static int insertA( Comparable [ ] a )
    for( int p = 1; p < a.length; p++ )
    Comparable tmp = a[ p ];
    int j = p;
    for( ; j > 0 && tmp.compareTo( a[ j - 1 ] ) < 0; j-- )
    a[ j ] = a[ j - 1 ];
    a[ j ] = tmp;
    Could somebody provide their view please.
    PK

    You return arrays just like any object:
    public Object[] getArray()Comparable is an interface. Any object that implements Comparable (and can therefore be stored in a Comparable's reference) is guarenteed to have a compareTo method.
    Does that help?

  • Acrobat pro Extended | Passing variable value with Querystring

    Hi,
    We are facing issue with opening a web link with passing a variable value as query string parameter. We have added a form button on the pdf page, on click of it we have opened a web page and we want to pass a variable value in the query string. We can not give the hard code value in querystring, as the value keeps on changing.
    Please refer to the images below.
    here the data will be my variable name, which contains some value. When i execute it, it passes data as a string, i want to pass its value in the query string parameter. How i can do this?
    I had found one more way, is to call a function on the form button click, and in that pass the query string parameter as a variable, it works. But the problem in this case i am faceing is, in the app.launchURL command i have to provide a http path, means something like http://www.google.com, then only it works. I have that page on my local (no server), so i want to add the path as onlu page.html
    //Reference code, this fun will be called on a button click
    function LaunchPage()
        app.launchURL("http://www.aptara.com/page.html?value="+data+""); //this works
        app.launchURL("page.html?value="+data+""); //this dosent works
    Please do let me know, how i should proceed. To repeat, i want to invoke a page, which is on my local system with a querystring, in which i sud pass a variable value.
    Thanks,
    Ajit danve
    Sr. Developer
    Aptara, Pune.

    re: George Johnson
    Thank you for the response. This process that we are looking to do is necessary. We have 400+ OLD PDF forms that currently are printed by our print shop and then manually filled out and scanned into our system. The current process requires a clinician to log into our scanning system, identify a patient chart, and then identify the type of report they are scanning in. This process is time consuming with possibility of errors (wrong chart selected, wrong form, etc.). Plus, we have to stock up to 400 forms at each location.
    We don’t have the funds to convert 400+ complex forms into electronic submissions where the form fields are discrete and file accordingly. So, what we have come up with to save costs of a new system and reduce potential errors is to add a barcode to each existing form.
    Basically, each form will get a barcode and a javascript function in the onload event to process and parse passed in link parameters.
    So when a clinician clicks on a form link in our EMR system the form will load passing in the patient acct. number and form name into the link parameters (all on our local intranet) so it will get embedded into the barcode on the form. They will then print the form fill out the data (or have the patient fill it out) and then drop it in the scanner. Our scanning system will automatically see the barcode and file the form under the correct patient and form folder based on the barcode info. (A scanned image of the form will save to the patient profile).
    Ultimately we would like to convert all of these forms to electronic signature/submission but we do not have the funds or the time to do this.

  • Pass Parameter value through hyperlink?

    Hello and a Happy New Year to everyone!
    I have an ASP.NET web application that I am making. I was wondering if it were possible to pass a value to a CR that has a parameter value.
    In my example, I have a report called rptLicenseReport. This report has a parameter value of FileNo. Which comes from the field File No in the table License Applications in the database (Access) . Of course, CR does its own curly bracket thing for the parameter... but I was wondering if it was possible to have a hyperlink on my main page that points to the report.aspx page (which holds the report viewer, and the report as a whole) while passing the File Number.
    Essentially I would like the link to look like : www.urllinkhere.com/report.aspx?FileNo=6
    and when clicked that path would open the report.aspx page and pass the FileNo into the report. I have tried to make the report and have the link pass just like that but the report comes back with an error stating that there is no parameters chosen/given (thinking off-hand, error is something like that).
    Any help with this problem would be greatly appreciated. For those interested my report is in VB language, not C#.
    Much Thanks!
    --Matt
    Edited by: Matthew Gonzalez on Jan 2, 2009 8:50 AM

    AG,
    Much thanks for the code, I modified it to fit my VB environment and it worked well. What I have it doing is utilizing some of the earlier information on the http requerying having the labelID in the URL get posted to a label. Using your code I then have the label ID set as the parameter source. This worked fine and it now populates the report with the ID of the earlier record selected.
    Here's my code as an FYI and future reference:
    Protected Sub LabelReference (ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
            lblID.Text = CInt(Request.QueryString("FileNo"))
        End Sub
        Protected Sub ReportDocument(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportSource1.DataBinding
            Dim rdoc As New ReportDocument
            Dim rptValue As Object
            rptValue = CInt(lblID.Text)
            rdoc.Load(Server.MapPath("~/files/rptLicenseView.rpt"))
            rdoc.SetParameterValue("FileNo", rptValue)
            CrystalReportViewer1.ReportSource = rdoc
        End Sub

  • No Pass-by-Value or Copy Constructors

    After having used AS3 for some months now, I've realized that
    there is no pass-by-value option when passing variables into
    functions. The only option is pass-by-reference. Similarly, there
    are no default copy constructors. So, if I want to create a copy of
    an object, I have to write code to create a new instance of the
    object and manually copy all of the source variable's properties to
    the new target object.
    This lack of a pass-by-value mechanism and copy constructors
    leads to some confusing behavior and necessitates writing quite a
    bit of extra code. A common case involving confusion is when a
    function call changes a property of a passed-in object. The caller
    might assume that the object will not be modified and then be
    surprised when it is. This is especially likely to happen when
    different people are working on the caller and the callee. It
    shouldn't be necessary for the caller to be concerned about the
    internal workings of an object being used but, because there is no
    pass-by-value mechanism, the caller often must take this into
    account.
    Because of the lack of a pass-by-value mechanism the onus is
    on the person writing a function to always make a copy of passed-in
    objects if they are going to be modified. Unfortunately, the lack
    of default copy constructors makes this an onerous task. The only
    way to copy an object is to write code to create a new object and
    then copy each property of the object. Where the properties are
    objects themselves a deep copy is needed and the amount of code can
    become large and the task tedious. To do this amounts to writing a
    set of copy constructors for each object and sub-object - each time
    a variable is accessed for modify.
    To make matters worse, it's not even possible to write a copy
    constructor for user-created classes. Consider the following
    attempt at writing a copy constructor to copy two instance
    variables for a custom Form class:
    public function Form(f:Form) {
    this._textHeight = f._textHeight;
    this._actionURL = f._actionURL;
    This causes a "Duplicate function definition" compile error
    because a default constructor already exists.
    Pass-by-value and built-in copy constructors are standard
    features in most OOP languages and their lack in AS3 is a glaring
    omission. I hope Adobe will seriously consider adding them to the
    next version of ActionScript.

    Nitin_Mathur wrote:
    at one time i had doubted my own conceptsNote that the type of a parameter may be different from the type of the object you created. However, it is still the same value that is passed, as pointed out by this example:
    public class Test {
        public Test() {
            //an object of type "MyClass" is created on the heap with the "new" operator:
            MyClass myClass = new MyClass();
            doSomething(myClass);//the reference to the object is passed by value
        private void doSomething(MyInterface myInterface) {
            //the passed value is a reference to a "MyClass" object,
            //but here it is considered to be a "MyInterface" object
            //and we don't have access to the "MyClass"-method "testClass()"
            myInterface.testInterface();
        public static void main(String[] args) {
            new Test();
    interface MyInterface {
        public void testInterface();
    class MyClass implements MyInterface {
        public void testInterface() {
            System.out.println("testInterface");
        public void testClass(){
            System.out.println("testClass");
    }

  • How to pass a value to the export parameter for a method (public instance)?

    Hello,
      I am trying ABAP OO newly. How to pass a value to the export parameter for a method (public instance) called in a report? This *export parameter has a reference type of structure.
    Thanks in advance,
    Ranjini

    Hi,
    "class definition
    class lcl... definition.
      public section.
        method m1 imporitng par type ref to data.  "now you can pass any reference to the method, but this way you have to maintain this reference dynamically inside the method (you can't be sure what that reference is really "pointing" at)
    endclass.
    "in program
    data: r_lcl type ref to lcl...
    create object r_lcl.
    call method r_lcl
      exporting
         par    =  "pass any reference variable here
    Regards
    Marcin

  • Subroutine parameters ..by default pass by value or pass by ref

    how parameters pass ?  value or ref
    if we use changing in both perform and form...will it become CALL BY REF?
    Message was edited by:
            balaji velpuri

    Hi,
    <u><b>The Parameter Interface</b></u>
    The USING and CHANGING additions in the FORM statement define the formal parameters of a subroutine. The sequence of the additions is fixed. Each addition can be followed by a list of any number of formal parameters. When you call a subroutine, you must fill all formal parameters with the values from the actual parameters. At the end of the subroutine, the formal parameters are passed back to the corresponding actual parameters.
    Within a subroutine, formal parameters behave like dynamic local data. You can use them in the same way as normal local data objects that you would declare with the DATA statement. They mask global data objects with the same name. The value of the parameters at the start of the subroutine is the value passed from the corresponding actual parameter.
    Subroutines can have the following formal parameters:
    <u><b>Parameters Passed by Reference</b></u>
    You list these parameters after USING or CHANGING without the VALUE addition:
    FORM <subr> USING ... <pi> [TYPE <t>|LIKE <f>] ...
    CHANGING ... <pi> [TYPE <t>|LIKE <f>] ...
    The formal parameter occupies no memory of its own. During a subroutine call, only the address of the actual parameter is transferred to the formal parameter. The subroutine works with the field from the calling program. If the value of the formal parameter changes, the contents of the actual parameter in the calling program also change.
    For calling by reference, USING and CHANGING are equivalent. For documentation purposes, you should use USING for input parameters which are not changed in the subroutine, and CHANGING for output parameters which are changed in the subroutine.
    To avoid the value of an actual parameter being changed automatically, you must pass it by value.
    <u><b>Input Parameters That Pass Values</b></u>
    You list these parameters after USING with the VALUE addition:
    FORM <subr> USING ... VALUE(<pi>) [TYPE <t>|LIKE <f>] ...
    The formal parameter occupies its own memory space. When you call the subroutine, the value of the actual parameter is passed to the formal parameter. If the value of the formal parameter changes, this has no effect on the actual parameter.
    <u><b>Output Parameters That Pass Values</b></u>
    You list these parameters after CHANGING with the VALUE addition:
    FORM <subr> CHANGING ... VALUE(<pi>) [TYPE <t>|LIKE <f>] ...
    The formal parameter occupies its own memory space. When you call the subroutine, the value of the actual parameter is passed to the formal parameter. If the subroutine concludes successfully, that is, when the ENDFORM statement occurs, or when the subroutine is terminated through a CHECK or EXIT statement, the current value of the formal parameter is copied into the actual parameter.
    If the subroutine terminates prematurely due to an error message, no value is passed. It only makes sense to terminate a subroutine through an error message in the PAI processing of a screen, that is, in a PAI module, in the AT SELECTION-SCREEN event, or after an interactive list event.
    <u><b>Specifying the Type of Formal Parameters</b></u>
    Formal parameters can have any valid ABAP data type. You can specify the type of a formal parameter, either generically or fully, using the TYPE or LIKE addition. If you specify a generic type, the type of the formal parameter is either partially specified or not specified at all. Any attributes that are not specified are inherited from the corresponding actual parameter when the subroutine is called. If you specify the type fully, all of the technical attributes of the formal parameter are defined with the subroutine definition.
    The following remarks about specifying the types of parameters also apply to the parameters of other procedures (function modules and methods). If you have specified the type of the formal parameters, the system checks that the
    corresponding actual parameters are compatible when the subroutine is called. For internal subroutines, the system checks this in the syntax check. For external subroutines, the check cannot occur until runtime. By specifying the type, you ensure that a subroutine always works with the correct data type. Generic formal parameters allow a large degree of freedom when you call subroutines, since you can pass data of any type. This restricts accordingly the options for processing data in the subroutine, since the operations must be valid for all data types. For example, assigning one data object to another may not even be possible for all data types. If you specify the types of subroutine parameters, you can perform a much wider range of operations, since only the data appropriate to those operations can be passed in the call. If you want to process structured data objects component by component in a subroutine, you must specify the type of the parameter.
    Regards,
    Bhaskar

Maybe you are looking for

  • Issue with field separator in GUI_UPLOAD

    Hello Gurus I am facing issue with gui_upload. I have a text file in which the fields are eparated by single Pipe  i.e |. Now when I try to read the data from file in internal table even with using field separator it does not insert data in proper fi

  • Creative Cloud membership (one-year, prepaid) - List of user

    Dear Team, Kindly let me know if we can use the CC(1 year Memb Plan) for more then 1 PC. i need to use the same license to MAC. Thanks

  • Buying from itunes

    why am i having to keep signing off and on when purchasing music vids etc-its like i buy one then as i browse for more a short time later it wont let me unless i sign out then in again

  • RAW-Vorschau in Bridge

    Hallo, wer kann mir bitte sagen, aus welchem Verzeichnis Bridge CS2 die erforderlichen Daten zur Anzeige der Camera-RAW-Daten ausliest. Trotz Update auf Camera-RAW 3.7 (bisher 3.6) und kopieren dieser Datei in alle relevanten Verzeichnisse weigert si

  • Cannot import .avi files with 5.1 audio created in Premiere 2.0

    Using Encore 2.0 when I attempt to import an .avi file I exported from Prem1ere 2.0 which was exported with 5.1 audio, I get an error message - "More that two audio channels for this type of encoding is not supported". Does Encore 2.0 not support 5.1