Download using GUI_download

Hi all,
i am trying to download the internal table which have 10 field, into the EXCEL file,
at the same time i wanted into the downloaded file
field name also appear....how can we do that,,
while downloading its appearing in a one column,
i want to shift the every field in different column,
Any idea about that how i will acheive this
Thanks for your help..
Manish

Hi manish,
1. For the same purpose
   i have developed an INDEPENDENT SUBROUTINE/FORM
   in which we pass just two things :
    a) itab
    b) file name with full path
2. It then downloads the file
   (ALONG WITH THE FIELD NAMES AT THE TOP)
  (We have to use GUI_DOWNLOAD two times,
   once for downloading data,
   and once for downloading the field names separated
    by tab)
3. Just copy paste in new program.
report abc.
data : itab like table of t001 with header line.
select * from t001 into table itab.
perform mydownload tables itab using 'D:\t001.txt'.
INDEPENDENT FORM
form mydownload tables ptab using filename.
DAta
  DATA : components     LIKE     rstrucinfo OCCURS 0 WITH HEADER LINE.
  DATA : allfields(300) TYPE c.
  DATA : fld(100) TYPE c.
  data : begin of htab occurs 0,
         allfields(300) type c,
         end of htab.
Get component list
  CALL FUNCTION 'GET_COMPONENT_LIST'
    EXPORTING
      program    = sy-repid
      fieldname  = 'ITAB'
    TABLES
      components = components.
construct
  LOOP AT components.
    CONCATENATE   components-compname
  CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO fld.
    CONCATENATE allfields fld INTO allfields .
  ENDLOOP.
  htab-allfields = allfields.
  append htab.
download first field list
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
  BIN_FILESIZE                    =
      FILENAME                        = 'D:\t001.txt'
     WRITE_FIELD_SEPARATOR           = 'X'
    TABLES
      DATA_TAB                        = htab
then download file data
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
  BIN_FILESIZE                    =
    FILENAME                        = filename
    APPEND                          = 'X'
   WRITE_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                        = ptab
  endform.
regards,
amit m.

Similar Messages

  • Fixing columns while downloading using GUI_DOWNLOAD!!

    Hi,
    I have declared an internal table which is downloaded using GUI_DOWNLOAD and after downloading the required outpout should appear in their own place for example:
    MATNR MEINS PLANS
    123       test1    test2
    12         test3    test3
    but whats actually happening ...
    123test1test2
    12test3test3
    how to fix the columns so that field value appear in that location only and from the same postion for all the records once downloaded..
    Regards
    Gunjan

    Hi Gunjan,
    You can try this:
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                      =  v_filename
        FILETYPE                      =  'ASC'
        WRITE_FIELD_SEPARATOR         = ' '
    For ASCII download, if you specify the field separator as spaces, then it will automatically separate fields with TABS.
    Hope this helps.
    Thanks,
    Rajesh

  • Problem with header download using GUI_DOWNLOAD

    Hi folks,
    Iam facing a particular problem while downloading an internal table to excel file using GUI_DOWNLOAD and file type as 'DBF'.
    Once i download the file, iam getting an automatic header with contents as "F1, F2, F3,...." for all the columns. But, i want to put my own header there. Is there any way out ?
    Thanks and Regards,
    Vijay.

    hi,
    may be this code will be helpful to u
    Just take one field in header(internal table) of type c. and push all the field headings into it.
    and give that internal table to fieldnames it will resolve the problem.
    DATA:BEGIN OF HEADER OCCURS 0,
          F1(30) TYPE C ,
         END OF HEADER.
    DATA:BEGIN OF ITEM OCCURS 0,
           IT1(30) TYPE C,
           IT2(3) TYPE C,
           IT3(4) TYPE C,
         END OF ITEM.
       HEADER-F1 = 'NAME'.
       APPEND HEADER.
       CLEAR HEADER.
       HEADER-F1 = 'AGE'.
       APPEND HEADER.
       CLEAR HEADER.
       HEADER-F1  = 'STAT'.
       APPEND HEADER.
       CLEAR HEADER.
    ITEM-IT1 = 'MANOHAR'.
    ITEM-IT2 = '124'.
    ITEM-IT3 = 'T'.
    APPEND ITEM.
    CLEAR ITEM.
    ITEM-IT1 = 'SAI'.
    ITEM-IT2 = '24'.
    ITEM-IT3 = 'T'.
    APPEND ITEM.
    CLEAR ITEM.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = 'C:\FILE13.XLS'
       FILETYPE                        = 'DBF'
      tables
        data_tab                        = ITEM
        FIELDNAMES                      = HEADER.
    regards,
    manohar.

  • Headings not downloaded using GUI_DOWNLOAD, used DBF as a file type

    Hello,
                 I have used the function module to download the data into an excel file using GUI_DOWNLOAD FM.
    I have given the file type as 'DBF', because if I give DAT type then the data for the amount not downloading properly.
    and preceeding zero's are not dowloaded properly. Hence used DBF.
    But when I use DBF file type , the header texts are not downloaded properly.
    CALL FUNCTION GUI_DOWNLOAD
        EXPORTING
          filename                       = lw_file
         filetype                        = DBF
       TABLES
          data_tab                      = t_output
        fieldnames                      = t_head
    fill the header texts for all the fields
    TYPES: BEGIN OF ty_head,
                   name(24),
      END OF ty_head.
    data:  wa_head TYPE ty_head,
           t_output TYPE STANDARD TABLE OF ty_output,
    wa_head-name = text-t01.
      condense wa_head-name.
      APPEND wa_head TO t_head.
        CLEAR wa_head.
      wa_head-name = text-t02.
      APPEND wa_head TO t_head.
      CLEAR wa_head.
      wa_head-name = text-t03.
      APPEND wa_head TO t_head.
      CLEAR wa_head.
    This is the code I have used...but the text is not displaying fully in the file.
    If I use DAT, then data will be wrong in some cases.(like zeros.amount in decimals).
    Thanks,
    AV

    HI,
    I suggest prepare the data in the internal table t_output as per your requirement first so as to avoid the data anomaly & then you can happily used DAT.
    Regards
    Abhii...

  • Heading  during downloading into local file using GUI_DOWNLOAD fun.module

    Hi Guru's
    we have a requirement that we want the plant description as a heading (first line of the file) in the local file. iam using "GUI_DOWNLOAD" function module for downloading data for which iam passing the charecter type internal table. before downloading iam passing all the filed headings to that table and then appending the internal table data into it. now iam getting data properly with field headings . but before that heading i want one more description for a plant field which iam using in my selection screen
    in the fun.module "GUI_DOWNLAOD"
    we have HEADER file but it is of XSTRING type so it is taking only 2 char.
    so how to use this . Plz help me.
    thanks well in advance.
    UR's
    GSANA

    Hi,
    Please check the below link,
    header in 'gui_download'
    Also check Manoj kumar's reply in the link,
    header information to gui_download
    Hope this helps.
    Best Regards.

  • Download Arabic text using GUI_DOWNLOAD

    Hi Experts,
    I am using GUI_DOWNLOAD to download the contents of an internal table to a local text (.txt) file. The internal table contain Arabic characters also. The Arabic characters appear as # in the downloaded text file.
    Please help to resolve this issue.
    Points will be rewarded for helful answers.

    Hi ,
    Try File type as  'DAT' , i guess it will solve your problem , Let me know if its not solved.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    FILENAME = 'C:/TEST.XLS'
    FILETYPE = 'DAT'
    WRITE_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = ITAB "internal table
    Regards,
    Saravana.S

  • Data missing while downloading the data using GUI_DOWNLOAD

    Hi experts,
    I'm uploading the Production Order data through excel and in the transaction level it's happening fine.
    After running the BDC I'm fetching the Production Order Number(AUFNR) and it's Status from the respective tables and downloading the data along with the Production Order Number(AUFNR) and it's Status using GUI_DOWNLOAD.  (Version is 4.6 C)
    After downloading some of the Production Order Numbers(AUFNR) and it's Status are missing in the Excel Log sheet . But it's very much there in the  SAP tables and also in the transaction screen level.
      CALL FUNCTION 'GUI_DOWNLOAD'
           EXPORTING
                bin_filesize            = v_bin_filesize
                filename                = v_name
                filetype                = 'ASC'
                write_field_separator   = 'X'
           TABLES
                data_tab                = it_final
           EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                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.
    Kindly give me your suggestions regarding this.
    Thanks in advance.
    Jessi

    Hi,
    I am not sure why it is not coming .
    But try by uncomment the bin_filesize.
    Because generally the size(bin_filesize) specification is for binary files .
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    *bin_filesize = v_bin_filesize "Comment This
    filename = v_name
    filetype = 'ASC'
    write_field_separator = 'X'
    TABLES
    data_tab = it_final.
    Regards,
    Raghava Channooru

  • I am using GUI_DOWNLOAD FM to download my internal table entries into .xls

    Hi
    I am using GUI_DOWNLOAD FM to download my internal table entries into .xls file. but it's not download total records in final table.
    in debugging it showing total records.
    exporting:
    filename
    filetype
    field-suprater
    header
    tables
    data_tab
    fieldnames
    plz help me.
    thanks
    Sankar

    Hi
    Use as below:
    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
    EXPORTING
    file_name = p_file " path offile where u need to download
    CREATE_PIVOT = 0
    DATA_SHEET_NAME = ' '
    PIVOT_SHEET_NAME = ' '
    PASSWORD = ' '
    PASSWORD_OPTION = 0
    TABLES
    PIVOT_FIELD_TAB =
    data_tab = int_data "internal table with data
    fieldnames = int_head "internal table with header
    EXCEPTIONS
    file_not_exist = 1
    filename_expected = 2
    communication_error = 3
    ole_object_method_error = 4
    ole_object_property_error = 5
    invalid_filename = 6
    invalid_pivot_fields = 7
    download_problem = 8
    OTHERS = 9
    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,
    Sreeram

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • How to download the chinese character using GUI_DOWNLOAD

    How to download the chinese character using GUI_DOWNLOAD from SAP 4.6c

    Hi,
       Make sure that the chinese font is installed in your system, because when you download in excel, the character formats are taken from the Frontend.  For detail see the below thread.
    [link1|Re: Download Chinese character]
    Thanks,
    Asit Purbey.

  • Downloading two different text files using gui_download

    Hi Folks,
    I have two internal tables.itab1 and itab2.Generally in  most cases I have to download only the data in itab1 as a text file using Gui_download.In some cases if a particular condition is satisfied I need to download both itab1 and itab2 data as two different text files using gui_download.To achieve this I had called the gui_download twice as I have to pass two different internal tables.
    But I am getting only itab1 textfile and not itab2 textfile.
    In the selection screen I am giving the path as c:\..
    Kindly let me know where I am going wrong.
    K.Kiran.

    Hi
    You keep the both files in a ITAB and in the loop of that Itab use GUI_DOWNLOAD to download the two files
    data: begin of itab,
              file like rlgrap-filename,
            end of itab.
    In initialization event
    put the two files into this ITAB.
    loop at itab
    call function gui_download.
    endloop.
    check like this
    Regards
    Anji

  • Issue in conversion of output file from alv to csv file using GUI_DOWNLOAD

    hi,
    I am using GUI_DOWNLOAD to convert the internal table that am getting as the output of an alv into a csv(comma separated file) file.I am using the following code but its not generating a csv file instead it is generating a normal space delimited file.
    The code is as follows:
    data : lv_fname type string.
    lv_fname = 'C:\Users\pratyusha_tripathi\Desktop\status8.csv'. " Provide the file path & file name with CSV extention
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = lv_fname " File name including path, give CSV as extention of the file
    FILETYPE = 'DAT'
    WRITE_FIELD_SEPARATOR = '#' " Provide comma as separator
    tables
    data_tab = ITAB " Pass the Output internal table
    FIELDNAMES =
    EXCEPTIONS
    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.
    Kindly let me know what changes can be made to make my code work.Also can GUI_download be used for batch processing and storing the output in application server?
    Thanks ,
    Pratyusha

    Hi,
    the short text description for WRITE_FIELD_SEPARATOR is "Separate Columns by Tabs in Case of ASCII Download", so why do you expect a comma?
    Try SAP_CONVERT_TO_CSV_FORMAT and then download.
    And no, GUI_DOWNLOAD is only for download via SAP GUI to a users computer.
    Best regards,
    Oliver

  • Is there anything to be taken care of while using GUI_DOWNLOAD in ITS?

    Hi All,
             I have a requirement on which I am using GUI_DOWNLOAD for downloading a file into a network Drive.In the foreground I am executing using ITS.When I click on 'SUBMIT' button it goes to "Interpreter failed ...Internal error code: 0x2101".Till the point of GUI_DOWNLOAD its working fine.When I am executing from SAP system,its working fine.Once I execute from browser only problem comes.Have anybody faced a similiar situation and if so please help me.
    Thanks in Advance,
       Anjaly

    Hi Anjaly,
    this means that the template could not be found. I assume you are using the ITS 620, in the integrated ITS this error would result in an ABAP runtime error.
    Ok, how to solve? Please examine the ITS trace files especially that one for the Bussiness HTML interpreter. Its is Agate<N>_sapjulep.trc.
    best regards
    Tobias

  • Need to include header in csv file while using GUI_DOWNLOAD

    Hi,
    Iam using GUI_DOWNLOAD for downloading certain texts,its working fine.now i need to include the header(i'e) some text say 'This is a error file'at the top.how can i do this?

    REPORT  ZTEST12347                              .
    DATA: BEGIN OF ITAB OCCURS 0,
            VBELN LIKE VBAK-VBELN,
            POSNR LIKE VBAP-POSNR,
          END OF ITAB.
    SELECT VBELN
           POSNR
          FROM VBAP
          UP TO 20 ROWS
          INTO TABLE ITAB.
    DATA: IT_LINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
    IT_LINE-TDLINE = 'this is error file'.
    append it_line.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                = 'C:test.txt'
      TABLES
        DATA_TAB                = IT_LINE
      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
        FILENAME                = 'C:test.txt'
        APPEND                  = 'X'
      TABLES
        DATA_TAB                = ITAB
      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.

  • Problem downloading in GUI_DOWNLOAD

    Please don't post your subjects in ALL CAPITALS
    HELLO FOLKS..
    I am downloading data from an int tab to excel.
    im using gui_download for that.
    we have to pass the internal table to this FM where all the fields' data are put into string field of itab
    separated by '#' and passed to FM.
    now the problem is- the data is getting copied into excel, but the hashes are still there. and the data is stored in only one cell not different.
    im using ascii encoding- 'ASC' and file encoding type '4103'.
    thanks in adv.
    Edited by: Matt on Jun 11, 2009 8:35 AM - edited title

    Hi Sumit,
    You need to declare constants like below:
    CONSTANTS: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
               c_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    And use the separator c_tab as below to concatenate the data into the workarea wa_objbin1 which will finally be updated to internal table t_objbin1.
    CONSTANTS: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
               c_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    And use the separator c_tab as below to concatenate the data into the workarea wa_objbin1 which will finally be updated to internal table t_objbin1.
    FORM  email_spreadsheet.
      DATA: l_check(3)      TYPE c,
            l_psapundo(3)   TYPE c,
            l_npsapundo(3)  TYPE c,
            wl_objbin_final TYPE solisti1.
      CLEAR wa_objbin1.
      CONCATENATE text-a01
                  text-a02
                  text-a03
                  text-a04
             INTO wa_objbin1 SEPARATED BY c_tab.
      CONCATENATE c_ret wa_objbin1 INTO wa_objbin1.
      APPEND wa_objbin1 TO t_objbin1.
      LOOP AT t_output INTO wa_output.
        MOVE : wa_output-check     TO l_check,
               wa_output-psapundo  TO l_psapundo,
               wa_output-npsapundo TO l_npsapundo.
        CONCATENATE wa_output-jobname
                    l_check
                    l_psapundo
                    l_npsapundo
               INTO wa_objbin1 SEPARATED BY c_tab.
        CONCATENATE c_ret wa_objbin1 INTO wa_objbin1.
        APPEND wa_objbin1 TO t_objbin1.
        CLEAR: wa_output, wa_objbin1.
      ENDLOOP.
      LOOP AT t_objbin1 INTO wa_objbin1.
        MOVE wa_objbin1-line TO wl_objbin_final-line.
        APPEND wl_objbin_final TO t_objbin_final.
        CLEAR: wa_objbin1, wl_objbin_final.
      ENDLOOP.
    ENDFORM.
    Then use this Perform to send the mail.
    FORM process_email.
    DATA: tl_objpack TYPE STANDARD TABLE OF sopcklsti1,
            wl_objpack TYPE sopcklsti1,
            tl_reclist TYPE STANDARD TABLE OF somlreci1,
            wl_reclist TYPE somlreci1,
            wl_mailid  TYPE tp_mailid,
            wl_docdata TYPE sodocchgi1.
    *--Body
      wl_docdata-obj_name  = 'Mail_Excel_File'(007).
      wl_docdata-obj_descr = 'Report on SAP Job Rollback Monitor'(008).
      CLEAR wa_objtxt.
      IF s_jobnam-low IS NOT INITIAL
         AND s_jobnam-high IS NOT INITIAL.
        CONCATENATE text-012 s_jobnam-low text-a05 ' ' s_jobnam-high
               INTO wa_objtxt SEPARATED BY space.
      ELSEIF s_jobnam-high IS INITIAL.
        CONCATENATE text-012 s_jobnam-low
               INTO wa_objtxt SEPARATED BY space.
      ENDIF.
      APPEND wa_objtxt TO t_objtxt.
    *-- Insert a blank line in the mail
      CLEAR wa_objtxt.
      APPEND INITIAL LINE TO t_objtxt.
      CLEAR wa_objtxt.
      IF t_output[] IS NOT INITIAL.
    *-- Please find attached the SAP Job Rollback Monitor
       MOVE text-009 TO wa_objtxt.
      ELSE.
    *-- No Jobs selected for the given criteria
       MOVE text-013 TO wa_objtxt.
      ENDIF.
      APPEND wa_objtxt TO t_objtxt.
      DESCRIBE TABLE t_objtxt LINES w_tab_lines.
      CLEAR wa_objtxt.
      READ TABLE t_objtxt INTO wa_objtxt INDEX w_tab_lines.
      wl_docdata-doc_size
             = ( w_tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ).
      CLEAR wl_objpack.
      wl_objpack-head_start = 1.
      wl_objpack-head_num = 0.
      wl_objpack-body_start = 1.
      wl_objpack-body_num = w_tab_lines.
      wl_objpack-doc_type = 'RAW'.
      APPEND wl_objpack TO tl_objpack.
    *--Attachment
    *-- Check if any data is found for the given criteria
      IF NOT t_output[] IS INITIAL.
        DESCRIBE TABLE t_objbin1 LINES w_tab_lines.
        wl_objpack-doc_size = w_tab_lines * 255.
        wl_objpack-transf_bin = 'X'.
        wl_objpack-head_start = 1.
        wl_objpack-head_num = 1.
        wl_objpack-body_start = 1.
        wl_objpack-body_num = w_tab_lines.
        wl_objpack-doc_type = 'XLS'.
        wl_docdata-obj_name = 'Job Rollback Monitor'(010).
        wl_objpack-obj_descr = 'Report on SAP Job Rollback Monitor'(008).
        APPEND wl_objpack TO tl_objpack.
      ENDIF.
      LOOP AT s_mailid INTO wl_mailid.
        CLEAR wl_reclist.
    *--Create the list of recipients
        wl_reclist-receiver = wl_mailid-low.
        wl_reclist-rec_type = 'U'.
        wl_reclist-express  = 'X'.
        APPEND wl_reclist TO tl_reclist.
    *--Send the e-mail
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = wl_docdata
            put_in_outbox              = 'X'
            commit_work                = 'X'
          TABLES
            packing_list               = tl_objpack
            contents_bin               = t_objbin_final
            contents_txt               = t_objtxt
            receivers                  = tl_reclist
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.
        IF sy-subrc = 0.
          COMMIT WORK.
          MESSAGE s999(zz) WITH 'Mail Sent Successfully'(011).
        ENDIF.
        CLEAR wl_mailid.
        REFRESH tl_reclist[].
      ENDLOOP.
    ENDFORM.
    Regards,
    Amit.
    Edited by: AMIT BISHT on Jun 11, 2009 9:02 AM
    Edited by: AMIT BISHT on Jun 11, 2009 9:03 AM

Maybe you are looking for