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_FILE_SAVE_DIALOG

Former Member
0 Kudos

Hi Experts,

I am using fm GUI_FILE_SAVE_DIALOG,

CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'

EXPORTING

WINDOW_TITLE = 'Select File'

FILE_FILTER = '(.xls)|.xls|'

IMPORTING

FULLPATH = SOURCEFILENAME

USER_ACTION = USER_ACTION.

IF USER_ACTION <> 0 AND USER_ACTION <> 1 AND USER_ACTION <> 2.

MESSAGE S000(ZZ) WITH TEXT-000.

EXIT.

ENDIF.

it is showing path select along with buttons Replace, Generate, and Extent. where i dnt need these.

i need bapi in bid like GUI_FILE_LOAD_DIALOG.

Thanks in Advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use Function Module GUI_Download. Follow the below steps if the file you want to save is an excel file.



SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK blk3.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'
    IMPORTING
      file_name  = p_file.

START-OF-SELECTION

* For Column Headers.
TYPES: BEGIN OF ty_fieldnames,
       field TYPE c LENGTH 50,
       END OF ty_fieldnames.

  wa_fieldnames-field = 'T1'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T2'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T3'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T4'.
  APPEND wa_fieldnames TO it_fieldnames.

* Save FIle.
CONCATENATE p_file '.xls' INTO p_file.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = p_file
      filetype                = 'DAT'
      append                  = ' '
      write_field_separator   = 'X'
    TABLES
      data_tab                = it_final
      fieldnames              = it_fieldnames
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2.

Regards,

Danish.

8 REPLIES 8

Former Member
0 Kudos

hi,

try the FM 'GUI_DOWNLOAD' using filetpye = 'BIN'. You have to calcuale the length in byte of file and convert the data:

...

 CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = gt_data   
  IMPORTING
      output_length = lv_len
    TABLES
      binary_tab    = lt_itab.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      bin_filesize            = lv_len
      filename                = lv_filename
      filetype                = 'BIN'
    TABLES
      data_tab                = lt_itab
    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.
............    
ELSE.

......
       ENDIF.

Regards..

franois_henrotte
Active Contributor
0 Kudos

you have to set

init = 'L'.

problem is you don't have a function to do it... but as "init" is a global variable of function pool you can set it in the memory stack

madhu_vadlamani
Active Contributor
0 Kudos

Hi Anusha,

I will suggest you go with class services cl_gui_frontend_services.

Regards,

Madhu.

sjeevan
Active Contributor
0 Kudos

Try this


selection-screen begin of block BCX with frame.
parameters: p_filep like rlgrap-filename.
selection-screen end of block BCX.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filep.
PERFORM find_dir USING p_filep.

Former Member
0 Kudos

Hi experts,

firstly i am using f4_filename,

then using the below code but i am not able to carry my filename properly and downloaded file is not in excel format.

TRANSLATE SOURCEFILENAME TO UPPER CASE.

SPLIT SOURCEFILENAME AT '.XLS' INTO SOURCEFILENAME FILENAME.

CONCATENATE SOURCEFILENAME '_ERRORS' INTO FILENAME.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = FILENAME

TABLES

DATA_TAB = DOWNLOADTAB

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

MOVE FILENAME TO SOURCEFILENAME.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = SOURCEFILENAME

TABLES

DATA_TAB = DOWNLOADTAB

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

MESSAGE S000(ZZ) WITH TEXT-001.

ENDIF.

ENDIF.

plz help me to sortout the issue,

thanks in advance.

0 Kudos

Hi Anu,

Can you check like this.

DATA : t_dfname TYPE rlgrap-filename VALUE u2018C:\u2019,

t_filename TYPE STRING.

CALL FUNCTION u2018F4_FILENAMEu2019

EXPORTING

program_name = sy-repid

dynpro_number = sy-dynnr

IMPORTING

file_name = t_dfname

t_filename = t_dfname.

IF t_filename IS INITIAL OR

t_filename = u2018C:\u2019.

MESSAGE:'Custom Message' type 'I'.

STOP.

ENDIF.

CALL FUNCTION u2018GUI_DOWNLOADu2019

EXPORTING

filename = t_filename

filetype = u2018DATu2019

TABLES

data_tab = Ittab.

CALL FUNCTION u2018MS_EXCEL_OLE_STANDARD_DATu2019

EXPORTING

file_name = t_dfname

TABLES

data_tab = ittab

fieldnames = it_head

EXCEPTIONS

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE u2018Excel OPEN Erroru2019 TYPE u2018Iu2019.

STOP.

ENDIF.

Regards,

Madhu.

Former Member
0 Kudos

Hi,

Use Function Module GUI_Download. Follow the below steps if the file you want to save is an excel file.



SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK blk3.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'
    IMPORTING
      file_name  = p_file.

START-OF-SELECTION

* For Column Headers.
TYPES: BEGIN OF ty_fieldnames,
       field TYPE c LENGTH 50,
       END OF ty_fieldnames.

  wa_fieldnames-field = 'T1'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T2'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T3'.
  APPEND wa_fieldnames TO it_fieldnames.
  wa_fieldnames-field = 'T4'.
  APPEND wa_fieldnames TO it_fieldnames.

* Save FIle.
CONCATENATE p_file '.xls' INTO p_file.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = p_file
      filetype                = 'DAT'
      append                  = ' '
      write_field_separator   = 'X'
    TABLES
      data_tab                = it_final
      fieldnames              = it_fieldnames
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2.

Regards,

Danish.

Former Member
0 Kudos

Thanku all for ur replies,

am not getting eventhough after making changes,

AT SELECTION-SCREEN ON VALUE-REQUEST FOR E_FILE.

*Function Module For Selecting File from its Location(error file)

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SY-REPID

FIELD_NAME = 'E_FILE'

IMPORTING

FILE_NAME = E_FILE.

  • Process lt_excel1

LOOP AT LT_FINAL INTO WA_FINAL.

CLEAR: OUTPUTTAB.

  • Validate input data

ERRORS_OCCURED = 'X'.

IF WA_FINAL-SHIPCUST IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-002.

ELSEIF WA_FINAL-NAME IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-003.

ELSEIF WA_FINAL-NAME2 IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-004.

ELSEIF WA_FINAL-SEARCHT IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-005.

ELSEIF WA_FINAL-STREET2 IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-006.

ELSEIF WA_FINAL-STREET3 IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-007.

ELSEIF WA_FINAL-STREET IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-008.

ELSEIF WA_FINAL-POSTAL IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-009.

ELSEIF WA_FINAL-CITY IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-010.

ELSEIF WA_FINAL-COUNTRY IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-011.

ELSEIF WA_FINAL-REGION IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-012.

ELSEIF WA_FINAL-TZONE IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-013.

ELSEIF WA_FINAL-INDUSTRY IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-014.

ELSEIF WA_FINAL-PLANT IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-015.

ELSEIF WA_FINAL-TOPAYMENT IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-016.

ELSEIF L_AGROUP(4) IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-017.

ELSEIF L_SORG(4) IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-018.

ELSEIF L_DCHAN IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-019.

ELSEIF L_DVIS(2) IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-020.

ELSEIF L_SCOND(2) IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-021.

ELSEIF L_INCO(3) IS INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-022.

ELSEIF L_TCLASS IS NOT INITIAL.

OUTPUTTAB-ERRORTEXT = TEXT-023.

ENDIF.

ENDLOOP.

  • Download Error File To Pc

CHECK LT_EXCEL1 IS NOT INITIAL.

REFRESH DOWNLOADTAB.

LOOP AT LT_FINAL INTO WA_FINAL.

MOVE-CORRESPONDING WA_FINAL TO DOWNLOADTAB.

APPEND DOWNLOADTAB.

CLEAR DOWNLOADTAB.

ENDLOOP.

TRANSLATE SOURCEFILENAME TO UPPER CASE.

SPLIT SOURCEFILENAME AT '.XLS' INTO SOURCEFILENAME FILENAME.

CONCATENATE SOURCEFILENAME '_ERRORS' INTO FILENAME.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = FILENAME

TABLES

DATA_TAB = DOWNLOADTAB

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

MOVE FILENAME TO SOURCEFILENAME.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = SOURCEFILENAME

TABLES

DATA_TAB = DOWNLOADTAB

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

MESSAGE S000(ZZ) WITH TEXT-001.

ENDIF.

ENDIF.