Download To Excel in PL/SQL
Hi,
Through my PL/SQL code for Download To Excel functionality, If fetch record count is more than 2k then sometime I get below mentioned error:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory ORA-06512: at "SYS.DBMS_LOB", line 805
ORA-06512: at "NCPCORE.NCP_BRANCH_CAMPUS_REC_PKG", line 1799
What could be the reason for the same?
82MT wrote:
Hi,
Through my PL/SQL code for Download To Excel functionality, If fetch record count is more than 2k then sometime I get below mentioned error:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory ORA-06512: at "SYS.DBMS_LOB", line 805
ORA-06512: at "NCPCORE.NCP_BRANCH_CAMPUS_REC_PKG", line 1799
What could be the reason for the same?
bug in the code
How do I ask a question on the forums?
https://forums.oracle.com/message/9362002#9362002
Similar Messages
-
Stop download to Excel from converting string of digits & dashes into date
Hi,
How can I stop BI and Excel data from converting a column of string data that is comprised of numbers and dashes into a date format when it is downloaded into Excel?
I'd like to solve this problem in BI, so that any users can download the data from a BI report into Excel without having to change the Excel date column back into a string column.
Thanks,
DarcyHi Again Darcy,
hmmm... That is very interesting. I just tried on OBIEE 10.1.3.2 ( a version before yours) on Windows XP with Office 2003 and an Oracle 11g DB backend and it did not have any problems pulling the value as text and not a DATE
Can you try something for me? In a new report, add any old dimensional (year, month name, etc) field twice into the report and change the second column formula to be following: '7001-2'
Try to export that report and see if that value comes through as text or a date. If it is something about the SQL server data set, then the above test should come through as text object in your excel download because we aren't pulling it from SQL Server, we'll creating it directly in OBIEE. If the above test does come through as a date, then it should mean that SQL Server isn't the issue. And if that is the case, I am starting to wonder if there's a setting in Office to can be enabled/disabled to avoid any data casting.
Best regards,
-Joe -
Download to Excel using pkg by Denes
I've had success using the package that Denes created for non-Interactive Reports, but now I have issue downloading to Excel when I create a SQL Report, with the option to Enable Search = Yes. When I download the report, it only appears to show columns that aren't searchable, or at least those columns that don't have a value for the column attribute for "Highlight Words." The report was created through a wizard, so APEX automatically created the items and processes to enable searching for values within the report. When I remove the item specified for Highlight Words (e.g. &P60_REPORT_SEARCH), the column then shows up in the downloaded file. I did not find any logic in the Export_Excel_Pkg where it might exclude such columns. Any ideas?
The issue appears to be resolved. In the EXCEL_REPORT_PKG.PRINT_REPORT_HEADER proc there is a cursor with a condition specifiying: include_in_export = 'Yes'. Strangely, even though in APEX I can see that the column attribute Include in Export = Yes, the values for these report columns in the APEX_APPLICATION_PAGE_RPT_COLS view for the INCLUDE_IN_EXPORT column was NULL. I had to again click on "Apply Changes" and it set the column value in the table to 'Yes' where before it was NULL.
-
Warning while downloading an Excel file from WD ABAP
Hi folks,
In one of requirements, Client wants to download all the data that is appearing on the screen ( WD ABAP Application ) to an Excel with a layout in different manner.
We achieved this with Simple Transformations.
Now the question is while downloading the excel file, the framework/other is throwing an Warning like
" The file you are trying to open, 'info.xls', is in a different format than specified by the extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now? "
Note: All the users of my client are using MS Office 2002 / 2003.
I am using the following code........!
*------ Call Transformation for Excel OUTPUT
CALL TRANSFORMATION ZEXCEL_OUTPUT
SOURCE
t_dates = t_dates
t_info = t_info
RESULT XML l_xml_string.
REPLACE ALL OCCURRENCES OF '<?xml version="1.0" encoding="utf-16"?>' l_xml_string WITH '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'.
**-- Call Function Module for converting string data to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = l_xml_string
mimetype = 'application/xml'
IMPORTING
buffer = l_xml_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'info.xml'
i_content = l_xml_xstring
i_mime_type = 'application/vnd.ms-excel'.
With this code I am generating a file of type XML SPREADSHEET 2003. While opening this file I am getting the above message which the user unwanted......
Can any one help me on this -
> How to avoid this warning?
Thanks and Regards,
Aneel Danda
Edited by: danda aneel on Jul 13, 2010 1:43 PMFirstly, Thanks for Your quick Response, Thomas.
Even though what ever may be the file name I am passing either info.xml or Info.xls , In error info.xls is coming.
Kindly provide me an alternative on this XML doesn't seem like it would match the 'application/vnd.ms-excel'.
what is the supported format.?
Similarly, It is not considering the UTF-8 / UTF-16 for xml.........same result is appearing in the output.
Edited by: danda aneel on Jul 14, 2010 7:52 AM -
Doubt on ALV report download to EXCEL
Hi All,
i have written a report with ALV_GRID FM, by default we get the option to download the output to excel. But when we click on the download to excel, it displays the output
in the frist page, but it also opens so many pages like
format, header, pivot,sub1,sub1....etc.
Pls. check the SAP standard report BCALV_TEST_FULLSCREEN, does the same thing when we do download to excel.
How can i avoid opening so many pages in excel?
Thanks for the help.
SekarHi ,
prabhu here , i think check the FM wheather u r passing all these to FM. for Excel keep export.param: --> i_save only and check.
regards
prabhu -
Help needed: Download to excel without pop-up
Hi All,
In a particular scenario, I require to trigger an action once a file have been successfully downloaded to EXCEL from Webdynpro UI. But in case of download functionilty, once the MS window pop-up for download comes up, the control is lost from Webdynpro and its impossible to track whether user have saved, opened or canceled the file.
Is there any functionality to directly download internal table content to EXCEL, without facing the download popup. Please let me know any function module or functionality for this.
Thanks in advance to all.
Regards,
Mainakyes there are many tutorials on SDN regarding this
u may procced like this :
get the contents in internal table and then use the FM 'SCMS_STRING_TO_XSTRING'
DATA text TYPE string.
DATA xtext TYPE xstring.
* get all declared attributes
lo_nd_sbook->get_static_attributes_table(
IMPORTING
table = lt_sbook ).
LOOP AT lt_sbook INTO ls_sbook.
CONCATENATE text ls_sbook-carrid
ls_sbook-connid
ls_sbook-fldate
ls_sbook-bookid
ls_sbook-order_date
ls_sbook-counter
ls_sbook-passname
cl_abap_char_utilities=>newline INTO text SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text
IMPORTING
buffer = xtext.
wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
i_filename = 'WDP.xls'
* String Variable
i_content = xtext
* File Type
i_mime_type = 'EXCEL' ).
here it_sbook is the inernal table and ls_sbook is the structure type of the attributes declared in the context node sbook
DATA ls_sbook TYPE wd_this->element_sbook.
* data LT_SFLIGHT type WD_THIS->ELEMENTS_SFLIGHT.
DATA lt_sbook TYPE wd_this->elements_sbook.
Edited by: amit saini on Oct 14, 2009 1:30 PM -
Excel 2007 to Sql server table. Column with more than 255 characters.
Hi there,
I am facing a problem while converting data from Excel 2007 to SQL server 2005 table. I am using BIDS 2005.I have an excel file where one particular column has more than 255 characters. I use OLEDB connection for excel file as there is no driver for Excel
2007 in BIDS2005. I am using Microsoft Office 12.0 Access Database Engine OLE DB Provider for Excel file.
Next, I changed advanced properties for the column to DT_NTEXT. But when I am getting errors on execution. They are:
[OLE DB Source [1949]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E21.
[OLE DB Source [1949]] Error: Failed to retrieve long data for column "action".
[OLE DB Source [1949]] Error: There was an error with output column "action" (2046) on output "OLE DB Source Output" (1959). The column status returned was: "DBSTATUS_UNAVAILABLE".
[OLE DB Source [1949]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "action" (2046)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "action"
(2046)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
Please advise on how can I deal with columns having more than 255 characters in Excel file.
Thanks!Here is what your connection string should look like for excel source
Provider
=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\temp\test.xls;Extended
Properties="EXCEL 8.0;HDR=YES";
http://sqlworkday.blogspot.com/ -
Download to Excel is hiding rows in a pivot view
Hello ,
When downloading a report to excel from OBIEE Dashboard , certain rows are getting hidden . For instance , I have total 15 rows in my pivot view and when I download that report into excel format , the rows from 8-13 are not showing up . After 7th row I see 14th row .
But when I download the same report from Answers I can see all rows in the pivot view .
I tried looking at the formatting options of the pivot view and everything is normal . This is happening only with this particular report , other reports in dashboard download normally .
Please let me know if anybody has ideas .
Thank you
Karthikkarthik,
From where ur downloading to excel ...use the download option available at "preview " button ,if you are using the same go with report links download button option
Last option create a new report (without any filters in case if u have)
Thanks,
Saichand.v -
Download to excel using GUI_DOWNLOAD : Date format
Hi Gurus,
I am downloading the data from an internal table to excel file using FM gui_download. The date field in my internal table is in the format MM-DD-YYYY (stored as Char 10 field). But when it downloads to excel, the date format changes to MM/DD/YYYY. I want to keep original format of MM-DD-YYYY in excel.
Please help, sure points for helpful answers.
should i use FM gui_download only, or is there some Other useful FM.
Regards,
AbhishekHi,
Check the code below:
v_date = sy-datum.
IF v_date CA '/'.
REPLACE '/' WITH '-' INTO v_date.
ENDIF.
Regards
Kannaiah -
Upload and download of excel file in the application server in background
Hi all,
i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
i mean i'll schedule the program in background.
im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
what method i have to follow ?Hi Ankit,
I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
In my opinion you have two possibilities:
1. Convert all files in the CSV format. This file format can be read with open dataset.
2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
Regards
Dirk -
Hello experts,
I know there are many threads on this topic in the forum. I tried using method cl_bsp_utility=>download
but nothing happens. Here is the scenario -
1. I have BSP
2. From Do_handle_event in controller class I am calling model method which handles downloading to excel.
Please help as this is real showstopper for the application, I am developing.
Thanks, in advance.
TruptiHi Gopal,
Thanks for your reply.
Tried the code you sent me. As I am using BSP-MVC, I am building method in controller class and with event handling calling the method that handles download to excel. But it is not doing anything at all.
Thank you.
Trupti -
In download to excel from bsp hw to increase excel column width to wrap txt
in download to excel from bsp how to increase excel column width to wrap text
in each column.
My client does not want to manually click each cell aftet downloading to excel to see full text in each columnHi,
You can achieve this by formatting your output using HTML table tag.
Try the following code.
DATA: lv_output TYPE string.
concatenate
'<table border="1">'
'<tr style="font-weight: bold; text-align:center; "><td>Name</td><td width="150">Description</td></tr>' cl_abap_char_utilities=>cr_lf
'<tr><td>First Name</td><td>Some Description goes here..... ....... ...... </td></tr>' cl_abap_char_utilities=>cr_lf
'<tr><td>2nd Name</td><td>XYZ.......</td></tr>' cl_abap_char_utilities=>cr_lf
'</table>'
into lv_output.
response->set_cdata( data = lv_output ).
Regards
Geogy
PS. Reward the useful answers. -
How can i bring the column heading downloaded in excel sheet?
hi all,
I am using FM SAP_CONVERT_TO_XLS_FORMAT to downloading populated internal table data into excel sheet by using filename type rlgrap-filename.
Now I need the column heading(field name) for downloaded data in excel sheet.
pls tell me how can i merge the col heading with data perfectly. Is there any FM fulfills this requirement.
pls give me a suitable approch.
Thanks
PRRHI,
Go thru this code.
REPORT ZRMM0056 NO STANDARD PAGE HEADING
MESSAGE-ID ZZ
LINE-SIZE 300
LINE-COUNT 65.
Program : ZRMM0056
Title : Non Inventory PO's
Description : Non Inventory Purchase Orders details with
Vendor and Invoice Receipts and Goods Receipts.
Input :
Select-options : 1. G/L Account No
Parameters : 1.File Paths for the Excel sheet
Others (Specify):
Output : Extract Files in the application server
Report :
Hear Ticket # : 113392
Created by : Srinivas Rao.M
Created on : 12/15/2005
Version : 1
Request : D10K944304
Transaction Code : Z420
Change History *
Date Programmer Search String Description *
12/19/2005 Srinivas D10K944316 Removed Purchasing document
Company code and Plant from
Select-Options and Inculded
G/L Account No and changed
code accordingly.
T A B L E S *
TABLES: EKBE, " History of Purchasing Document
EKPO, " Purchasing Document Item
EKKO, " Purchasing Document Header
LFA1, " Vendor master (general section)
EKKN. " Account Assignment in Purchasing Doc
INTERNAL TABLES
*--Internal table to store Purchasing document header data
DATA : BEGIN OF IT_POHEADER OCCURS 0,
EBELN LIKE EKKO-EBELN, "Purchasing document
AEDAT LIKE EKKO-AEDAT, "Created on
ERNAM LIKE EKKO-ERNAM, "Created by
LIFNR LIKE EKKO-LIFNR, "Vendor
END OF IT_POHEADER.
*--Internal table to store Purchasing document Item data
DATA : BEGIN OF IT_POITEM OCCURS 0,
EBELN LIKE EKPO-EBELN, "Purchasing document
EBELP LIKE EKPO-EBELP, "Item Number
MATNR LIKE EKPO-MATNR, "Material number
BUKRS LIKE EKPO-BUKRS, "Company code
WERKS LIKE EKPO-WERKS, "Plant
MATKL LIKE EKPO-MATKL, "Material Group
MENGE LIKE EKPO-MENGE, "Order Quantity
NETPR LIKE EKPO-NETPR, "Net Price
PEINH LIKE EKPO-PEINH, "Price unit
NETWR LIKE EKPO-NETWR, "Net Value
END OF IT_POITEM.
*--Internal table to hold final display data.
DATA : BEGIN OF IT_FINAL OCCURS 0,
EBELN LIKE EKKO-EBELN, "Purchasing document
EBELP LIKE EKPO-EBELP, "Item Number
AEDAT LIKE EKKO-AEDAT, "Created on
ERNAM LIKE EKKO-ERNAM, "Created by
MATNR LIKE EKPO-MATNR, "Material number
BUKRS LIKE EKPO-BUKRS, "Company code
WERKS LIKE EKPO-WERKS, "Plant
MATKL LIKE EKPO-MATKL, "Material Group
MENGE LIKE EKPO-MENGE, "Order Quantity
NETPR LIKE EKPO-NETPR, "Net Price
PEINH LIKE EKPO-PEINH, "Price unit
NETWR LIKE EKPO-NETWR, "Net Value
LIFNR LIKE EKKO-LIFNR, "Vendor
NAME1 LIKE LFA1-NAME1, "Vendor Name
GSBER LIKE EKKN-GSBER, "Business area
*--IR details
IR_BELNR LIKE EKBE-BELNR, "IR-Number of Material Document
IR_BUZEI LIKE EKBE-BUZEI, "IR-Item in material Document
IR_BUDAT LIKE EKBE-BUDAT, "IR-Posting date
IR_MENGE LIKE EKBE-MENGE, "IR-Quantity
*--GR details
GR_BELNR LIKE EKBE-BELNR, "GR-Number of Material Document
GR_BUZEI LIKE EKBE-BUZEI, "GR-Item in material Document
GR_BUDAT LIKE EKBE-BUDAT, "GR-Posting date
GR_MENGE LIKE EKBE-MENGE, "GR-Quantity
END OF IT_FINAL.
*--Internal table to store History per Purchasing Document data
DATA : BEGIN OF IT_HISTORY OCCURS 0,
EBELN LIKE EKBE-EBELN, "Purchasing document
EBELP LIKE EKBE-EBELP, "Item
VGABE LIKE EKBE-VGABE, "Trans/Event type
BELNR LIKE EKBE-BELNR, "Number of Material Document
BUZEI LIKE EKBE-BUZEI, "Item in material Document
BUDAT LIKE EKBE-BUDAT, "Posting date
MENGE LIKE EKBE-MENGE, "Quantity
BEWTP LIKE EKBE-BEWTP, "Posting history category
END OF IT_HISTORY.
*--Internal table to store vendor name.
DATA : BEGIN OF IT_VENDOR OCCURS 0,
LIFNR LIKE LFA1-LIFNR, "Vendor Number
NAME1 LIKE LFA1-NAME1, "Vendor Name
END OF IT_VENDOR.
*--Internal table to store Business area for Purchasing document
DATA : BEGIN OF IT_BUSINESS OCCURS 0,
EBELN LIKE EKKN-EBELN, "Purchasing document
EBELP LIKE EKKN-EBELP, "Purchasing Item
SAKTO LIKE EKKN-SAKTO, "G/L Account No
GSBER LIKE EKKN-GSBER, "Business area
END OF IT_BUSINESS.
DATA : BEGIN OF FIELDNAMES OCCURS 0,
TEXT(40),
END OF FIELDNAMES.
VARIABLES DECLARATION *
DATA: V_FILE LIKE IBIPPARMS-PATH, "File path
V_FLD LIKE DYNPREAD-FIELDNAME, "Dynpread fieldname
V_FLAG(1) VALUE SPACE. "FLAG VARIABLE
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.
*--Begin of change D10K944316
SELECT-OPTIONS : S_SAKTO FOR EKKN-SAKTO. "G/L Accoun no.
*--End of change D10K944316
SELECTION-SCREEN END OF BLOCK S1.
SELECTION-SCREEN BEGIN OF BLOCK S2 WITH FRAME TITLE TEXT-002.
PARAMETERS : P_EXCEL AS CHECKBOX DEFAULT ' ' . " download to excel
PARAMETERS : C_FILE(128) DEFAULT : 'C:\ZRMM0056.xls'.
SELECTION-SCREEN END OF BLOCK S2.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR C_FILE.
*-Form to get file path for download of data
PERFORM GET_FILE_PATH.
AT SELECTION-SCREEN.
PERFORM SCREEN_VALIDATIONS.
START-OF-SELECTION
START-OF-SELECTION.
*--Extract Purchasing document header data.
PERFORM GET_PO_HEADER_DATA.
*--Extract Purchasing document Item data.
IF NOT IT_BUSINESS[] IS INITIAL.
PERFORM GET_PO_ITEM_DATA.
*--Get complete required data in final internal table
PERFORM GET_FINAL_DATA.
ENDIF.
END-OF-SELECTION
END-OF-SELECTION.
IF V_FLAG IS INITIAL.
*--Display Purchasing document details
IF NOT IT_FINAL[] IS INITIAL.
PERFORM DISPLAY_PODATA.
IF P_EXCEL = 'X'.
*--To down load data to excel sheet
PERFORM DOWN_LOAD_TO_EXCEL.
ENDIF.
ENDIF.
ELSE.
MESSAGE I001(ZZ) WITH 'No data found'(003).
ENDIF.
TOP-OF-PAGE
TOP-OF-PAGE.
*--To display page header
PERFORM PAGE_HEADER.
*& Form GET_PO_HEADER_DATA
To Get Purchasing header data
FORM GET_PO_HEADER_DATA .
*--To extract Business Area details
CLEAR IT_BUSINESS.
REFRESH IT_BUSINESS.
SELECT EBELN "Purchasing document
EBELP "Purchasing document item
SAKTO "G/L Account no
GSBER "Business area
FROM EKKN
INTO TABLE IT_BUSINESS
WHERE SAKTO IN S_SAKTO.
IF SY-SUBRC <> 0.
V_FLAG = 'X'.
MESSAGE I001(ZZ) WITH
'No data selected for the given selection criteria'(004).
STOP.
ELSE.
*--To extract Purchasing document details with respect
to G/L Account no
CLEAR IT_POHEADER.
REFRESH IT_POHEADER.
SELECT EBELN "Purchasing document
AEDAT "Created on
ERNAM "Created by
LIFNR "Vendor
FROM EKKO
INTO TABLE IT_POHEADER
FOR ALL ENTRIES IN IT_BUSINESS
WHERE EBELN = IT_BUSINESS-EBELN.
IF NOT IT_POHEADER[] IS INITIAL.
CLEAR IT_VENDOR.
REFRESH IT_VENDOR.
*--Extracting Vendor details
SELECT LIFNR "Vendor #
NAME1 "Name
FROM LFA1
INTO TABLE IT_VENDOR
FOR ALL ENTRIES IN IT_POHEADER
WHERE LIFNR = IT_POHEADER-LIFNR.
ENDIF.
ENDIF.
ENDFORM. " GET_PO_HEADER_DATA
*& Form GET_PO_ITEM_DATA
To extract Purchasing document item data
FORM GET_PO_ITEM_DATA .
CLEAR IT_POITEM.
REFRESH IT_POITEM.
SELECT EBELN "Purchasing document
EBELP "Item Number
MATNR "Material number
BUKRS "Company code
WERKS "Plant
MATKL "Material Group
MENGE "Order Quantity
NETPR "Net Price
PEINH "Price unit
NETWR "Net Value
FROM EKPO
INTO TABLE IT_POITEM
FOR ALL ENTRIES IN IT_BUSINESS
WHERE EBELN = IT_BUSINESS-EBELN
AND EBELP = IT_BUSINESS-EBELP.
IF NOT IT_POITEM[] IS INITIAL.
CLEAR IT_HISTORY.
REFRESH IT_HISTORY.
SELECT EBELN "Purchasing document
EBELP "Item
VGABE "Trans/Event type
BELNR "Number of Material Document
BUZEI "Item in material Document
BUDAT "Posting date
MENGE "Quantity
BEWTP "Posting history category
FROM EKBE
INTO TABLE IT_HISTORY
FOR ALL ENTRIES IN IT_POITEM
WHERE EBELN = IT_POITEM-EBELN
AND EBELP = IT_POITEM-EBELP
AND ( VGABE = '1' OR VGABE = '2' ) "1 = GR , 2 = IR
AND ( BEWTP = 'Q' OR BEWTP = 'E' ). "Q = GR , R = IR
IF SY-SUBRC = 0.
SORT IT_HISTORY BY EBELN EBELP.
ENDIF.
ENDIF.
ENDFORM. " GET_PO_ITEM_DATA
*& Form GET_FILE_PATH
Select file path
FORM GET_FILE_PATH .
CLEAR V_FILE.
MOVE 'p_flname' TO V_FLD.
MOVE C_FILE TO V_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = V_FLD
IMPORTING
FILE_NAME = V_FILE
EXCEPTIONS
OTHERS = 1.
MOVE V_FILE TO C_FILE.
ENDFORM. " GET_FILE_PATH
*& Form PAGE_HEADER
To Print page header and other details
FORM PAGE_HEADER .
*--Page Header
ULINE AT /1(300).
FORMAT COLOR 1.
WRITE:/ 'Run Date:'(005), SY-DATUM, 45 'Stanley Works'(006),
100 'Page No:'(007), SY-PAGNO LEFT-JUSTIFIED, 298 ''.
WRITE:/ 'Run Time:'(008), SY-UZEIT, 43 SY-TITLE, 100 SY-UNAME, 298 ''.
WRITE:/ 'Source :'(009), SY-SYSID, 100 SY-CPROG, 298 ''.
FORMAT COLOR OFF.
ULINE AT /1(300).
FORMAT COLOR 4.
WRITE : / SY-VLINE , (10) 'Purchasing Doc'(010),
SY-VLINE, (5) 'Item'(011),
SY-VLINE, (10) 'Created On'(012),
SY-VLINE, (7) 'Crea By'(013),
SY-VLINE, (10) 'Material'(014),
SY-VLINE, (6) 'Com cd'(015),
SY-VLINE, (5) 'Plant'(016),
SY-VLINE, (10) 'Mat Group'(017),
SY-VLINE, (13) 'Order Qty'(018),
SY-VLINE, (11) 'Net Price'(019),
SY-VLINE, (10) 'Price Unit'(020),
SY-VLINE, (13) 'Net Value'(021),
SY-VLINE, (8) 'Bus Area'(022),
SY-VLINE, (10) 'Vendor'(023),
SY-VLINE, (28) 'Vendor Name'(024),
*--IR details
SY-VLINE, (10) 'IR-Mat Doc'(025),
SY-VLINE, (5) 'IR-It'(026),
SY-VLINE, (9) 'IR-Post dt'(027),
SY-VLINE, (13) 'IR-Quantity'(028),
*--GR details
SY-VLINE, (10) 'GR-Mat Doc'(029),
SY-VLINE, (5) 'GR-It'(030),
SY-VLINE, (9) 'GR-Post dt'(031),
SY-VLINE, (13) 'GR-Quantity'(032), SY-VLINE.
FORMAT COLOR OFF.
ULINE AT /1(300).
ENDFORM. " PAGE_HEADER
*& Form SCREEN_VALIDATIONS
Selection screen validations
FORM SCREEN_VALIDATIONS .
*--Validation for G/L Account No
IF NOT S_SAKTO IS INITIAL.
SELECT SAKNR UP TO 1 ROWS
INTO EKKN-SAKTO
FROM SKA1 WHERE
SAKNR IN S_SAKTO.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E001(ZZ) with 'Please enter a valid G/L Account no'(048).
ENDIF.
ENDIF.
*--Validation for Excel file path
IF P_EXCEL = 'X'.
IF C_FILE = ' '.
MESSAGE E001(ZZ) with 'Please enter a valid Excle Path'(035).
ENDIF.
ENDIF.
ENDFORM. " SCREEN_VALIDATIONS
*& Form DISPLAY_PODATA
To Display Purchasing Document details
FORM DISPLAY_PODATA .
FORMAT COLOR 2.
SORT IT_FINAL BY EBELN EBELP AEDAT BUKRS WERKS.
LOOP AT IT_FINAL.
WRITE : / SY-VLINE ,(10) IT_FINAL-EBELN, "Purchasing Doc
SY-VLINE, (5) IT_FINAL-EBELP, "Item
SY-VLINE, (10) IT_FINAL-AEDAT, "Created On
SY-VLINE, (7) IT_FINAL-ERNAM, "Created By
SY-VLINE, (10) IT_FINAL-MATNR, "Material
SY-VLINE, (6) IT_FINAL-BUKRS, "Company code
SY-VLINE, (5) IT_FINAL-WERKS, "Plant
SY-VLINE, (10) IT_FINAL-MATKL, "Material Group
SY-VLINE, (13) IT_FINAL-MENGE, "#EC UOM_IN_MES
"Order Qty
SY-VLINE, (11) IT_FINAL-NETPR, "#EC UOM_IN_MES
"Net Price
SY-VLINE, (10) IT_FINAL-PEINH, "#EC UOM_IN_MES
"Price Unit
SY-VLINE, (13) IT_FINAL-NETWR, "#EC UOM_IN_MES
"Net Value
SY-VLINE, (8) IT_FINAL-GSBER, "Bus Area
SY-VLINE, (10) IT_FINAL-LIFNR, "Vendor
SY-VLINE, (28) IT_FINAL-NAME1, "Vendor name
*--IR details
SY-VLINE, (10) IT_FINAL-IR_BELNR, "IR-Mat Doc
SY-VLINE, (5) IT_FINAL-IR_BUZEI, "IR-It
SY-VLINE, (9) IT_FINAL-IR_BUDAT, "IR-Post dt
SY-VLINE, (13) IT_FINAL-IR_MENGE, "#EC UOM_IN_MES
"IR-Quantity
*--GR details
SY-VLINE, (10) IT_FINAL-GR_BELNR, "GR-Mat Doc
SY-VLINE, (5) IT_FINAL-GR_BUZEI, "GR-It
SY-VLINE, (9) IT_FINAL-GR_BUDAT, "GR-Post dt
SY-VLINE, (13) IT_FINAL-GR_MENGE, SY-VLINE.
"#EC UOM_IN_MES
"GR-Quantity
ENDLOOP.
FORMAT COLOR OFF.
ENDFORM. " DISPLAY_PODATA
*& Form DOWN_LOAD_TO_EXCEL
text
FORM DOWN_LOAD_TO_EXCEL .
<b>REFRESH FIELDNAMES.
FIELDNAMES-TEXT = TEXT-010.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-011.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-012.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'Created By'(036).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-014.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'Company Code'(037).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-016.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'Material Group'(038).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'Order Quantity'(039).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-019.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-020.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-021.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'Business Area'(040).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-023.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-024.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'IR Material Doc'(041).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'IR Item'(042).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'IR Posting Date'(043).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-028.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'GR Material Doc'(044).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'GR Item'(045).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = 'GR Posting Date'(046).
APPEND FIELDNAMES.CLEAR FIELDNAMES.
FIELDNAMES-TEXT = TEXT-032.
APPEND FIELDNAMES.CLEAR FIELDNAMES.
*--FM to download data to Excel sheet
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = C_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_FINAL
FIELDNAMES = FIELDNAMES
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE E001(ZZ) WITH 'Data could not downloaded'(047).
ENDIF.</b>ENDFORM. " DOWN_LOAD_TO_EXCEL
*& Form GET_FINAL_DATA
To Populate required data in final internal table
FORM GET_FINAL_DATA .
CLEAR IT_FINAL.
REFRESH IT_FINAL.
LOOP AT IT_POITEM.
CLEAR IT_POHEADER.
READ TABLE IT_POHEADER WITH KEY EBELN = IT_POITEM-EBELN.
IF SY-SUBRC = 0.
MOVE : IT_POHEADER-EBELN TO IT_FINAL-EBELN, "Purchasing Doc
IT_POITEM-EBELP TO IT_FINAL-EBELP, "Item
IT_POHEADER-AEDAT TO IT_FINAL-AEDAT, "Created On
IT_POHEADER-ERNAM TO IT_FINAL-ERNAM, "Created By
IT_POITEM-MATNR TO IT_FINAL-MATNR, "Material
IT_POITEM-BUKRS TO IT_FINAL-BUKRS, "Company code
IT_POITEM-WERKS TO IT_FINAL-WERKS, "Plant
IT_POITEM-MATKL TO IT_FINAL-MATKL, "Material Group
IT_POITEM-MENGE TO IT_FINAL-MENGE, "Order Qty
IT_POITEM-NETPR TO IT_FINAL-NETPR, "Net Price
IT_POITEM-PEINH TO IT_FINAL-PEINH, "Price Unit
IT_POITEM-NETWR TO IT_FINAL-NETWR, "Net Value
IT_POHEADER-LIFNR TO IT_FINAL-LIFNR. "Vendor
*--To Insert IR details
CLEAR IT_HISTORY.
READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN
EBELP = IT_POITEM-EBELP
VGABE = '2'
BEWTP = 'Q'.
IF SY-SUBRC = 0.
MOVE :
IT_HISTORY-BELNR TO IT_FINAL-IR_BELNR, "IR-Number of Mat Doc
IT_HISTORY-BUZEI TO IT_FINAL-IR_BUZEI, "IR-Item in mat Doc
IT_HISTORY-BUDAT TO IT_FINAL-IR_BUDAT, "IR-Posting date
IT_HISTORY-BUDAT TO IT_FINAL-IR_MENGE. "IR-Quantity
ENDIF.
*--To insert GR details
CLEAR IT_HISTORY.
READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN
EBELP = IT_POITEM-EBELP
VGABE = '1'
BEWTP = 'E'.
IF SY-SUBRC = 0.
MOVE :
IT_HISTORY-BELNR TO IT_FINAL-GR_BELNR, "IR-Number of Mat Doc
IT_HISTORY-BUZEI TO IT_FINAL-GR_BUZEI, "IR-Item in mat Doc
IT_HISTORY-BUDAT TO IT_FINAL-GR_BUDAT, "IR-Posting date
IT_HISTORY-BUDAT TO IT_FINAL-GR_MENGE. "IR-Quantity
ENDIF.
*--To insert Vendor details
CLEAR IT_VENDOR.
READ TABLE IT_VENDOR WITH KEY LIFNR = IT_POHEADER-LIFNR.
IF SY-SUBRC = 0.
MOVE : IT_VENDOR-NAME1 TO IT_FINAL-NAME1.
ENDIF.
*--To insert Business area
CLEAR IT_BUSINESS.
READ TABLE IT_BUSINESS WITH KEY EBELN = IT_POITEM-EBELN
EBELP = IT_POITEM-EBELP.
IF SY-SUBRC = 0.
MOVE : IT_BUSINESS-GSBER TO IT_FINAL-GSBER.
ENDIF.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ENDLOOP.
ENDFORM. " GET_FINAL_DATA
thanks
Sunil -
hi,
by ALV_GRID is it possible to filter the no of columns download into Excel?
EX: if my ALV(report) contains 30 fileds and i am diplaying only 10 fileds on output by using variant.. is it possible to down load that displayed 10 feilds into excel sheet not total 30 fileds..
sample codes are welcome......
Regards
Ashok Parupalli.
Message was edited by: Ashok ParupalliHi Ashok,
You need to download the total excel sheet into Internal table, there is a one way to ignore excel sheet rows, but you can ignore records only starts from first in the excel sheet, you can not ignore the middle of records in the excel sheet, i mean if the excle sheer is having 30 rows, then you can take from 20th row to 30th row, but you can not ignore the middle of records while uploading the excel sheet.
i do not know whether it is possible with OLE, anyways Look at transaction DWDM for demo/examples, there's lots of tricks with OLEobjects
look at the below program, this is OO concept
http://www.sapgenie.com/abap/code/abap41.htm
Thanks
Sudheer -
Using download button in ALV to download to excel
Hi,
Please provide me the solution on using download button in Hierarchial List ALV to download to excel.I need to download the Header and Item details in a single line (in one line)in the Excel sheet.
Please suggest the solution and sample code ASAP.
Thanks and Regards,
Latha.Hi Rames,
my mail id : [email protected]
Thanks and Regards,
Vidyullatha.
Maybe you are looking for
-
i downloaded 3 songs to my pc and sync'd my ipod and the songs do not tranfer. is this related to not having the proper itunes version vs ios? I cannot get the songs to sync, but I can move other songs to different playlists and they sync fine...an
-
How do I duplicate layers & groups without automatically adding a "copy", "copy 1", "copy #" at the end of the new group? It's been pestering me for quite a while now, since I often work with the same elements over and over again. Its frustrating to
-
Transaction code for creation of transaction keys in obyc
Dear Experts, Can u tell me what is the transaction code for creation of transaction keys in obyc asap. Thanks & Regards, Radhika.
-
Adobe Reader Blocked in Safari
It's been a while, but ever since I upadated to Safari 7.0.1 (or maybe even the version earlier), I've been unable to open any PDF documents inside of Safari. When I click on a link on Google linked to a PDF document, a grey page shows up with the me
-
How to Schedully running PL/SQL?
Hi everyone, i'm a novice in pl/sql, i'm still learning on the script. I have a database which storing the inventory for waste product. I need to keep track the new waste and update the balance everyday exactly at 11pm. My problem is sometimes the jo