Downloading a file to excel sheet
To all forum people
While I download an internal table into an excel-sheet I would like to place a field name in the excel-sheet corresponding to each field in my internal table so how could this be done are there any function modules pertaining to this issue or is there any other method to do this.....
murali
Hi
The following is a sample code download to EXCEL file
REPORT Sample
NO STANDARD PAGE HEADING
LINE-SIZE 180
LINE-
COUNT 90 0001-
LINE-COUNT 65 "0001+
MESSAGE-ID z1.
TABLES: MARC.
DATA : BEGIN OF i_marc OCCURS 0,
matnr LIKE marc-matnr, "Material
werks LIKE marc-werks, "Plant
mmsta LIKE marc-mmsta, "MM/PP Status
ekgrp LIKE marc-ekgrp, "Purchasing Group
dispo LIKE marc-dispo, "MRP Controller
plifz LIKE marc-plifz, "PDT (Planned Dlv Time)
webaz LIKE marc-webaz, "GRT (Goods Receipt Time)
fevor LIKE marc-fevor, "Production Scheduler
insmk LIKE marc-insmk, "Post to Inspection Stock
ladgr LIKE marc-ladgr, "Loading Group
kautb LIKE marc-kautb, "Automatic PO Allowed
kordb LIKE marc-kordb, "Source List
prctr LIKE marc-prctr, "Profit Center
lgpro LIKE marc-lgpro, "Issue Storage Location
abcin LIKE marc-abcin, "Cycle Count Phys Inventory Ind
sernp LIKE marc-sernp, "Serial Number Profile
lgfsb LIKE marc-lgfsb, "Stor Loc for External Procure
END OF i_marc.
STRUCTURES DECLARATION
DATA: BEGIN OF wf_msg.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF wf_msg.
DATA : BEGIN OF rec_marc,
matnr(18),
z_delim1(1),
werks(4),
z_delim2(1),
mmsta(2),
z_delim3(1),
ekgrp(3),
z_delim4(1),
dispo(3),
z_delim5(1),
plifz(3),
z_delim6(1),
webaz(3),
z_delim7(1),
fevor(3),
z_delim8(1),
insmk(1),
z_delim9(1),
ladgr(4),
z_delim10(1),
kautb(1),
z_delim11(1),
kordb(1),
z_delim12(1),
prctr(10),
z_delim13(1),
lgpro(4),
z_delim14(1),
abcin(1),
z_delim15(1),
sernp(4),
z_delim16(1),
lgfsb(4),
z_delim17(1),
END OF rec_marc.
VARIABLES DECLARATION
DATA: w_lines like sy-tabix,
w_records like sy-tabix.
****DELIMETERS DECLARATION
DATA: p_del type c value ',', "delimeter
p_del1 type c value ';'. "delimeter
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_matnr FOR marc-matnr,
s_werks FOR marc-werks,
s_mmsta FOR marc-mmsta,
s_ekgrp FOR marc-ekgrp,
s_dispo FOR marc-dispo,
s_plifz FOR marc-plifz,
s_webaz FOR marc-webaz,
s_fevor FOR marc-fevor,
s_insmk FOR marc-insmk,
s_ladgr FOR marc-ladgr,
s_kautb FOR marc-kautb,
s_kordb FOR marc-kordb,
s_prctr FOR marc-prctr,
s_lgpro FOR marc-lgpro,
s_abcin FOR marc-abcin,
s_sernp FOR marc-sernp,
s_lgfsb FOR marc-lgfsb.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION SCREEN FOR DOWN LOAD OPTION
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
PARAMETERS:
r_list radiobutton group a1,
p_del default ',', "delimeter
DATA: p_filePC TYPE rlgrap-filename value 'C:\zmarc.xls',
typ TYPE rlgrap-filetype value 'DAT',
fname TYPE rlgrap-filename,
ftype TYPE rlgrap-filetype,
fsize TYPE i.
SELECTION-SCREEN END OF BLOCK blk2.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION
END-OF-SELECTION.
if r_list = 'X'.
PERFORM output_list.
elseif r_dldPC = 'X'.
PERFORM download_file_PC.
endif.
*& Form get_data
Get data from table MARC
FORM get_data.
CLEAR: i_marc. REFRESH: i_marc.
SELECT matnr
werks
mmsta
ekgrp
dispo
plifz
webaz
fevor
insmk
ladgr
kautb
kordb
prctr
lgpro
abcin
sernp
lgfsb
INTO TABLE i_marc
FROM marc
WHERE matnr IN s_matnr
AND werks IN s_werks
AND mmsta IN s_mmsta
AND ekgrp IN s_ekgrp
AND dispo IN s_dispo
AND plifz IN s_plifz
AND webaz IN s_webaz
AND fevor IN s_fevor
AND insmk IN s_insmk
AND ladgr IN s_ladgr
AND kautb IN s_kautb
AND kordb IN s_kordb
AND prctr IN s_prctr
AND lgpro IN s_lgpro
AND abcin IN s_abcin
AND sernp IN s_sernp
AND lgfsb IN s_lgfsb.
ENDFORM. " get_data
*& Form output_list
Output List with Column Headings
FORM output_list.
CLEAR: w_lines.
DESCRIBE TABLE i_marc LINES w_lines.
if w_lines gt 0.
ULINE.
WRITE:/28 'MM/PP',
38 'MRP',
48 'Prod',
58 'Purch',
68 'Profit',
80 'Planned',
92 'GR',
100 'Post to',
114 'Auto',
122 'Source',
132 'Issue',
140 'CC Phys',
150 'Loading',
160 'Serial No',
172 'SLoc'.
WRITE:/1 'Material',
20 'Plant',
28 'Status',
38 'Ctrlr',
48 'Sched',
58 'Grp',
68 'Ctr',
80 'Dlv. Time',
92 'Time',
100 'Insp. Stock',
114 'PO',
122 'List',
132 'SLoc',
140 'Indicator',
150 'Group',
160 'Profile',
172 'for EP'.
ULINE.
LOOP AT i_marc.
WRITE:/ i_marc-matnr,
20 i_marc-werks.
set left scroll-boundary." Added to keep the left 2 columns fixed
while viewing the list online
WRITE:28 i_marc-mmsta,
38 i_marc-dispo,
48 i_marc-fevor,
58 i_marc-ekgrp,
68 i_marc-prctr,
80 i_marc-plifz,
92 i_marc-webaz,
100 i_marc-insmk,
114 i_marc-kautb,
122 i_marc-kordb,
132 i_marc-lgpro,
140 i_marc-abcin,
150 i_marc-ladgr,
160 i_marc-sernp,
172 i_marc-lgfsb.
ENDLOOP.
ULINE.
endif.
ENDFORM. " output_list
*& Form download_file_PC
Download file to Local directory on PC
FORM download_file_PC.
CLEAR: w_lines, w_records.
DESCRIBE TABLE i_marc LINES w_lines.
if w_lines gt 0.
Download file
PERFORM open_file using p_filePC.
PERFORM output_file_PC.
PERFORM close_file using p_filePC.
PERFORM write_summary.
endif.
ENDFORM. " download_file_PC
*& Form write_summary
FORM write_summary.
write : / '******************************************************'.
write : / '**** PROGRAM IS ENDED SUCCESSFULLY **'.0001-
write : / '**** PROGRAM HAS ENDED SUCCESSFULLY *****'."0001+
write : / '******************************************************'.
skip.
write : / 'No. of recds written :', 38 w_records.
skip.
if r_dldUx = 'X'.
write : / 'Output file name : ' , p_fileUX.
elseif r_dldPC = 'X'.
write : / 'Output file name : ' , p_filePC.
endif.
skip.
write : / '******************************************************'.
ENDFORM. " write_summary
*& Form open_file
text
-->P_P_FILEUX text
FORM open_file USING output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE.
if sy-subrc <> 0.
Send technical message
CLEAR wf_msg.
wf_msg-msgid = 'ZB'.
wf_msg-msgnr = '003'.
wf_msg-msgtyp = 'E'.
wf_msg-msgv1 = output_file.
CALL FUNCTION 'Z_ERROR'
EXPORTING
msg = wf_msg
pid = sy-cprog
EXCEPTIONS
others = 1.
endif.
ENDFORM. " open_file
*& Form close_file
Close File
FORM close_file USING output_file.
close dataset output_file.
if sy-subrc <> 0.
Send technical message
clear wf_msg.
wf_msg-msgid = 'Z3'.
wf_msg-msgnr = '003'.
wf_msg-msgtyp = 'E'.
wf_msg-msgv1 = output_file.
call function 'Z_ERROR'
EXPORTING
msg = wf_msg
pid = sy-cprog
EXCEPTIONS
others = 1.
endif.
ENDFORM. " close_file
*& Form output_file_PC
Write Data to Local PC File
FORM output_file_PC.
DATA: BEGIN OF i_PCFile OCCURS 0,
rec(2000) TYPE C,
END OF i_PCFile.
data: dload_record(1000).
DATA: flength TYPE i.
Transfer Header Line
clear: dload_record.
concatenate 'Material' 'Plant' 'MM/PP Status' 'Purch Grp.' 'MRP Ctrl.'
'Planned Dlv. Time' 'GR Time' 'Prod Sched'
'Post to Insp. Stock''Loading Group''Auto PO'
'Source List''Profit Ctr.' 'Issue SLoc''CC Phys Indicator'
'Serial No Profile' 'SLoc for EP'
into dload_record
separated by p_del.
condense dload_record no-gaps.
i_PCFile-rec = dload_record.
append i_PCFile.
clear i_PCFile.
Transfer Data
loop at i_marc.
w_records = w_records + 1.
clear: rec_marc, dload_record.
move-corresponding i_marc to rec_marc.
move p_del to: rec_marc-z_delim1, rec_marc-z_delim2,
rec_marc-z_delim3, rec_marc-z_delim4,
rec_marc-z_delim5, rec_marc-z_delim6,
rec_marc-z_delim7, rec_marc-z_delim8,
rec_marc-z_delim9, rec_marc-z_delim10,
rec_marc-z_delim11,rec_marc-z_delim12,
rec_marc-z_delim13,rec_marc-z_delim14,
rec_marc-z_delim15,rec_marc-z_delim16,
rec_marc-z_delim17.
move rec_marc to dload_record.
condense dload_record no-gaps.
i_PCFile-rec = dload_record.
append i_PCFile.
clear i_PCFile.
endloop.
IF p_filePC NE SPACE.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_filePC
filetype = typ
IMPORTING
act_filename = fname
act_filetype = ftype
filesize = fsize
TABLES
data_tab = i_PCFile
EXCEPTIONS
invalid_filesize = 1
invalid_table_width = 2.
IF SY-SUBRC NE 0.
WRITE 'File can not be opened'.
ENDIF.
Begin 0001+
Set PC Filename to whatever is returned from the Function Module, to
display later
p_filePC = fname.
End 0001+
ELSE.
WRITE:/ 'Please Enter File Name'.
ENDIF.
ENDFORM. " output_file_PC
if it helps please reward points
Regards
Prabhakar
Similar Messages
-
Downloading table data into Excel sheet - Webdynpro Java
Hi All,
We have developed a custom webdynpro application that executes an RFC and displays data in Table UI element. We have provided a button to download the data in excel sheet. When data is huge like, total number of rows filled up in the table are around 11,000 & columns are 32, and when user tries to download whole 11000 rows in excel sheet, the timeout occurs after 20 mins due to huge data. But when I apply filtering on the same table data and then try to download some 700 rows out of 11000 into excel, it took me around 3.36 mins.
If anyone encountered such scenario in past, please guide in this regard to speed-up the download to excel functionality or suggest any other alternative.
We are using 7.3 Portal and tableUtilities java class for export to excel functionality.
Thanks,
Amol.hi monica ,
sorry im not able to understand properly ,
The server don't restarts automatically when we uploading a huge data, onlly we open the file instead of save the file.
If we save the file the problem is that when we try to open this, the process can take hours and sometimes excel is blocked
you mean that after saving the file to your desktop , having huge data you are not able to open the file i.e the excel file. your file gets blocked or consumes more time to open the file ,
or else when you are prompted for saving or opening , on click of opening you are facing the problem ?
let me be clear with your part , here your application deals with uploading the data from webdynpro table to excel sheet and allowing the end user to save or open the file right .
Regards
Govardan Raj S -
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 -
Application Server file into EXCEL SHEET
Hi ,
i want down load the Application Server FILE into EXCEL SHEET directly..
how to do this one.
regards,
venu.Hi Srinivas
I tried using CG3Z to upload excel onto application server but failed to do the same,
Any pointers regarding the same would be of great help.
Regards
Sukumari
Edited by: Manjeera Chinigiri on Mar 31, 2008 3:08 PM -
Dump in prodcution server while downloading ALV report to excel sheet
HI ALL,
ALV report is working fine in bother DEV and PROD servers....but in production while downloading report to excel sheet it is going to dump.
"dump is below:
Short text
Field symbol has not yet been assigned.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLKKBL" had to be terminated because it has
come across a statement that unfortunately cannot be executed. "
But in development this problem is not there, iam able to download ALV report to EXCEL sheet.
Any help experts......
Thanks in advance
RamHi,
I had the same problem,
Run a consistency check for your ALV and you will find out. See if you havent passed any unnecessary parameter to FM.
/people/rainer.hbenthal/blog/2009/09/25/sos--my-alv-report-is-not-working
Dump while printing ALV (field symbol not assigned)
Sumit -
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 -
Error while downloading Report as an Excel Sheet
Hi All,
I have a issue regarding enabling download of report as a excel sheet. Here is the summary of the issue I am facing.
I have enabled report links in the Dashboard and saved the Dashboard. The download link is visible and when I click on the link
it gives the option of excel and pop up window starts showing that the download has started. But midway it says the application URL is unavailable.
My query is are there any server settings which we need to enable or add to allow the download of reports are excel sheets.
The download to excel works fine in Firefox.
The problem is with MIME type which is .mhtml in IE browser.
Our Instance is SSO wired.
If we remove the SSO, download to excel works fine in both IE and Firefox.
Any inputs on this?
Regards
(S.Prashant)
Edited by: user783550 on Sep 15, 2009 11:11 PMthis issue is related to the web server hosting sso. i had posted the same question on this forum, hope it will help you as well - Download to excel issue
-
How to download internal table to excel sheet
I have a requirement to download nearly 8 to 10 internal tables to excel sheets(for each internal table one excel sheet) without displaying the diolog box showing open and save buttons.
scenario :
I will enter the path name like this - C:\myfolder\Custom_programs.xls.
C:\myfolder\Custom_tables.xls.
(File name does not exit..it has to created inside the
specified folder)
in submit button I populate 2 internal tables say it1 and it2. then I need to move the tables contents to the path I have specified above.
attach_file_to_response method is not working for the above reqt since it is showing the dialog box.
Please provide a suitable solution...Please ignore all the responders that are stating that you can use GUI_DOWNLOAD from Web Dynpro ABAP. As you found out, this absolutely will not work, since this function module and other download logic like it depends upon a connection to the SAPGUI. People posting to use the GUI_DOWNLOAD from WDA need to learn a little more about the architecture of WDA before they go posting incorrect repsonses in the forum. I have little tollerance for people posting outright incorrect information in the WDA Forum.
What you want to do - download silent - is not easily done from WDA. There are rules about how web applications must behave in a browser. Normal HTML/JavaScript does not allow silent downloads for security reasons. Obviously there are many untrustworthy websites on the internet that you wouldn't want to allow to directly access your local machine. WDA must live within these same browser limitations.
SAP has done some work using a Java Applet to get around some of these security issues. This funcitonality comes in NetWeaver 7.01. It is the AcfUpDownload UI element:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b9157c878a2d67e10000000a42189c/frameset.htm
However it is designer for usage with the Content or KPro server - so even it might not meet your needs. -
Download ALV report to excel sheet
halo fellow SAPiens,
i want to download my alv report into excel sheet...........for tht i used UGI_DOWNLOAD........here if i use the file type as 'ASC' all the leading zeros of numeric values are removed and date format is "yyyy/mm/dd".......
i need the leading zeros and date format in "dd/mmyyy"
when i use file type 'DBF' i get the leading zeros but my date is replaced by '#####.............wht shld i do...........To get the leading zeros to come, append an apostrophe to the start of each field that has the leading zeros as shown
loop at itab.
concatenate '''' itab-field1 into itab-field1.
modify itab.
endloop.
note that
1. This sometimes doesnt show correctly in excel and you may have to double click on the cell to prevent the apostrophe from displaying in the sheet
2. You field needs to have an extra character to add the apostrophe -
Download search result in Excel sheet
hello Experts ,
I am working on UCM 11g.
We have a search template which helps us to search on UCM. I have to extract our search result in MS excel sheet. Could you please suggest the easiest way for it?
Thanks,
MaheshHello,
I have been trying to create the following component from BEX's book, which creates an extra value on a drop down to export search resullts to a CSV file:
<@dynamichtml custom_searchapi_result_options@>
<$include super.custom_searchapi_result_options$>
<option value="window.location='<$HttpCgiPath$>?<$QUERY_STRING
$>&IsJava=1&MergeInclude=spreadsheet_search_results'">
Download Spreadsheet</option>
<@end@>
<@dynamichtml spreadsheet_search_results@>
Title,Author,Date,Security Group,Content ID,Content Type
<$loop SearchResults$><$dDocTitle$>,<$dDocAuthor$>,<$dInDate
$>,<$dSecurityGroup$>,<$dDocName$>,<$dDocType$>
<$endloop$>
<$setContentType("text/csv")$>
<$setHttpHeader("Content-Disposition",
"attachment;filename=search_results.csv")$>
<@end@>
As this drop down is now different in UCM 10gR3 this no longer appears to work (I get an error when adding these as a resource file) I presume I need change this include "$include super.custom_searchapi_result_options". How do I find out which include to use? I am quite new to creating custom components.
Thanks for your help, -
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 -
BAPI for automatic Pr creation witth multiple files from excel sheet
I have written a programm for automatic PR creation with the help of bapi , where its picks data from excel sheet and makes PR .It is picking excel files from one folder(Files) for PR creation and moving to another folder(Files sucess).
now the problem is if Folder (Files) contains one excel sheet ,PR is created fine , but if the Folder(Files) have multiple excel sheet ,its is creating 1st PR right, but next PR's contains all the line item of 1st PR , 2nd PR and so on .can anyone suggest me where is the problem in codes.
types : begin of x_file ,
key1(10),
pur_grp(4),
maktx(40),
plant(4) ,
req(10),
s_qty(13),
wbs(24),
gl(10),
trackno(10),
supl(4),
deladd(255).
types : end of x_file .
data : str5 type char10.
data : mm type char2.
data : yyyy type char4.
data : dd type char2.
data : str9 type char10.
data : str6 type char10.
data : month type char2.
data : year type char4.
year = sy-datum+0(4).
month = sy-datum+4(2).
dd = sy-datum+6(2).
yyyy = sy-datum+0(4).
mm = sy-datum+4(2).
dd = sy-datum+6(2).
clear str6 .
clear str5.
concatenate dd'.' month '.' year into str5 .
concatenate yyyy mm dd into str6 .
DATA : file type rlgrap-filename .
data : it_file type table of x_file .
data : wa_file type x_file .
data : it_header type table of x_file .
data : wa_header type x_file .
*& Internal Table For Define Row and Coloum Postion
data: col_start type i value 1 ,
row_start type i value 2,
col_end type i value 256 ,
row_end type i value 65000 .
*& Internal Table For Retrieve Data From Excel
*data: excel_bdcdata like kcde_cells occurs 0 with header line.
*data: excel_bdcdata1 like kcde_cells occurs 0 with header line.
data: excel_bdcdata like ALSMEX_TABLINE occurs 0 with header line.
data: excel_bdcdata1 like ALSMEX_TABLINE occurs 0 with header line.
data: it_index type i.
DATA : IT_INDEX1 TYPE I.
*& Define Field Symbol
field-symbols: <fs> .
data : bdcdata like bdcdata occurs 0 with header line.
data : messtab like bdcmsgcoll occurs 0 with header line.
data : req_items type table of bapiebanc .
data : wa_req_items type bapiebanc .
data : req_acc_asg type table of bapiebkn.
data : wa_req_acc_asg type bapiebkn.
DATA : RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE .
*data : return type table of bapireturn.
*data : wa_return type bapireturn .
data : number type ebeln .
*****************************MOVE FILES******************************
data : xsource type string .
data : xdestin type string .
data : destin1 type string .
data : destin2 type string .
DATA : DEST1 TYPE STRING.
DATA : DEST11 TYPE STRING.
DATA : DEST2 TYPE STRING.
DATA : DEST22 TYPE STRING.
data : sou_dir_name like SALFILE-LONGNAME.
data : tar_dir_name like SALFILE-LONGNAME.
data : tar_dir_name1 like SALFILE-LONGNAME.
data : sou_filename like EDI_PATH-PTHNAM .
data : tar_filename like EDI_PATH-PTHNAM .
data : filename1 type string .
data : tar_filename1 like EDI_PATH-PTHNAM .
data : file_itab like SALFLDIR occurs 0 with header line.
data : wa_file_itab like SALFLDIR.
data : file_count type i .
data : dir_count type i.
data : dir_table like sdokpath occurs 0 with header line.
data : file_table like SDOKPATH occurs 0 with header line.
data : wa_file_table like sdokpath.
data : strr type string ,
str1 type string ,
str2 type string ,
str3 type string .
DATA : PA_VAL TYPE CHAR1.
sou_dir_name = 'D:\barcodes\files\'.
tar_dir_name = 'D:\barcodes\files-success\'.
"success folder.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
DIRECTORY = sou_dir_name
FILTER = '.'
IMPORTING
FILE_COUNT = file_count
DIR_COUNT = dir_count
TABLES
FILE_TABLE = file_table
DIR_TABLE = dir_table
EXCEPTIONS
CNTL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
loop at file_table into wa_file_table.
clear : strr , str1 , str2 , str3 .
strr = wa_file_table-PATHNAME .
concatenate sou_dir_name strr into str1 .
concatenate tar_dir_name strr into str2 . " success
concatenate tar_dir_name1 strr into str3 . " failed
FILE = STR1 .
*start-of-selection.
*& Function For Retrieve Data From Excel
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = FILE
i_begin_col = col_start
i_begin_row = row_start
i_end_col = col_end
i_end_row = row_end
tables
intern = excel_bdcdata
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF sy-subrc NE 0.
WRITE : / 'File Error'.
EXIT.
ENDIF.
loop at excel_bdcdata.
translate excel_bdcdata to upper case .
move excel_bdcdata-col to it_index.
assign component it_index of structure wa_file to <fs> .
move excel_bdcdata-value to <fs>.
at end of row.
append wa_file to it_file .
clear wa_file.
endat.
endloop.
sort it_file by key1. "pur_grp maktx plant .
it_header[] = it_file[].
delete adjacent duplicates from it_header comparing key1 pur_grp maktx
plant .
data : h_item(5) type n .
data : h_pack(10) type n .
data : line_no(5) type n .
data : ln_no(5) type n .
loop at it_header into wa_header .
ln_no = 1.
h_item = h_item + 10.
h_pack = h_pack + 1.
wa_req_items-preq_item = h_item .
wa_req_items-doc_type = 'BOM'.
wa_req_items-pur_group = wa_header-pur_grp .
wa_req_items-MATERIAL = wa_header-maktx .
wa_req_items-plant = wa_header-plant .
wa_req_items-pckg_no = h_pack .
wa_req_items-deliv_date = str6 .
wa_req_items-item_cat = '0'.
wa_req_items-acctasscat = 'P'.
*wa_req_items-distrib = '2' .
**wa_req_items-gr_ind = 'X'.
wa_req_items-ir_ind = '2'.
wa_req_items-purch_org = 'TISL' .
wa_req_items-QUANTITY = wa_header-s_qty.
wa_req_items-PREQ_NAME = wa_header-req.
wa_req_items-SUPPL_PLNT = wa_header-supl.
wa_req_items-trackingno = wa_header-trackno.
append wa_req_items to req_items .
clear wa_req_items.
wa_req_acc_asg-preq_item = h_item .
wa_req_acc_asg-g_l_acct = wa_file-gl .
WA_req_acc_asg-wbs_elem = wa_header-wbs .
append wa_req_acc_asg to req_acc_asg .
clear wa_req_acc_asg.
h_pack = h_pack + 1 .
endloop.
clear ln_no .
***BREAK-POINT.
*& BAPI FUNCTION
call function 'BAPI_REQUISITION_CREATE'
importing
number = number
tables
requisition_items = req_items
requisition_account_assignment = req_acc_asg
return = return .Can someone please give me sol........
-
Application server file to excel sheet with .csv format
I am having comma seperated file in the application server, now i want that my program should pick the file from application server and store it in the excel sheet with .CSV extension
Use the OPEN DATASET and READ DATASET statements to read from the file on application server and the function module GUI_DOWNLOAD to save it on the local system.
Manoj -
Download internal table to Excel sheet
Hi,
I am trying a sampole program to download an internal table to excel and am
uisng the Fm GUI_DOWNLOAD for the same. But how do I ensure that each column
of internal will be aligned as columns in the excel sheet to. I a trying to do
that with a separator but I am not able to figure out.
Below is my code.
REPORT z_excel_download.
DATA : it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.
DATA : BEGIN OF it_file OCCURS 0,
data(2000),
END OF it_file.
SELECT * FROM mara INTO TABLE it_mara UP TO 100 ROWS.
LOOP AT it_mara.
CONCATENATE it_mara-matnr
it_mara-ersda
it_mara-ernam
it_mara-pstat
it_mara-mtart
it_mara-mbrsh INTO it_file-data SEPARATED BY '/t'.
APPEND it_file.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\Documents and Settings\XXXXXX\Desktop\test.xls'
TABLES
data_tab = it_file
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks.Hi Varun,
On SDN are plenty of post where you can find the answer to your problem.
Please try the following code that I found here several years ago to resolve your problem.
Regards,
Eric
REPORT Excel.
TABLES:
sflight.
* header data................................
DATA :
header1 LIKE gxxlt_p-text VALUE 'Suresh',
header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
* Internal table for holding the SFLIGHT data
DATA BEGIN OF t_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA END OF t_sflight.
* Internal table for holding the horizontal key.
DATA BEGIN OF t_hkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_h.
DATA END OF t_hkey .
* Internal table for holding the vertical key.
DATA BEGIN OF t_vkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_v.
DATA END OF t_vkey .
* Internal table for holding the online text....
DATA BEGIN OF t_online OCCURS 0.
INCLUDE STRUCTURE gxxlt_o.
DATA END OF t_online.
* Internal table to hold print text.............
DATA BEGIN OF t_print OCCURS 0.
INCLUDE STRUCTURE gxxlt_p.
DATA END OF t_print.
* Internal table to hold SEMA data..............
DATA BEGIN OF t_sema OCCURS 0.
INCLUDE STRUCTURE gxxlt_s.
DATA END OF t_sema.
* Retreiving data from sflight.
SELECT * FROM sflight
INTO TABLE t_sflight.
* Text which will be displayed online is declared here....
t_online-line_no = '1'.
t_online-info_name = 'Created by'.
t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
APPEND t_online.
* Text which will be printed out..........................
t_print-hf = 'H'.
t_print-lcr = 'L'.
t_print-line_no = '1'.
t_print-text = 'This is the header'.
APPEND t_print.
t_print-hf = 'F'.
t_print-lcr = 'C'.
t_print-line_no = '1'.
t_print-text = 'This is the footer'.
APPEND t_print.
* Defining the vertical key columns.......
t_vkey-col_no = '1'.
t_vkey-col_name = 'MANDT'.
APPEND t_vkey.
t_vkey-col_no = '2'.
t_vkey-col_name = 'CARRID'.
APPEND t_vkey.
t_vkey-col_no = '3'.
t_vkey-col_name = 'CONNID'.
APPEND t_vkey.
t_vkey-col_no = '4'.
t_vkey-col_name = 'FLDATE'.
APPEND t_vkey.
* Header text for the data columns................
t_hkey-row_no = '1'.
t_hkey-col_no = 1.
t_hkey-col_name = 'PRICE'.
APPEND t_hkey.
t_hkey-col_no = 2.
t_hkey-col_name = 'CURRENCY'.
APPEND t_hkey.
t_hkey-col_no = 3.
t_hkey-col_name = 'PLANETYPE'.
APPEND t_hkey.
t_hkey-col_no = 4.
t_hkey-col_name = 'SEATSMAX'.
APPEND t_hkey.
t_hkey-col_no = 5.
t_hkey-col_name = 'SEATSOCC'.
APPEND t_hkey.
t_hkey-col_no = 6.
t_hkey-col_name = 'PAYMENTSUM'.
APPEND t_hkey.
* populating the SEMA data..........................
t_sema-col_no = 1.
t_sema-col_typ = 'STR'.
t_sema-col_ops = 'DFT'.
APPEND t_sema.
t_sema-col_no = 2.
APPEND t_sema.
t_sema-col_no = 3.
APPEND t_sema.
t_sema-col_no = 4.
APPEND t_sema.
t_sema-col_no = 5.
APPEND t_sema.
t_sema-col_no = 6.
APPEND t_sema.
t_sema-col_no = 7.
APPEND t_sema.
t_sema-col_no = 8.
APPEND t_sema.
t_sema-col_no = 9.
APPEND t_sema.
t_sema-col_no = 10.
t_sema-col_typ = 'NUM'.
t_sema-col_ops = 'ADD'.
APPEND t_sema.
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
* DATA_ENDING_AT = 54
* DATA_STARTING_AT = 5
filename = 'TESTFILE'
header_1 = header1
header_2 = header2
no_dialog = 'X'
no_start = ' '
n_att_cols = 6
n_hrz_keys = 1
n_vrt_keys = 4
sema_type = 'X'
* SO_TITLE = ' '
TABLES
data = t_sflight
hkey = t_hkey
online_text = t_online
print_text = t_print
sema = t_sema
vkey = t_vkey
EXCEPTIONS
cancelled_by_user = 1
data_too_big = 2
dim_mismatch_data = 3
dim_mismatch_sema = 4
dim_mismatch_vkey = 5
error_in_hkey = 6
error_in_sema = 7
file_open_error = 8
file_write_error = 9
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12
OTHERS = 13
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Downloading PO's into excel sheet?
Hello All!
I am trying to download the po's into excel sheet through a programm. In this regard i would like to know the procedure for that.
Presently my plan is to collect all the fields into two internal tables (one for header and another for item data).Now how to append the two internal table into a single itab. I want to use this itab in gui_download funtion module!
Am i doing right. If i am going wrong plz guide me.
Mail me to [email protected]
Regards,
LNhi,
no need to download the header and data seperately.
dowload the data only.
kindly chek the below code.
here 'v_start_row' is '2', so it avoid the header. if u wants the header make it as '1'.
v_end_col means the numbers of columns u have
DATA : int_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : v_start_col TYPE i VALUE '1',
v_start_row TYPE i VALUE '2', "only from data row
v_end_col TYPE i VALUE '6', "no of columns.
v_end_row TYPE i VALUE '1000'.
PERFORM f_upload.
*& Form f_upload
text
--> p1 text
<-- p2 text
FORM f_upload .
CLEAR : int_excel, int_excel[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = wf_filename
i_begin_col = v_start_col
i_begin_row = v_start_row
i_end_col = v_end_col
i_end_row = v_end_row
TABLES
intern = int_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
*Message is 'Unable to upload data from ' wf_filename.
MESSAGE e169(zm050) WITH wf_filename.
ELSE.
SORT int_excel BY row col.
REFRESH : record.
CLEAR : record.
LOOP AT int_excel.
CASE int_excel-col.
WHEN 1.
record-wf_mf_zone_code_003 = int_excel-value.
WHEN 2.
record-wf_mf_country_code_004 = int_excel-value.
WHEN 3.
record-wf_country_code_001 = int_excel-value.
WHEN 4.
record-wf_zone_desc_002 = int_excel-value.
WHEN 5.
record-wf_loekz = int_excel-value.
ENDCASE.
AT END OF row.
APPEND record.
CLEAR record.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. " f_upload
hope this helps u.
if so pls reward points
regards,
anversha
[email protected]
Maybe you are looking for
-
IOS4 4.1 firmware update causes camera function to malfunction
After updating to firmware 4.1, the camera function is not working properly. The images taken are not in a red hue from the normal picture. Is there anyway to fix this or should I revert back to the previous firmware?
-
Dear Brothers, I want to use SCCM to have a Query Collection to generate computers no longer active by detecting more than 90 days of no logon to our AD (Dead or not Pinging but still in AD), after this activity I will delete this computers to comple
-
How to display my country flag on the task bar in osx mavericks?
How to display my country flag on the task bar in osx mavericks?
-
An hp5550 series laserjet printer was just donated to our office. It needed a fuser kit and I just replaced it. Now the sheets are pink when copies are made. What's going on?
-
USB6210 et PCI6232 : lecture de deux valeur analogiques simultanément
Bonjour, Pour une application, je dois lire deux entre analogique en même temps. J'utilise pour mes tests l'USB-6210 et pour la prod le PCI-6232. J'ai réalisé un petit programme en C avec : DAQmxCreateTask DAQmxCreateAIVoltageChan ( ..., "Dev1/ai