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: 

How Can we genarate Excel file without GUI_DOWNLOAD

Former Member
0 Kudos

Hi All,

Is there any way to genarate Excel file from an internal table without using the function module 'GUI_DOWNLOAD'.

Also i don't want to put in application server also.

My requirement is i have to generate one excel file and need to put in the legacy system.

I would appreciate any help in this regard.

Regards,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Look at the following example code.......

*at selection-screen on value-request for p_file.

*call function 'F4_FILENAME'

  • exporting

  • program_name = syst-cprog

  • dynpro_number = syst-dynnr

  • field_name = 'p_file'

  • importing

  • file_name = p_file

  • .

*

*s_file = p_file.

*

*start-of-selection.

*

*select matnr meins from mara into table witab up to 5 rows.

*

  • CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

  • EXPORTING

    • BIN_FILESIZE =

  • FILENAME = s_file

  • FILETYPE = 'ASC'

    • APPEND = SPACE

    • WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = SPACE

    • WRITE_LF = 'X'

    • COL_SELECT = SPACE

    • COL_SELECT_MASK = SPACE

    • IMPORTING

    • FILELENGTH =

  • CHANGING

  • DATA_TAB = witab

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

Thanks,

If this helps you reward with points.

6 REPLIES 6

Former Member
0 Kudos

the requirement is not clear.

you are talking about generating excel file, then where you want to place it ? you said, you dont want to place it application server and presentation server

normally,to send file to legacy system,what we do is, placing that file on specified folder in application server. on a periodic basis,that file will be sent to that legacy system (either by shell command/script)

regards

srikanth

Former Member
0 Kudos

Hi,

Look at the following example code.......

*at selection-screen on value-request for p_file.

*call function 'F4_FILENAME'

  • exporting

  • program_name = syst-cprog

  • dynpro_number = syst-dynnr

  • field_name = 'p_file'

  • importing

  • file_name = p_file

  • .

*

*s_file = p_file.

*

*start-of-selection.

*

*select matnr meins from mara into table witab up to 5 rows.

*

  • CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

  • EXPORTING

    • BIN_FILESIZE =

  • FILENAME = s_file

  • FILETYPE = 'ASC'

    • APPEND = SPACE

    • WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = SPACE

    • WRITE_LF = 'X'

    • COL_SELECT = SPACE

    • COL_SELECT_MASK = SPACE

    • IMPORTING

    • FILELENGTH =

  • CHANGING

  • DATA_TAB = witab

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

Thanks,

If this helps you reward with points.

0 Kudos

Hi,

You can try function modules such as MS_EXCEL_OLE_STANDARD_DAT

START_EXCEL

~Suresh

Former Member
0 Kudos

Hi venkat,

Go thru this code..

with this u can download in xls,rtf ,txt formats..


data f_flag type sy-ucomm.
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM P_SELFIELD TYPE SLIS_SELFIELD.
  CASE P_UCOMM.
    WHEN 'DWNL'.
      PERFORM OPEN_SAVE_DIALOG.
      IF F_FLAG EQ 0.
        PERFORM DOWNLOAD.
      ELSE.
        EXIT.
      ENDIF.
  ENDCASE.
ENDFORM.                    
FORM OPEN_SAVE_DIALOG .
  DATA: G_FILE_NAME TYPE STRING,
        G_FILE_PATH TYPE STRING,
        G_FULL_PATH TYPE STRING,
        G_ACTION TYPE I.
  CLEAR F_FLAG.
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
    CHANGING
      FILENAME     = G_FILE_NAME
      PATH         = G_FILE_PATH
      FULLPATH     = G_FULL_PATH
      USER_ACTION  = G_ACTION
    EXCEPTIONS
      CNTL_ERROR   = 1
      ERROR_NO_GUI = 2
      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.
  IF G_ACTION EQ 0.
    G_PATH = G_FULL_PATH.
  ELSE.
    F_FLAG = G_ACTION.
  ENDIF.
ENDFORM.  


FORM DOWNLOAD .

* Downloads to the specified location.
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    EXPORTING
      FILENAME                = G_PATH
      FILETYPE                = 'DAT'
    CHANGING
      DATA_TAB                = 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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                   
         

andreas_mann3
Active Contributor
0 Kudos

hi,

use <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">OLE</a> - technique

A.