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

problem with ws_upload

Former Member
0 Likes
1,786

Hi Experts,

Kindly help me redg this:

I have used ws_upload function module in my program, Im getting the following error:

Upload/Ws_Upload and Download/Ws_Download are obsolete, since they are not

Unicode-enabled; use the class cl_gui_frontend_services.

Please help me to fix this.... very urgent...

Points are sure for helpful answers....

Regards,

Radhika.D

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,387

Hi

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

11 REPLIES 11
Read only

amit_khare
Active Contributor
0 Likes
1,387

Use GUI_UPLOAD instead of WS_UPLOAD.

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
1,387

Hi Premraj,

Use the Function Module GUI_UPLOAD instead of WS_UPLOAD. this shall solve your problem.

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

Kiran

Read only

Former Member
0 Likes
1,388

Hi

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

Read only

0 Likes
1,387

Hi All,

Im asked to fix this unicode error, i cant change the FM.

Regards,

Radhika. D

Read only

Former Member
0 Likes
1,387

Hi

may be ur vertion not supporting these FM because up to 4.6 ERP vertion they had used this FM

if ur vertion is beyond that use <b>GUI_upload</b> and <b>GUI_downlod</b> to use same functionality

reward if usefull

Read only

former_member404244
Active Contributor
0 Likes
1,387

hi,

U have to change the function module to either GUI_UPLOAD or use cl_gui_frontend_services.

*--Local Variables

DATA: lv_file TYPE string.

  • Local constants

CONSTANTS : lc_type TYPE char10 VALUE 'ASC'. "File type.

*--Call the function to get the file into an internal table.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file

filetype = lc_type

has_field_separator = c_x

TABLES

data_tab = i_upload

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.

Regards,

Nagaraj

Read only

0 Likes
1,387

HI NAGARAJ,

HOW TO USE CL_GUI_FRONTEND_SERVICES

Read only

0 Likes
1,387

Hi

goto pattern and select abap objects radio button and give these both

CL_GUI_FRONTEND_SERVICES class

FILE_OPEN_DIALOG method

reward points to all helpful answers

kiran.M

Read only

0 Likes
1,387

Hi Check the Sample code below.

----


  • Display a dialog box for selecting file name *

  • <-- OV_FILENAME - name of the file selected *

----


form filename_get_upload changing ov_filename type c.

data: lt_filetable type filetable.

data: ls_filetable type file_table.

data: lv_filecount type i.

call method cl_gui_frontend_services=>file_open_dialog

exporting

window_title = 'Select file for upload'

  • DEFAULT_EXTENSION =

  • DEFAULT_FILENAME =

  • FILE_FILTER =

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

changing

file_table = lt_filetable

rc = lv_filecount

  • 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 and lv_filecount > 0.

read table lt_filetable into ls_filetable index 1.

ov_filename = ls_filetable-filename.

endif.

endform. " FILENAME_GET_UPLOAD

form pc_upload changing ov_rc type i.

data: lv_filename type string.

lv_filename = p_infile.

  • Uploading file into internal table

call method cl_gui_frontend_services=>gui_upload

exporting

filename = lv_filename

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = SPACE

  • HEADER_LENGTH = 0

  • DAT_MODE = SPACE

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

read_by_line = 'X'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

changing

data_tab = gt_intab[]

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

not_supported_by_gui = 17

error_no_gui = 18

others = 19.

if sy-subrc <> 0.

ov_rc = sy-subrc.

message e001(z010) with 'File upload failed. Error code:' ov_rc.

exit.

endif.

endform. " PC_UPLOAD

<b>Reward if Helpful</b>

Read only

Former Member
0 Likes
1,387

Hi Premraj,

I have once worked in doing the Unicode fix.

The Unicode fix also involves changing the code.

The WS_UPLOAD is incompatible. So you can go ahead and change it to GUI_UPLOAD to make it unicode compatible. Theres no harm in it and i have done it myself.

Regards,

Yogesh

Read only

Former Member
0 Likes
1,387

Hi,

You need to use GUI_UPLOAD instead of WS_UPLOAD as it is preferrable than CL_GUI_FRONTEND_SERVICES also. And make sure the file name variable should be of <b>Type STRING</b> Otherwise you will get a <b>short Dump.</b>

e.g.:


DATA: v_filenname type string.

CONSTANTS:  c_tab         TYPE  abap_char1
                         VALUE cl_abap_char_utilities=>horizontal_tab.

PARAMETERS: p_file      TYPE rlgrap-filename DEFAULT text-003,

start-of-selection.
v_filename = p_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                =  v_filename
      has_field_separator   = c_tab
    TABLES
      data_tab                = it_invc

Reward points if helpful answer.

Ashvender