How to Convert an internal table into Text File

Hello friends,
Can you help me to find out the way to convert an internal table data into a flat file.
the problem is that my internal table contains fields with data type INT also.

please  go through the code and the parameter passed to the  finction module  ... since  you didn't show your coding  i am giving you the sample code  also ..
REPORT y_ss_test_ekko .
* To hold selection data
DATA: i_ekko TYPE STANDARD TABLE OF ekko.
* To hold converted text data
DATA: i_text(4096) TYPE c OCCURS 0.
* Selection Screen
PARAMETERS: p_ebeln LIKE ekko-ebeln.
* Select data into an ITAB based on the selection Criteria
SELECT * FROM  ekko
         INTO  TABLE i_ekko
         WHERE ebeln = p_ebeln.
* Process further only if found some data
IF NOT i_ekko[] IS INITIAL.
* Convert data in internal table to a delimited text data
  CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
       EXPORTING
            i_field_seperator    = '|'
       TABLES
            i_tab_sap_data       = i_ekko
       CHANGING
            i_tab_converted_data = i_text
       EXCEPTIONS
            conversion_failed    = 1
            OTHERS               = 2.
  IF sy-subrc <> 0.
    WRITE: / 'Program failed to Convert data.'.
  ELSE.
*   Download convert data to Presentation Server
    CALL FUNCTION 'DOWNLOAD'
         TABLES
              data_tab = i_text
         EXCEPTIONS
              OTHERS   = 8.
    IF sy-subrc <> 0.
      WRITE: / 'Program failed to download data.'.
    ENDIF.
  ENDIF.
ENDIF.
reward  points  if it is  usefull   ....
Girish

Similar Messages

  • Conversion of internal table into excel file format &put it on app server

    Hi,
    My requirement is to convert the internal table into excel file format and I have to store it on application server so that administrator can send the file thr e-mail attachment.
    So, please let me know how to convert the records of internal table and store it on application server in Excel file format.
    TIA,
    Nitin

    Hi,
      Use FM GUI_DOWNLOAD to download the data from inernal table to excel sheet.
    Then Using tcode CG3Z u can transfer file to application server.
    *&      Form  sub_download
          text
    -->  p1        text
    <--  p2        text
    FORM sub_download.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
        BIN_FILESIZE                    =
          filename                        = p_path
         filetype                        = 'ASC'
        APPEND                          = ' '
         write_field_separator           = 'X'
        HEADER                          = '00'
        TRUNC_TRAILING_BLANKS           = ' '
        WRITE_LF                        = 'X'
        COL_SELECT                      = ' '
        COL_SELECT_MASK                 = ' '
        DAT_MODE                        = ' '
        CONFIRM_OVERWRITE               = ' '
        NO_AUTH_CHECK                   = ' '
        CODEPAGE                        = ' '
        IGNORE_CERR                     = ABAP_TRUE
        REPLACEMENT                     = '#'
        WRITE_BOM                       = ' '
        TRUNC_TRAILING_BLANKS_EOL       = 'X'
        WK1_N_FORMAT                    = ' '
        WK1_N_SIZE                      = ' '
        WK1_T_FORMAT                    = ' '
        WK1_T_SIZE                      = ' '
      IMPORTING
        FILELENGTH                      =
        TABLES
          data_tab                        = it_final
        FIELDNAMES                      =
      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.
    ENDFORM.                    " sub_download
    Otherwise use OPEN DATASET and TRANSFER statement to download data from internal table to direct application server
    Regards,
    Prashant

  • How to import the internal table into subroutine as parameter

    how to import the internal table into subroutine as parameter, and its structure can be recognized inside the subroutine

    Hi Yong,
    try this:
    parameters: p_tabnm like dd03l-tabname.
    field-symbols: <fs_tabname> type standard table.
    data: itab_ref type ref to data.
    create data itab_ref type standard table of (p_tabnm)
                         with default key.
    assign itab_ref->* to <fs_tabname>.
    select * from (p_tabnm) into table <fs_tabname>.
    perform subroutine tables <fs_tabname>
                       using p_tabnm.
    *&      Form  subroutine
          text
         -->P_<FS_TABNAME>  text
         -->P_P_TABNM  text
    form subroutine  tables   p_tabname type standard table
                     using    p_tabnm.
    Here p_tabname already has the structure of the table you gave as input
    parameter
    endform.                    " subroutine

  • How to copy complete internal table into main dababase table

    please tell me how to copy complete internal table into main dababase table by overwriting all the entries of the main DBtable.

    HI,
    you can use<b> Insert Or  Modify statement ..</b>
    <b>Modify updates the existing record, insert creates a new one. ...</b>
    insert ZDBTAB from table itab.
    Modify ZDBTAB from table Itab.
    The structure of itab should be exactly the same as the z table.
    You should not update standard tables directly though.
    rewards if usefuyl
    regards,
    nazeer

  • I can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.

    i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    hope1hope2 wrote:
    i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.
    It's very unlikely that you'l
    l find any help here; this forum is used only
    for testing purposes. Unfortunately, I cannot suggest
    another forum
    Extra line breaks kindly supplied by the software.

  • How to convert select-options table into single field internal table

    Hi,
    My requirement is to convert select-options table into single internal table which has one field.
    e.g. select-options: s_matnr for mara-matnr.
           select-options table can have options  'BT',"EQ", "NE", "GE", "GT", "LE", "LT", "CP" etc. select-options table
           have   Sign:I ,Option:BT, Low: 1, High.10.The new internal table records should be 1,2,3,4,5,6,7,8,9,10.
    Please suggest any function module available for this scenario in SAP.
    Thanks,
    Somi.
    Edited by: somi reddy satti on Sep 15, 2009 3:18 PM

    Hi Sowmya,
    Here is the answer if I understand well of your question.
    Data: begin of gt_mon OCCURS 0,
                  mon(2)             TYPE n,
             end of gt_mon.
    Data: begin of gt_year OCCURS 0,
                  year(4)             TYPE n,
             end of gt_year.
    Select-options: s_period       FOR ptdw_pws_db-kmonth NO-EXTENSION
                                                                                    DEFAULT sy-datum(6)
                                                                                    TO sy-datum(6).
    For example according to above statement period is 201110 is 201201.
    Period field does n't exists in SAP for selection. If your selection is on date based on period which is given on the selection-screen then you need to convert the period to date by concatenating ( or using FM to convert )01 at the end of each period . You need to declare one range table for date to select the data from table.
    loop at s_period.
    gr_date-sign   = s_period-sign.
    gr_date-option = s_period-option.
    COncatenate s_period-low
                          '01'
    into gr_date-high.
    COncatenate s_period-high                   
                           '01'
    into gr_date-low
    append gr_date.                      
    ENDloop.
    Thanks,
    Satheesh

  • How to convert an internal table to a PDF

    Hello Experts,
    Is there a way that an internal table can be converted into a PDF file?
    The itab is:
    data: i_data(100) type c occurs 0 with header line.
    Thanks.

    Hai,
    first convert ur internal table data to  OTF.by usinf thid Function Module
    data: t_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
    t_pdf LIKE tline OCCURS 100 WITH HEADER LINE*.
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
       format                      = 'PDF'
      MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
    IMPORTING
       BIN_FILESIZE                = w_size
      BIN_FILE                    =
      TABLES
        otf                         = t_otf
        lines                       = t_pdf
    EXCEPTIONS
       ERR_MAX_LINEWIDTH           = 1
       ERR_FORMAT                  = 2
       ERR_CONV_NOT_POSSIBLE       = 3
       ERR_BAD_OTF                 = 4
       OTHERS                      = 5
      IF sy-subrc <> 0.
       RAISE error.  " oops
      ENDIF.
    and then use gui_download  function module.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       BIN_FILESIZE                  =  w_size
        filename                      =  'C:\Documents and Settings\adc\Desktop\pdf123.pdf'
       FILETYPE                      = 'BIN'
      APPEND                        = ' '
      WRITE_FIELD_SEPARATOR         = 'X'
      HEADER                        = '00'
      TRUNC_TRAILING_BLANKS         = ' '
      WRITE_LF                      = 'X'
      COL_SELECT                    = 'X'
      COL_SELECT_MASK               = 'XX X XX'
      DAT_MODE                      = ' '
      CONFIRM_OVERWRITE             = ' '
      NO_AUTH_CHECK                 = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      WRITE_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      tables
        data_tab                      =   t_pdf
    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.
    reward if helpful
    raam

  • How to consolidate 4 internal table into one

    how can we consolidate data from
    two or more internal tables into one
    please help
    its a bit uegent
    thanks in advance

    Hi,
    If you want to combine two internal table,you can follow 2 approaches.
    Case1: If both the internal table are of same structure,
    append lines of itab1 to itab2.
    The above statement will append all the records in itab1 to itab2.
    Case2:If both the internal table are of differnt structure,
    you need one or more common fields in the two tables to connect.
    loop at itab1.
    move-corresponding itab1 to itab.
    loop at itab2 where f1 = itab1-f1.
    move-corresponding itab2 to itab.
    append itab.
    clear : itab2, itab.
    endloop.
    clear itab1.
    endloop.
    Now itab will hold the entries from itab1 and itab2.

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 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.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • How to convert a Form to a Text file and XML file?

    Hi:
    I want to convert a Form to a Text file and XML file,but I don't know how convert?
    Please help!
    Oracle Form Builder V10.1.2.0.2
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Thanks in advance!

    ..or follow the steps in Mtalink note; Doc ID: Note:196924.1
    Forms XML Conversion Feature ( Converting Forms To XML)

  • HOW TO CONVERT SAP DB TABLE TO XML FILE

    Initially I want to store sap db table as xml file so that an external program can read it. Also i want that when table is updated only updated data is stored in xml file.
    Edited by: Sandip Mane on Apr 2, 2008 9:19 PM
    Edited by: Alvaro Tejada Galindo on Apr 2, 2008 12:47 PM

    should do this way
    CALL TRANSFORMATION (`ID`)
    SOURCE output = your_itab[]
    RESULT XML xml_out.
    also check this link
    Convert data from internal table to XML file.

  • Upload data from Internal table to text file with  '~' separator

    can anyone help me to download data from internal table to flat file with  ''  separator. GUI_DOWNLOAD is not working in my case ....like for ''  separator

    Here it is
    REPORT  zkb_test1.
    TYPE-POOLS: truxs.
    DATA: i_scarr TYPE TABLE OF scarr,
    i_conv_data TYPE truxs_t_text_data.
    SELECT * FROM scarr INTO TABLE i_scarr.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator    = '~'
      TABLES
        i_tab_sap_data       = i_scarr
      CHANGING
        i_tab_converted_data = i_conv_data
      EXCEPTIONS
        conversion_failed    = 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.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = 'C:\Test1.txt'
        filetype                = 'ASC'
      CHANGING
        data_tab                = i_conv_data
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Kathirvel

  • How to convert an internal table of char type to Raw (1022 char) format int

    Hi All,
    I am facing the problem while converting the character type internal table to Raw (1022 char) format internal table.
    Example :
    Source :
    Internal table - Itab_send of type char132.
    Target : ( Required )
    Internal table - itab_receive of type SDOK_SDATX .
    Note : SDOK_SDATX = Raw ( 1022 char )
    Thank  you,
    Purshoth

    Possible Solution : Move it to source character field to string and string to raw field.
    try to find FM , go in se37 and *RAW *
    RSAB_CONVERT_RAW_TO_CHAR convert raw to char.
    Edited by: Harsh Bhalla on Dec 15, 2009 10:31 PM

  • How to pass a internal table into Java Bean

    Hi Experts,
    I created a JSPDyn page to display Sales orders form R/3 using bapi_sales_order_getlist.
    I used JCO to establish connectivity between JSP Dynpage and R/3. I executed the bapi successfully, i want to move the sales orders retrieved from the Bapi to a Java Bean. So that i can use the bean to populate the value as a table.
    with regards,
    James.
    Valuable answers will be rewarded.....

    Hi Bala,
    If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
    However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
    Regards,
    Uday

  • How to attach an internal table as excel file in wf container.

    Hi all, I have a task that is attaching an xml file in wf container, but I need to attach as excel file, how can I convert this xml to excel ?
    my currento code is like this:
    * Call Transformation to generate XSTRING of the generated data      *
      TRY .
          CALL TRANSFORMATION ztr_wf_excel
                       SOURCE appl_stat = li_data2
                       RESULT XML pi_attach.
        CATCH cx_st_error INTO lo_exception.
          lv_text = lo_exception->get_text( ).
      ENDTRY.
      IF lv_text IS INITIAL.
        pi_header-file_type      = 'B'.
        pi_header-file_name      = 'Data'.
        pi_header-file_extension = 'XLS'.
        pi_header-language       = 'E'.
          CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
            EXPORTING
              workitem_id = lw_worklist-wi_id
              att_header  = pi_header
              att_bin     = pi_attach
              do_commit   = 'X'
            IMPORTING
              att_id      = lw_att_id.
    this code is working fine, but I need to attach an excel file instead an xml file
    How can I do that?
    Regards

    hi ,
    Follow this approach :
    You can use following funcntions. First one to create internal table to string and second FM SCMS_STRING_TO_XSTRING to convert String to XSTRING. Then this XSTRING value you can pass to CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE.
    data: tab_str type string.
      data: begin of it_tab1,
           name(20),
           age(10) ,
          end of it_tab1.
    data : lv_name type xstring.
             data it_tab like STANDARD TABLE OF it_tab1.
             data: wa like line of it_tab.
             wa-name = 'naresh'.
             wa-age = '30'.
             append wa to it_tab.
             wa-name = 'naresh1'.
             wa-age = '31'.
             append wa to it_tab.
    CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'
    IMPORTING
       TEXT                      = tab_str
      TABLES
        TEXT_TAB                  = it_tab
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
      EXPORTING
        TEXT           = tab_str
    IMPORTING
       BUFFER         = lv_name
    CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
      EXPORTING
        I_FILENAME      = 'c:\test.txt'
        I_CONTENT       = lv_name
        I_MIME_TYPE     = 'TXT'
    Refer below links. This has been discussed many times :
    Re: download a file

Maybe you are looking for

  • Hi i need  help with a maths problem

    I have to find the inital value of a loan The information given is the payment per month, rate of interest, months of loan Premium(double payment, double rate, int months); for (int i=1; i<= months; i++) double newRate = rate; newRate /= (100 * 12);

  • Lookout 6.7.1 Client old alarms are not displaying.

    The Client Lookout program alarms are pointed to the server alarm objects (example  ..\[ServerLink]\Alarms\test_alarm.active). However when the alarm display filter option on the client PC for "old alarms" is set to greater than 0, no old alarms are

  • How do I move all my movies onto an external hard drive and still run imovie

    My Mac hard drive is full due to 300GB's of movies. I don't want to lose the movies and still want to work on them/create projects etc. I've bought an external hard drive so have copied and pasted all the movies across from MAC hard drive to external

  • Lexical params - not parsed correctly

    Hi All, Does BIP support lexical param for a Oracle DB? I have a query that looks like, select &rp_item_flex_all_seg item_code, ood.organization_name from &lp_item_from, org_organization_definitions ood of these &rp_item_flex_all_seg is created a glo

  • Copying Files From a Remote Machine through "rcp" command not working.

    Hi All, I'm a new comer to this famous forum. I was trying to go through the PDF "Solaris Advanced User's Guide" .So in chapter 9-"Using the network" i came across "Copying Files From a Remote Machine". And the syntax was "rcp machinename:source dest