2008 May 22 4:44 PM
Hi there,
Would I be right in saying that CALL METHOD cl_gui_frontend_services can only be used while the program is running on the presentation server (i.e. in Forground)
we have a problem where a program is crashing because its using this method but we are running the program on the Application servers (i.e. in Backgrouand)
Is there an alternative . . . . we have to run this in background, by the way I'm picking up the files on a network directory
Thanks.
i.e.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = p_path
filter = p_file
files_only = 'X'
CHANGING
file_table = t_filetab
count = return
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.
Hi there,
Would I be right in saying that CALL METHOD cl_gui_frontend_services can only be used while the program is running on the presentation server (i.e. in Forground)
we have a problem where a program is crashing because its using this method but we are running the program on the Application servers (i.e. in Backgrouand)
Is there an alternative . . . . we have to run this in background, by the way I'm picking up the files on a network directory
Thanks.
i.e.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = p_path
filter = p_file
files_only = 'X'
CHANGING
file_table = t_filetab
count = return
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.
2008 May 22 5:10 PM
Maybe this can help you
FORM get_directory_list TABLES file_list STRUCTURE rsfillst
USING dirname
filenm
pattern.
DATA: sap_yes(1) VALUE 'X',
sap_no(1) VALUE ' '.
DATA: no_cs VALUE ' '.
*DATA FILE like FILE_LIST.
DATA: BEGIN OF file,
dirname(75) TYPE c, " name of directory. (possibly truncated.)
name(75) TYPE c, " name of entry. (possibly truncated.)
type(10) TYPE c, " type of entry.
len(8) TYPE p, " length in bytes.
owner(8) TYPE c, " owner of the entry.
mtime(6) TYPE p, " last modification date, seconds since 1970
fmode(9) TYPE c, " like "rwx-r-x--x": protection mode.
useable(1) TYPE c,
subrc(4) TYPE c,
errno(3) TYPE c,
errmsg(40) TYPE c,
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
seen(1) TYPE c,
changed(1) TYPE c,
END OF file.
DATA: errcnt(2) TYPE p VALUE 0.
*DATA : l_ref(17),
* l_resto(13),
* l_cant_pos TYPE i.
CALL 'C_DIR_READ_FINISH' " just to be sure
ID 'ERRNO' FIELD file_list-errno
ID 'ERRMSG' FIELD file_list-errmsg.
CALL 'C_DIR_READ_START' ID 'DIR' FIELD dirname
ID 'FILE' FIELD filenm
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
IF sy-subrc <> 0.
RAISE access_error.
ENDIF.
DO.
CLEAR file.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD file-type
ID 'NAME' FIELD file-name
ID 'LEN' FIELD file-len
ID 'OWNER' FIELD file-owner
ID 'MTIME' FIELD file-mtime
ID 'MODE' FIELD file-fmode
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
file-dirname = dirname.
MOVE sy-subrc TO file-subrc.
CASE sy-subrc.
WHEN 0.
CLEAR: file-errno, file-errmsg.
CASE file-type(1).
WHEN 'F'. " normal file.
WHEN 'f'. " normal file.
WHEN OTHERS. " directory, device, fifo, socket,...
MOVE sap_no TO file-useable.
ENDCASE.
IF file-len = 0.
MOVE sap_no TO file-useable.
ENDIF.
WHEN 1.
EXIT.
WHEN OTHERS. " SY-SUBRC >= 2
ADD 1 TO errcnt.
IF errcnt > 10.
EXIT.
ENDIF.
IF sy-subrc = 5.
MOVE: '???' TO file-type,
'???' TO file-owner,
'???' TO file-fmode.
ELSE.
ENDIF.
MOVE sap_no TO file-useable.
ENDCASE.
* * Does the filename contains the requested pattern?
* * Then store it, else forget it.
IF pattern = no_cs.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ELSE.
IF file-name CP pattern.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ENDIF.
* IF file-name(29) CP pattern(29).
* CLEAR : l_ref, l_resto, l_cant_pos.
*
* SPLIT file-name+29 AT '-' INTO l_ref l_resto.
* l_cant_pos = strlen( l_ref ).
* IF l_resto CP pattern+46 AND l_cant_pos BETWEEN 1 AND 16.
* MOVE-CORRESPONDING file TO file_list.
* APPEND file_list.
* ENDIF.
* ENDIF.
ENDIF.
ENDDO.
CALL 'C_DIR_READ_FINISH'
ID 'ERRNO' FIELD file_list-errno
ID 'ERRMSG' FIELD file_list-errmsg.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
2008 May 22 5:10 PM
Your understanding is very much correct. The class is for foreground opertaions. If you wana use for background task then you have to have all your resources in background. So your network file path has to be mapped in the application server.
Contact your basis team to create the mapping in the app server for the network drive path. If your app server is running on different OS then you would need to FTP the file into the server or use some auto file pooling software to put the file in right directory.
Us the OPEN DATASET and READ DATASET and CLOSE DATASET to process the file contents.
Hope this helps.
Fra
reward if resolved.