Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

gui_upload

Former Member
0 Likes
783

Hi ,

Im trying to use GUI_Upload to upload and excel file in ECC 6.0

But the filename is in the fn modules is of type string

hence im convereting the value into string and issuing that value to filename .

But still it is giving and dump .

I tried with ws_upload and upload as well .

DATA : BEGIN OF itab OCCURS 0,

filex type rlgrap-filename,

END OF itab,

DATA: v_filex TYPE string .

v_filex = itab-filex .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = V_FILEX

FILETYPE = 'DBF'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = I_IK11

  • 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

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Pls check this fn module

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
757

Did you check if this statement

v_filex = itab-filex .

is correct. you table itab doesnt have a headerline. you might have to assign it to a workarea before assigning it to the string variable

5 REPLIES 5
Read only

Former Member
0 Likes
758

Did you check if this statement

v_filex = itab-filex .

is correct. you table itab doesnt have a headerline. you might have to assign it to a workarea before assigning it to the string variable

Read only

Former Member
Read only

Former Member
0 Likes
757

filename = V_FILEX

FILETYPE = 'DBF'

Comment this and check .

Read only

Former Member
0 Likes
757

hii

for uploading excel file use following FM

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = p_pfile
      i_begin_col             = 1
      i_begin_row             = 2
      i_end_col               = 45
      i_end_row               = 8
    TABLES
      intern                  = it_excel
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.
  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.                               " IF sy-subrc <> 0

*Populate data to internal tables and structructures
  SORT it_excel BY row col.

  LOOP AT it_excel INTO ls_excel.

    CASE ls_excel-col.
      WHEN 1.
        ls_data-doc_type = ls_excel-value.
      WHEN 2.
        ls_data-rec_no = ls_excel-value.
   end case
endloop.

it will solve your problem

thx

twinkal

Read only

Former Member
0 Likes
757

Hi,

YOu can use this code.

&----


*& Report ZSD_EXCEL_INT_APP

*&

&----


*&

*&

&----


REPORT ZSD_EXCEL_INT_APP.

parameter: file_nm type localfile.

types : begin of it_tab1,

f1(20),

f2(40),

f3(20),

end of it_tab1.

data : it_tab type table of ALSMEX_TABLINE with header line,

file type rlgrap-filename.

data : it_tab2 type it_tab1 occurs 1,

wa_tab2 type it_tab1,

w_message(100) TYPE c.

at selection-screen on value-request for file_nm.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

u2022 PROGRAM_NAME = SYST-REPID

u2022 DYNPRO_NUMBER = SYST-DYNNR

u2022 FIELD_NAME = ' '

STATIC = 'X'

u2022 MASK = ' '

CHANGING

file_name = file_nm

EXCEPTIONS

MASK_TOO_LONG = 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.

start-of-selection.

refresh it_tab2[].clear wa_tab2.

file = file_nm.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = file

i_begin_col = '1'

i_begin_row = '1'

i_end_col = '10'

i_end_row = '35'

tables

intern = it_tab

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3

.

IF sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at it_tab.

case it_tab-col.

when '002'.

wa_tab2-f1 = it_tab-value.

when '004'.

wa_tab2-f2 = it_tab-value.

when '008'.

wa_tab2-f3 = it_tab-value.

endcase.

at end of row.

append wa_tab2 to it_tab2.

clear wa_tab2.

endat.

endloop.

data : p_file TYPE rlgrap-filename value 'TEST3.txt'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

u2022

o

ï‚§

ï‚§ Display error messages if any.

IF sy-subrc NE 0.

MESSAGE e001(zsd_mes).

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT it_tab2 INTO wa_tab2.

TRANSFER wa_tab2 TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

loop at it_tab2 into wa_tab2.

write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.

endloop.

Thanks

Sarada