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: 

about downloading the file

Former Member
0 Kudos

hi

i have this coding

DATA : BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERNAM LIKE MARA-ERNAM,

END OF ITAB.

DATA: v_file TYPE string.

PARAMETER : P_FILE TYPE RLGRAP-FILENAME.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM UPLOAD.

START-OF-SELECTION.

V_FILE = P_FILE.

PERFORM UPLOAD1.

FORM UPLOAD.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'P_FILE'

IMPORTING

FILE_NAME = P_FILE

.

ENDFORM.

FORM UPLOAD1.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = 'V_FILE'

DEF_PATH = ' '

  • MASK = ' '

  • MODE = ' '

  • TITLE = ' '

  • IMPORTING

  • FILENAME =

  • RC =

  • EXCEPTIONS

  • INV_WINSYS = 1

  • NO_BATCH = 2

  • SELECTION_CANCEL = 3

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

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

FILENAME = 'V_FILE'

FILETYPE = 'DAT'

MODE = 'A'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM.

in this coding i can download the itab , after the selecting the file from selectionscreen , it storing the itab in another file , WHY IT IS LIKE THAT

PLS HELP ON THIS MATTER

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hii..

Jamshad...

You have to Pass the FileName as Variable (So V_File should not be in Single Quotes)

Check it Below : Changes are in BOLD....

And one more thing Use GUI_DOWNLOAD instead of WS_DOWNLOAD(which is obselete)

FORM UPLOAD1.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

<b>DEF_FILENAME = V_FILE</b>

DEF_PATH = ' '

  • MASK = ' '

  • MODE = ' '

  • TITLE = ' '

  • IMPORTING

  • FILENAME =

  • RC =

  • EXCEPTIONS

  • INV_WINSYS = 1

  • NO_BATCH = 2

  • SELECTION_CANCEL = 3

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

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

<b>FILENAME = V_FILE</b>

FILETYPE = 'DAT'

MODE = 'A'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM.

<b>Reward if Helpful</b>

4 REPLIES 4

former_member223537
Active Contributor
0 Kudos

If you want to upload the file, use FM 'GUI_UPLOAD' instead of WS_DOWNLOAD.

If you want to download the file, use FM 'GUI_DOWNLOAD'

0 Kudos

If you are familiar with ABAP objects, try these methods:

CALL METHOD cl_gui_frontend_services=>gui_upload

CALL METHOD cl_gui_frontend_services=>gui_download

Arne

varma_narayana
Active Contributor
0 Kudos

Hii..

Jamshad...

You have to Pass the FileName as Variable (So V_File should not be in Single Quotes)

Check it Below : Changes are in BOLD....

And one more thing Use GUI_DOWNLOAD instead of WS_DOWNLOAD(which is obselete)

FORM UPLOAD1.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

<b>DEF_FILENAME = V_FILE</b>

DEF_PATH = ' '

  • MASK = ' '

  • MODE = ' '

  • TITLE = ' '

  • IMPORTING

  • FILENAME =

  • RC =

  • EXCEPTIONS

  • INV_WINSYS = 1

  • NO_BATCH = 2

  • SELECTION_CANCEL = 3

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

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

<b>FILENAME = V_FILE</b>

FILETYPE = 'DAT'

MODE = 'A'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM.

<b>Reward if Helpful</b>

Former Member
0 Kudos

Hi Jamshad,

I didn't understand ' in another file'. Can u clarify me what do u mean by storing itab in another file..

Regards,

Sai