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

download to folder path (tricky) .

Former Member
0 Likes
7,039

hi

My requirement: download from al11 to presentation server.

user wants an input field to specify the destination folder where the file should be downloaded.

for e.g. Func Mod F4_FILENAME gets the name of a file, but i only want to specify a folder for eg.

C:\Documents and Settings\userabap\Desktop\

let me be more clear:

i want to have a F4 help on an input field where i can get the above file path by using the help.

hope u got my point.

help will be rewarded.

1 ACCEPTED SOLUTION
Read only

Former Member
3,383
PARAMETERS: 
*           path for log/error files
            P_DIR_LG  TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
*Browse Dialog on Value Request on P_DIR_LG--------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DIR_LG.
  PERFORM SUB_DIRECTORY_SELECT USING P_DIR_LG.

*&---------------------------------------------------------------------*
*&      Form  SUB_DIRECTORY_SELECT
*&---------------------------------------------------------------------*
*     Browse through the Directories and get the user selection
*----------------------------------------------------------------------*
*      -->P_DIR   directory
*----------------------------------------------------------------------*
FORM SUB_DIRECTORY_SELECT  USING    P_DIR TYPE LOCALFILE.

* Local Data

  DATA: L_SEL_DIR     TYPE STRING.


* Browse the Directories
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
*     EXPORTING
*       WINDOW_TITLE        =
*      INITIAL_FOLDER       =
    CHANGING
      SELECTED_FOLDER      = L_SEL_DIR
    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.
  ELSE.
    P_DIR = L_SEL_DIR.
  ENDIF.


ENDFORM.                    " SUB_DIRECTORY_SELECT
9 REPLIES 9
Read only

Former Member
0 Likes
3,383

Hi,

May be you can decide the file name and concatenate the file name with the folder path you choose.

Or you can use C13G0_GET_FILENAME_F4

Hope this solves your purpose.

Award points if it helps.

-Gaurang

Read only

Former Member
3,384
PARAMETERS: 
*           path for log/error files
            P_DIR_LG  TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
*Browse Dialog on Value Request on P_DIR_LG--------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DIR_LG.
  PERFORM SUB_DIRECTORY_SELECT USING P_DIR_LG.

*&---------------------------------------------------------------------*
*&      Form  SUB_DIRECTORY_SELECT
*&---------------------------------------------------------------------*
*     Browse through the Directories and get the user selection
*----------------------------------------------------------------------*
*      -->P_DIR   directory
*----------------------------------------------------------------------*
FORM SUB_DIRECTORY_SELECT  USING    P_DIR TYPE LOCALFILE.

* Local Data

  DATA: L_SEL_DIR     TYPE STRING.


* Browse the Directories
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
*     EXPORTING
*       WINDOW_TITLE        =
*      INITIAL_FOLDER       =
    CHANGING
      SELECTED_FOLDER      = L_SEL_DIR
    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.
  ELSE.
    P_DIR = L_SEL_DIR.
  ENDIF.


ENDFORM.                    " SUB_DIRECTORY_SELECT
Read only

Former Member
0 Likes
3,383

Hi, Please try this. Here give the folder path but not file name, Pass the file name to GUI_Download, This works as F4 help.

Place this at the At selection-screen event:

At selection-screen.
*&---------------------------------------------------------------------*
*&                      Form  get_path
*&---------------------------------------------------------------------*
*                Get The File Path for Download.
*----------------------------------------------------------------------*
FORM get_path.
* Provide F4 Help for Download Path Selection
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
            program_name  = 'ZFIPDRDGCSV'
            dynpro_number = sy-dynnr
            field_name    = p_wsfile
       CHANGING
            file_name     = p_wsfile
       EXCEPTIONS
            mask_too_long = 1
            OTHERS        = 2.
*
  IF sy-subrc <> 0.
    MESSAGE s001(zf) WITH 'Given Path Unsucessful'(010).
  ENDIF.
*
ENDFORM.                    " get_path

call function gui_download.
where filename = p_wsfile

Hope it works.

Thanks.

Reward helpful Answers.

Read only

sharadendu_agrawal
Active Participant
3,383
*----------------------------------------------------------------------*
*                          Selection Screen                            *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01.

SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-b11.

PARAMETERS : p_local  AS   CHECKBOX DEFAULT 'X'        MODIF ID grp,
             p_output LIKE rlgrap-filename OBLIGATORY  MODIF ID grp.
*                                       DEFAULT     c_file. D-RD1K907385

SELECTION-SCREEN END OF BLOCK b11.

SELECTION-SCREEN BEGIN OF BLOCK b12 WITH FRAME TITLE text-b12.

SELECT-OPTIONS : s_paobjn  FOR ykpcat_paobjnr-paobjnr MODIF ID mod,
                 s_type    FOR ykpcat_paobjnr-type    MODIF ID mod.

SELECTION-SCREEN END OF BLOCK b12.


SELECTION-SCREEN END OF BLOCK b01.

SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.

PARAMETERS : p_delws  RADIOBUTTON GROUP rd1 USER-COMMAND flag,
             p_modify RADIOBUTTON GROUP rd1 DEFAULT 'X',
             p_delete RADIOBUTTON GROUP rd1 .

SELECTION-SCREEN END OF BLOCK b02.

*----------------------------------------------------------------------*
*                         AT SELECTION-SCREEN                          *
*----------------------------------------------------------------------*
*--Providing F4 help for the file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_output.
  PERFORM execute_f4help USING 'P_OUTPUT' 'P_LOCAL'.

*---------------------------------------------------------------------*
*                      AT SELECTION SCREEN OUTPUT                    *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.

*--Take the selection from the user
  LOOP AT SCREEN.
    IF screen-group1 = 'GRP'.
      IF NOT p_delws IS INITIAL.
        screen-active = 0.
        screen-invisible = 1.
      ELSE.
        screen-active = 1.
        screen-invisible = 0.
      ENDIF.
    ENDIF.

*--Hide the user selection criteria when Delete With
*--Selection is not selected
    IF screen-group1 = 'MOD'.
      IF p_delws IS INITIAL.
        screen-active = 0.
        screen-invisible = 1.
      ELSE.
        screen-active = 1.
        screen-invisible = 0.
      ENDIF.
    ENDIF.

    MODIFY SCREEN.

  ENDLOOP.

*&--------------------------------------------------------------------*
*&      Form  execute_f4help
*&--------------------------------------------------------------------*
*       Form called for f4 help to the output file field.
*---------------------------------------------------------------------*
FORM execute_f4help USING fp_file
                          fp_local.

*--  Local data declaration
  DATA : l_local TYPE c,
         tl_dynpread TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.

  CLEAR l_local.
  REFRESH tl_dynpread.

*--  Populating tl_dynpread with screen elements ie checkboxes whose
*--  Values are tracked.
  tl_dynpread-fieldname = fp_local.       " Presentation Server
  APPEND tl_dynpread.

*--  Check the Values from Screen
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     = sy-cprog  " Calling program
      dynumb     = sy-dynnr  " Screen number
    TABLES
      dynpfields = tl_dynpread
    EXCEPTIONS
      OTHERS     = 11.

  IF sy-subrc NE 0.
    MESSAGE e103(zz) WITH
    'Exception raised while reading the Screen.'(002).
  ENDIF.                               " IF SY-SUBRC NE 0.

*--  Getting server type
  READ TABLE tl_dynpread WITH KEY fieldvalue = 'X'
                                  BINARY SEARCH.
  IF sy-subrc IS INITIAL.
    l_local = 'P'.
  ELSE.
    l_local = 'A'.
  ENDIF.

*--  Selects the directory list based on the dowmload location
*--  button selected.
  CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
    EXPORTING
      dynpfield_filename = fp_file
      dyname             = sy-cprog
      dynumb             = sy-dynnr
      filetype           = 'P'
      location           = l_local
      server             = space.

ENDFORM.                    " EXECUTE_F4HELP

Hope this helps........

p_local is a checkbox to determine if its a local file or a server file.

Read only

Former Member
0 Likes
3,383

Hi guys

I am thankful to you for your support, unfortunately my purpose is not yet met.

actually i need to get only the folder path and not the file path.

thanks

Read only

0 Likes
3,383

Hello Sam Al,

but have you ever tried this suggested solutions? You will get only the Folder Path.

Regards

Gregor

Read only

Former Member
0 Likes
3,383

hi check this..

execute the tcode CG3Y..then will ask for the folder on the presentation server

regards,

venkat

Read only

0 Likes
3,383

Hi Sam,

is your problem solved ??

i want similar requirement, need to create folder or select folder through F4 help.

Read only

0 Likes
3,383

if solved pls reply to me