How to export table values to excel in WebDynpro

Create a button named ‘Export to excel’.

Define an action to your button.

clip_image001

Result:

clip_image003.jpg

clip_image005

Click here to see full code.

How to upload an excel file into SAP internal tables

Excel file

 1

Selection-Screen

 

Parameter to get excel file destination.

 2

Result:

 3

 

Codes:

 

** Job: Upload from excel into internal table..

report  zfile_upload_from_excel.

type-pools truxs.

parameter p_excel type rlgrapfilename

               default ‘C:\EXCEL_EXAMPLE.xls’

            obligatory.

* Excel Structure

typesbegin of itab,

       val1 type string,

       val2 type string,

       val3 type string,

       end of itab.

data lt_itab type standard table of itab,

       ls_itab type itab,

       it_type type truxs_t_text_data.

* Getting Excel File Destination

at selection-screen 

   on value-request for p_excel.

call function ‘F4_FILENAME’

 exporting

  field_name    ‘P_EXCEL’

 importing

  file_name     p_excel.

start-of-selection.

* Converting Excel File

call function ‘TEXT_CONVERT_XLS_TO_SAP’

 exporting

  i_tab_raw_data       it_type

  i_filename           p_excel

 tables

  i_tab_converted_data lt_itab[].

end-of-selection.

loop at lt_itab into ls_itab.

  write:/ ls_itabval1.

  write space.

  write ls_itabval2.

  write space.

  write ls_itabval3.

endloop.

How to make an multi-sheet excel file with SAP ABAP

Result:

 

Two sheets excel example.

Sheet1.

1

Sheet2.

2

Codes:

report  zanil.

*** Job: OLE Excel from SAP

***      with two sheets

**  Include objects

includeole2incl.

**  Table definitions

tables:  m_mbmps,

         zperlist1,

         zperlist2.

** Macro Definition

define ole_check_error.

  if &1 ne 0.

    message e000 with &1.

    exit.

  endif.

endofdefinition.

endif.

call method of h_excel  ‘Workbooks’ h_mapl.


Click here for the full code


Program to view user roles and transaction on ALV and Excel

Selection-Screen

 selection-screen

 

Codes:

 

report  zanil.

* Job: User Roles and Role Assignees

*      report in ALV and EXCEL format

typepoolsslis.

tablesagr_users,

        usr21,

        usr02,

        adrp,

        indx.

* ALV Data

data gls_grid_header type slis_t_listheader

       with header line,

       gls_events      type slis_t_event,

       gs_fieldcat_t   type slis_t_fieldcat_alv,

       gs_fieldcat_wa  type slis_fieldcat_alv,

       gs_layout       type slis_layout_alv.

* General User Info Table

data begin of uinfo occurs 100,

 bname      like usr21bname,

 persnumber like usr21persnumber,

 addrnumber like usr21addrnumber,

 name_first like adrpname_first,

 name_last  like adrpname_last,

end of uinfo


Click here to download full code