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

passing the filepath

Former Member
0 Likes
2,160

Hi

How do u pass file path that ur entering in selection screen to the function module GUI_DOWNLOAD.Urgent.

Regards,

Nagaraju

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,780

data : IN_FILE TYPE STRING.

PARAMETERS : UFILE LIKE RLGRAP-FILENAME.

MOVE UFILE TO IN_FILE.

call function 'GUI_DOWNLOAD'

exporting

filename = input_file

filetype = 'ASC'

has_field_separator = FIELD_SEP

tables

data_tab = IN_FILE

exceptions

Edited by: Sujamol Augustine on May 15, 2008 5:12 PM

14 REPLIES 14
Read only

Former Member
0 Likes
1,780

file type should be string ...

Read only

Former Member
0 Likes
1,781

data : IN_FILE TYPE STRING.

PARAMETERS : UFILE LIKE RLGRAP-FILENAME.

MOVE UFILE TO IN_FILE.

call function 'GUI_DOWNLOAD'

exporting

filename = input_file

filetype = 'ASC'

has_field_separator = FIELD_SEP

tables

data_tab = IN_FILE

exceptions

Edited by: Sujamol Augustine on May 15, 2008 5:12 PM

Read only

Former Member
0 Likes
1,780

The file has to be passed in a type string.

From the FM:

REFERENCE(FILENAME) TYPE STRING

p_filename <--your screen parameter

data: p_string type string.

move p_filename to p_string.

"then pass p_string to the FM.

Warren

Read only

Former Member
0 Likes
1,780

do this way


* This method of file download with check uses the latest techniques
* and achieves a very neat solution
  DATA: ld_filename TYPE string,
        ld_path TYPE string,
        ld_fullpath TYPE string,
        ld_result TYPE i.

* Display save dialog window
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
*      window_title      = ' '
      DEFAULT_EXTENSION = 'XLS'
      default_file_name = 'accountsdata'
      INITIAL_DIRECTORY = 'c:\temp\'
    CHANGING
      filename          = ld_filename
      path              = ld_path
      fullpath          = ld_fullpath
      user_action       = ld_result.

* Check user did not cancel request
  CHECK ld_result EQ '0'.

  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_fullpath
        filetype         = 'ASC'
*       APPEND           = 'X'
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]     "need to declare and populate
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3. 

Read only

Former Member
0 Likes
1,780

Declare a variable of type string.

DATA v_path TYPE string,

get the input from the user concatenate stuff(like date time) if you want to and the assign it to the string variable and the pass it to GUI_download

v_path = p_opfile.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_path

filetype = 'DAT'

write_field_separator = 'X'

TABLES

data_tab = i_excel

fieldnames = i_fname

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

OTHERS = 22.

IF sy-subrc NE 0.

MESSAGE e000(zfi) WITH text-106.

ENDIF.

Read only

Former Member
0 Likes
1,780

Concatenate it to the front of the File name.

Read only

Former Member
0 Likes
1,780

You pass it to the parameter FILENAME

Example:

PARAMETERS: p_fwpath  TYPE localfile default 'C:\TEST\dummy.txt'.
data : l_path type string.

l_path = p_fwpath.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = l_path
    TABLES
      data_tab                = g_t_final.

Hope this is helpful.

Thanks,

Pavan

Read only

Former Member
0 Likes
1,780

data g_name TYPE string.

g_name = p_path.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = g_name

TABLES

data_tab = i_t

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

Read only

Former Member
0 Likes
1,780

check this simple example...

parameters:p_file like rlgrap-filename.

data:string1 type string.

data: begin of itab occurs 0,

a type c,

c type c,

b type i,

end of itab.

itab-a = 'a' .

itab-c = ':'.

itab-b = 1 .

append itab .

itab-a = 'b' .

itab-c = ':'.

itab-b = 2 .

append itab .

itab-a = 'c' .

itab-c = ':'.

itab-b = 3 .

append itab .

data: file type string .

string1 = p_file.

start-of-selection.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = string1

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = ':'

TABLES

DATA_TAB = itab.

regards,

venkat

Read only

Former Member
0 Likes
1,780

Hi,

You can use the FM,

KD_GET_FILENAME_ON_F4 to read the file name.

data : FILE_NAME_STR type string.

Move FILE_NAME to FILE_NAME_STR.

FILE_NAME_STR pass this variable to the FM GUI_DOWNLOAD.

reaward if it helps,

regards,

mahantesh

Read only

Former Member
0 Likes
1,780

-

Read only

Former Member
0 Likes
1,780

Hi,

You can refer this code.

DATA : v_file TYPE string.

PARAMETERS: p_file TYPE rlgrap-filename.

----


  • AT SELECTION SCREEN ON VALUE-REQUEST

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

IMPORTING

file_name = p_file.

v_file = p_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = v_file

  • FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

  • SHOW_TRANSFER_STATUS = ABAP_TRUE

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB =

  • FIELDNAMES =

  • 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

  • OTHERS = 22

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

Here if you press F4, popup wil come to choose the File.

Regards

Sandeep Reddy

Read only

Former Member
0 Likes
1,780

Initial File name

Parameters: pfilemm type rlgrap-filename.

But in FM download

parameter is of type string

name of file here is lv_path.

I need to download into .CSV format.

How should I correlate.

I used another fm for conversion into csv

SAP_CONVERT_TO_CSV_FORMAT

code: correct me

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ';'

TABLES

I_TAB_SAP_DATA = gi_matmaster_mara

  • CHANGING

  • I_TAB_CONVERTED_DATA =

EXCEPTIONS

CONVERSION_FAILED = 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.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = lv_file

  • FILETYPE = '.CSV'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

  • SHOW_TRANSFER_STATUS = ABAP_TRUE

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = gi_matmaster_mara

  • FIELDNAMES =

  • 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

  • OTHERS = 22

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

Regards,

Nagaraju

Read only