Dynamic table as output in Function Module

Hi all,
I am trying to output a dynamic table from a FM. I am a generating a dynamic internal table in the FM. Now i want to assign that internal table to a table parameter of the FM so that i can use that table in the calling program. can this be done?
regards,
hamza

You may need to look into code of sap function module
RFC_READ_TABLE

Similar Messages

  • How to declare Dynamic table in Tables Parameters of a Function Module...

    Hi Gurus,
    I would like to Know how to declare a Dynamic table in Tables parameters of a Function Module.
    so that it should be able to hold any table data ....
    I have tried all possible ways of trying to assign fields-symbol like declarations which doesnt allow here ...
    plz Dont reply with the basics of creating dynamic internal tables, coz my case is not an Internal table it is FM table parameter declaration.....

    Hi,
    If you are requirement is to create a function module with tables parameter having a generic line type i.e. no specific line type
    just declare it with a name under Parameter name with out specifying the type.
    A reference function module with such parameter, i would quote is the standard GUI_UPLOAD/ GUI_DOWNLOAD where the parameters specified under TABLES are generic.
    If you want to process the values passed to these parameters in the source code of function module, field symbols would be a preferable option.
    Regards,
    Sharath Panuganti

  • Dynamic programming: send data to function module, mapping...

    Hello abappers,
    I have a requirement to be able to send a the name of a table and a table-field to a function module, it can be a table of any type, so the function module should be generic in nature, the function module receives the table name and table-field name and then selects data for the field specified from the table specified (in the import parameter of the FM). Within the function module, I want to be able to determine the fields type? and then send this field to an internal table representing a a destination table (also specified in the import parameters).
    the idea is to be able to map a field from any table to a specified field in another table, the table(source and destination) and field names will only determined at run time as specified by the user.
    any assistance will be appreciated, I am not very familiar with dynamic\generic programming.

    Hello Bijo,
    Following are the steps to implement this requirement:
    1. Create import parameter for table name i.e. TABLE_NAME
    2. Create tables parameter for fields table
    3. Define table. DATA TABLE TYPE REF TO DATA. Also create single column internal table for fields and load all fields to select from database.
    Inside function module you can implement following steps:
    4. Load all the fields name into internal table. for this you can use DD03L for field details and use TABLE_NAME as key.
    5. Once you have all the fields ready in internal table then construct fieldcatlog using these fields
    loop at internal table with all the fields.
    move it to field catalog.
    append field catalog.
    endloop.
    6. Pass this field catalog table to static method create_dynamic_table
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = fieldcatalog_tab
    importing
    ep_table = table.
    Here table is defined with data object type.
    now assign table reference to field symbol of type table.
    ASSIGN table->* to <field-tab>.
    Also create work area <field-wa> using refrence of table.
    create data object wa LIKE LINE OF <field-tab>.
    ASSIGN wa->* to <field-wa>.
    Also define field symbol for field name.
    for e.g. <field_name>
    7. Dynamic internal table is ready
        Now using can use select as follows:
        SELECT (fields)  "--> fields is single column internal table to hold fields need to be selected
             INTO CORRESPONDING FIELDS OF TABLE <itab> "--> itab created dynamically at runtime
            FROM (TABLE_NAME) --> Table name imported
         WHERE (where_clause). --> where_clause is single column internal table with data type CHAR72.
    Select data into <itab> and use ASSIGN COMPONENT to move data from one table to another as follows:
    8. To fill this dynamic internal table using ASSIGN COMPONENT <Comp_number> OF STRUCTURE <field-wa> TO <field-name>
    So in this case if first field of structure STRUCT1 is user_id then sudo-code will be
    loop at internal table containing list of fields into field_wa
    ASSIGN COMPONENT field_wa OF STRUCTURE <field-wa> TO <field>. "Here field_wa is wa area for single column internal table holding all the fieldnames.
    Now <field-name> points to user_id field. Move some value into it as nornally we do with variables.
    move '001' to <field-name>.
    or
    <field-name> = '001'.
    endloop.
    after completing all the fields one row will be ready in <field_wa>.
    APPEND <field_wa> to <field_tab>.
    Let me know incase you face any issues!
    Hope this helps you.
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 23, 2009 7:02 PM
    Edited by: Augustarian on Aug 23, 2009 7:08 PM
    Edited by: Augustarian on Aug 23, 2009 7:09 PM

  • How to get tables used by a Function Module

    Hi,
    How to know the tables used by a function module dynamically.
    Cuurently im using BAPI_MATERIAL_SAVEDATA in my report program.
    I tried FM GET_TABLES to know the tables, but could see only tables used in the report.
    Main issue in my case is when im running this update program, could observe different tables being displayed as updated in SM50(Process Overview).Want to clarify as why these tables which are not being used in my report are being displayed in SM50.
    So was doubtin weather this FM is using these displayed tables.
    Thanks in advance for u r replys.
    Regards,
    Dedeepya

    Hi Dedeepya,
    you could use a SQL Trace (tx. ST05) to list all tables affected and operations that realize. Just active the trace, execute FM, and Deactive trace. Then click in "Display trace" and check it.
    Best regards,
    Pablo

  • Update TVARV table entries using a Function Module or Program

    Hi Gurus,
    My requirement is that I have a entry in TVARV table which has a 'low'. We would like to change this value whenever we desire. We are unable to do it via sm30 and se16 as table maintenance access is not permitted in Production environment.
    Can you please provide any Function module or program code to do it?
    Requirement - User can enter a value into TVARV table by executing a function module or program
    Thank you all, will award points,
    Priyansh

    Hi Priyansh,
    Please refer to SAP Help for more information on variant maintenance and more specifically variable values in variants. You can use t/code STVARV for maintaining the variant variables in table TVARVC (Client-Specific Variant Variables).
    Note: I suggest to use the TVARVC table instead of TVARV.
    If you are looking for Function Modules in the area of Variant Maintenance, then please have a look at Function Group SVAR (t/code SE80).
    If you are looking for Function Modules in the area of User Variables in Variants, then please have a look at Function Group SVUV (t/code SE80).
    Furthermore, if you are looking for a program to update table TVARVC, please have a look at ABAP: Dynamic Variant Processing with STVARV.
    Best eregards,
    Sander

  • Printing ALV Report output through Function Modules

    Hi All,
    I want to print my ALV Grid output through function modules/statement (not through print option in menu).
    This is because, i am generating a PDF from spool when user clicks on a button. If any changes happened in the ALV output layout, they will be captured in spool through printing it.
    So can you please tell me how to print the ALV Output through FMs or sending the ALV output to spool.
    Thanks & Regards,
    Senthil.
    Edited by: senthil nathan on May 17, 2010 2:49 PM

    Hi Dev,
    Thanks for the reply.
    I want to print the ALV when the user clicks on a button in toolbar. Lets say the user has made some changes to the layout, (E.g hiding a field) and when i print that output it should use the changed layout, If i use the FM suggested by you, i cant acheive this.
    If you try to print this manually, the system uses the changed layout and not the original. Thats why i want to know FMs/statement to print.
    Regards,
    Senthil.

  • Doubt in  export, import and table para when creating Function Module

    Dear fellow ABAPers,
    I have a doubt in defining export, import and table parameter while creating a function module.
    I am calling a function module inside a user exit. Now in the user exit the SAP fills an internal table called i_lfa1 with all the data user has eneterd.
    Now I want to pass this whole internal table to function module and the perform some checks on the values of internal table.
    After that function module fills an error structure with values depending on some check.
    1)
    How do I pass this internal table to function module ? 
    When I am creating function module in se37 where do I define this iternal table type ? Is it in Import or Table parameter during function module creation?
    2)
    Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?
    Please clear my doubt..
    Relevant points will be awarded.
    Regards,
    Tushar.

    Hi Tushar,
    1. How do I pass this internal table to function module ?
       I assume u are creating your own Y/Z FM.
       Pass it thru TABLES parameter.
    2. When I am creating function module in se37 where do I define this iternal table type
       Define this in TABLES interface.
       What Type ?
       THE SAME TYPE WHICH HAS BEEN DEFINED
        WHILE PASSING IN THE USER-EXIT FUNCTION MODULE.
       IF U SEE THE FM OF THE USER-EXIT,
       U WILL COME TO KNOW.
    3.
    Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?
    Define it in TABLES interace. (not in export, import)
      (Since what u are going to return is an internal table)
      U can take for eg. BDCMSGCOLL.
      OR u can create your own Y/Z structure
    for the same purpose.
      (or u can use the structure type T100)
    I hope it helps.
    Regards,
    Amit M.

  • Passing selection table as parameter to function modules

    i tried to pass a selection table as a parameter to a function module but there is a problem stating the eror the table length is different.
    *& Report  ZSFSELECT_OPTIONS_PGM
    REPORT  zsfselect_options_pgm.
    TABLES zselect_options.
    SELECT-OPTIONS sop FOR zselect_options-id.
    DATA  : fname(15) TYPE c.
    *CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
       formname                 = fname
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
      FM_NAME                  =
    EXCEPTIONS
      NO_FORM                  = 1
      NO_FUNCTION_MODULE       = 2
      OTHERS                   = 3
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    DATA lth(2) TYPE c.
    DATA ty TYPE i.
    DATA o TYPE i.
    DATA l TYPE i.
    DATA k TYPE c.
    DESCRIBE FIELD sop-sign TYPE lth LENGTH ty IN CHARACTER MODE.
    CALL FUNCTION fname
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
      TABLES
        sf_sop                     =sop
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    in the smart form i have tried to pass the sp as the table.
    i have created a program line node
    :SELECT * FROM zselect_options INTO TABLE it_tab WHERE id IN sf_sop.

    Hi,
    If i understand ur problem correctly u r trying to pass a select-option to Tables for a smartform function module. It gives an error & it correct.
    If u understand the structure of a select option, it will have 4 fields in it & the structure will be
    SIGN                   CHAR1
    OPTION               CHAR2
    LOW                   Type Zfield
    HIGH                   Type Zfield
    But ur receiving Table paramter of the smnartform FM will be having only 1 field - Type Zfield
    So this mismatch gives u an error.
    Solution:
    Case1:
    Write code outsied th FM in ur program to get all the values & build an internal table & pass that to the FM.
    Case2:
    Define the Structure of table in the smartforms as tols earlier & then try passsig the Select option.
    Thanks & Regards,
    Bhargava

  • CRM Tables , Tables Mappings , T-codes , Function modules

    Hi All,
    I am new to CRM , I want to know the tables , table mappings transaction
    codes , functional modules used . Can any one mention the link / list down all which i have mentioned above .
    I will be very helpful if i get this information.
    cheers,
    Chandra.

    hi,
       CRM tables:
        https://forums.sdn.sap.com/click.jspa?searchID=2400935&messageID=3134573
        https://forums.sdn.sap.com/click.jspa?searchID=2400935&messageID=3128631
        https://forums.sdn.sap.com/click.jspa?searchID=2400935&messageID=3269744
    CRM FM:
       https://forums.sdn.sap.com/click.jspa?searchID=2400963&messageID=3239545
    Reward points if useful..
    Regards
    Nilesh

  • Function Modue with Dynamic Table as output parameter

    Hi experts,
    i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in <ft>.
    How can i return <ft> as output parameter of function module (table) ?
    function
    import parameter  - > IC_TABLE
    source code
    data :   lt_OPTIONS   type standard table of RFC_DB_OPT,
             lt_fields    type standard table of rfc_db_fld,
             lt_data      type standard table of tab512,
             la_rfcdata   type tab512,
             la_rfcfields type rfc_db_fld,
             lr_dref      type ref to data.
    field-symbols: <ft>         type table.
    field-symbols: <structure>  type any.
    field-symbols: <field_to>   type any.
    field-symbols: <field_from> type any.
    CALL FUNCTION 'RFC_READ_TABLE'
      EXPORTING
        query_table                = IC_TABLE
      DELIMITER                  = ' '
      NO_DATA                    = ' '
      ROWSKIPS                   = 0
      ROWCOUNT                   = 0
      tables
        OPTIONS                    = lt_OPTIONS
        fields                     = lt_fields
        data                       = lt_data
    EXCEPTIONS
       TABLE_NOT_AVAILABLE        = 1
       TABLE_WITHOUT_DATA         = 2
       OPTION_NOT_VALID           = 3
       FIELD_NOT_VALID            = 4
       NOT_AUTHORIZED             = 5
       DATA_BUFFER_EXCEEDED       = 6
       OTHERS                     = 7.
      create data lr_dref type table of (ic_table).
      assign lr_dref->* to <ft>.
    Fill data from OLTP table into ct_table.
      assign local copy of initial line of <ft> to <structure>.
      loop at lt_data into la_rfcdata.
        loop at lt_fields into la_rfcfields.
          assign component sy-tabix of structure <structure> to <field_to>.
          if sy-subrc is initial.
            assign la_rfcdata+la_rfcfields-offset(la_rfcfields-length)
              to <field_from>.
            <field_to> = <field_from>.
          endif.
        endloop.
        append <structure> to <ft>.
      endloop.
    Thanks in advance
    Martin

    Hi Martin,
    parameters with generic types are not allowed. So TYPE ANY TABLE etc. will not work. As Alex alreads said, you could return a reference to your table.
    Your parameter should be typed like:
    re_table type ref to data.
    At the end of your function module get a reference of your table into your parameter:
    get reference of <ft> into re_table
    After the call of your function module you can now handle and work with your table as wished:
    * Declaration
    data: re_table type ref to data.
    field-symbols: <my_table> type standard table.
    * Assign reference to fieldsymbol
    assign re_table->* to <my_table>
    if sy-subrc NE 0.
    " Error: Could not assign reference
    endif.
    Best regards,
    Fabian

  • Export, Import and Table declaration in custom function module

    I am creating a custom function module. Parameters needed are export internal table and one data field from the internal table.
    What do i need to fill for 'associated type' for these export parameters since size of the internal table and type for the data field from the internal table vary.

    Hello Albert
    If the function module need not be RFC-enabled then you have many ways to define such dynamic parameters, e.g.:
    FUNCTION ZUS_SDN_DYNAMIC_PARAMS.
    *"*"Local Interface:
    *"  EXPORTING
    *"     REFERENCE(ET_ITAB) TYPE  TABLE
    *"     REFERENCE(ET_ITAB_1) TYPE  ANY
    *"     REFERENCE(ET_ITAB_2)
    *"     REFERENCE(ED_DATA) TYPE  CLIKE
    *"     REFERENCE(ED_DATA_1) TYPE  ANY
    *"     REFERENCE(ED_DATA_2)
    ENDFUNCTION.
    See also: How to return back a structure of dynamic tables in a Function Module
    Regards
      Uwe

  • Reg output in Function module

    Under Function  Module
    Exporting  parameter
    *"  EXPORTING
    *"     VALUE(Y_HIGHEST_MSGTYPE) LIKE  TE950-DISPLAY_MOVEIN
    Here I want to do  Error out  one Message based on condition.
    I Written condition,  but  how  should I incorporate  error as output in exporting parameter .
    This T9950-DISPlay_movein  having  following  parameters
    fields
    MSGNR(3)
    BPWMODE(1)
    DISPLAY_BPE(1)
    DISPLAY_BPA(1)
    DISPLAY_BPI(1)
    Thanks,
    Sonar

    Hi Sonar,
    I hope you are referring to a custom FM. If it is standard, please mention the name and people would be able to provide the details.
    To get the error messages, you can create and Error Internal Table and pass it to your Tables parameter. Later on read this table and show your messages.
    If you have issues, please elaborate a little more, cut paste some code and it will easier to analyze.

  • Transfer ALV Output through Function Module

    Hi All,
    I have a requirement where I am dealing with two systems.
    1) There is a report program which run in ECC Server and it makes an RFC Call to trigger another program in APO Server
    2) The target program generates an ALV Output and I just want to bring back the output into ECC system
    3) How to achieve this ? How can transport the AVL Output throug the parameters of the RFC Function Module.
    Any help/clue  on this would be highly appreciated
    Thanks,
    Babu Kilari

    Hello Babu,
    If you are submitting the standard report in background mode, try this algo:
    1. You can export the output list to the ABAP memory using the EXPORTING LIST TO MEMORY.
    2. Then get the list details using the FM: LIST_FROM_MEMORY. Return the resultant internal table to your RFC.
    Hope this helps.
    BR,
    Suhas

  • Update the custom table by using Custom Function module.

    Hi Experts,
            My requirement is ,
    1) To create the Custom Z table with fields
               vbak-vbeln
               likp-vbeln
               vbuk-vbeln
      After creating this Z table.
    2) I have to create one custom function module.
        Based on this function module i have to update that Z table.
    3) Before these steps i have to write down an ALV report based on the tables vbak and vbeln, in that table i have to print vbak-vbeln. and also in report i generated check box and one custom button in application toolbar. after the report will displayed , when ever i click the button in application tollbar , this function module will executed and the table will be updated.
        But I developed the ALV report with custom button and check box successfully.
      My doubt is how to write the function module and based on that function module how to update the table.
          Please suggest me on this requirement.
        Thanks in Advance.
    Thanks and Regards
    Srihari.

    HI ,
         Can any one help me out on my above requiremnet..
    Thanks and Regards
    Srihari.

  • Table name in which function module and function group store

    Hai,
    Any one help me, What is the table name, the function modules and fouction groups are stored.
    Thanks,
    Elamaran

    ...and table enlfdir has additional info.... function module RS_GET_ALL_INCLUDES is useful for getting a list of includes used by an fm.
    Message was edited by: Neil Woodruff

Maybe you are looking for

  • Document format issue from iPad

    I created a pages document on the iPad, when I open it up in Pages for the Mac the formating is seriously off.  At first it looks like the text is just shifted, but there are images that are 3 pages out of place. I can quick preview the pages documen

  • Page layout does not support "&auml".

    Hello. I used design manager to create a page layout (SharePoint 365). No matter what I am not able to fiqure out how to create characters like "&auml". Can someone confirm that SharePoint 2013 does not support non-English language page layouts. User

  • I finally have a question

    OK, how can I say this.... You know I needed an internet connection and I did not want to have to use a "phone's" keypad because I have fat fingers. So, I got a USB thing from Sierra Wireless and signed up with ATT (big mistake but anyway) for intern

  • RFC-- XI

    Hi all, I have a simple scenario of RFC sending a message to XI... I configured RFC Reciever, but unfortunatly when I get the message from RFC I see that the fields are not formated correctly (thouth the structure of XML is right). My R/3 is installe

  • Workflow for DVD from HD+SD source...

    Based on the lengthy so-called "single-field conversion" issues with iM09, I'm looking for some inputs on the best workflow to retain high quality for DVD distribution for mixed media - video shot with HD & SD camcorders.. Here's what I did: A> Conve