Function module for move internal table records into MSexcel file

Hi all,
Tell me the function module which is used to
move internal table records in to MSexcel file.
Give the sample program...

Please search the forum for FM  "GUI_DOWNLOAD" You will get tons of threads with sample code.
Also take a look into SAP_CONVERT_TO_XLS_FORMAT
Thanks

Similar Messages

  • How to add the records of 2 internal table records into one file

    hello experts,
    My scenario is...
    I am retrieving the data for the for the credit, debit and trailer records of the customer into 3 different internal tables and finally i have to append all those records into one file first debit records then credit records finally the trailer record.... how to do that can anyone give some idea plzzzzzzzzz..
    Plz its bit urgent..
    Thanks a lot for your anticipation
    SRI

    Hello,
    Do like this.
    " Assume u have three itab.
    "Itab1 - debit
    "Itab2 - credit
    "Itab3 - Credit.
    REPORT ZV_TEST_SERVER .
    *PARAMETERS: P_FILE TYPE STRING."RLGRAP-FILENAME.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB1
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB2  " Check here
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB3 " Check here
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    If useful reward.
    Vasanth

  • Function module for finding number of records in table

    Do we have any function module to find number of records in a table?
    Thanks,
    Shweta

    use the EM_GET_NUMBER_OF_ENTRIES. You just have to write your table name into the input table IT_TABLES in the TABNAME field

  • Function Module for separating a date range into days

    Hi all,
    Does anyone know if there is a function module which gives back the list of days when we give a date range as input parameter to the function module. For example, we enter the range 10.07.2006 - 13.07.2006 and the function module gives back a table  in form 10.07.2006, 11.07.2006, 12.07.2006, 13.07.2006.
    Thanks,
    Sükrü

    Hi suekrue,
    1. Exactly for this purpose,
       i have written an
       INDEPENDENT FORM (subroutine)
      wherein we pass
       a) fromdate
       b) todate
       c) ITAB
    2. and it gives all the dates in the internal table.
    3. just copy paste
    4.
    data :  itab type table of sy-datum with header line.
    parameters : fromdate type sy-datum default '20060701'.
    parameters : todate type sy-datum default sy-datum.
    perform getdays tables itab using fromdate todate.
    break-point.
    FORM
    form getdays
    tables itab
    using fromdate todate.
      data : curdate type sy-datum.
      curdate = fromdate.
      do.
        if curdate > todate.
          exit.
        endif.
        itab = curdate.
        append itab.
        curdate =  curdate + 1.
      enddo.
    endform.                    "getdays
    regards,
    amit m.

  • How to download internal table data into xml file?

    Hi,
    Experts,
    I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
    Thank you,
    Shabeer ahmed.

    check this
    data : gd_repid type sy-repid.
    GD_REPID = SY-REPID.
    DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
           M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
           G_IXML TYPE REF TO IF_IXML,
           W_STRING TYPE XSTRING,
           W_SIZE TYPE I,
           W_RESULT TYPE I,
           W_LINE TYPE STRING,
           IT_XML TYPE DCXMLLINES,
           S_XML LIKE LINE OF IT_XML,
           W_RC LIKE SY-SUBRC.
    DATA: XML TYPE DCXMLLINES.
    DATA: RC TYPE SY-SUBRC,
          BEGIN OF XML_TAB OCCURS 0,
          D LIKE LINE OF XML,
          END OF XML_TAB.
    data : l_element           type ref to if_ixml_element,
           xml_ns_prefix_sf     type string,
           xml_ns_uri_sf        type string.
    CLASS CL_IXML DEFINITION LOAD.
    G_IXML = CL_IXML=>CREATE( ).
    CHECK NOT G_IXML IS INITIAL.
    M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
    CHECK NOT M_DOCUMENT IS INITIAL.
    CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
       NAME = 'REPAIRDATA'
       DATAOBJECT = IT_FINAL_LAST1[]
    IMPORTING
       DATA_AS_DOM = L_DOM
    CHANGING
       DOCUMENT = M_DOCUMENT
    EXCEPTIONS
       ILLEGAL_NAME = 1
       OTHERS = 2.
    CHECK NOT L_DOM IS INITIAL.
    W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
    *Start of code for Header
    * namespace
    t_mnr = sy-datum+4(2).
    CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
      EXPORTING
        LANGU         = 'E'
        MONTH         = t_mnr
    IMPORTING
       T247          = wa_t247
    concatenate sy-datum+6(2)
                wa_t247-ktx
                sy-datum(4) into t_var1.
    concatenate sy-uzeit(2)
                sy-uzeit+2(2)
                sy-uzeit+4(2) into t_var2.
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    l_element  = m_document->get_root_element( ).
    xml_ns_prefix_sf = 'TIMESTAMP'.
    concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
    clear : t_var1,
            t_var2,
            t_mnr,
            wa_t247.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'FILECREATOR'.
    xml_ns_uri_sf    =   'SAP'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'CLAIMGROUP'.
    xml_ns_uri_sf    = '1'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'CLAIMTYPES'.
    xml_ns_uri_sf    = 'W'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    *End of Code for Header
    CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
      DOCUMENT = M_DOCUMENT
    IMPORTING
      XML_AS_STRING = W_STRING
      SIZE = W_SIZE
    TABLES
      XML_AS_TABLE = IT_XML
    EXCEPTIONS
      NO_DOCUMENT = 1
      OTHERS = 2.
    LOOP AT IT_XML INTO XML_TAB-D.
    APPEND XML_TAB.
    ENDLOOP.
    *Start of Code for File name
    concatenate p_file
                '\R'
                '000_119481'
                sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
                sy-uzeit(2)   sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
    *End of Code for File name
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE = W_SIZE
      FILENAME = p_file
      FILETYPE = 'BIN'
    TABLES
      DATA_TAB = XML_TAB
    EXCEPTIONS
      OTHERS = 10.
    IF SY-SUBRC  = 0.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Function Module Extractor with Internal Table

    Hi All,
    I have a need to extract records from a complex SQL Statements, so I will be using different SQL Statements and merging the results in to a single internal table. In the function modules what will happen if I do not use cursor WITH HOLD option, (I know it maintains the cursor position) and what if I directly load into E_T_DATA  from my internal table. How this will affect the datapackage size?
    In the future I will have records beyond 1 million and I am concerned to send all the 1 million record in one package rather than multiple packages during extraction.
    Please give a solution if you have come acroos this kind of situation with your development.
    Thanks,
    Alex.

    Alex,
    I do not see why the complexity of ABAP statements should make you change the data processing logic proposed by SAP by way of the sample Function module.  
    It appears to me that you are changing something knowing fully well its implications and then trying to find a solution for it.
    Good Luck!
    Mathew.

  • Reg : Joining the all internal table records into a single internal table

    Hi all
    I am having 5 internal tables and i want to put all these entries in a single intrnal table and my requirement is for each and every record it has to go through all the internal tables and if an entry is missing meand.it has to go through the other internal tables and for missing entries i should leave it as blank and rest of the contents i have to display can any please gimme some logic how to do this??
    Thanks in advance

    Don't have time or will to deliver turnkey solutions, but here is a frame:
    LOOP AT itab1...
      READ TABLE itab2 WITH TABLE KEY... (fields linking itab1 and itab2)
      READ TABLE itab3 WITH TABLE KEY... (fields linking itab1 and itab3)
      LOOP AT itab4 WHERE... (fields linking itab1 and itab4)
        READ TABLE itab5 WITH TABLE KEY... (fields linking itab4 and itab5)
        MOVE-CORRESPONDING... (all five work areas to target work area)
        APPEND itabtarget...
      ENDLOOP.
    ENDLOOP.
    so use READ when there is a 1:1 relationship (e.g. check table entry), and LOOP when there is a 1:N relationship (e.g. items for a header)
    Thomas

  • BAPI/Function Module for posting internal order + cost center plan

    Hi Guru:
    Is there any function module/BAPI, which could be used to post internal order + cost center( both of them )plan data?
    Like post a record:
    internal order = 10000
    cost center = C1000
    amount = 1000$
    for plann version 30?
    It seems the BAPI could only contain 1 cost object, either cost center or internal order.
    Thanks.
    Eric

    Hi again,
    I think you may have missed something important here. In R/3 there can only be a single "real" cost object for any one posting. If not then the whole SAP financail model would collapse as there would be "double postings" and that is certainly not wanted.
    If there is a need to post to two cost objects, like in your case, then one of the cost objects MUST be statistical.
    In your scenario SAP has thought of a solution that might be of help for you. An internal order can be set to be statistical in master data. When posting to both the cost center and the internal order then you will get a real posting for the CC and a statisitical posting for the IO. Reporting does work with this as per your requirement.
    Hope this gives you some hints for how to proceed.
    Regards, Johan
    Aaaaah. Noted that this was only plan data. Sorry. But the same still applies for plan data postings as well as for actual data postings. If there should be just one posting that could be "drilled down" from IO to CC -> If you post twice then, when doing "Grand total" for instance, double values would appear. So, still IO should be statistical. //Johan
    Message was edited by: Johan von Reedtz

  • Bapi Or Function Module for Updating a table

    Can u Plz let me know , is there any bapi or function module to update few fields of a standard table using an internable.

    Hi Shiva Kumar Tirumalasetty ,
         There is no FM / BAPI to update directly to any SAP tables . SAP won't suggests to develop a FM/BAPI like that , as it will cause some data inconsistency problem .
    We have to search and find BAPI's/ FM's for requirement specific if not exists then need to think about the alternate options (LSMW/ BDC etc..)
    Hope this answers your question.
    Thanks,
    Greetson

  • Function Module to Download Internal table in EXCEL

    Hi All,
    I need a Function Module to download the Internal table to Excel File.
    I Have used SAP_CONVERT_TO_XLS_FORMAT,
    but this function modules are using GUI_Download indirectly.
    I dont want to use GUI_DOWNLOAD as i am going to call this Function Module in Portal.
    So pls anybody has this type of function module.
    Thanks & Regards,
    Dhruv Shah

    Hello Dhruv.
    In Agreement with Deniz.
    It is required to Export the query as an excel file.
    [SAP HELP Library - Standard Reference - Exporting as a CSV File / MS Excel 2000 File|http://help.sap.com/saphelp_nw04/helpdata/en/d2/11a28fc26d4042a6d230a9783152f2/content.htm]
    [SDN - Reference - Error in "Export to Microsoft Excel" from Portal|Error in "Export to Microsoft Excel" from Portal;
    Hope this works out well.
    Good Luck & Regards.
    Harsh Dave

  • Function module for updating COBRB table

    Hi,
    Is there any function module to update the entries in COBRB table.
    I have already tried the following but it's not updating ithe entries:
    1) k_settlement_rule_fill : get the objnr from PRPS and use it for CORBA and COBRB
    2)  k_settlement_rule_delete :  using  objnr only
    3) k_posting_rule_insert
    Regards
    Prabhat

    Hi,
    Please check this FM K_SETTLEMENT_RULES_UPDATE.
    Check FM AUC_SETTLEMENT_POST for sample codes.
    Regards,
    Ferry Lianto

  • Unable to read E$ table records into excel file in linux machine

    Hi
    I am using below code in ODI procedure to read E$ table record and store it in excel file
    ODI Procedure: Technology=Java Beanshall and Command on Target I written below code and placed it in CKM Oracle KM
    <@
    String OS = System.getProperty("os.name").toLowerCase();
    String v_path="";
    if((OS.indexOf("win") >= 0))
    v_path="D:\Unload_Dir\<%=snpRef.getSession("SESS_NO")%>.xlsx";
    else if (OS.indexOf("mac") >= 0)
    v_path="path details";
    else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 )
    v_path="/odi_a/oracle/Middleware/logs/wcds/odi_logs/<%=snpRef.getSession("SESS_NO")%>.xlsx";
    else if (OS.indexOf("sunos") >= 0)
    v_path="soliaris path";
    @>
    OdiSqlUnload "-FILE=<@=v_path@>" "-DRIVER=<%=odiRef.getInfo("DEST_JAVA_DRIVER")%>" "-URL=<%=odiRef.getInfo("DEST_JAVA_URL")%>" "-USER=<%=odiRef.getInfo("DEST_USER_NAME")%>" "-PASS=<%=odiRef.getInfo("DEST_ENCODED_PASS")%>" "-FILE_FORMAT=VARIABLE" "-ROW_SEP=\r\n" "-DATE_FORMAT=yyyy/MM/dd HH:mm:ss" "-CHARSET_ENCODING=ISO8859_1" "-XML_CHARSET_ENCODING=ISO-8859-1"
    select * from <%=odiRef.getTable("L","ERR_NAME", "W")%>
    But is not reading the data into .xlsx file ,
    Please help me it is very urgent
    Can I use below code
    String os = "";
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
    os = "windows";
    } else if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
    os = "linux";
    } else if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
    os = "mac";
    T
    his is high priority, please help me urgent
    Regards,
    Phanikanth
    Edited by: Phanikanth on Feb 28, 2013 5:43 AM
    Edited by: Phanikanth on Feb 28, 2013 6:00 AM
    Edited by: Phanikanth on Feb 28, 2013 7:42 AM

    Hi,
    can you describe what is happening when you run the ODI procedure described below:
    - Does the procedure fail with an error, if yes, which error(full details)?
    - Does the procedure pass but no xslx file is been created?
    - Does the procedure pass and an xslx file is been created, but Excel can't read it? If yes, what is the structure of the xslx file when read in an editor?
    What I can see from your code below is that you have choosen -FILE_FORMAT=VARIABLE, but the XSLX format is supposed to be XML.
    Regards,
    Alex

  • Help Export TABLE Records into Flat File with INSERTs - error

    Hi,
    When i'm trying to run this procedure I got this error:
    ORA-00932:inconsistent datatypes: expected - got -
    Can anybody tell me why?
    Thanks
    CREATE OR REPLACE PROCEDURE generate_stmt(prm_table_name IN VARCHAR2,
    prm_where_clause IN VARCHAR2,
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2) IS
    TYPE ref_cols IS REF CURSOR;
    mmy_ref_cols ref_cols;
    mmy_column_name VARCHAR2(100);
    mmy_column_data_type VARCHAR2(1);
    mmy_col_string VARCHAR2(32767);
    mmy_query_col_string VARCHAR2(32767);
    V_FILE_HNDL UTL_FILE.file_type;
    begin
    OPEN mmy_ref_cols FOR
    SELECT LOWER(column_name) column_name
    FROM user_tab_columns
    WHERE table_name = UPPER(prm_table_name)
    ORDER BY column_id;
    LOOP
    FETCH mmy_ref_cols
    INTO mmy_column_name;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_col_string := mmy_col_string || mmy_column_name || ', ';
    mmy_query_col_string := mmy_query_col_string || ' ' || mmy_column_name || ',';
    END LOOP;
    CLOSE mmy_ref_cols;
    V_FILE_HNDL := UTL_FILE.FOPEN('TEST','TESST.TXT', 'W');
    mmy_col_string := 'INSERT INTO ' || LOWER(prm_table_name) || ' (' ||
    CHR(10) || CHR(9) || CHR(9) || mmy_col_string;
    mmy_col_string := RTRIM(mmy_col_string, ', ');
    mmy_col_string := mmy_col_string || ')' || CHR(10) || 'VALUES ( ' ||
    CHR(9);
    mmy_query_col_string := RTRIM(mmy_query_col_string,
    ' || ' || '''' || ',' || '''' || ' || ');
    dbms_output.put_line(mmy_column_name);
    OPEN mmy_ref_cols
    FOR ' SELECT ' || mmy_query_col_string ||
    ' FROM ' || prm_table_name ||
    ' ' || prm_where_clause;
    loop
    FETCH mmy_ref_cols
    INTO mmy_query_col_string;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_query_col_string := mmy_query_col_string || ');';
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_col_string);
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_query_col_string);
    end loop;
    end;

    Buddy,
    Try this..
    CREATE OR REPLACE PROCEDURE generate_stmt
    (prm_table_name IN VARCHAR2,
    prm_where_clause IN VARCHAR2,
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2) IS
    TYPE ref_cols IS REF CURSOR;
    mmy_ref_cols ref_cols;
    mmy_column_name VARCHAR2(100);
    mmy_column_data_type VARCHAR2(1);
    mmy_col_string VARCHAR2(32767);
    mmy_query_col_string VARCHAR2(32767);
    V_FILE_HNDL UTL_FILE.file_type;
    begin
    OPEN mmy_ref_cols FOR
    SELECT LOWER(column_name) column_name
    FROM user_tab_columns
    WHERE table_name = UPPER(prm_table_name)
    ORDER BY column_id;
    LOOP
    FETCH mmy_ref_cols
    INTO mmy_column_name;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_col_string := mmy_col_string || mmy_column_name || ', ';
    mmy_query_col_string := mmy_query_col_string || ' ' || mmy_column_name || ',';
    END LOOP;
    CLOSE mmy_ref_cols;
    mmy_col_string := 'INSERT INTO ' || LOWER(prm_table_name) || ' (' ||CHR(10) || CHR(9) || CHR(9) || mmy_col_string;
    mmy_col_string := RTRIM(mmy_col_string, ', ');
    mmy_col_string := mmy_col_string || ')' || CHR(10) || 'VALUES ( ' ||CHR(9);
    mmy_query_col_string := RTRIM(mmy_query_col_string,' || ' || '''' || ',' || '''' || ' || ');
    V_FILE_HNDL := UTL_FILE.FOPEN('TEST','TESST.TXT', 'W');
    OPEN mmy_ref_cols FOR 'SELECT ' || mmy_query_col_string ||' FROM ' || prm_table_name ||' ' || prm_where_clause;
    loop
    FETCH mmy_ref_cols INTO mmy_query_col_string;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_query_col_string := mmy_query_col_string || ');';
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_col_string);
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_query_col_string);
    end loop;
    UTL_FILE.FCLOSE(V_FILE_HNDL);
    END;
    This would work for table with one and only one column.
    Look at the line below:
    FETCH mmy_ref_cols INTO mmy_query_col_string;
    mmy_query_col_string has been declared as string...So it would hold single value only.That's the reason when you try this block on table with more than one column,mmy_query_col_string would've to hold a table row type data which it would not...
    Good luck!!
    Bhagat

  • Function module for BSEG table

    Hi Guru's,
      SELECT bukrs
             belnr
             gjahr
             budat
             monat
             waers
             awkey
        FROM bkpf
        INTO TABLE i_bkpf_data
        WHERE  bukrs EQ pa_bukrs AND
               budat IN so_budat.
    SORT i_bkpf_data BY bukrs belnr gjahr.
        IF i_bkpf_data[] IS NOT INITIAL.
          SELECT bukrs belnr gjahr koart dmbtr wrbtr pswsl
                 kokrs kostl hkont aufnr lifnr ebeln buzei shkzg
            FROM bseg
            INTO TABLE i_bseg_data
            FOR ALL ENTRIES IN i_bkpf_data
            WHERE 
                    bukrs  EQ pa_bukrs AND
                   belnr    EQ i_bkpf_data-belnr AND
                   gjahr    EQ i_bkpf_data-gjahr AND
                   kostl    IN so_kostl AND
                   lifnr      IN so_lifnr AND
                   hkont   IN so_hkont.
       ENDIF.
    I got performance issue on this Query..while accessing the data from BSEG table,its makes performance issue in my program so i want to improve performance of the program.i was analysed that BSEG table makes performance issue..
    Hi..Anybody give the solution imporving this Query or give some function module for accessing BSEG table..
    Note..I want to pass my selection inputs also into function module..i was seen some function module for BSEG,those are not satisfying the my inputs so those also making performance issue..
    Regards
    P.Senthil Kumar

    Hi Everybody,
    About how to use this function Does anyone have an idea?
    I've found it.
    call function 'FI_DOCUMENT_READ'
    exporting
       i_awtyp = 'VBRK'
       i_awref = vbfa_tab-vbeln
       i_awsys = vbrk-logsys
       i_bukrs = vbrk-bukrs
       i_gjahr = vbrk-gjahr
    tables
       t_bkpf = xbkpf
       t_bseg = xbseg
    exceptions
    wrong_input = 1
    not_found = 2.
    But this is not enough.
    Best Regards Rasim.

  • How to find the function module for standard tables.

    Hi
    Could any one please tell me how to find the standard function module to update the standard tables
    Thanks & Regards
    Sowmya

    Hi sowmya,
    To find the function modules for standard tables you go for a where used list of that particular table and check only function module interfaces checkbox...
    and more over you can go for DB_UPDATE_TABLE will be the function module for updating database table..
    Hope this information would help you
    Regards
    Narin Nandivada

Maybe you are looking for