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: 

Regarding downlaod the output from ALV grid format

Former Member
0 Kudos
160

Hi

i want to download the output ALV grid format into excel sheet .

but condition is when ever user press the button (&ZDL) the should be downloaded.

and also how to convert the output into CSV format.

2 REPLIES 2

former_member181962
Active Contributor
0 Kudos
57

The download feature is already available in the ALV grid application tool bar.

Upon clicking this button, the data will be downloaded in the format you want.

Once the data is downloaded, you can convert the file into whatever type you like.

Regards,

Ravi

Former Member
0 Kudos
57

hi,

when '&ZDL'.

use this condition

check this one for down loading

try to download an ALV report in excel format using (list ->export -> local file-> soread sheet )

hi this is full program

REPORT ZCR_BOMPLANT_DOWNLOAD.

TABLES : MAST , "Material to BOM Link

STKO , "BOM Header

MARA . "General Material Data

TYPES : BEGIN OF TY_MASTER ,

MATNR TYPE MAST-MATNR , "Material Number

WERKS TYPE MAST-WERKS , "Plant

STLAN TYPE MAST-STLAN , "BOM Usage

STLNR TYPE MAST-STLNR , "Bill of material

STLAL TYPE MAST-STLAL , "Alternative BOM

ANDAT TYPE MAST-ANDAT , "Date record created on

AEDAT TYPE MAST-AEDAT , "Date of Last Change

AENAM TYPE MAST-AENAM , "Name of Person Who Changed Object

STLST TYPE STKO-STLST , "BOM status

ZPLP1 TYPE MBEW-ZPLP1 , "Future Planned Price 1

DWERK TYPE MVKE-DWERK , "Delivering Plant (Own or External)

END OF TY_MASTER .

*

TYPES : MY_TYPE(20) TYPE C.

DATA : IT_MASTER TYPE STANDARD TABLE OF TY_MASTER,

WA_MASTER TYPE TY_MASTER .

*

DATA : IT_HEADER TYPE TABLE OF MY_TYPE.

DATA : W_PTH TYPE RLGRAP-FILENAME.

DATA : W_FILE TYPE RLGRAP-FILENAME.

*--- Add Header Fields to Header Table ---

APPEND 'Material Number' TO IT_HEADER .

APPEND 'Plant' TO IT_HEADER .

APPEND 'BOM Usage' TO IT_HEADER .

APPEND 'Bill Code' TO IT_HEADER .

APPEND 'Alternative BOM' TO IT_HEADER .

APPEND 'Created On' TO IT_HEADER .

APPEND 'Changed On' TO IT_HEADER .

APPEND 'Changed By' TO IT_HEADER .

APPEND 'BOM Status' TO IT_HEADER .

APPEND 'Planned Price' TO IT_HEADER .

APPEND 'Delivery Plant' TO IT_HEADER .

*

IF SY-MANDT = '700'.

W_PTH = '
lkdb01\ISD\IS\Software Developments\Developments\Data Files\SAP Dumps\BOM_Available\'.

ELSE.

W_PTH = 'C:\'.

ENDIF.

START-OF-SELECTION.

*

*--- Load Data to Internal Table ---

*

  • SELECT MASTMATNR MASTWERKS MASTSTLAN MASTSTLNR MASTSTLAL MASTANDAT MASTAEDAT MASTAENAM STKO~STLST

  • INTO TABLE IT_MASTER

  • FROM MAST

  • INNER JOIN STKO ON STKOSTLNR EQ MASTSTLNR

  • AND STKOSTLAL EQ MASTSTLAL

  • INNER JOIN MARA ON MARAMATNR EQ MASTMATNR

  • WHERE MARA~MTART LIKE 'ZFG%'

  • AND STKO~LKENZ NE 'X'

  • AND STKO~LOEKZ NE 'X'

  • AND STKO~STLST EQ '1'.

SELECT MAST~MATNR MAST~WERKS MAST~STLAN MAST~STLNR MAST~STLAL MAST~ANDAT MAST~AEDAT MAST~AENAM STKO~STLST MBEW~ZPLP1 MVKE~DWERK

INTO TABLE IT_MASTER

FROM MAST

INNER JOIN STKO ON STKO~STLNR EQ MAST~STLNR

AND STKO~STLAL EQ MAST~STLAL

INNER JOIN MARA ON MARA~MATNR EQ MAST~MATNR

INNER JOIN MBEW ON MBEW~MATNR EQ MAST~MATNR

AND MBEW~BWKEY EQ MAST~WERKS

INNER JOIN MVKE ON MVKE~MATNR EQ MAST~MATNR

WHERE MARA~MTART LIKE 'ZFG%'

AND STKO~LKENZ NE 'X'

AND STKO~LOEKZ NE 'X'

AND STKO~STLST EQ '1'.

IF SY-SUBRC <> 0.

MESSAGE I014(ZLOAD).

ENDIF.

*

*--- Set Path to Function Module ---

*

CONCATENATE W_PTH SY-DATUM ' - ' 'BOM_AVAILABLE_PLANT.XLS' INTO W_FILE.

*

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = W_FILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = IT_MASTER

FIELDNAMES = IT_HEADER

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_EIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

*

IF SY-SUBRC = 0.

SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.

MESSAGE I023(ZLOAD) WITH text-001.

ELSE.

MESSAGE I022(ZLOAD) WITH W_FILE. "Errors while downloading.

ENDIF.

END-OF-SELECTION.

SUBMIT ZI005_MARA_DUMP_SOLIDEAL_N.