Skip to Content
author's profile photo
Former Member

reports

hi,

i have a requirement.

am uploading data from excel sheet to ztable .

but in output i need to display total number of records in ztable ,total number of success and error records.send me any sample code if possible ASAP.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 12:46 PM

    use GUI_UPLOAD to upload the data to ztable.

    Use describe statement to find the no of records.

    pls reward if helpful.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi shori,

      am able to insert data frm xcel sheet to ztable.but nw i want to display total number of records in ztable.and also success n error records

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 12:46 PM

    HI RANJHANI

    see this its wii help u

    DATA: v_file LIKE rlgrap-filename,

    v_filename TYPE string.

    REFRESH i_matcontrol.

    CLEAR i_matcontrol.

    TRANSLATE v_exten TO UPPER CASE.

    *

    IF v_exten = 'XLS'.

    v_file = p_p_file.

    *

    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

    EXPORTING

    i_field_seperator = 'X'

    i_tab_raw_data = ws_rawdata

    i_filename = v_file

    TABLES

    i_tab_converted_data = i_data.

    ELSEIF v_exten = 'TXT'.

    v_filename = p_p_file.

    • File upload

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = v_filename

    filetype = 'ASC'

    has_field_separator = 'T'

    TABLES

    data_tab = i_data

    EXCEPTIONS

    file_open_error = 1

    file_read_error = 2

    no_batch = 3

    gui_refuse_filetransfer = 4

    invalid_type = 5

    no_authority = 6

    unknown_error = 7

    bad_data_format = 8

    header_not_allowed = 9

    separator_not_allowed = 10

    header_too_long = 11

    unknown_dp_error = 12

    access_denied = 13

    dp_out_of_memory = 14

    disk_full = 15

    dp_timeout = 16

    OTHERS = 17.

    CASE sy-subrc.

    WHEN 1.

    MESSAGE e001(00) WITH text-001.

    STOP.

    WHEN 2.

    MESSAGE e001(00) WITH text-002.

    STOP.

    WHEN 0.

    IF i_data IS INITIAL.

    MESSAGE s001(00) WITH text-008.

    ENDIF.

    ENDCASE.

    ENDIF.

    *

    DELETE i_data WHERE matnr IS INITIAL AND

    werks IS INITIAL.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi kumar,

      how to display error n success records .should i use two internal table.?i used describe statement for display total number of records and also sy-tfill, but am not getting correct output

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 06:31 AM

    Here is a solution for ur requirement....

    See the code for reference....

    data: itab like table of ZTABLE with header line,

    Success type i,

    Error type i,

    total type i.

    ***Your code to upload file

    ***make sure ITAb has same structure as ZTABLE

    loop at itab.

    insert into ZTABLE values itab.

    if sy-subrc eq 0.

    write:/ 'Success',ITAB.

    Success = Success + 1.

    else.

    write:/ 'Error',ITAB.

    error = error + 1.

    endif.

    endloop.

    total = success + error.

    write:/ 'Total No of records:',total.

    write:/ 'No of records successfully inserted:',success.

    write:/ 'No of records with Error:',Error.

    Reward points if useful, get back in case of query...

    Cheers!!!

    Add comment
    10|10000 characters needed characters exceeded