Wednesday, October 18, 2017

SAP ABAP: Search help for file name

Every time we work on an interface using flat files, excel files, pdf's always we have to deal with the parameter file name in order to provide a storage or reading path to the user in order to process the files.

Here a handy function module that shows the local or server directory depending on the location we specify.

datal_path       type dxfields-longpath,
      l_o_path       type dxfields-longpath.

l_path ch_path.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
 EXPORTING
    I_LOCATION_FLAG       im_location
*   I_SERVER              =
    I_PATH                l_path
*   FILEMASK              = '*.*'
*   FILEOPERATION         = 'R'
 IMPORTING
*   O_LOCATION_FLAG       =
*   O_SERVER              =
    O_PATH                l_o_path
    ABEND_FLAG            ex_abend_flag
 EXCEPTIONS
   RFC_ERROR             1
   OTHERS                2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ch_path l_o_path.



 I_LOCATION_FLAG "A" for application server, "P" for presentation server.

Inside this function module, the method cl_gui_frontend_services-file_open_dialog and the function module F4_DXFILENAME are called, which are the ones used commonly when we work with file systems.


This post is a courtesy from Carlos Castro.



No comments:

Post a Comment

Python - borrar lineas extra de archivos .txt en un directorio

 Aqui el codigo Python para borrar lineas extra en un archivo plano: import os path = "c:\\temp" path_new='c:\\temp\\CleanFile...