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.



SAP ABAP: Ayuda para busqueda de archivos

Cada vez que trabajamos en una interfaz usando archivos planos, archivos de excel, o pdf's siempre tenemos que lidiar con el nombre del archivo de parámetros para proporcionar una ruta de almacenamiento o lectura al usuario para procesar los archivos.

Aquí hay un práctico módulo de funciones que muestra el directorio local o del servidor según la ubicación que especifiquemos.



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" para el servidor de aplicaciones, "P" para el servidor de presentación.

Dentro de este módulo de función, se invocan el método cl_gui_frontend_services => file_open_dialog y el módulo de funciones F4_DXFILENAME, que son los que se usan comúnmente cuando trabajamos con sistemas de archivos.


Esta publicación es cortesía de Carlos Castro.

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...