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: 

download pgm needed

Former Member
0 Kudos

can anybody have pgm to download in to flat file from sap.

this is not upload to sap.download from sap to application server

send some simple coding

just using few table and fields

6 REPLIES 6

Former Member
0 Kudos

please, dont post duplicates .

Regards

Prabhu

Former Member
0 Kudos

Hi Arun ,

Since you want to download to application server , so you need to use the

Open Dataset , write dataset and close dataset commands.

Please see the help for the above and you would be albe to write a program for your requirement.

Regards

Arun

Former Member
0 Kudos

Hi,

Try the following code n let me know.

"----


  • Type declaration of the structure to hold file data *

"----


data:

begin of fs_table,

str type string,

end of fs_table.

"----


  • Internal table to hold file data *

"----


data:

t_table like standard table

of fs_table.

"----


  • Type declaration of the structure to hold file data *

"----


data:

begin of fs_table1,

str type string,

end of fs_table1.

"----


  • Internal table to hold file data *

"----


data:

t_table1 like standard table

of fs_table1.

*" Data declarations...................................................

"----


  • Work variables *

"----


data:

w_file_name(50) type c value 'YH645_050103'.

open dataset w_file_name for input in text mode encoding default.

do.

read dataset w_file_name into fs_table1-str.

if sy-subrc ne 0.

exit.

endif.

append fs_table1 to t_table1.

enddo.

close dataset w_file_name.

call function 'GUI_DOWNLOAD'

exporting

  • BIN_FILESIZE =

filename = 'C:\Assign\bkpf'

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

  • IMPORTING

  • FILELENGTH =

tables

data_tab = t_table1

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

loop at t_table1 into fs_table1.

write: / fs_table1-str.

endloop.

reward if helpful.

regards,

kiran kumar k

Former Member
0 Kudos

HI Arun

Analyse this code.

REPORT test.
*--Internal table & Work area Declaration
DATA : t_data TYPE STANDARD TABLE OF t000,
       wa_data TYPE t000.
DATA : w_message(100)  TYPE c.
 
*--Application Server File path from user
PARAMETERS  :  p_file TYPE  rlgrap-filename.
 
 
START-OF-SELECTION.
 
*--Get data into the Internal table t_data
  SELECT * FROM t000 INTO TABLE t_data .
 
 
 
*--- Create the application server file path
  OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_message.
 
*--- Display error messages if any.
  IF sy-subrc NE 0.
    MESSAGE w_message TYPE 'E'.
    EXIT.
  ELSE.
 
*---Data is downloaded to the application server file path
    LOOP AT t_data INTO wa_data.
      TRANSFER wa_data TO p_file.
    ENDLOOP.
  ENDIF.
 
*--Close the Application server file (Mandatory).
  CLOSE DATASET p_file.
 
  IF sy-subrc NE 0.
    MESSAGE  'Error closing the File' TYPE 'E'.
    EXIT.
  ELSEIF sy-subrc IS INITIAL.
    WRITE : 'File saved in the location' , p_file.
  ENDIF.

Take a look at this help.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c8c358411d1829f0000e829fbfe/frameset.htm

You will find some sample code as well.

This has been discussed a lot . Please refer the following links

Regards,

Rk

Message was edited by:

Rk Pasupuleti

0 Kudos

thanks a lot

suppose if they give any some location path .

eg:

'/usr/test.dat' wat we have to put in p_file.

how to declare it.

0 Kudos

HI Arun

Give the same thing in P_file

but you<b> need to validate the path first off all</b>

For validating Just check these links

<b>

</b>

If it helps Reward with points

Regards Rk