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

Load file from Cliente PC or SAP Server

Former Member
0 Likes
889

Hi everyone! I'm trying to load a file from a local path of pc or from a path server, it depends on the values of a radiobutton. The code is next:

PARAMETERS: p_file TYPE localfile,
            p_rad1 RADIOBUTTON GROUP rad,
            p_rad2 RADIOBUTTON GROUP rad.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.


  CASE 'X'.
    WHEN p_rad1.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = ' '
        IMPORTING
          file_name     = p_file.
    WHEN p_rad2.
      CALL FUNCTION 'F4_FILENAME_SERVER'
        EXPORTING
          pfad              = '/usr/sap/trans/'
        IMPORTING
          file_name         = p_file
        EXCEPTIONS
          no_file_on_server = 1
          OTHERS            = 2.
  ENDCASE.

The problem is when i try to search the file with the help request option it doesn't show anything, and i don't know what is the error in the code, i'd be thankfull if you could heling me. Thanks!!

Hi everyone! I'm trying to load a file from a local path of pc or from a path server, it depends on the values of a radiobutton. The code is next:

PARAMETERS: p_file TYPE localfile,
            p_rad1 RADIOBUTTON GROUP rad,
            p_rad2 RADIOBUTTON GROUP rad.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.


  CASE 'X'.
    WHEN p_rad1.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = ' '
        IMPORTING
          file_name     = p_file.
    WHEN p_rad2.
      CALL FUNCTION 'F4_FILENAME_SERVER'
        EXPORTING
          pfad              = '/usr/sap/trans/'
        IMPORTING
          file_name         = p_file
        EXCEPTIONS
          no_file_on_server = 1
          OTHERS            = 2.
  ENDCASE.

The problem is when i try to search the file with the help request option it doesn't show anything, and i don't know what is the error in the code, i'd be thankfull if you could heling me. Thanks!!

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
822

And what if you use:

          program_name  = sy-repid
          dynpro_number = sy-dynnr
          field_name    = 'P_FILE'

? (ps: SY and SYST are equivalent)

Please debug too, to make sure what are the values of the variables. Do you see if P_RAD1 and P_RAD2 are filled correctly based on the checkbox you tick?

Read only

RaymondGiuseppi
Active Contributor
0 Likes
822

You didn't define a default radiobutton, so both are initial, and one will only be set to 'X' after PAI (AT SELECTION-SCREEN) but if you press F4 immediately, you won't call any of the F4 FM. You should also set a dummy function code on the radiobutton group to insure PAI is executed before F4 when user change location of file.

NB: F4_FILENAME is an unreleased FM that call obsolete FM WS_FILENAME_GET, so better use method CL_GUI_FRONTEND_SERVICES=> FILE_OPEN_DIALOG or FILE_SAVE_DIALOG.