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.

Similar Messages

  • To pass the values in repetitive structures any function module

    hi all,
          Is there any function module to pass the values in repetitive structures like infotype 0041(Date spcification). I heard there is a function module, so any of you can tell that function module.
    thanks,
    sekhar.

    Hi Chandra,
    If your question is to find a date for a given dar value in IT 0041 then this is the sol:
    Yes there is a function Module for IT0041, HR_ECM_READ_IT0041_DATE_TYPE
    eg: 
    INFOTYPES: p0041.
    DATA: lv_msg TYPE REF TO if_hrpa_message_handler,
              lv_date TYPE D.
    GET pernr.
    CLEAR: lv_date.
        CALL FUNCTION 'HR_ECM_READ_IT0041_DATE_TYPE'
          EXPORTING
            datar           = 'U2'       " specify the value of the dar value, for which u have to find date
            p0041           = p0041
            message_handler = lv_msg
          IMPORTING
            date            = lv_date.
    For the dar value U2, lv_date will have the corresponding date.
    Hope this will clear your doubt.
    Thanks,
    Kishore

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

  • How to pass multiple values from workbook to planning function ?

    Hi,
    I have created Planning function in Modeler and it has one parameter(Variable represents = Multiple single values).
    When executing the planning function by create planning seq. in the web template : I see value of variable store data like ...
        A.) input one value -> V1
        B.) input three values -> V1;V2;V3
    This function execute completely in web.
    However, I want to use the planning function in workbook(Excel).
    The value of variable can't input V1;V2;V3... I don't know how to pass multiple values from workbook to parameter(Multiple single values type) in planning function ?
    thank you.

    Hi,
    Please see the attached how to document (page no 16).
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be">how to</a>
    Hope this was helpful
    thanks

  • How to pass default value of argument to stored function?

    Hi,
    in procedure I don't have to pass all arguments, because I set it with name, but in stored function I have to set arguments with index som I must set all arguments. Some arguments have default value. So how to pass default value?
    thx for any comments

    It really helps me if someone tell me that it isn't possiblle.
    thx.

  • Pass internal tables in Export  Parameters of  Function Module

    Hi
    How to pass internal tables through export parametes of the calling function module. i
    think i can pass it by reference ....
    if so can anyone suggest how to do it?

    Hi,
    You can Export values of an Internal table in two ways, by :
    1) specifying in Tables tab
    (Not recommended since it's an obsolete in ECC 6.0)
    If used, will reduce the performance of the FM
    Tables are always passed by reference
    2) specifying in Exports tab.
    The parameter should be a Table type (created in se11)
    having a Line type that refers to the structure of the data.
    Pass by Value is not used for Normal Function modules.
    Used usually for RFC enabled FMs.
    Cheers,
    Remi

  • Read workitem Container Value in Terminating event Check Function Module

    Hi
    I have some problems reading work item data / values of a work item container element in a check function module on a terminating event – Do any of you know if this is possible, and if so, how it’s done ?
    In My scenario I have created a multiline approval step for my business document, one task pr Line Owner.  The Event Approved is defined as a terminating event for this task, and the line owner is passed to the task container.
    Now, when I raise the event, with the line owner as an event parameter, I would like to check if the line owner on the raised event, matches the line owner in the task container in question in a check fm. But here I faced the problem, that only event data, and not work item data, are passed to the Check Function module.
    Regards,
    Morten Nielsen

    Hello Morten, hello Arghadip,
    in the instance linkage's check function module (entered via transaction SWEINST) you'll have the workitem-id in the system event parameter EVTRECEIVER_ID
    With this number you can use the frame work in order to read the work item container.
    This is a sample coding, how you access the correct work item container using SAP Enterprise and it's new OO frame work, which checks on the terminating event of BUS2105.Released the correct release code for a work item.
    INCLUDE <cntn01>.
    INCLUDE <SWFCNTN01>.
    INCLUDE RSWEINCL.
    *** Read workitem instance and container from event
           DATA: wi_id            TYPE swwwihead-wi_id.
           swc_get_element EVENT_CONTAINER evt_receiver_id wi_id.
           IF sy-subrc <> 0.
              MESSAGE E015(ZPREL) WITH evt_receiver_id
                                           RAISING wrong_call.
           ENDIF.
           DATA: lv_wi_handle    TYPE REF TO if_swf_run_wim_internal.
           DATA: ls_context      TYPE sww_wimctx.
           DATA: lv_wi_container TYPE REF TO if_swf_cnt_container.
    *    - set context
           ls_context-do_commit  = ' '.
           ls_context-called_btc = 'X'.
           ls_context-exec_user  = sy-uname.
           ls_context-fbname     = 'Z_CHECK_RELEASE_CODE'.
           CLEAR lv_wi_handle.
           CALL METHOD cl_swf_run_wim_factory=>initialize( ).
           CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
                   EXPORTING
                      im_wiid             = wi_id
                      im_read_for_update  = ' '
    *                 im_enqueue_owner    = fb_name
    *                 im_wait_for_enqueue = 'X'
                      im_context          = ls_context
                   RECEIVING
                      re_instance         = lv_wi_handle.
    *** This check is only done for workitem linkage TS90100081
           IF lv_wi_handle->m_sww_wihead-wi_rh_task <> 'TS90100081'. "#EC_SYNTEXT
              EXIT. "Let event pass, as this is an instance linkage to another workitem
           ENDIF.
           DATA: releaseCode_wi        TYPE t16fc-frgco.
    *    - read releaseCode from workitem container
           lv_wi_container = lv_wi_handle->get_wi_container( ).
    *    - perform binding event container -> workitem container
           swf_get_element lv_wi_container 'RELEASECODE' releaseCode_wi.
          DATA: e             TYPE REF TO cx_swf_run_wim.
          CATCH cx_swf_run_wim INTO e.
             RAISE WORKFLOW_RUNTIME_ERROR.
       ENDTRY.
    *** From here on, the variable releaseCode_WI hold the
    *** container element RelaseCode of the work item, that
    *** is going to be terminated...
    *** Further coding from here as appropriate...
    Best regards,
    Florin

  • Parameter Passing By Value

    Okay here is the deal Say i have a class called "CUSTOMERINFO" and in this class there are attributes such as first and last name..
    okay now in the main class i create an instance.. Now i want to send it to a method to have another "CUSTOMERINFO" equal the same values as the first, but don't want them pointing at the same memory block.. therefore they are 2 separate entities and i can change one with out affecting the other.. I know there is a way i just can't find the syntax on the net.. its something like "METHODA(ByVal String newValue){}
    THANKS

    Try this
    public class CustomerInfo
    private firstName = "";
    private lastName = "";
    public CustomerInfo(String firstName , String lastName)
      this.firstName = firstName
      this.lastName  = lastName
    public String getFirstName()
      return firstName;
      public String getLastName()
      return lastName;
    } // End CustomerInfo class
    public class SameInfo
    private firstName = "";
    private lastName = "";
    public void setFirstName()
      this.firstName = firstName;
    public void setLastName()
      this.lastName = lastName;
    } // End SameInfo class
    public class Driver
    public static void main(String[] args)
      CustomerInfo customerOne = new CustomerInfo("Bob", "Dole")
      SameInfo anotherPerson = new SameInfo();
      anotherPerson.setFirstName(customerOne.getFirstName())
      anotherPerson.setLastName(customerOne.getLastName());
    }

  • Problem in getting last value of a string in Function Module

    Hi,
    I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
    here's d code:-
    FUNCTION Z_STRING_LENGTH1.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_STRING) TYPE  STRING
    *"     VALUE(LENGTH) TYPE  I
    *"  EXPORTING
    *"     VALUE(E_STRING) TYPE  STRING
    data: STRING_F type string, "Stores the value in string format
          STRING_LENGTH type i, "Length of the string
          DIFF type i,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 type string,  "Stores the 1st String
          STRING2 type string,  "Stores the 2nd String
          STRING3 type string,  "Stores the 3rd String
          STRING4 type string,  "Stores the 3rd String
          STRING5 type string,  "Stores the 3rd String
          LENGTH2 type I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING2 = STRING_F+LENGTH(DIFF).
    ELSE.
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    length2 = length - 1.
    STRING3 = STRING1+length2(1).
    STRING4 = STRING2+0(1).
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      concatenate STRING1 '-' STRING2  into STRING5.
      e_string = STRING5.
    ELSE.
      concatenate  STRING1 STRING2 into STRING5.
      e_string = STRING5.
    ENDIF.
    ENDFUNCTION.
    Edited by: ricx .s on May 12, 2009 5:20 AM

    Hi,
    I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
    Please check the modified code below... have optimized it as well by removing one extra if condition....
    you can copy and paste the code below...
    DATA: STRING_F TYPE STRING, "Stores the value in string format
          STRING_LENGTH TYPE I, "Length of the string
          DIFF TYPE I,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 TYPE STRING,  "Stores the 1st String
          STRING2 TYPE STRING,  "Stores the 2nd String
          STRING3 TYPE STRING,  "Stores the 3rd String
          STRING4 TYPE STRING,  "Stores the 3rd String
          STRING5 TYPE STRING,  "Stores the 3rd String
          LENGTH2 TYPE I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
      STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
    " which is not required
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    IF LENGTH IS NOT INITIAL.
      LENGTH2 = LENGTH - 1.
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value as 0
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 0, then it gives me a dump
    STRING3 = STRING1+LENGTH2(1).
    IF STRING2 IS NOT INITIAL.
      STRING4 = STRING2+0(1).
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value greater than or equal to
    " the string length
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 8, then it gives me a dump
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      CONCATENATE STRING1 '-' STRING2  INTO STRING5.
      E_STRING = STRING5.
    ELSE.
      CONCATENATE  STRING1 STRING2 INTO STRING5.
      E_STRING = STRING5.
    ENDIF.

  • HOW  TO PASS SELECT-OPTIONS PARAMETER TO A FUNCTION MODULE.

    Hi friends.
    HOW DO U PASS A SELECT-OPTIONS PARAMTER TO A FUNCTION MODULE AS ITS IMPORT PARAMETER(IN MY CASE rfc fM) .
    Really urgent!!!
    thanks to one and all

    Hi,
    If you are passing a single value, its better you take it from s_option-low or s_option-high (select options).
    Else if you are passing values to the FM in a loop for all select option values, then better you declare an internal table with type <b>WSELKUNNR</b>.
    get low & high fields from each row & pass them.
    It will make you clear when you check out your select options in debug mode by entering different combinations of inputs.

  • Arrays pass by value

    hi guys
    are primative arrays passed by value or passed by reference
    cheers
    spob

    Java uses pass by value. The references to the arrays
    are passed by value, though of course a copy of a
    reference refers to the same thing as the "original"
    reference does.I hope you got the support one!
    This is an automatically generated Delivery Status Notification.
    Delivery to the following recipients failed.
    [email protected]
    [email protected]

  • Passing Select-option to Function Module

    Hi ,
         I want to pass a select-option directly to the function Module tables parameter . Can anyone highlight on how i can declare the table in Function module side .
    Thanks & Regards,
    Raj

    Hi.
    In the TABLES tab of the specific FM ,
    give the parameter name ( which u have defined as Select options ). Since select options is like an Internal Table with values sign,option,low and high , u can give it here.
    Also give the ref. type and type specification.
    Pl try this.
    Thanks,
    Maheshwari.V

  • Function Modules for indirect values

    What are the  function modules for indirect values?

    Hi,
    The SAP function module for indirect valuation of wages is RP_FILL_WAGE_TYPE_TABLE_EXT.
    Also, if indirect valuation is being used, the annual salary field ANSAL also may not be populated. Again, there are some SAP function modules to help us out:
    RP_ANSAL_FROM_PERNR - Use this one if all you have is PERNR
    RP_ANSAL_FROM_INFOTYPE - Good if you have already data for infotypes 0001 & 0008
    RP_ANSAL_FROM_WAGETYPES - It requires a list of wage types used in 8 .
    by
    Prasad gvk.

  • Passing dynamic table to function module

    Hi all,
    actully i have to pass dynamic internal table from function module.
    for that i use syntax
    move <dyn_table> to data_tab.
    but now my question is that in fm parameters what is the  type spec & associated type for data_tab in fm parameters.
    regards,
    anuj

    Hi
    Good
    Here is a simple example of passing an internal table "itab" to a function module "REUSE_ALV_LIST_DISPALY".
    It displays the internal table data into a list format.
    data : itab like ztest213 occurs 0 with header line.
    tables : ztest213 .
    select * from ztest213 into table itab.
    loop at itab.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = ' '
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ztest213'
    IS_LAYOUT =
    IT_FIELDCAT =
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IR_SALV_LIST_ADAPTER =
    IT_EXCEPT_QINFO =
    I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab
    exceptions
    program_error = 1
    others = 2
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endloop.
    Thanks
    mrutyun^

  • Sales Order function module to retrieve the item availability values

    Hi,
      Is there any function module to retrieve the item availability schedule line values.
    Navigation:->
    Go to sales order (Change Mode) -> Schedule lines tab ->  In application toolbar you can find Item availability icon.
    When this is pressed, next screen you can find the split up of schedule line values. I am developing an ALV report and is required to retrieve the Split up of the schedule line values.
    Is there any function module to retrieve the same.
    BR/ Josh

    HI,
      I have found one function module ATP_EXPLANATION. I am not able to figure out the parameters that needs to be inputted to this function module. If anyone has used this before, could you kindly help me out.
    This function module returns the Split up for Schedule lines in the tablea 'MDVEX'.
    BR/ Josh

Maybe you are looking for

  • Mixing RAM question...

    Up to now all the RAM I have installed has been PC2-4200... Went to the store and asked for 4Gigs of PC2-4200 and was given 4Gigs of PC2-6300... Crucial website states that PC2-6300 is compatible with my Power Mac... Just want to know if mixing the t

  • How Do I Display Quotation Marks in Dynamic HTML Text

    I'm using a dynamic text file that has some Quotation Marks that need to be displayed with the content on certain words in the TXT file. How do i display Quotation Marks inside a Dynamic text field? Please Advise. As soon as possible. Thanks

  • Did you receive an unsolicited promo offer and after accepting realize your employee discount was dropped?

    This is EXACTLY what happened to me! About two months ago, I received a text from Verizon stating, "Verizon appreciates your loyalty. You are currently on the $50/2GB plan. You can now get an extra 2GB of data per month for the same price you pay now

  • KM content Migration from EP 5 to Ep7

    Hi There. We are trying to migrate Km content from EP5 to EP.. i know that this can be achieved through ICE. and i have seen couple of blogs also but i am still not able to get any step by step info..  along with all pre-requisite.. Can you please sh

  • Employee Qualification - HR ABAP

    Hi,     I want to know the field name and Table Name  for Employee Qualification i found the table P0022-AUSBI .Here shows only number like 43,44,49,50. How can i get the text for particular number and also which table i want to link it.Can you help