Some of the Common Errors in UCCHECK and their resolution

Case – 1:

Error : Upload/Ws_Upload and Download/Ws_Download are obsolete, since they are not Unicode-enabled; use the class cl_gui_frontend_services

Cause : From Version ECC6.0 (Unicode complaint environment), the Function Mod-ules UPLOAD / WS_UPLOAD / DOWNLOAD / WS_DOWNLOAD has become obso-lete. In replacement of these Function Modules, we have GUI_UPLOAD / GUI_DOWNLOAD.

Solution: All the UPLOAD / WS_UPLOAD function modules need to be replaced with GUI_UPLOAD FM and all the DOWNLOAD / WS_DOWNLOAD with the GUI_DOWNLOAD function modules.

For replacing WS_UPLOAD :

1
* call function ‘WS_UPLOAD’
* exporting
* filename = p_filel
* filetype = ‘DAT’ “‘ASC’ “‘DAT’
* tables
* data_tab = record
* exceptions
* conversion_error = 1
* file_open_error = 2
* file_read_error = 3
* invalid_type = 4
* no_batch = 5
* unknown_error = 6
* invalid_table_width = 7
* gui_refuse_filetransfer = 8
* customer_error = 9
* others = 10.

DATA : L_P_FILEL TYPE STRING.

Clear: L_P_FILEL.
L_P_FILEL = P_FILEL.

CALL FUNCTION ‘GUI_UPLOAD’
EXPORTING
FILENAME = L_P_FILEL
FILETYPE = ‘ASC’
TABLES
DATA_TAB = RECORD
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.

Clear: L_P_FILEL.

*} REPLACE

Note – 1 : The parameter FILENAME in GUI_UPLOAD is of type STRING for version ECC6.0. In 4.6C version (Non Unicode complaint environment), for the above code, ex-port parameter filename in UPLOAD / WS_UPLOAD was of data type “Character”. This need to be taken care of otherwise if an Extended Syntax Check is performed using the transaction SLIN, there would bet a Call Function Interface Error because of this. So to avoid that, one needs to declare a variable L_P_FILEL of type STRING and assign-ing that to the Parameter FILENAME. Also it’s better to have file type ‘ASC’.

For replacing WS_DOWNLOAD:

*{ REPLACE RE2K900049 1
* CALL FUNCTION ‘WS_DOWNLOAD’
* EXPORTING
* FILENAME = W_FILENAME
* FILETYPE = ‘ASC’
* TABLES
* DATA_TAB = TAB_PC2
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TYPE = 4
* NO_BATCH = 5
* UNKNOWN_ERROR = 6
* INVALID_TABLE_WIDTH = 7
* GUI_REFUSE_FILETRANSFER = 8
* CUSTOMER_ERROR = 9
* OTHERS = 10.
*

** Begin of Changes – 46C To ECC6 – IN9AGARWAL
DATA : L_W_FILENAME TYPE STRING.

Clear: L_W_FILENAME.
L_W_FILENAME = W_FILENAME.

CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
FILENAME = L_W_FILENAME
FILETYPE = ‘ASC’
TABLES
DATA_TAB = TAB_PC2
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

For replacing UPLOAD :

PARAMETERS: I_NFILE LIKE RLGRAP-FILENAME DEFAULT
‘c:fidocgen.prn’.

Note : Please make sure that default location is given if its not then dont use default file-name parameter in your Function module.

1
* CALL FUNCTION ‘UPLOAD’
* EXPORTING
* FILENAME = I_NFILE “NOME FILE
* FILETYPE = ‘ASC’
* TABLES
* DATA_TAB = FILIN
* EXCEPTIONS
* CONVERSION_ERROR = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* OTHERS = 6.
*

So we will be using the method ` GUI_UPLOAD` of the class `CL_GUI_FRONTEND_SERVICES`. Now in 4.6, while using FM UPLOAD, a pop-up used to appear, prompting you to get/locate the path of the file. To get the same function-ality in GUI_UPLOAD use code as below-

data: ft type filetable,
rc type i,
l_i_nfile type string,
l_i_nfile_temp type string.

data: l_ft type line of filetable.

clear: l_i_nfile_temp, rc, l_ft, l_i_nfile.
refresh: ft.
l_i_nfile_temp = i_nfile.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = ‘File open’
DEFAULT_FILENAME = l_i_nfile_temp
CHANGING
FILE_TABLE = ft
RC = rc
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5.

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

read table ft into l_ft index 1.

l_i_nfile = l_ft-filename.

CALL FUNCTION ‘GUI_UPLOAD’
EXPORTING
FILENAME = l_i_nfile
FILETYPE = ‘ASC’
TABLES
DATA_TAB = FILIN
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.

clear: l_i_nfile_temp, rc, l_ft, l_i_nfile.
refresh: ft.

For replacing DOWNLOAD :

DOWNLOAD is obsolete function module for storing SAP data in a file in the file sys-tem of the presentation server.
EXAMPLE :

PARAMETERS: PC_FILE LIKE RLGRAP-FILENAME DEFAULT
‘c:test.txt’ modif id LOC.

* CALL FUNCTION ‘DOWNLOAD’
* EXPORTING
* FILENAME = PC_FILE
* FILETYPE = ‘DAT’
* IMPORTING
* FILESIZE = W_FSIZE
* ACT_FILENAME = W_FNAME
* ACT_FILETYPE = W_FTYPE
* TABLES
* DATA_TAB = TAB
* EXCEPTIONS
* CONVERSION_ERROR = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* OTHERS = 6.

So we will be using the method `GUI_DOWNLOAD` of the class `CL_GUI_FRONTEND_SERVICES`. Now in 4.6, while using FM DOWNLOAD, a pop-up used to appear, prompting you to to put the path to save the file. To get the same functionality in GUI_DOWNLOAD use code as below-

data: l_filename type string,
l_path type string,
l_fullpath type string,
l_filename_temp type string.
** End of Changes – 46C To ECC6 – IN9AGARWAL

** Begin of Changes – 46C To ECC6 – IN9AGARWAL
Clear: l_filename, l_path, l_fullpath, l_filename_temp.
l_filename_temp = PC_FILE.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = ‘File save’
DEFAULT_FILE_NAME = l_filename_temp
CHANGING
FILENAME = l_filename
PATH = l_path
FULLPATH = l_fullpath
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
FILENAME = l_filename
FILETYPE = ‘ASC’
TABLES
DATA_TAB = tab
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Leave a comment