9 Replies Latest reply: Aug 6, 2008 9:36 AM by Sravanthi Balabhadrapatruni RSS

Use of WS_UPLOAD

sudhakar v
Currently Being Moderated

Hi All,

 

I am working on 3.1I version i am uploading the data from excel file to SAP

i have only the function module WS_UPLOAD.

i am getting the problem when ever i am uploading TEST.XLS file .

 

could you pls give send me the coding part for that and how to use WS_UPLOAD function module for .XLS files.

 

Thanks in advance

  • Re: Use of WS_UPLOAD
    Md Faheem
    Currently Being Moderated
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME =wsfile
    FILETYPE = 'DAT'
    TABLES
    DATA_TAB = plant
    EXCEPTIONS
    CONVERSION_ERROR = 1
    FILE_OPEN_ERROR = 2
    FILE_READ_ERROR = 3
    INVALID_TABLE_WIDTH = 4
    INVALID_TYPE = 5
    NO_BATCH = 6
    UNKNOWN_ERROR = 7
    OTHERS = 8.
    
    IF SY-SUBRC 0.
    WRITE: / 'Error Uploading', wsfile, SY-SUBRC.
    STOP.
    ENDIF.

     

    The call is very simple. The filename is the name of the variable that holds the user selection for the file on the presentation server. Filetype is a little tricky. There are a number of different values available, including

     

    'ASC' (ASCII)

    'DAT' (Tab-delimited data)

    'IBM' (EBCDIC)

    'BIN' (binary)

    Check the function module documentation for a complete list of values.

  • Re: Use of WS_UPLOAD
    Raja Babu
    Currently Being Moderated

    Hi Sudhakar

     

    Check this

     

    *   *Retrieve data file from presentation server(Upload from PC)*DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
    DATA: begin of it_datatab occurs 0,
      row(500) type c,
     end of it_datatab.
    
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename        = i_file
                filetype        = 'ASC'
           TABLES
                data_tab        = it_datatab  "ITBL_IN_RECORD[]
           EXCEPTIONS
                file_open_error = 1
                OTHERS          = 2.

    OR

     

    code

    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = 'D:\Quota_upload.xls' "Change here with quote
    FILETYPE = 'DAT'
    TABLES
    data_tab = int_input
    EXCEPTIONS
    conversion_error = 1
    invalid_table_width = 2
    invalid_type = 3
    no_batch = 4
    unknown_error = 5
    gui_refuse_filetransfer = 6
    others = 7.

     

  • Re: Use of WS_UPLOAD
    Jay Raj
    Currently Being Moderated

    check this code

     

    REPORT  zupload_excel_to_itab.
    
    TYPE-POOLS: truxs.
    
    PARAMETERS: p_file TYPE  rlgrap-filename.
    
    TYPES: BEGIN OF t_datatab,
    col1(30)    TYPE c,
    col2(30)    TYPE c,
    col3(30)    TYPE c,
    END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
    wa_datatab type t_datatab.
    
    DATA: it_raw TYPE truxs_t_text_data.
    
    * At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION u2018F4_FILENAMEu2019
    EXPORTING
    field_name = u2018P_FILEu2019
    IMPORTING
    file_name  = p_file.
    
    ***********************************************************************
    *START-OF-SELECTION.
    START-OF-SELECTION.
    
    CALL FUNCTION u2018TEXT_CONVERT_XLS_TO_SAPu2019
    EXPORTING
    *     I_FIELD_SEPERATOR        =
    i_line_header            =  u2018Xu2019
    i_tab_raw_data           =  it_raw       u201D WORK TABLE
    i_filename               =  p_file
    TABLES
    i_tab_converted_data     = it_datatab[]    u201CACTUAL 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.
    
    ***********************************************************************
    * END-OF-SELECTION.
    END-OF-SELECTION.
    LOOP AT it_datatab INTO wa_datatab.
    WRITE:/ wa_datatab-col1,
    wa_datatab-col2,
    wa_datatab-col3.
    ENDLOOP.

     

    or check this [link|http://www.sapfans.com/forums/viewtopic.php?f=13&t=309588]

  • Re: Use of WS_UPLOAD
    saradadevi nanduri
    Currently Being Moderated

    Hi,

     

    REPORT ZS_BDC5 .

    *HANDLING TABLE CONTROL IN BDC

    DATA : BEGIN OF IT_DUMMY OCCURS 0,

    DUMMY(100) TYPE C,

    END OF IT_DUMMY.

    DATA : BEGIN OF IT_XK01 OCCURS 0,

    LIFNR(10) TYPE C,

    BUKRS(4) TYPE C,

    EKORG(4) TYPE C,

    KTOKK(4) TYPE C,

    NAME1(30) TYPE C,

    SORTL(10) TYPE C,

    LAND1(3) TYPE C,

    SPRAS(2) TYPE C,

    AKONT(6) TYPE C,

    FDGRV(2) TYPE C,

    WAERS(3) TYPE C,

    END OF IT_XK01,

    BEGIN OF IT_BANK OCCURS 0,

    BANKS(3) TYPE C,

    BANKL(10) TYPE C,

    BANKN(10) TYPE C,

    KOINH(30) TYPE C,

    LIFNR(10) TYPE C,

    END OF IT_BANK.

    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

    IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

     

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = 'C:\VENDOR.TXT'

    FILETYPE = 'ASC'

    TABLES

    DATA_TAB = IT_DUMMY.

     

    LOOP AT IT_DUMMY.

    IF IT_DUMMY-DUMMY+0(2) = '11'.

    IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).

    IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).

    IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).

    IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).

    IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).

    IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).

    IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).

    IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).

    IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).

    IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).

    IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).

    APPEND IT_XK01.

    ELSE.

    IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).

    IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).

    IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).

    IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).

    IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).

    APPEND IT_BANK.

    ENDIF.

    ENDLOOP.

     

    LOOP AT IT_XK01.

    REFRESH IT_BDCDATA.

    perform bdc_dynpro using 'SAPMF02K' '0100'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-REF_LIFNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'RF02K-LIFNR'

    IT_XK01-LIFNR.

    perform bdc_field using 'RF02K-BUKRS'

    IT_XK01-BUKRS.

    perform bdc_field using 'RF02K-EKORG'

    IT_XK01-EKORG.

    perform bdc_field using 'RF02K-KTOKK'

    IT_XK01-KTOKK.

    perform bdc_dynpro using 'SAPMF02K' '0110'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-TELX1'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFA1-NAME1'

    IT_XK01-NAME1.

    perform bdc_field using 'LFA1-SORTL'

    IT_XK01-SORTL.

    perform bdc_field using 'LFA1-LAND1'

    IT_XK01-LAND1.

    perform bdc_field using 'LFA1-SPRAS'

    IT_XK01-SPRAS.

    perform bdc_dynpro using 'SAPMF02K' '0120'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-KUNNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0130'.

    perform bdc_field using 'BDC_CURSOR'

    'LFBK-KOINH(02)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    DATA : FNAM(20) TYPE C,

    IDX TYPE C.

    MOVE 1 TO IDX.

    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.

    CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKS.

     

    CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKL.

     

    CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKN.

     

    CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-KOINH.

    IDX = IDX + 1.

    ENDLOOP.

     

    perform bdc_dynpro using 'SAPMF02K' '0130'.

    perform bdc_field using 'BDC_CURSOR'

    'LFBK-BANKS(01)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPMF02K' '0210'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB1-FDGRV'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFB1-AKONT'

    IT_XK01-AKONT.

    perform bdc_field using 'LFB1-FDGRV'

    IT_XK01-FDGRV.

    perform bdc_dynpro using 'SAPMF02K' '0215'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB1-ZTERM'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0220'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB5-MAHNA'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0310'.

    perform bdc_field using 'BDC_CURSOR'

    'LFM1-WAERS'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFM1-WAERS'

    IT_XK01-WAERS.

    perform bdc_dynpro using 'SAPMF02K' '0320'.

    perform bdc_field using 'BDC_CURSOR'

    'WYT3-PARVW(01)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPLSPO1' '0300'.

    perform bdc_field using 'BDC_OKCODE'

    '=YES'.

    CALL TRANSACTION 'XK01' USING IT_BDCDATA

    MODE 'A'

    UPDATE 'S'

    MESSAGES INTO IT_BDCMSGCOLL.

    ENDLOOP.

     

    FORM BDC_DYNPRO USING PROG SCR.

    CLEAR IT_BDCDATA.

    IT_BDCDATA-PROGRAM = PROG.

    IT_BDCDATA-DYNPRO = SCR.

    IT_BDCDATA-DYNBEGIN = 'X'.

    APPEND IT_BDCDATA.

    ENDFORM.

     

    FORM BDC_FIELD USING FNAM FVAL.

    CLEAR IT_BDCDATA.

    IT_BDCDATA-FNAM = FNAM.

    IT_BDCDATA-FVAL = FVAL.

    APPEND IT_BDCDATA.

    ENDFORM.

     

    Thanks

    Sarada

  • Re: Use of WS_UPLOAD
    Khimavath Vikranth
    Currently Being Moderated

    Hi,

     

    Is your WS_UPLOAD code looks like this? Please let me know. I am working in 3.1 version it is working correctly

     

    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = 'Your file.xls' "Change here with quote
    FILETYPE = 'DAT'
    TABLES
    data_tab = it_tab (Internal table)
    EXCEPTIONS
    conversion_error = 1
    invalid_table_width = 2
    invalid_type = 3
    no_batch = 4
    unknown_error = 5
    gui_refuse_filetransfer = 6
    others = 7.

     

    Thanks

    Vikranth

  • Re: Use of WS_UPLOAD
    sudhakar v
    Currently Being Moderated

    Hi All,

     

    Again this is sudhakar

     

    This is giving a& = && something symbols when i was uploading .xls file .

    if it is . csv  file then it is supporting

     

    could pls explain me how to upload the data.

    by using only WS_UPLOAD(only for .xls file) .

     

    i am working on 3.1i version.

     

    Thanks in advance...

  • Re: Use of WS_UPLOAD
    sudhakar v
    Currently Being Moderated

    Hi All,

     

    when i was uploading the .xls file in the fm WS_UPLOAD it is

    giving like   ' ÐÏ#ࡱ'

     

    could you pls help me out by using .xls files uploading to SAP

     

    by using fm WS_UPLOAD.

     

    I have used file type both ASC or DAT as well.

     

    but i am unable to get the output. i am working on 3.1I version.

     

     

    Thanks in advance.

     

  • Re: Use of WS_UPLOAD
    Shmulik Shmilovitz
    Currently Being Moderated

    Download it with type dat and than activate FM u2018TEXT_CONVERT_XLS_TO_SAPu2019.

    It'll solve your problem.

     

    <removed by moderator>

     

    Rebeka

     

    Edited by: Mike Pokraka on Aug 6, 2008 8:32 AM

  • Re: Use of WS_UPLOAD
    Sravanthi Balabhadrapatruni
    Currently Being Moderated

    Hi

     

    [ws_upload|http://goldenink.com/abap/ws_upload.html]

     

    Regards,

    Sravanthi

Actions