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

regarding dynamic file names

Former Member
0 Likes
708

hiii ,

iam doing BDC . i want to download data into an excel sheet . IS THERE ANY FUNCTION MODULE , WITH WHICH I CAN PROVIDE A DYNAMIC FILE NAME LIKE WE DO IN WINDOWS . IT SHOULD PROVIDE AN OPTION TO BROWSE THE DRIVES AND THEN IT SHOULD TAKE THE FILENAME .

regards ,

varma

hiii ,

iam doing BDC . i want to download data into an excel sheet . IS THERE ANY FUNCTION MODULE , WITH WHICH I CAN PROVIDE A DYNAMIC FILE NAME LIKE WE DO IN WINDOWS . IT SHOULD PROVIDE AN OPTION TO BROWSE THE DRIVES AND THEN IT SHOULD TAKE THE FILENAME .

regards ,

varma

6 REPLIES 6
Read only

Former Member
0 Likes
659

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

    • BIN_FILESIZE =

FILENAME = ''

FILETYPE = 'ASC'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ','

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ';'

    • COL_SELECT_MASK = ','

    • DAT_MODE = ' '

    • IMPORTING

    • FILELENGTH =

TABLES

DATA_TAB = it_final

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

Read only

Former Member
0 Likes
659

while recording , record that F4 help for file also so that it becomes part of ur BDC

Read only

Former Member
0 Likes
659

hi,

u can get the filename from the selection-screen on which file name is a parameter.

1. the file location may be local PC or application server.

2. if local PC u can use FM <b>/SAPDMC/LSM_F4_FRONTEND_FILE</b>

3. if u want to have file on application server u can use FM /SAPDMC/LSM_F4_SERVER_FILE

reward if useful....

Read only

Former Member
0 Likes
659

Hi Varma,

Please try 'TEST_FRONTEND_SERVICES' program which demonstrates how to use a class 'CL_GUI_FRONTEND_SERVICES'

If you can not get this class or report then write to me on [email protected]

The reason for not getting report or class is use of old SAP version. In this case you can use function module download which has option of opening a dialog to download the file.

Best Regards,

Chintamani

Read only

Former Member
0 Likes
659

Hi Ravi

Try the method FILE_SAVE_DIALOG from CL_GUI_FRONTEND_SERVICES class.

Thanks

Kathirvel

Read only

Former Member
0 Likes
659

Hi Ravi

Try this code and let me know if it did not solve your problem.

REPORT zkb_file_download .

DATA: i_t000 TYPE STANDARD TABLE OF t000.

DATA: v_filename TYPE string,

v_path TYPE string,

v_fullpath TYPE string.

SELECT * FROM t000 INTO TABLE i_t000.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

CHANGING

filename = v_filename

path = v_path

fullpath = v_fullpath

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.

ENDIF.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = v_fullpath

filetype = 'ASC'

CHANGING

data_tab = i_t000

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

error_no_gui = 23

OTHERS = 24.

IF sy-subrc <> 0.

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

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

ENDIF.

Thanks

Kathirvel