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: 

ALV to Excel

Former Member
0 Kudos

i have written a program,

the output is an ALV,now i want the ALV and also an excel file in the same report.

how i can achieve this.

is there any function module which will convert all the ALV data to excel.

10 REPLIES 10

gopi_narendra
Active Contributor
0 Kudos

Follow the path

System --> List --> Save --> Local File --> Spread Sheet

And give the path where you want to save this, and press Transfer

Regards

Gopi

0 Kudos

i dont want to export.

in the program,i want to code in such a way that i want ALV and excel file as the output simultaneously.

0 Kudos

hi,

what u want?

data should b saved in excel or it should open?

0 Kudos

i want the data in excel and in ALV,not by doing exporting to excel.

i want this to be generated from excel.

0 Kudos

Use the FM - ALV_XXL_CALL. here is the sample -


REPORT  ZSKC_ALV_XXL.

TYPE-POOLS : KKBLO.

DATA : ITAB LIKE T100 OCCURS 0,
       T_FCAT_LVC TYPE LVC_S_FCAT OCCURS 0 WITH HEADER LINE,
       T_FCAT_KKB TYPE KKBLO_T_FIELDCAT.


START-OF-SELECTION.

* Get data.
  SELECT * UP TO 20 ROWS
  FROM   T100
  INTO   TABLE ITAB
  WHERE  SPRSL = SY-LANGU.

  CHECK SY-SUBRC EQ 0.

* Create the field catalog.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
   EXPORTING
      I_STRUCTURE_NAME             = 'T100'
    CHANGING
      CT_FIELDCAT                  = T_FCAT_LVC[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3.

  CHECK SY-SUBRC EQ 0.
* make sure you pass the correct internal table name in the field catalog.
  t_fcat_lvC-tabname = 'ITAB'.
  MODIFY T_FCAT_LVC TRANSPORTING TABNAME WHERE TABNAME NE SPACE.

* Transfer to KKBLO format.
  CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
    EXPORTING
      IT_FIELDCAT_LVC                 = T_FCAT_LVC[]
    IMPORTING
      ET_FIELDCAT_KKBLO               = T_FCAT_KKB
   EXCEPTIONS
     IT_DATA_MISSING                 = 1
     IT_FIELDCAT_LVC_MISSING         = 2
     OTHERS                          = 3.

  CHECK SY-SUBRC EQ 0.

* Call XXL.
  CALL FUNCTION 'ALV_XXL_CALL'
    EXPORTING
      I_TABNAME                    = 'ITAB'
      IT_FIELDCAT                  = T_FCAT_KKB
    TABLES
      IT_OUTTAB                    = ITAB[]
    EXCEPTIONS
      FATAL_ERROR                  = 1
      NO_DISPLAY_POSSIBLE          = 2
      OTHERS                       = 3.

  IF SY-SUBRC <> 0.
  ENDIF.

Hope it helps.

Former Member
0 Kudos

Hi Prashant ,

In the tool bar provided by ALV there is an optin to down load the ALV which provides this option of downloading the ALV to excel.

Regards

Arun

Former Member
0 Kudos

Hi,

yes you can send the alv output to anykind of format as per your requirement.

use this function module

XXL_FULL_API

Regards,

Pritha.

Former Member
0 Kudos

hi,

use

<b>LIST_DOWNLOAD</b>

CALL FUNCTION 'LIST_DOWNLOAD'

EXPORTING

LIST_INDEX = sy-lsind

METHOD = 'NOCO'

  • EXCEPTIONS

  • LIST_DOWNLOAD_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

RTF - Save in rich text format

DAT - Save as spreadsheet

NOCO - Save without converting

Hope it will helpful to u.

0 Kudos

do i need to use the function module in the same program.

Former Member
0 Kudos

thanks