Application Development 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: 

Upload file from PC

Former Member
0 Kudos

Hi

I have to upload a file from PC and in my selection screen i have declared like this


PARAMETERS       : P_FN TYPE RLGRAP-FILENAME.

But i am not getting the F4 help for this field until or unless with out the F4 help i can not choose the file which is in the system.

Can any one help me out how to get the F4 help.

Thanks

JAJ

1 ACCEPTED SOLUTION

Former Member
0 Kudos
PARAMETERS:gv_f_pc  TYPE rlgrap-filename.
DATA:FILENAME TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gv_f_pc .
*--- search help to select file from pc
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      STATIC        = 'X'
    CHANGING
      file_name     = gv_f_pc
    EXCEPTIONS
      mask_too_long = 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.

START-OF-SELECTION.

  FILENAME = gv_f_pc.

CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = filename
          FILETYPE                = 'ASC'
        TABLES
          DATA_TAB                = GT_DATA
        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
          OTHERS                  = 17.

      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDIF.
3 REPLIES 3

former_member181995
Active Contributor
0 Kudos

Fm:

F4_Filename

Former Member
0 Kudos
PARAMETERS:gv_f_pc  TYPE rlgrap-filename.
DATA:FILENAME TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gv_f_pc .
*--- search help to select file from pc
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      STATIC        = 'X'
    CHANGING
      file_name     = gv_f_pc
    EXCEPTIONS
      mask_too_long = 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.

START-OF-SELECTION.

  FILENAME = gv_f_pc.

CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = filename
          FILETYPE                = 'ASC'
        TABLES
          DATA_TAB                = GT_DATA
        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
          OTHERS                  = 17.

      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDIF.

Former Member
0 Kudos

chk dis code.

data: l_p_file type string, "for setting default file name

l_p_path type string.

l_p_file = 'file'.

**-- Calling function module for F4 help in pathname on selection screen

call method cl_gui_frontend_services=>file_save_dialog

exporting

default_file_name = l_p_file

changing

filename = l_p_path

path = l_p_path

fullpath = l_p_file

exceptions

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.