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

F4 for the file path

Former Member
0 Likes
1,134

Hello Everybody,

Can someone tell me how to do the F4 for the file which is to be loaded from the presentation server,like v have for UPLOAD Function Module.

I have a Parameter for the file path in the selection,I want to know how do v take the file path by searching thru F4??

Thanks,

Anushka.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
981

Hi Anushka,

refer sample code:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : rb_pc RADIOBUTTON GROUP r1 DEFAULT 'X'

USER-COMMAND ucomm, "For Presen

p_f1 LIKE rlgrap-filename

MODIF ID rb1, "Input File

rb_srv RADIOBUTTON GROUP r1,

"For Application

p_f2 LIKE rlgrap-filename

MODIF ID rb2,

"Input File

p_direct TYPE char128 MODIF ID abc DEFAULT c_path

.

"File Directory

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-020.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f1.

*-- Browse Presentation Server

PERFORM f1000_browse_presentation_file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f2.

*-- Browse Application Server

PERFORM f1001_browse_appl_file.

*&----


*& Form f1000_browse_presentation_file

*&----


  • Pick up the file path in the presentation server

*&----


FORM f1000_browse_presentation_file .

CONSTANTS: lcl_path TYPE char20 VALUE 'C:\'.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_path = lcl_path

mask = c_mask "',.,..'

mode = c_mode

title = text-006

IMPORTING

filename = p_f1

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

flg_pre = c_x.

ENDIF.

ENDFORM. " f1000_browse_presentation_file

*&----


*& Form f1001_browse_appl_file

*&----


  • Pick up the file path in the application server

*&----


FORM f1001_browse_appl_file .

DATA: lcl_directory TYPE char128.

lcl_directory = p_direct.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = lcl_directory

filemask = c_mask

IMPORTING

serverfile = p_f2

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE e000(zmm) WITH text-039.

  • flg_app = 'X'.

ENDIF.

ENDFORM. " f1001_browse_appl_file

Reward points if this Helps.

Manish

6 REPLIES 6
Read only

Former Member
0 Likes
982

Hi Anushka,

refer sample code:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : rb_pc RADIOBUTTON GROUP r1 DEFAULT 'X'

USER-COMMAND ucomm, "For Presen

p_f1 LIKE rlgrap-filename

MODIF ID rb1, "Input File

rb_srv RADIOBUTTON GROUP r1,

"For Application

p_f2 LIKE rlgrap-filename

MODIF ID rb2,

"Input File

p_direct TYPE char128 MODIF ID abc DEFAULT c_path

.

"File Directory

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-020.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f1.

*-- Browse Presentation Server

PERFORM f1000_browse_presentation_file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f2.

*-- Browse Application Server

PERFORM f1001_browse_appl_file.

*&----


*& Form f1000_browse_presentation_file

*&----


  • Pick up the file path in the presentation server

*&----


FORM f1000_browse_presentation_file .

CONSTANTS: lcl_path TYPE char20 VALUE 'C:\'.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_path = lcl_path

mask = c_mask "',.,..'

mode = c_mode

title = text-006

IMPORTING

filename = p_f1

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

flg_pre = c_x.

ENDIF.

ENDFORM. " f1000_browse_presentation_file

*&----


*& Form f1001_browse_appl_file

*&----


  • Pick up the file path in the application server

*&----


FORM f1001_browse_appl_file .

DATA: lcl_directory TYPE char128.

lcl_directory = p_direct.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

directory = lcl_directory

filemask = c_mask

IMPORTING

serverfile = p_f2

EXCEPTIONS

canceled_by_user = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE e000(zmm) WITH text-039.

  • flg_app = 'X'.

ENDIF.

ENDFORM. " f1001_browse_appl_file

Reward points if this Helps.

Manish

Read only

Former Member
0 Likes
981

Use the function module.

F4_FILENAME.

points would help

Read only

Former Member
0 Likes
981

HI,Use the function module <b>KD_GET_FILENAME_ON_F4</b>

In the event AT SELECTION-SCREEN on FIELD FILED_NAME

call the Function moduel

Regards

Sudheer

Read only

Former Member
0 Likes
981

For Application server files, you can use

F4_DXFILENAME_TOPRECURSION

For Presentation server files, you can use

F4_FILENAME

REgards,

Ravi

Read only

0 Likes
981

If you want to use class/methods, here is an example.




report zrich_0001.

data: ifiletable type filetable.
data: xfiletable like line of ifiletable.
data: rc type i.

parameters: p_file1 type localfile default'C:test.txt'.

at selection-screen on value-request for p_file1.

call method cl_gui_frontend_services=>file_open_dialog
   EXPORTING
*    WINDOW_TITLE            =
*    DEFAULT_EXTENSION       =
*    DEFAULT_FILENAME        =
*    FILE_FILTER             =
     INITIAL_DIRECTORY       = 'C:'
*    MULTISELECTION          =
  changing
    file_table              = ifiletable
    rc                      = rc
*    USER_ACTION             =
  EXCEPTIONS
    FILE_OPEN_DIALOG_FAILED = 1
    CNTL_ERROR              = 2
    ERROR_NO_GUI            = 3
    others                  = 4.
        .
 read table ifiletable into xfiletable index 1.
 if sy-subrc = 0.
  p_file1 = xfiletable-FILENAME.
 endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
981

Hai

Check the following Code for F4 for Files

DATA: I_FILETABLE TYPE FILETABLE,

V_RC TYPE I.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. "local file with contracts

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

WINDOW_TITLE = 'Find File'

DEFAULT_EXTENSION = 'C:\'

DEFAULT_FILENAME = ''

FILE_FILTER = ',..'

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

FILE_TABLE = I_FILETABLE

RC = V_RC

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE I_FILETABLE INTO P_FILE INDEX 1.

Regards

Sreeni