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: 

Generating report in Excell

Former Member
0 Kudos

HI,

I have one predefined excell format templet, i want data to be populated into the same format from ABAP Program. and later user can save the format and do changes according.

how to do this any idea are welcome.

6 REPLIES 6

Former Member
0 Kudos

Use the FM.

GUI_DOWNLOAD

Former Member
0 Kudos

HI,

You can transfer data to a excel sheet using FM ' GUI_DOWNLOAD'.

Here is a sample code for this,

TYPES : BEGIN OF ls_test,

line type string,

END OF ls_test.

DATA : lw_test type ls_test,

li_test TYPE STANDARD TABLE OF ls_test,

int1 TYPE C,

int2 TYPE c.

DATA : gv_tab(1) TYPE c

VALUE cl_abap_char_utilities=>horizontal_tab .

int1 = '1'.

int2 = '2'.

CONCATENATE int1 gv_tab int2 gv_tab '=SUM(A1:B1)'

INTO lw_test-line .

APPEND lw_test to li_test.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'E:\EXCELFORM.XLS'

FILETYPE = 'ASC'

tables

data_tab = li_test

Hope it will help you

Thanks and Regards

Rahul Sharma

Former Member
0 Kudos

GUI_DOWNLOAD will enable you to download your internal table contents into an excel sheet in your system

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = PATH """your file path

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = TABLE_DWNLD "your Inernal table name.

Later after the user has changed the data in the excel sheet , you can upload this data to your ABAP program using the FM GUI_UPLOAD

Regards

Winnie

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi Manohar,

Check the code below...


PARAMETERS : p_dload TYPE rlgrap-filename.
DATA : w_dload TYPE string.
 
TYPES : BEGIN OF ty_kna1,      " structure
        kunnr TYPE kna1-kunnr,
        name1 TYPE kna1-name1,
        ort01 TYPE kna1-ort01,
        land1 TYPE kna1-land1,
        END OF ty_kna1.
 
DATA :  it_kna1 TYPE TABLE OF ty_kna1.  "body
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dload.
  PERFORM f_dload.
START-OF-SELECTION.
 
  PERFORM f_extract.
  PERFORM f_download.  " download file to presentation server
*&---------------------------------------------------------------------*
*&      Form  f_dload
*&---------------------------------------------------------------------*
FORM f_dload .
  CALL FUNCTION 'F4_FILENAME'
* EXPORTING
*   PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
    IMPORTING
      file_name           = p_dload
             .
 
ENDFORM.                    " f_dload
*&---------------------------------------------------------------------*
*&      Form  f_extract
*&---------------------------------------------------------------------*
FORM f_extract .
  SELECT kunnr
          name1
          ort01
          land1 FROM kna1 INTO TABLE it_kna1 .
ENDFORM.                    " f_extract
 
*&---------------------------------------------------------------------*
*&      Form  f_download
*&---------------------------------------------------------------------*
FORM f_download .
  w_dload = p_dload.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*   BIN_FILESIZE                    =
      filename                        = w_dload
   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                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
    TABLES
      data_tab                        = it_kna1
*   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.
ENDFORM.                    " f_download


With Regards..

Former Member
0 Kudos

Hi,

You can also use this FM to populate excell sheet 'XXL_SIMPLE_API'

Regards

Former Member
0 Kudos

HI

Thank you for your quick reponce.

any idea how we can Use OLE to do this Excel report.