Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

variable path for up/downloading file

former_member182371
Active Contributor
0 Likes
1,965

Hi,

i´ve developed a report that reads a file from a folder (input folder), then processes the data and finally deletes this file (from input folder) and downloads it to a new folder (output folder).

If user decides to use a new path for up/download how can i control this new situation? via a table storing different paths?

Any suggestion will be welcomed.

Best regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,404

Hi,

Have a parameter for the 'file path' in the selection screen of the report and provide f4 help for that field, if the user changes the value by choosing f4 option, the changed value will be available in the parameter field, that can be passed to the function module used to download the file.

Rgds,

Hi,

Have a parameter for the 'file path' in the selection screen of the report and provide f4 help for that field, if the user changes the value by choosing f4 option, the changed value will be available in the parameter field, that can be passed to the function module used to download the file.

Rgds,

4 REPLIES 4
Read only

Former Member
0 Likes
1,405

Hi,

Have a parameter for the 'file path' in the selection screen of the report and provide f4 help for that field, if the user changes the value by choosing f4 option, the changed value will be available in the parameter field, that can be passed to the function module used to download the file.

Rgds,

Read only

0 Likes
1,404

Hi everyone,

you're right, I've faced this issue several times before, and this is how I achieved it:


* Selection-screen
PARAMETERS: p_fileup LIKE rlgrap-filename OBLIGATORY,
            p_filedn LIKE rlgrap-filename OBLIGATORY.

* Events
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fileup.
  PERFORM f4_fichero USING p_fileup.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filedn.
  PERFORM f4_fichero USING p_filedn.

* Main program
START-OF-SELECTION.
  PERFORM carga_fichero.
*... further processing
  PERFORM descarga_fichero_errores.

* Routines
*&---------------------------------------------------------------------*
*&      Form  f4_fichero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->_FILE  text
*----------------------------------------------------------------------*
FORM f4_fichero USING _file.
*
  DATA: l_subrc TYPE n.

  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
*   EXPORTING
*     PROGRAM_NAME        = sy-cprog
*     DYNPRO_NUMBER       = sy-dynnr
*     FIELD_NAME          = ' '
*     STATIC              = ' '
*     MASK                = ' '
    CHANGING
      file_name           = _file
    EXCEPTIONS
      mask_too_long       = 1
      error_message       = 2
      OTHERS              = 3.

  IF sy-subrc <> 0.
    l_subrc = sy-subrc.

    MESSAGE e000(zf)
      WITH 'Error en función'(200)
           'KD_GET_FILENAME_ON_F4'
           'SY-SUBRC:'(201)
           l_subrc.
  ENDIF.
*
ENDFORM.                    " f4_fichero

*&---------------------------------------------------------------------*
*&      Form  carga_fichero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM carga_fichero.
*
  DATA: l_subrc TYPE n.
  DATA: l_filename TYPE string.

  l_filename = p_fileup.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                      = l_filename
      filetype                      = 'ASC'
      has_field_separator           = c_yes
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      data_tab                      = t_fichero
    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
      error_message                 = 17
      OTHERS                        = 18.

  IF sy-subrc <> 0.
    l_subrc = sy-subrc.

    MESSAGE e000(zf)
      WITH 'Error en función'(200)
           'GUI_UPLOAD'
           'SY-SUBRC:'(201)
           l_subrc.
  ENDIF.
*
ENDFORM.                    " carga_fichero

*&---------------------------------------------------------------------*
*&      Form  descarga_fichero_errores
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM descarga_fichero_errores.
*
  DATA: l_subrc TYPE n.
  DATA: l_filename TYPE string.
  DATA: lt_fichero LIKE e_fichero_entrada OCCURS 200 WITH HEADER LINE.

  l_filename = p_filedn.

  LOOP AT t_fichero WHERE NOT xerror IS initial.
    CLEAR: lt_fichero.
    MOVE-CORRESPONDING t_fichero TO lt_fichero.
    APPEND lt_fichero.
  ENDLOOP.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*     BIN_FILESIZE                  =
      filename                      = l_filename
      filetype                      = 'ASC'
*     APPEND                        = ' '
      write_field_separator         = c_yes
*     HEADER                        = '00'
*     TRUNC_TRAILING_BLANKS         = ' '
*     WRITE_LF                      = 'X'
*     COL_SELECT                    = ' '
*     COL_SELECT_MASK               = ' '
*   IMPORTING
*     FILELENGTH                    =
    TABLES
      data_tab                      = lt_fichero
    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
      error_message                 = 22
      OTHERS                        = 23.

  IF sy-subrc <> 0.
    l_subrc = sy-subrc.

    MESSAGE e000(zf)
      WITH 'Error en función'(200)
           'GUI_DOWNLOAD'
           'SY-SUBRC:'(201)
           l_subrc.
  ENDIF.
*
ENDFORM.                    " descarga_fichero_errores

The thing is, I ask for 2 paths: input file and error in output file. Then I code some f4* routines. Then I upload the input file (f4_carga_fichero), do the processing, and finally I loop at the records with error and download these records via form descarga_fichero_errores.

I hope it helps. BR,

Alvaro

PS: Pablo->Forza Atleti!

Read only

former_member182371
Active Contributor
0 Likes
1,404

Hi,

what i´m trying to control is to avoid modifying the program when the up/download path changes.

The user would rather prefer modifying an entry in a table and not the program.

Best regards.

Read only

former_member182371
Active Contributor
0 Likes
1,404

Hi,

thanks Alvaro you´re always a great help.

Best regards