Download Header details to Excel
Hi Experts,
Can we download header text to excel?
Regards
Mani
Hi Mani!
You need extract this message with FM READ_TEXT and FM GUI_DOWNLOAD.
Regards.
Similar Messages
-
Download header data to excell
Hi guru,
I am using gui_download for downloading header data to excell.The probleam i am facing that the field length(so many descriptions) exceeds more than 256 char. so iam unable to download some of data .I want it should display in one line in the excell.
pl..this is my below code.I am only getting up to length 256 char..only.
form DOWNLOAD_COSTS .
TYPES:
BEGIN OF ty_xlhead,
fld(1000) TYPE c, "For header name
END OF ty_xlhead.
DATA: l_name TYPE string.
l_type type char10.
l_name = wk_filename.
l_type = wk_filetype.
Data: l_filename TYPE string,
l_path TYPE string.
l_filename = space.
DATA:
it_xlhead TYPE STANDARD TABLE OF ty_xlhead,
wa_xlhead TYPE ty_xlhead.
data:x_type type string.
data:x_type1 type string.
data:w_type type string.
data:x_tab like table of x_type.
concatenate 'MATERIAL' 'DESCRIPTION' 'STATUS(1)' 'TOTAL COST(1)'
'MATERIAL(1)'
'SUB CONTRACT(1)'
'FREIGHT(1)'
'DUTY(1)'
'MATERIAL HANDLING(1)'
'VOLUME SUPPLY(1)'
'SLIT LOSS(1)'
'SCRAP(1)'
'DIRECT LABOR(1)'
'VARIABLE OVERHEAD(1)'
'FIXED OVERHEAD(1)'
'STATUS(2)'
'TOTAL COST(2)'
'MATERIAL(2)'
'SUB CONTRACT(2)'
'FREIGHT(2)'
'DUTY(2)'
'MATERIAL HANDLING(2)'
'VOLUME SUPPLY(2)'
'SLIT LOSS(2)'
'SCRAP(2)'
'DIRECT LABOR(2)'
'VARIABLE OVERHEAD(2)'
'FIXED OVERHEAD(2)'
into x_type separated by ' '.
*append x_type to x_tab.
CLEAR wa_xlhead.
wa_xlhead-fld = x_type.
APPEND wa_xlhead TO it_xlhead.
CLEAR wa_xlhead.
wa_xlhead-fld = x_type1.
APPEND wa_xlhead TO it_xlhead.
CALL method CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
exporting
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME = l_name
WITH_ENCODING =
FILE_FILTER =
INITIAL_DIRECTORY =
prompt_on_overwrite = 'X'
CHANGING
filename = l_filename
PATH = L_PATH
fullpath = l_name
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
cntl_error = 1
ERROR_NO_GUI = 2
not_supported_by_gui = 3
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.
CALL function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = l_name
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 = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
tables
data_tab = t_down
FIELDNAMES = it_xlhead[]
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.I think the only way to achieve this is via OLE (object link enabling).
Look at this:
[SAP OLE|http://help.sap.com/saphelp_nw70/helpdata/EN/59/ae3c98488f11d189490000e829fbbd/content.htm]
Edited by: Micky Oestreich on May 27, 2008 2:42 PM -
How can I download footer details along with report in excel
Hi,
I would like to download dashboard page Footer details (user details, report runtime info and page number are included in footer of dashboard page) as well along with my report, when I download into excel. How would I achieve this?
Please suggest!
Thanks,
SMAHi All…Thanks in Advance
I don’t understand why it's behaving so typically.
There are two things here
1. When I create a report from Answers and use the hand button (top most left) set all the details. Download then and there itself to excel it’s showing the user info even though there no such info shown with report in Answers, This is working fine.
2. However when I place the same report and enable the print, download links for the same report on dashboard page and when I try to download the report to excel it does not show me the user details even though after enabling the footer details using hand symbol of edit dashboard properties.
Here end user wants this functionality when ever he download’s the report from dashboard page (not the ad hoc report from Answers) user details should appear in his downloaded excel or something.
Reg
SMA -
Download header and date to excel
i have an alv report i want whwn i download my alv to excel with push button ( standard)
to get in the header of the excel HEADER an DATE
how???
thanks....check this
Excel to Internal Table and vice versa
Regards
Prabhu -
Color to the header of the excel sheet which is downloaded from report
Hi ,
According to my requirement i need to Color to the header of the excel sheet which was getting downloaded from the report output.For the downloading to the excel i am using "EXCEL_OLE_STANDARD_DAT" function module.In the report output color is getting displayed.
so suggest me how can i achieve this.
Thanks in Advance,
KiranmaiHello,
As far as I know, using EXCEL_OLE_STANDARD_DAT directly is not very flexible and it doesn't have any coloring options.
However, if you use OLE manually in your code, you can get color.. check this sample program
*& Report ZKRIS_OLE3_PALETTE
*& Displays the full OLE color range in excel
REPORT ZKRIS_OLE3_PALETTE.
TYPE-POOLS ole2 .
DATA: count TYPE i,
count_real TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA:
h_cell TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
h_int TYPE ole2_object,
h_width TYPE ole2_object,
h_columns TYPE ole2_object,
h_rows TYPE ole2_object,
h_font TYPE ole2_object,
h_entirecol TYPE ole2_object.
DATA: h_range TYPE ole2_object.
DATA: h_merge TYPE ole2_object.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
* creating workbook
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = 1.
SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
CALL METHOD OF sheet 'ACTIVATE'.
DATA: col TYPE i VALUE 1,
row TYPE i VALUE 2,
col1 TYPE i VALUE 2,
col_real TYPE i VALUE 1.
row = 1.
col = 3.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '2:2'.
SET PROPERTY OF h_rows 'WrapText' = 1.
col = 9.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'No.'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Background'.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
SET PROPERTY OF h_cell 'Bold' = 1.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
CALL METHOD OF excel 'Rows' = h_rows
EXPORTING
#1 = '1:1'.
SET PROPERTY OF h_rows 'WrapText' = 1.
GET PROPERTY OF h_rows 'Font' = h_font.
SET PROPERTY OF h_font 'Bold' = 1.
count = 1.
count_real = count.
row = 2.
col = 3.
DO 56 TIMES.
PERFORM write_num_and_color.
ENDDO.
* autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'C:L'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_entirecol 'Autofit' = 1.
* write palette on lhs
*range
CALL METHOD OF excel 'Range' = h_range
EXPORTING
#1 = 'A2'
#2 = 'A20'.
CALL METHOD OF h_range 'Merge' = h_merge .
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = 2
#2 = 1.
SET PROPERTY OF h_cell 'Value' = 'Palette'.
SET PROPERTY OF h_cell 'Orientation' = 90. "angled.
SET PROPERTY OF h_cell 'HorizontalAlignment' = 3. "center align
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'Bold' = 1. "bold
SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
SET PROPERTY OF h_f 'Size' = '14'.
SET PROPERTY OF h_cell 'VerticalAlignment' = 2. "center align
* autofit
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'A:A'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_columns 'ColumnWidth' = 4.
*& Form write_num_and_color
* text
FORM write_num_and_color.
index = row_max * ( row - 1 ) + col.
CALL METHOD OF sheet 'Cells' = cells
EXPORTING
#1 = index.
SET PROPERTY OF cells 'Value' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
col = col + 1.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = row
#2 = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = 1.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real.
row = row + 1.
col = col - 3.
count = count + 1.
IF count = 29.
count = 1.
row = 2.
col = col + 6.
ENDIF.
count_real = count_real + 1.
ENDFORM. "write_num_and_color -
I want to download a report into Excel sheet with color Heading..Is it Poss
Hi All
I want to download error records into Excel sheet with color Heading..Is it Possible to download into excel with Color Heading?
here i am <b>using the 3 sheets in one</b>
t_error-bkpf -> Sheet1
t_error-bseg-> sheet 2
t-error-bsec -> sheet3.
Rgds
Raghav<b>The following thread has the code which will put data into multiple sheets</b>
Download to multiple sheets in Excel
FOR COLOR LOGIC JUST REFER THIS PROGRAM
*& Report ZNEGI17 *
REPORT ZNEGI17 NO STANDARD PAGE HEADING.
* this report demonstrates how to send some ABAP data to an
* EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
* handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
H_MAPL TYPE OLE2_OBJECT, " list of workbooks
H_MAP TYPE OLE2_OBJECT, " workbook
H_ZL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
TABLES: SPFLI.
DATA H TYPE I.
* table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
*& Event START-OF-SELECTION
START-OF-SELECTION.
* read flights
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
* display header
ULINE (61).
WRITE: / SY-VLINE NO-GAP,
(3) 'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(4) 'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(8) 'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
ULINE /(61).
* display flights
LOOP AT IT_SPFLI.
WRITE: / SY-VLINE NO-GAP,
IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE /(61).
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-007
EXCEPTIONS
OTHERS = 1.
* start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
* PERFORM ERR_HDL.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
* CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:kis_excel.xls'
* PERFORM ERR_HDL.
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-008
EXCEPTIONS
OTHERS = 1.
* get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
* tell user what is going on
* CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
* EXPORTING
** PERCENTAGE = 0
* TEXT = TEXT-009
* EXCEPTIONS
* OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL1 USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL1 USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL1 USING 1 3 1 'Von'(003).
PERFORM FILL_CELL1 USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL1 USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
* changes by Kishore - start
* CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP EXPORTING #1 = 2.
PERFORM ERR_HDL.
* tell user what is going on
SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
* CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
* EXPORTING
** PERCENTAGE = 0
* TEXT = TEXT-009
* EXCEPTIONS
* OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL1 USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL1 USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL1 USING 1 3 1 'Von'(003).
PERFORM FILL_CELL1 USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL1 USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
* changes by Kishore - end
* disconnect from Excel
* CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'C:SKV.XLS'.
FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
* FORM FILL_CELL *
* sets cell at coordinates i,j to value val boldtype bold *
FORM FILL_CELL1 USING I J BOLD VAL.
data : color(5) type x value 'H80000008'.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'Bold' = BOLD .
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'ColorIndex' = 3 .
PERFORM ERR_HDL.
ENDFORM.
*& Form ERR_HDL
* outputs OLE error if any *
* --> p1 text
* <-- p2 text
FORM ERR_HDL.
IF SY-SUBRC <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
*& Form FILL_CELL1
* text
* -->P_H text
* -->P_1 text
* -->P_0 text
* -->P_IT_SPFLI_CARRID text
form FILL_CELL using I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
endform. " FILL_CELL1
kishan negi -
DOWNLOAD HEADER & ITEM RECORD INTO EXCEL FILE
I WANT TO KNOW THE LOGIC TO POPULATE HEADER DATA AND ITEM DATA INTO SAME INTERNAL TABLE AND AGAIN DOWNLOAD THE SAME TO EXCEL FILE .
Header structure : rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
Item structure : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Final internal table : Combination of these 2 fields. i need to populate these and download.Hi,
fill at first your ITAB with header-date and append it. Then append your items.
Do not SORT after appending.
Regards Mario -
Download ALV output to excel with formatting
Hi All,
i want to download ALV output to excel sheet and the uneditable fields in ALV oputput should be locked (uneditable) in excel also.
Can you please tell me approach to achieve this functionality?
Thanks in advance.Thanks Vamsi. Your Suggestion was helpful.
I have used excel integration and used SET PROPERTY OF (COLUMN) 'LOCKED' = 1.
For more details refer below mentioned link.
http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B(Password%2Bprotected)%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in (http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B%28Password%2Bprotected%29%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in -
Download to multiple sheet excel in the background
Hi,
I am trying to download data into multiple excel sheets in the background. I was able to create comma delimited csv file in the server, which can be opened as excel file. This is good when it does not have more that one worksheets.
I have three internal table and to send these internal tables in different worksheets in the same excel file.
Is it possible to have multiple sheets excel file from the csv file?
Thanks,
LokmanHi Lokman,
<b>1</b>.
Yes it is Possible.
<b>2</b>.
Am sending one example program .That is clear to understand .
REPORT zvenkat_head MESSAGE-ID zvenkat .
INCLUDE ole2incl. " Include for OLE object
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object,
h_f TYPE ole2_object. " font
*Structure for users deleted
DATA: BEGIN OF itab_yb001_udel OCCURS 0,
bname LIKE yb001-bname,
name_text LIKE addr3_val-name_text,
END OF itab_yb001_udel.
DATA: BEGIN OF itab_yb001_tadd OCCURS 0.
INCLUDE STRUCTURE yb001.
DATA: name_text LIKE addr3_val-name_text,
ttext LIKE tstct-ttext.
DATA: END OF itab_yb001_tadd.
*Structure for Transactions deleted
DATA: BEGIN OF itab_yb001_tdel OCCURS 0.
INCLUDE STRUCTURE yb001.
DATA: name_text LIKE addr3_val-name_text,
ttext LIKE tstct-ttext.
DATA: END OF itab_yb001_tdel.
DATA: BEGIN OF itab_yb001_uadd OCCURS 0,
bname LIKE yb001-bname,
name_text LIKE addr3_val-name_text,
END OF itab_yb001_uadd.
PARAMETERS: p_fname LIKE rlgrap-filename. " File name to download
PERFORM download_file.
FORM - DOWNLOAD_FILE
FORM download_file.
DATA index TYPE i.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 0.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
CALL METHOD OF application 'Worksheets' = sheet.
CALL METHOD OF sheet 'Add'.
Create 1 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 1.
SET PROPERTY OF sheet 'Name' = 'Transactions Added'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_theader.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m03
EXCEPTIONS
OTHERS = 1.
LOOP AT itab_yb001_tadd.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_tadd-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_tadd-tcode.
PERFORM fill_cell USING index 3 0 itab_yb001_tadd-name_text.
PERFORM fill_cell USING index 4 0 itab_yb001_tadd-ttext.
PERFORM fill_cell USING index 5 0 itab_yb001_tadd-agr_name.
ENDLOOP.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m03
EXCEPTIONS
OTHERS = 1.
Create 2 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 2.
SET PROPERTY OF sheet 'Name' = 'Transactions Deleted'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_theader.
LOOP AT itab_yb001_tdel.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_tdel-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_tdel-tcode.
PERFORM fill_cell USING index 3 0 itab_yb001_tdel-name_text.
PERFORM fill_cell USING index 4 0 itab_yb001_tdel-ttext.
PERFORM fill_cell USING index 5 0 itab_yb001_tdel-agr_name.
ENDLOOP.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m04
EXCEPTIONS
OTHERS = 1.
Create 3 Excel Sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 3.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Users Added'.
PERFORM f_xl_uheader.
LOOP AT itab_yb001_uadd.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_uadd-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_uadd-name_text.
ENDLOOP.
Create 4 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 4.
SET PROPERTY OF sheet 'Name' = 'Users Deleted'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_uheader.
LOOP AT itab_yb001_udel.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_udel-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_udel-name_text.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = p_fname "filename
#2 = 1. "fileFormat
PERFORM err_hdl.
Closes excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0.
Close the file
CALL METHOD OF workbook 'CLOSE'.
Quit the file
CALL METHOD OF application 'QUIT'.
FREE OBJECT application.
ENDFORM. "DOWNLOAD_FILE
*& Form F_XL_THEADER
Header for XL sheet
--> p1 text
<-- p2 text
FORM f_xl_theader .
output column headings to active Excel sheet
PERFORM fill_cell USING 1 1 1 text-t01.
PERFORM fill_cell USING 1 2 1 text-t02.
PERFORM fill_cell USING 1 3 1 text-t03.
PERFORM fill_cell USING 1 4 1 text-t04.
PERFORM fill_cell USING 1 5 1 text-t05.
ENDFORM. " F_XL_THEADER
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
FORM fill_cell USING i j bold val.
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = i #2 = j.
PERFORM err_hdl.
SET PROPERTY OF cells 'Value' = val .
PERFORM err_hdl.
GET PROPERTY OF cells 'Font' = h_f.
PERFORM err_hdl.
SET PROPERTY OF h_f 'Bold' = bold .
PERFORM err_hdl.
ENDFORM. "FILL_CELL
outputs OLE error if any *
--> p1 text
<-- p2 text
FORM err_hdl.
IF sy-subrc <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), sy-subrc.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
Header for XL sheet
--> p1 text
<-- p2 text
FORM f_xl_uheader .
PERFORM fill_cell USING 1 1 1 text-t01.
PERFORM fill_cell USING 1 2 1 text-t03.
ENDFORM. " F_XL_UHEADER
Please try to understand first and replicate to ur requirement.
Please let me know if u have any problem.
<b>Thanks,
Venkat.O</b> -
How to download customer hierarchy in Excel sheet?
Hi,
Good day.
I was able to display the customer hierarchy via transaction VDH2N however, I would also like to download and save this hierarchies in Excel but there was no such option in that transaction. Can anyone tell me how and where I can download the customer hierarchy, please? I wanted to downloaded exact details found in VDH2N. Please help.
Thank you and have a good day.
Kindest regards,
LemilyHi Saurabh,
Thanks for your immediate reply. The issue I have with SE16N is that it did not generate all complete and exact details for customer hierarchy that is found in transaction VDH2N. In VDH2N, I can see that there are 3 levels and other sub levels. But when I tried to use SE16N, it did not capture all levels, especially the sub levels. And I wanted to download or export all customer level that is found in VDH2N but this is not possible in SE16N.
Thank you and have a nice day.
Kindest regards,
Lemily -
Regarding Download data in MS Excel format and Check box
Hi Friends
In my Project some task is here i.e. select check box of the particular Customer number click on submit button. That time display of those customer details
How we can do this if have any coding of this application can you sent me.
And one more query
One form having some data click on submit button that data will display in Excel format and Download data in MS Excel format
Can you tell me how to work on these two concepts?
Regards
VijayDear Vijay,
Please go through the [Download data in MS Excel format|http://wiki.sdn.sap.com/wiki/display/WDJava/ExporttoExcel(WithoutthirdpartyAPIs)]
to download the table contents to MS Exel.
& Also go through [How to Add Dynamic Checkboxes in a Web Dynpro Java |http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90915916-c158-2c10-6fa0-f0e25f3ccd6b?quicklink=index&overridelayout=true] for check bok UI.
Warm Regards,
Upendra Agrawal -
Download SAP data to Excel file in Presentation server
Hi gurus,
I need to download SAP data to excel file. for that im using SAP_CONVERT_TO_XLS_FORMAT function module. I have to download with column header and also date should be in YYMMDD format. Im changing the format in ITAB but when populating to excel leading zero's were removed.(EX. 12102007 is converted to 071012 and it was populated as 71012). can someone explain how to use this function module or give someother solution for this....And if possible explain the parameters of the function module SAP_CONVERT_TO_XLS_FORMAT. Is there any function module for converting date as required format?
Thanks,
AmalHi Amal...
The Problem you are facing is because of Display properties of Microsoft Excel itself. I believe this can not be solver with in SAP. Instead I would suggest you to go for a .csv format. which can also be viewed in Excel.
In any case if you get to find a different solution for this, I would appriciate if you can share it with me :).
Santosh -
Downloading Prompt parameters to Excel
Hello,
I have dashboard prompt and a Table view in my report. I would like to download the report to EXCEL which includes Table data and Selected prompt parameters by the user.
I tried to use Filter View, but it is giving me all the filters applied in the report, not only the ones selected in the prompts. But, I need only the Prompt filters selected by the user !!
Please Suggest !!only workaround is to save the report filters as a separaet filer with simple name:
for e.g. column1 = 1 and column2 = 'xyz' and column3 = '123abc'
save above set as separate filter say Otherfilers and then apply to the report.
*use reference while applying filter and not contents so that the name of the filter appears instead of the details. -
Downloading records in in excel sheet from ALV.
Hi,
I am downloading Records from ALV GRID DIsplay to Excel sheet but i am unable to get all records that are displayed in ALV report.
I am getting only 73 records if i have only 180
Any inputs please for correctine the error
Regards
Rasheed.hi
you can follow these stapes and get ur work done
go to List > select Export > Spreadsheet or just click the excel icon from the tool bar.This would download the data to excel.
hope this helps
regards
Aakash Banga -
Download from ALV to excel sheet.
When i am downloading the Alv to excel sheet. I want to get the field descritption also in the excel sheet.
Refer:
https://forums.sdn.sap.com/click.jspa?searchID=14433981&messageID=3603627
Maybe you are looking for
-
Manually adjusted G/L and Material values in MIRO document
Dear All, Can you please help me get the logic of capturing data from RBCO and RBMA for manually adjusted entries. I have a Purchase Register, which is completely based on the MIRO documents. The values are picked up from RSEG and RBKP. Header-wise a
-
How do i see which parameters are being passed to wwv_flow.accept?
Greetings everyone, After submiting a page i get this error: "The requested URL /pls/apex/wwv_flow.accept was not found on this server." I placed some inserts inside my page process to check and i found out the process isn t even being executed. This
-
How in the HECK can I change my Hard Drive icon??!??!!
I've tried searching these discussion forums for how to do this, but the question has always remained unanswered! Does ANYbody know how to use this? I'd buy applecare but I'm a student and can't afford it. Would somebody please figure out how to make
-
[2.2.4] WIF KB Versions does not agree with current KB Version 3.05. WS KNOX6860 will not be loaded I just loaded Zen 7 SP1 IR14 and hoping to fix it and its still happening.
-
Any free ipad app,so that I can open my Microsoft Word documents
Any free ipad app,so that I can open my Microsoft Word documents