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: 

gui_download

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I am using FM GUI_DOWNLOAD and I would like to ask if its possible to let the user decide on which path would the text file be saved.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

hi,

call this CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

before gui_download.

Regards

vijay

20 REPLIES 20

Former Member
0 Kudos

data: ld_filename type string ;

ld_filename = 'c:\demo.txt'.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

HII

call function 'GUI_DOWNLOAD'

exporting

filename = ld_filename

filetype = 'ASC'

tables

data_tab = it_datatab[]

exceptions

file_open_error = 1

file_write_error = 2

others = 3.

thanks & regards

Naresh

Message was edited by: Naresh Kumar Amaragani

rahulkavuri
Active Contributor
0 Kudos

u can use this code and refer to


data: fname type string.
 
fname = 'c:demo.txt'.
 
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    filename                      = fname
*   APPEND                        = ' '
*   WRITE_FIELD_SEPARATOR         = ' '
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
 
*   DAT_MODE                      = ' '
 
* IMPORTING
*   FILELENGTH                    =
  TABLES
    data_tab                      = itab
    

Message was edited by: Rahul Kavuri

former_member188685
Active Contributor
0 Kudos

hi,

call this CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

before gui_download.

Regards

vijay

0 Kudos

Hi Vijay,

Can you give a small example on how to declare the FM that you said. Also, can it be inside a form just above the FM gui_download?

By the way, is there a way for me to practice BDC and other stuff on my sap netweaver ABAP edition?

Again, Thank you guys for all your help!

0 Kudos

Hi,

You should use the method DIRECTORY_BROWSE of CL_GUI_FRONTEND_SERVICES. This will select only the directory part of it.

FILE_OPEN_DIALOG is to open a existing file not to select the path of the directory.

regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

check out this program

BCALV_BDS_MAINTENANCE

search this source for file_save_dialog

you will find sample for file_save_dialog as well as gui_download

Regards

Raja

0 Kudos

check this program as well

RS_DBG_TABLE_TO_EXCEL

Regards

Raja

0 Kudos

Hi,

sorry it is SAVE not open

that is class CL_GUI_FRONTEND_SERVICES method <b>FILE_SAVE_DIALOG</b>

check it in SE24.

Regards

vijay

Message was edited by: Vijay Babu Dudla

0 Kudos

Hi guys,

Again thanks for all your helpful replies. By the way, I installed SAP netweaver ABAP edition on my PC and I am wondering if I could practice BDC and other stuff on it?

Thanks again!

0 Kudos

yes you can do that.

Regards

vijay

0 Kudos

Hi,

You usually practice BDC's on the business transactions that are not a part of WAS only, you need to have the modules for business transactions.

However, you can probably try something on the classification system for creating characteristics etc.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

Hi Vijay,

Sorry for being so stubborn. On what transaction can I practice BDC on abap preview edition?

Thanks!

0 Kudos

try it on MM01 it is very simple to code. you can browse SDN for samples.

Regards

vijay

0 Kudos

you can try BDC for , for example SU01, or for that matter any transaction (no enjoy transactions) whichis available.

if you want to learn new stuffs, its got BSP and it fyou installed 2004s you can also practice ABAP webdynpro.

Regards

Raja

0 Kudos

you will not find MM01 in minisap

Raja

0 Kudos

ABAP sneak previw edition does not have modules on it, I am not sure where will you get MM01 from. As I said in my previous post you can try on characteristics CT04 transaction.

Regards,

Ravi

0 Kudos

Hi Viray,

Sorry , i think i'm wrong. I think you should try what Raja suggested.

Regards

vijay

former_member188685
Active Contributor
0 Kudos
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Import from a local file'
      default_extension       = 'DAT'
*      DEFAULT_FILENAME        =
      file_filter             = l_file_filter
      initial_directory       = 'C:'
*      MULTISELECTION          =
*      WITH_ENCODING           =
    CHANGING
      file_table              = l_file_table
      rc                      = l_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

      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
          FILENAME                = V_FILE
          FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
        CHANGING
          DATA_TAB                = IT_MAIN[]
        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
          NOT_SUPPORTED_BY_GUI    = 22
          OTHERS                  = 23.
      IF SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

0 Kudos

it should be CL_GUI_FRONTEND_SERVICES=><b>FILE_SAVE_DIALOG</b>

Regards

Raja

Former Member
0 Kudos

Hi Viraylab,

Just copy this code and run. It will pop up a window so that the user can decide on which path would the text file be saved.

&----


*& Report ZKUN_FILE11 *

*& *

&----


*& *

*& *

&----


REPORT zkun_file15 .

DATA : count TYPE i,

gv_file TYPE string,

dir TYPE string,

fil TYPE string,

ch TYPE c VALUE '\'.

DATA: BEGIN OF itab OCCURS 0 .

INCLUDE STRUCTURE zkunal1.

DATA: END OF itab.

DATA: wa_file_table TYPE file_table,

tab TYPE STANDARD TABLE OF file_table.

SELECT * FROM zkunal1 INTO TABLE itab.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

  • EXPORTING

  • WINDOW_TITLE =

  • DEFAULT_EXTENSION =

  • DEFAULT_FILENAME =

  • FILE_FILTER =

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

file_table = tab

rc = count

  • 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.

LOOP AT tab INTO wa_file_table.

WRITE : / wa_file_table-filename.

gv_file = wa_file_table-filename.

CONDENSE gv_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = gv_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'

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = itab

  • 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.

ELSE.

MESSAGE i001(zmsg_kunal).

ENDIF.

ENDLOOP.

Regards,

Kunal.

Note : <b>it depends on you how you are populating your internal table itab. Here in this code, it has been populated from the database table zkunal1.</b>

Message was edited by: Kunal Kumar