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

put a file on presentation server

Former Member
0 Likes
2,346

hi everybody

wats the tcode to access the presentations server and how to put a file there?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,974

Hi,

Upload Data into SAP from a Presentation Server:

Retrieve data file from presentation server(Upload from PC)

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = i_file

filetype = 'ASC'

TABLES

data_tab = it_datatab "ITBL_IN_RECORD[]

EXCEPTIONS

file_open_error = 1

OTHERS = 2

Download Data from SAP to presentation server file(PC)

DATA: ld_filename TYPE string,

  • Pre version 4.7 declaration e_file like rlgrap-filename.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

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.

Hope this helps you.

Thanks,

Ruthra

7 REPLIES 7
Read only

Former Member
0 Likes
1,974

there is a class cl_gui_frontend_services

the method gui_download can be used for this purpose.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = <put the entire path of file here. example 'C:\test.txt'

filetype = 'ASC'

write_field_separator = 'X'

changing

data_tab = ITAB "this is your internal table that holds the data to be written to the file.

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

.

Read only

Former Member
0 Likes
1,974

Sia

Presentation server is nothing but the workstation (Desktop), on which you are working on.... I think you wanted to know abt Application Server. Then the transactions are CG3Z, CG3Y and AL11...

Thanks

Amol Lohade

Read only

Former Member
0 Likes
1,975

Hi,

Upload Data into SAP from a Presentation Server:

Retrieve data file from presentation server(Upload from PC)

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = i_file

filetype = 'ASC'

TABLES

data_tab = it_datatab "ITBL_IN_RECORD[]

EXCEPTIONS

file_open_error = 1

OTHERS = 2

Download Data from SAP to presentation server file(PC)

DATA: ld_filename TYPE string,

  • Pre version 4.7 declaration e_file like rlgrap-filename.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

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.

Hope this helps you.

Thanks,

Ruthra

Read only

Former Member
0 Likes
1,974

Hi,

The function module to load internal table data to a file on presentation server(your computer) is GUI_DOWNLOAD.

Check this sample code


REPORT  z_file_download.
DATA: w_name(90) TYPE c.
DATA:
  BEGIN OF fs_flight,
    carrid   LIKE sflight-carrid,
    connid   LIKE sflight-connid,
    fldate   LIKE sflight-fldate,
    price    LIKE sflight-price,
    currency LIKE sflight-currency,
  END OF fs_flight.
DATA:
  BEGIN OF fs_head,
    carrid(10) TYPE c,
    connid(10) TYPE c,
    fldate(10) TYPE c,
    price(10) TYPE c,
    curr(10) TYPE c,
  END OF fs_head.
DATA:
  t_head LIKE
   TABLE OF
         fs_head.
DATA:
  t_flight LIKE
     TABLE OF
           fs_flight.

fs_head-carrid = 'CARRID'.
fs_head-connid = 'CONNID'.
fs_head-fldate = 'FLDATE'.
fs_head-price  = 'PRICE'.
fs_head-curr   = 'CURRENCY'.
APPEND fs_head TO t_head.
SELECT-OPTIONS:
  s_carrid FOR fs_flight-carrid.



START-OF-SELECTION.
  SELECT carrid
         connid
         fldate
         price
         currency
    FROM sflight
    INTO TABLE t_flight
   WHERE carrid IN s_carrid.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    filename                      = 'D:\flight.xls'
   FILETYPE                      = 'ASC'
*   APPEND                        = ' '
    WRITE_FIELD_SEPARATOR         = 'X'
*   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                     = ' '
* IMPORTING
*   FILELENGTH                    =
  tables
    data_tab                      = t_head
 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.



  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'D:\flight.xls'
      filetype                = 'ASC'
      append                  = 'X'
      write_field_separator   = 'X'
    TABLES
      data_tab                = t_flight
    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 EQ 0.
    MESSAGE 'Download successful' TYPE 'I'.
  ENDIF.
  IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards

Abhijeet

Read only

Former Member
0 Likes
1,974

to put a file on presentation server u can use

cl_gui_frontend_services=>gui_download

and to put a file application server u need to use the syntax

open dataset <name of the parameter> for input.

}

close dataset <name of the parameter>.

Read only

Former Member
0 Likes
1,974

Hi Sia,

*"Table declarations...................................................
TABLES:
  vbak.                                " Sales Document Header

*"Selection screen elements............................................
SELECT-OPTIONS:
  s_vbeln FOR vbak-vbeln.              " Sales Document

*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Internal Table - VBAK                                               *
*"--------------------------------------------------------------------*
DATA:
  BEGIN OF t_vbak OCCURS 0,
    vbeln TYPE vbak-vbeln,             " Sales Document
    erdat TYPE vbak-erdat,             " Document Date
    erzet TYPE vbak-erzet,             " Time
    ernam TYPE vbak-ernam,             " Name
  END OF t_vbak.

*"--------------------------------------------------------------------*
* Work variables                                                      *
*"--------------------------------------------------------------------*
DATA:
  file_path LIKE ibipparms-path,
  file_path1 TYPE string.



SELECT vbeln                           " Sales Document
       erdat                           " Document Date
       erzet                           " Time
       ernam                           " Name
  FROM vbak
  INTO TABLE t_vbak
 WHERE vbeln IN s_vbeln.


**"--------------------------------------------------------------------*
** Function Module -  F4_FILENAME                                      *
**"--------------------------------------------------------------------*
*CALL FUNCTION 'F4_FILENAME'
** EXPORTING
**   PROGRAM_NAME        = SYST-CPROG
**   DYNPRO_NUMBER       = SYST-DYNNR
**   FIELD_NAME          = ' '
* IMPORTING
*   file_name           =  file_path.


file_path1  =  'C:/Doc4.doc'.


*"--------------------------------------------------------------------*
* Function Module -  GUI_DOWNLOAD                                     *
*"--------------------------------------------------------------------*
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    filename                      = file_path1
    filetype                      = 'ASC'
*    append                        = 'X'
    write_field_separator         = 'X'
*   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                     = ' '
* IMPORTING
*   FILELENGTH                    =
  TABLES
    data_tab                      =  t_vbak
 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 EQ 0.
  MESSAGE 'File Download Successful'(001) TYPE 'S'.
ENDIF.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
1,974

Sia,

You have a list of FM to acces the Presentation server...

Please check them out below,

TMP_GUI_CREATE_DIRECTORY : Create a folder on P server

TMP_GUI_DIRECTORY_LIST_FILES : List the files on a folder in P server

TMP_GUI_READ_DIRECTORY : Read from a folder

TMP_GUI_REMOVE_DIRECTORY : Delete a folder on P server

ITS_DIRECTORY_GET

ITS_DIRECTORY_LIST_FILES

PFL_CHECK_DIRECTORY : Check if a folder exists or not

To put a file onto the P server, use GUI_DOWNLOAD

Regards

Indu