Application Development 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: 

Uoload function module

Former Member
0 Kudos

Hi

What should be the file format to upload the data to internal table thru UPLOAD fucntion module. Is it filename.xls or something else.

Regards

Raj

7 REPLIES 7

Former Member
0 Kudos

Hi,

if the fiel is the Excel fiel then the, then use .xls

fiel formats normally ASC or BIN

Regards

Sudheer

0 Kudos

Data can be transferred binarily or as text.

Example

Binary upload: No conversion or interpretation

begin of itab,

raw(255) type x,

end of itab occurs 0.

CALL FUNCTION 'GUI_UPLOAD'

exporting

filetype = 'BIN'

filename = 'C:\DOWNLOAD.BIN'

tables

data_tab = itab.

Text upload

begin of itab,

text(255) type c,

end of itab occurs 0.

CALL FUNCTION 'GUI_UPLOAD'

exporting

filetype = 'ASC'

filename = 'C:\DOWNLOAD.TXT'

tables

data_tab = itab.

Regards,

Sai

former_member196299
Active Contributor
0 Kudos

UPLOAD Function module is obsolete now u can use GUI_UPLOAD for the same purpose and filename.txt format . even filename.xls can also be used.

Regards,

Ranjita

Former Member
0 Kudos

Hi raja,

your flat file can be a .txt file or .xls file, but accordingly you shall be modifying the parameter in you GUI_UPLOAD function module.

the important thing is to have the same order of data supporting the order of fields in the internal table.

<b>Reward points if this helps,</b>

Kiran

varma_narayana
Active Contributor
0 Kudos

Hi...

The File Type can be .TXT(NOTEPAD) or .XLS(EXCEL)

Eg:

report yrp00_22 .

types: begin of vendor,

lifnr type rf02k-lifnr, "Vendor no

ktokk type rf02k-ktokk, "Acc group

name1 type lfa1-name1,

sortl type lfa1-sortl,

ort01 type lfa1-ort01,

pstlz type lfa1-pstlz,

land1 type lfa1-land1,

spras type lfa1-spras,

end of vendor.

data : itab type table of vendor ,

wa type vendor.

data : v_file type string,

v_message type string.

parameters : p_file(30) default 'c:\VENDOR1.xls' .

start-of-selection.

move p_file to v_file.

call function 'GUI_UPLOAD'

exporting

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

tables

data_tab = itab.

<b>Reward if Helpful</b>

Former Member
0 Kudos

here check this program i am spliting the record depend upon ',' and dont use ws_upload etc fm's are obsolete....

data: begin of itab_string occurs 0,

record type char255,

end of itab_string.

data: L_FILETABLE TYPE FILETABLE,

L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.

data: p_file1 type string.

  • selection screen .

PARAMETERS: P_FILE TYPE LOCALFILE.

initialization.

at selection-screen on value-request for P_FILE.

  • IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

  • EXPORTING

  • WINDOW_TITLE =

  • DEFAULT_EXTENSION = 'CSV'

  • DEFAULT_FILENAME = 'C:\Documents and Settings\196093\Desktop\STATUS.csv'

  • FILE_FILTER =

  • INITIAL_DIRECTORY = 'C:\Documents and Settings\196093\Desktop\'

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

FILE_TABLE = L_FILETABLE

RC = RC

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5

.

IF SY-SUBRC <> 0.

ELSE.

LOOP AT l_filetable INTO L_FILETAB_H.

P_FILE = L_FILETAB_H-FILENAME.

move p_file to p_file1.

EXIT.

ENDLOOP.

ENDIF.

  • passing the selected file name to gui_upload for loading the data

  • into internal table

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = p_file1

  • FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = itab_string

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(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.

ENDIF.

loop at itab_string.

  • now split the statuses

split itab_string at ',' into itab_status-aufnr itab_status-asttx itab_status-asttx1.

  • and move one internal table

append itab_status.

clear itab_status.

endloop.

reward points to all helpful answers

kiran.M

Former Member
0 Kudos

hi raja

ya it should be .xls format only........

REWARD IF USEFULL....