Skip to Content
author's profile photo Former Member
Former Member

To upload data from excel file into maintenance view of a z-table.

Hi,

I have created a z-table and also created its Table Maintenance Generator. Now I have to import data from an excel spreadsheet into the view of that z-table through BDC. I did the BDC recording of Transaction 'sm30' to maintain entries into the view of that ztable. So far I have written the code below and correspondingly a new entry is added into the view because of the recording but no entries are imported through excel file. Please help me out.

Regards,

Rakesh Nair

1.txt.zip (1.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 03, 2013 at 09:18 AM

    Instead of BDC, you can directly insert the record in to the table.

    For example - the code insert a record into a z-table

    loop at it_exception_data into wa_exception_data.


    wa_exceptions-cntr = sy-tabix. "wa_exception_data-cntr.
    wa_exceptions-zcode = wa_exception_data-zcode.
    wa_exceptions-zenglish = wa_exception_data-zenglish.
    wa_exceptions-zarabic = wa_exception_data-zarabic.

    INSERT INTO ZEXCEPTIONS VALUES wa_exceptions.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2013 at 10:00 AM

    Hi Rakesh,

    Do upload the data in z table directly, that will reflect in your TMG also.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2013 at 10:03 AM

    Hi,

    Wouldn't be better instead of a BCD use the function ALSM_EXCEL_TO_INTERNAL_TABLE??

    I found it very much easier to develop and debug than use a BDC.

    Hope it helps,

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2013 at 08:33 AM

    Hi,

    I have managed to come with a code that allows to update the maintenance view of my z-table from excel file. But the only thing is, after insertion of each record into internal table and then into maintenance view of that table through BDC, it is getting saved one by one. I need to first import block of records from excel file and then save in the end. Saving data from excel file into maintenance view one-by-one through BDC, takes considerable amount of time. So, how am supposed to get block of data through BDC and then save in the end.

    report zrakesh_bank_bdc555
    no standard page heading line-size 255.
    tables: zrakesh_bank.
    type-pools: truxs.

    types: begin of itab,
    zbank_id type zrakesh_bank-zbank_id,
    zbank_name type zrakesh_bank-zbank_name,
    zbank_address type zrakesh_bank-zbank_address,
    zbank_contact type zrakesh_bank-zbank_contact,
    end of itab.

    data: it_itab type table of itab,
    wa_itab type itab,
    it_type type truxs_t_text_data.

    parameters: p_file type rlgrap-filename default 'C:\Documents and Settings\sap\Desktop\zrakesh_bank555.xls'.

    data: bdcdata_it like bdcdata occurs 0 with header line.

    at selection-screen on value-request for p_file.

    call function 'F4_FILENAME'
    exporting
    program_name = syst-cprog
    * DYNPRO_NUMBER = SYST-DYNNR
    field_name = 'P_FILE'
    importing
    file_name = p_file
    .

    form bdc_dynpro using program dynpro.
    clear bdcdata_it.
    bdcdata_it-program = program.
    bdcdata_it-dynpro = dynpro.
    bdcdata_it-dynbegin = 'X'.
    append bdcdata_it.
    endform.

    form bdc_field using fnam fval.
    clear bdcdata_it.
    bdcdata_it-fnam = fnam.
    bdcdata_it-fval = fval.
    append bdcdata_it.
    endform.


    "include bdcrecx1.

    start-of-selection.

    "perform open_group.

    call function 'TEXT_CONVERT_XLS_TO_SAP'
    exporting
    i_field_seperator = 'X'
    * I_LINE_HEADER =
    i_tab_raw_data = it_type
    i_filename = p_file
    tables
    i_tab_converted_data = it_itab
    * 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.



    perform bdc_dynpro using 'SAPMSVMA' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'VIEWNAME'.
    perform bdc_field using 'BDC_OKCODE'
    '=UPD'.
    perform bdc_field using 'VIEWNAME'
    'ZRAKESH_BANK'.
    perform bdc_field using 'VIMDYNFLDS-LTD_DTA_NO'
    'X'.

    loop at it_itab into wa_itab.

    perform bdc_dynpro using 'SAPLZRAKESH_BANK_FG' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'VIM_POSITION_INFO'.
    perform bdc_field using 'BDC_OKCODE'
    '=NEWL'.








    perform bdc_dynpro using 'SAPLZRAKESH_BANK_FG' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'ZRAKESH_BANK-ZBANK_CONTACT(01)'.
    perform bdc_field using 'ZRAKESH_BANK-ZBANK_ID(01)'
    wa_itab-zbank_id.
    perform bdc_field using 'ZRAKESH_BANK-ZBANK_NAME(01)'
    wa_itab-zbank_name.
    perform bdc_field using 'ZRAKESH_BANK-ZBANK_ADDRESS(01)'
    wa_itab-zbank_address.
    perform bdc_field using 'ZRAKESH_BANK-ZBANK_CONTACT(01)'
    wa_itab-zbank_contact.
    endloop.

    perform bdc_field using 'BDC_OKCODE'
    '=SAVE'.
    perform bdc_dynpro using 'SAPLZRAKESH_BANK_FG' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'ZRAKESH_BANK-ZBANK_ID(02)'.
    perform bdc_field using 'BDC_OKCODE'
    '=BACK'.
    perform bdc_dynpro using 'SAPLZRAKESH_BANK_FG' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'ZRAKESH_BANK-ZBANK_ID(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=BACK'.
    perform bdc_dynpro using 'SAPMSVMA' '0100'.
    perform bdc_field using 'BDC_OKCODE'
    '/EBACK'.
    perform bdc_field using 'BDC_CURSOR'
    'VIEWNAME'.

    call transaction 'SM30' using bdcdata_it mode 'A'
    update 'S'.


    modify zrakesh_bank from table it_itab .
    clear wa_itab.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.