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
838

Guys,

I want upload the excel sheet data to internal table.

i want to use GUI_UPLOAD. If any one having simple program on this please help .

regards,

vijay

8 REPLIES 8
Read only

Former Member
0 Likes
795

&----


*& Report ZSACH_BDC2 *

*& *

&----


*& *

*& *

&----


report zsach_bdc2

no standard page heading line-size 255.

data: begin of itab1 occurs 0,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

mtart type mara-mtart,

maktx type makt-maktx,

meins type mara-meins,

end of itab1.

data : wa_ctu_params type ctu_params.

data : t_bdcdata like bdcdata occurs 6 with header line.

start-of-selection.

perform get_file.

perform call_transaction.

perform fill_t_bdcdata.

form get_file.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\BDC1.TXT'

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = itab1

  • 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.

endform.

form call_transaction.

clear wa_ctu_params.

wa_ctu_params-dismode = 'A'.

wa_ctu_params-updmode = 'S'.

wa_ctu_params-defsize = 'X'.

endform.

form fill_bdc_entry using

val1

val2

val3.

clear t_bdcdata.

if val3 = 'X'.

move val1 to t_bdcdata-program.

move val2 to t_bdcdata-dynpro.

move val3 to t_bdcdata-dynbegin.

else.

move val1 to t_bdcdata-fnam.

move val2 to t_bdcdata-fval.

endif.

append t_bdcdata.

clear t_bdcdata.

endform.

form fill_t_bdcdata.

loop at itab1.

refresh t_bdcdata.

perform fill_bdc_entry using :

'SAPLMGMM' '0060' 'X',

'RMMG1-MATNR' itab1-matnr ' ',

'RMMG1-MBRSH' itab1-mbrsh ' ',

'RMMG1-MTART' itab1-mtart ' ',

'BDC_OKCODE' '=ENTR' ' '.

perform fill_bdc_entry using :

'SAPLMGMM' '0070' 'X',

'BDC_OKCODE' '=ENTR' ' ',

'MSICHTAUSW-KZSEL(01)' 'X' ' '.

perform fill_bdc_entry using :

'SAPLMGMM' '4004' 'X',

'BDC_OKCODE' '=BU' ' ',

'MAKT-MAKTX' itab1-maktx ' ',

'MARA-MEINS' itab1-meins ' '.

call transaction 'MM01' using t_bdcdata options from wa_ctu_params

messages into itab1.

endloop.

endform. " fill_t_bdcdata

Read only

Former Member
0 Likes
795

you cant use GUI_UPLOAD to upload a XLS file to the program.either you have to convert to txt and then use GUI_UPLOAD or use the below function module to upload XLS file directly to your program.

use the function module, <b>TEXT_CONVERT_XLS_TO_SAP</b>.

here is the link about it.

http://www.sapdevelopment.co.uk/file/file_upexcel.htm

http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm

http://www.sapdevelopment.co.uk/file/file_upexcelalt2.htm

Regards

Srikanth

Message was edited by: Srikanth Kidambi

Read only

0 Likes
795
types: begin of ttab,
       rec(1000) type c,
       end of ttab.
 
types: begin of tdat,
       fld1(10) type c,
       fld2(10) type c,
       fld3(10) type c,
       end of tdat.
 
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
 
data: file_str type string.
 
parameters: p_file type localfile.
 
at selection-screen on value-request for p_file.
  call function 'KD_GET_FILENAME_ON_F4'
       exporting
            static    = 'X'
       changing
            file_name = p_file.
 
start-of-selection.
 
  file_str = p_file.
 
  call function 'GUI_UPLOAD'
       exporting
            filename                = file_str
       tables
            data_tab                = itab
       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.
 
 
delete itab index 1.
 
  loop at itab.
    clear idat.
    split itab-rec at cl_abap_char_utilities=>horizontal_tab
                          into idat-fld1
                               idat-fld2
                               idat-fld3.
    append idat.
 
  endloop.
 
 
  loop at idat.
    write:/ idat-fld1, idat-fld2, idat-fld3.
  endloop.
Read only

dani_mn
Active Contributor
0 Likes
795

<b>

report ZTEST2.

data: file_path type string.

data: itab type standard table of t001.

start-of-selection.

file_path = 'C:FILE.XLS'.

  call method cl_gui_frontend_services=>gui_upload

    exporting    filename                = file_Path

    changing    data_tab                = itab.

</b>

Regards,

Read only

Former Member
0 Likes
795

HI,

REPORT ZXXX.

tables: lfa1.

&----


*int table declaration

&----


data: begin of it_lfa1 occurs 0,

vendor like lfa1-lifnr,

land1 like lfa1-land1,

name1 like lfa1-name1,

ort01 like lfa1-ort01,

end of it_lfa1.

&----


*selection screen

&----


selection-screen: begin of block b1 with frame title text-001.

parameters: p_file type rlgrap-filename default 'C:/Customer.txt'

obligatory.

selection-screen: end of block b1.

&----


*at selection screen

&----


at selection-screen on value-request for p_file.

perform file_help using p_file.

&----


*start-of-selection

&----


start-of-selection.

perform upload_file using p_file.

&----


*end of selection

&----


end-of-selection.

perform write_data.

&----


*& Form file_help

&----


  • text

----


  • -->P_P_FILE text

----


form file_help using p_p_file.

data: l_filepath type ibipparms-path.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = l_filepath

.

p_p_file = l_filepath.

endform. " file_help

&----


*& Form upload_file

&----


  • text

----


  • -->P_P_FILE text

----


form upload_file using p_p_file.

W_FILENAME = P_FILE.

W_FILETYPE = 'DAT'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = W_FILENAME

FILETYPE = W_FILETYPE

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = 'X'

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_LFA1

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 I000(ZZ) WITH 'UNABLE TO UPLOAD'.

ENDIF.

endform. " upload_file

&----


*& Form write_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form write_data .

loop at it_lfa1.

write:/ it_lfa1-vendor,

it_lfa1-land1,

it_lfa1-name1,

it_lfa1-ort01.

endloop.

endform. " write_data

hope this helps,

do reward if it helps,

priya.

Read only

baskaran00
Active Participant
0 Likes
795

Hi Vijay,

Try with the foll. code to upload the file into the Internal table.

DATA : itab like TABLE OF ZMara WITH header line.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Material.xls'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = '#'

TABLES

DATA_TAB = itab.

Regards,

Router

Read only

Former Member
0 Likes
795

HI.

First convert your XLS file to TXT file and then use FM GUI_UPLOAD.

Read only

Former Member
0 Likes
795

Hi

good

call this fm

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = rlgrap-filename

i_begin_col = '1'

i_begin_row = '2'

i_end_col = '22'

i_end_row = '1000'

TABLES

intern = it_upload

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.

reward points if it is helpful,

thanks,

sap-abap.