miércoles, noviembre 04, 2009

FICHEROS - Listar ficheros de directorio local y del servidor SAP

Transacciones para trabajar con fichero del servidor SAP AL11, N2UX, CG3Y y CG3Z.

*****
PARAMETER: p_fdir TYPE pfeflnamel DEFAULT
*'/usr/sap/tmp'.
'C:\pruebas\xml'.
PARAMETER: p_local AS CHECKBOX DEFAULT 'X'.

DATA: BEGIN OF it_filedir OCCURS 10.
INCLUDE STRUCTURE salfldir.
DATA: END OF it_filedir.

DATA: l_it_file_table TYPE TABLE OF sdokpath WITH HEADER LINE.
DATA: l_it_dir_table TYPE TABLE OF sdokpath.

************************************************************************
START-OF-SELECTION.
************************************************************************

IF p_local EQ 'X'.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
directory = p_fdir
filter = '*.XML'
* IMPORTING
* FILE_COUNT =
* DIR_COUNT =
TABLES
file_table = l_it_file_table
dir_table = l_it_dir_table
EXCEPTIONS
cntl_error = 1
OTHERS = 2.

LOOP AT l_it_file_table.
WRITE: / l_it_file_table-pathname.
ENDLOOP.

ELSE.
* Get Current Directory Listing for OUT Dir
* OJO al probar el MF directamente en la SE37 (convierte a mayúsculas).
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
name = p_fdir
TABLES
file_tbl = it_filedir.

* List of files are contained within table it_filedir
LOOP AT it_filedir.
WRITE: / it_filedir-name.
ENDLOOP.
ENDIF.