Format of Excel Sheet
Hi experts,
I am working on Account receivables in oracle applications.I am getting one problem . I run my query in Toad and I am saving output in .xls format.i got output in comma separted.like
cust_no|Cust_name|trx_no|trx_date|amount|open_bal|closed_bal|curr_bal
1 xxx 110 12/01/06 10000 50000 60000 10000
But i want output like this
Cust_no:1
Cust_name:xxx
open_bal:50000
Trx_no Trx_date Amount Curr_bal
110 12/01/06 10000 10000
closed_bal:60000.
I want output like this in excel sheet.
how to do This?Please give me solution.
I want this output by using query only to display in excel sheet.Dont use rdf and anything.
My code is:
SELECT
HCA.ACCOUNT_NUMBER ACCOUNT_NUMBER
,RCT.TRX_NUMBER TRX_NUMBER
,HP.PARTY_NAME PARTY_NAME
,DECODE(RCT.STATUS_TRX,'OP','OPEN','CLOSED') STATUS
,HL.ADDRESS1 || HL.ADDRESS2 || HL.ADDRESS3|| HL.PROVINCE || HL.CITY || HL.STATE ||HL.POSTAL_CODE || HL.COUNTRY ADDRESS
,HCSU.LOCATION LOCATION
,RCT.TRX_DATE TRX_DATE
,APS.DUE_DATE DUE_DATE
,RCTG.GL_DATE GL_DATE
,APS.AMOUNT_DUE_ORIGINAL AMOUNT_DUE_ORIGINAL
,APS.AMOUNT_DUE_REMAINING AMOUNT_DUE_REMAINING
,APS.AMOUNT_APPLIED AMOUNT_APPLIED
,DECODE(RCTT.TYPE,'DM','DEBIT MEMO','CM','CREDIT MEMO','DEP','DEPOSIT','GUAR','GURANTEE','INVOICE') TYPE
,RCTT.STATUS STATUS1
,RBS.NAME NAME
,RCT.CT_REFERENCE CT_REFERENCE
,F1(HCA.ACCOUNT_NUMBER,'01-OCT-2007') OPENING_BALANCE
,F2(HCA.ACCOUNT_NUMBER,RCT.TRX_NUMBER,'01-OCT-2007','04-NOV-2007') CURRENT_BAL
,F1(HCA.ACCOUNT_NUMBER,'01-OCT-2007') + F2(HCA.ACCOUNT_NUMBER,RCT.TRX_NUMBER,'01-OCT-2007','04-NOV-2007') CLOSED_BAL
,GCC.SEGMENT1 BC
FROM
RA_CUSTOMER_TRX_ALL RCT
,AR_PAYMENT_SCHEDULES_ALL APS
,RA_CUST_TRX_TYPES_ALL RCTT
,RA_CUST_TRX_LINE_GL_DIST_ALL RCTG
,RA_BATCH_SOURCES_ALL RBS
,HZ_PARTY_SITES HPS
,HZ_PARTIES HP
,HZ_CUST_ACCOUNTS HCA
,HZ_CUST_SITE_USES_ALL HCSU
,HZ_CUST_ACCT_SITES_ALL HCAS
,HZ_LOCATIONS HL
,GL_CODE_COMBINATIONS GCC
WHERE
RCT.CUSTOMER_TRX_ID=APS.CUSTOMER_TRX_ID
AND RCTT.CUST_TRX_TYPE_ID=RCT.CUST_TRX_TYPE_ID
AND RCTG.CUSTOMER_TRX_ID=RCT.CUSTOMER_TRX_ID
AND RCT.BATCH_SOURCE_ID=RBS.BATCH_SOURCE_ID
AND HP.PARTY_ID = HCA.PARTY_ID
AND HP.PARTY_ID=HPS.PARTY_ID
AND HL.LOCATION_ID = HPS.LOCATION_ID
AND HCA.CUST_ACCOUNT_ID =HCAS.CUST_ACCOUNT_ID
AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
AND HPS.PARTY_SITE_ID = HCAS.PARTY_SITE_ID
AND RCT.BILL_TO_SITE_USE_ID = HCSU.SITE_USE_ID
AND GCC.CODE_COMBINATION_ID = RCTG.CODE_COMBINATION_ID
AND HCSU.SITE_USE_CODE = 'BILL_TO'
AND RCTG.GL_DATE BETWEEN '01-OCT-2007' AND '04-NOV-2007'
AND RCT.TRX_NUMBER = '1107010103'
GROUP BY
HCA.ACCOUNT_NUMBER
,RCT.TRX_NUMBER
,HP.PARTY_NAME
,DECODE(RCT.STATUS_TRX,'OP','OPEN','CLOSED')
,HL.ADDRESS1 || HL.ADDRESS2 || HL.ADDRESS3|| HL.PROVINCE || HL.CITY || HL.STATE ||HL.POSTAL_CODE || HL.COUNTRY
,HCSU.LOCATION
,RCT.TRX_DATE
,APS.DUE_DATE
,RCTG.GL_DATE
,APS.AMOUNT_DUE_ORIGINAL
,APS.AMOUNT_DUE_REMAINING
,APS.AMOUNT_APPLIED
,DECODE(RCTT.TYPE,'DM','DEBIT MEMO','CM','CREDIT MEMO','DEP','DEPOSIT','GUAR','GURANTEE','INVOICE')
,RCTT.STATUS
,RBS.NAME
,RCT.CT_REFERENCE
,GCC.SEGMENT1
I'm not looking at your code as you haven't formatted it on the forum. To do this use [code][/code] or [pre][/pre] tags around the code. Try editing your first post and re-pasting the code using those tags so we can read it.
You are currently getting...
SQL> with t as (select 1 as cust_no
2 ,'xxx' as cust_name
3 ,110 as trx_no
4 ,to_date('12/01/2006','DD/MM/YYYY') as trx_date
5 ,10000 as amount
6 ,50000 as open_bal
7 ,60000 as close_bal
8 ,10000 as curr_bal
9 from dual)
10 -- END OF TEST DATA
11 select * from t;
CUST_NO CUS TRX_NO TRX_DATE AMOUNT OPEN_BAL CLOSE_BAL CURR_BAL
1 xxx 110 12/01/2006 00:00:00 10000 50000 60000 10000And you want something like this?
SQL> with t as (select 1 as cust_no
2 ,'xxx' as cust_name
3 ,110 as trx_no
4 ,to_date('12/01/2006','DD/MM/YYYY') as trx_date
5 ,10000 as amount
6 ,50000 as open_bal
7 ,60000 as close_bal
8 ,10000 as curr_bal
9 from dual)
10 -- END OF TEST DATA
11 select col1||','||col2||','||col3||','||col4
12 from (
13 select cust_no, 1 as ord_col, 'Cust_no:' as col1, TO_CHAR(cust_no) as col2, null as col3, null as col4 from t union all
14 select cust_no, 2, 'Cust_name:', cust_name, null, null from t union all
15 select cust_no, 3, 'Open_bal:', TO_CHAR(open_bal), null, null from t union all
16 select cust_no, 4, 'Trx_no', 'Trx_date', 'Amount', 'Curr_bal' from t union all
17 select cust_no, 5, TO_CHAR(trx_no), TO_CHAR(trx_date, 'DD/MM/YY'), TO_CHAR(amount), TO_CHAR(curr_bal) from t union all
18 select cust_no, 6, 'Close_bal:', TO_CHAR(close_bal), null, null from t
19 )
20 order by cust_no, ord_col;
COL1||','||COL2||','||COL3||','||CO
Cust_no:,1,,
Cust_name:,xxx,,
Open_bal:,50000,,
Trx_no,Trx_date,Amount,Curr_bal
110,12/01/06,10000,10000
Close_bal:,60000,,
6 rows selected.
SQL>Remember, Comma seperated files are NOT excel files. .xls files are proprietary microsoft format files. If you save your data out as comma seperated you should use the file extension ".csv".
Excel can recognise CSV files and will load them in, as can other products.
Similar Messages
-
Formatting of EXCEL Sheets during download
Hi all,
There is a requirement for Formatting EXCEL Sheets when downloaded into an FTP site in background.
The internal table is saved in application server with .xls extension and transferred to FTP thru RFC.
is there any way to format this EXCEL file and get it formatted in FTP when it is seen.
The report will run in background daily and every day the report has to be in same format.
Thanks in Advance..
Vivek ..Hi
You can not format EL file that is uploaded. You have to format the internal table before generation XL file from the internal table. Internal table should have all fields in char type. set char length for each field like
data: begin of itab..
field1(20) type c,
field2(20) type c,
Append header record if u want into this itab as first record.
Append all records into this itab.
Generate XL file from this itab.
I suggest you that..
Upload this itab in to application server as 'DAT' format then generate XL file from this file. Dont set .xls when you upload itab to appl. server.
Bala
Note: Award points if helpful -
Inserting dates in mm/dd/yyyy format in excel sheet
I am reading data from sql server 2005 which returns dates in the yyyy/mm/dd format. Now I have to insert this data into an excel sheet and it is supposed to be in the mm/dd/yyyy format. I tried converting the date formats in java but when I insert the date as a String the program throws
java.sql.SQLException: [Microsoft][ODBC Excel Driver] Data type mismatch in criteria expression.
If I try to insert it as a java.util.Date or java.sql.Date it also includes the timestamp(which i do not want ) since thats the way MS SQL Server returns it in the result set.
Someone said using PreparedStatement would help. How?
Can someone please help me ?neoforu7 wrote:
I have to insert data into excel sheets that already have pre defined macroes that do some calculations and get the data in the format i want. I dont know if this is possible with POI or JExcel. You most definitely not are going to find that in ODBC. The excel odbc driver does very, very little.
[http://support.microsoft.com/kb/178717]
And I also dont have the time to learn these. So please help me if u canSorry - then you should just tell someone that it isn't going to happen.
Your requirements, excel and macros, is going to take a LOT of time.
At a minimum, without seeing the exact requirements and macros, myself I wouldn't start with less than three months of time. -
Formatting / Post Processing of Exported Excel Sheet
Hi ,
Issue:
The Columns in the Excel Sheet are not fully visible when we export Report from CR viewer to Excel Sheet. So we had planned for Post processing of the Excel Sheet using VBA or .NET etc to format the Excel Sheet, which would be on the server side, meaning the End user will never see the formatting process, but only the End Report. Is it possible to achieve this ??
NOTE:
1) VBA or .NET could not be run on the Linux Server but we could take advantage of the windows server in the presentation layer.
Architecture:
Presentation Layer
Linux Server <--> Windows .Net Server <--
> End User
{Crystal RAS Server} <-->{GUI CR Viewer Application}<--
>
Our Proposed Solution:
1) Create an GUI Application that has CR viewer in it .
2) Create a Separate Excel Export button on the webpage.
3) when the user wants to export the report , he clicks the button.
4) The GUI/ application saves the Exported Excel Sheet from the Ras server to the windows server.
5) Then the .Net or the Vba code is applied to process/Format the Excel Sheet.
6) When complete the End user is prompted for saving the report to a local disk.
My questions:
1) Can this be achieved ?
2) what would be the best way to handle this ?
3) what should be the process flow ?
4) what are the things to be considered while planning for such a design ?
Regards,
Ramkumar GovindasamySo you're looking at using RAS .NET SDK on the Application Layer to export a Crystal Report to Excel, save to temp file on the Application Layer machine, process that temp file, and stream that back out to the client web browser.
Considerations:
1. You need to create your own custom UI button to trigger the process, since the .NET Web Forms Crystal Reports viewer won't have the hooks to customize the Excel export.
2. Running Excel VBA from your Web App may be problematic - you'd have to be particularly careful if the system is under load, since the Excel VBA - COM-Interop isn't necessarily designed for high throughput. Under high load, you may get file locking or COM-Interop layer just refuse to process. It's pretty common to try and catch exceptions and retry if you encounter this.
You'd likely not find anyone here familiar with 2 above, but 1 is fairly common.
Sincerely,
Ted Ueda -
Vendor open items wise ALV Grid Display (FBL1N) report to Excel Sheet
Hi All,
I need vendor wise open items and cleared items in ALV Grid format in excel sheet.
I'm Trying that in T Code FBL1N, After the execution. I had select ALV Grid format like this From the menu bar->Settings-> Switch list.
After that i get ALV Grid format, Then i'm doing export the data to excel sheet. like this From the Menu bar->List->Export->Spread sheet.
That time i'm getting Error Message no. 0K064, Filter criteria, sorting, totals and subtotals are not taken into account.
I want vendor wise sorting totals and subtotals,
How can i over come this Error please let me now.
Thanks,
AmarHi Amar,
Please check the KBA 2083705.
https://websmp230.sap-ag.de/sap(bD1odSZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3230383337303526
Regards,
Monika -
Down load report output from SAP to Excel sheet
Hi,
Actually i am downloading report out into Excel sheet using FM GUI_LOAD. But in this case in Excel sheet we are getting the date format as *3/21/2008. But the requerment is the date format in Excel sheet should be display like 3/21/2008.So please advice me.
Code:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = w-filename
filetype = 'DBF'
col_select = 'X'
col_select_mask = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
wk1_n_format = 'X'
wk1_t_format = 'X'
DAT_MODE = 'X'
TABLES
data_tab = dtab_dat
fieldnames = htab.
Thanks in advance.
Regards,
Satya.Hi,
Please let me know the type of dtab_dat.
Regards
jana -
How to export the data as integer into excel sheet?
Hi All,
I am working on export to excel functionality and using JEXCEL API to create it. When I export the data to excel sheet, the data are stored in text format in the excel sheet. If I click on summation button on excel sheet, it is not summing up the column values since it is stored as the text format.
I am writing the following code:
for(Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();){
String attributeName = (String)iter.next();
for(int index = 0; index < dataNode.size(); index++){
try{
IWDNodeElement nodeElement = dataNode.getElementAt(index);
String colVal = nodeElement.getAttributeAsTex(attributeName);
Label value = new Label(j, index + 1, colVal);
sheet.addCell(value);
j++;
Here colVal is the variable which holds the data in string format. So I was just trying to convert it into integer format and used Integer.parseInt(colVal).
But Label keyword accepts only the int,int,string arguments.
Is there any other option to change it as integer value while exporting to excel sheet.
Pls suggest.
This is very urgent.
Regards,
Subashini.Hi Gopal,
Pls refer the following link.
/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
I have used the same coding which is mentioned in this link.
And also I cannot use integer.parseInt(colval) because new Label() will accept only the int,int,string as parameters.
Here goes my to excel method code which exports the data to excel sheet .
private FileInputStream toExcel(IWDNode dataNode, Map columnInfos) {
String fileName = "output.xls";
IWDCachedWebResource cachedExcelResource = null;
int i = 0;
try{
File f = new File("output.xls");
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
for(Iterator coluinfoitr = columnInfos.keySet().iterator(); coluinfoitr.hasNext();){
Label label = new Label(i, 0, (String)columnInfos.get(coluinfoitr.next()));
sheet.addCell(label);
i++;
int j = 0;
for(Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();){
String attributeName = (String)iter.next();
for(int index = 0; index < dataNode.size(); index++){
try{
IWDNodeElement nodeElement = dataNode.getElementAt(index);
String colVal = nodeElement.getAttributeAsText(attributeName);
Label value = new Label(j, index + 1, colVal);
sheet.addCell(value);
catch (Exception e){
wdComponentAPI.getMessageManager().reportException(" Data Retrive Err :" + e.getLocalizedMessage(),false);
j++;
workbook.write();
FileInputStream excelCSVFile = new FileInputStream(f);
cachedExcelResource = getCachedWebResource(excelCSVFile, fileName, WDWebResourceType.getWebResourceType("xls", "application/ms-excel"));
wdContext.currentContextElement().setExcelDownload(cachedExcelResource.getURL());
workbook.close();
It is exporting the data in text format. So I am unable to sum up the column values in the excel sheet.
I need an alternate solution wherein I can export the data in integer format to excel sheet and then sum up the column values by clicking on summation button.
Hope I am clear now.
Pls suggest.
Regards,
Subashini. -
Sending a excel sheet as attachment in mail
Hi,
I have requirement where I need to send excel sheet as attachment in mail. I could do it by using FM SO_NEW_DOCUMENT_ATT_SEND_API1. But, I am not able to format the excel sheet before sending.
I need to make heading bold, fix column width and wrap text in some cells, and send the mail.
Pls help me with your suggestions.
Thanks,
Siva.this link will show you how to do formatting in Excel using the OLE method, then use that EXCEL to send the MAIL using your program \
[OLE-format excel |http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm]
Hope That Helps
Anirban M. -
How can I mail the Job Log in the form of an excel sheet?
Daily I have to monitor a Job and I have to retrieve the Job Log in an excel sheet, Format the excel sheet, and then mail the excel sheet and the Job Status(Finished/Cancelled) to Client/Person Incharge.
I want to automate this entire process. Please guide me, how can I write a program that mails the Job Log, in the form of an excel sheet, to the Client?
Edited by: Jiten Rajendra Barai on Nov 25, 2008 3:03 PMHi,
You can use this FM to mail the excel sheet.
SO_NEW_DOCUMENT_ATT_SEND_API1
Also have a look at the below thread, it might be very helpful.
Sending Excel attachment in E-mail
Cheers... -
Hi,
My requirement is to format an excel sheet.
I have the excel already on my system and now i need to adjust the column sizes and make the first line in the excel to bold characters.
This the code that i have written
****declarations
INCLUDE ole2incl.
DATA: excel TYPE ole2_object.
DATA: w_books TYPE ole2_object.
DATA: w_book TYPE ole2_object.
DATA: l_fileformat TYPE localfile.
DATA: column TYPE ole2_object.
code***
l_fileformat = l_ftemp.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
SET PROPERTY OF excel 'VISIBLE' = 1.
Open the file
CALL METHOD OF excel 'WORKBOOKS' = w_books.
CALL METHOD OF w_books 'OPEN' = w_book
EXPORTING
#1 = l_fileformat.
CALL METHOD OF w_books 'Columns' = column EXPORTING #1 = 1.
CALL METHOD OF column 'Autofit'.
CALL METHOD OF w_book 'SAVE'.
CALL METHOD OF w_book 'close'.
CALL METHOD OF excel 'Quit'.
FREE excel.
This code does not adjust the cloumn width. It opens up on the desktop and does not close. Can anyone help me on this?
Its very urgent.
Thanks,
rakshaHi,
Copy and paste the below program, you understnad everything
*& Report ZETA_EXCEL_DOWNLOAD_CLIPBOARD *
report zeta_excel_download_clipboard .
include ole2incl.
data: w_cell1 type ole2_object,
w_cell2 type ole2_object.
*--- Ole data Declarations
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
gs_interior type ole2_object, " Pattern
worksheet type ole2_object,
h_cell type ole2_object,
h_cell1 type ole2_object,
range type ole2_object,
h_sheet2 type ole2_object,
h_sheet3 type ole2_object,
gs_font type ole2_object,
flg_stop(1) type c.
** Internal table Declaration
data: begin of t_excel occurs 0,
vkorg(20) type c, "Sales Org
vbtyp(20) type c, "Document Category
auart(20) type c, "Document Type
ernam(20) type c, "Created By
vbeln(20) type c, "Document Number
posnr(20) type c, "Item Number
erdat(20) type c, "Created Date
vdatu(20) type c, "Header Requested Delivery Date
reqdat(20) type c, "Request date
condat(20) type c, "Confirm date
lifsk(20) type c, "Header Block
txt30(30) type c, "Order User Status Description
lifsp(20) type c, "Line Block
dispo(20) type c, "MRP Controller
dsnam(20) type c, "MRP Controller Description
vmsta(20) type c, "Material Sales Status
kunnr(20) type c, "Sold To
cname(35) type c, "Sold To Name
regio(20) type c, "State
cufd(10) type c, "CUD
bstnk(20) type c, "PO#
bsark(20) type c, "Ordering Method
matnr(20) type c, "Material
maktx(35) type c, "Material Description
t200(20) type c, "T200
vtext(20) type c, "T200 Description
matkl(20) type c, "Material Group
zzbomind(7) type c, "BOM Indicator
ostat(20) type c, "Order Status
cmgst(20) type c, "CRD
inco1(20) type c, "Incoterms
oqty(20) type c, "Order Quantity
pqty(20) type c, "Open Quantity
unit(20) type c, "UOM
onet(20) type c, "Order Value
pnet(20) type c, "Open Value
curr(20) type c, "Currency key
so_bezei like tvkbt-bezei,"Sales Office
sg_bezei like tvgrt-bezei,"Sales Group
bname(20) type c, "Ordering Party
contact(20) type c, "Contact Name
telf1(20) type c, "Contact telf1
reqqty(20) type c, "Item Request qty
reqval(20) type c, "Item Request value
conqty(20) type c, "Item Confirm qty
conval(20) type c, "Item Confirm value
zzrev(02) type c, "Revenue recognition acceptance
bezei(20) type c, "Revenue recognition text
vgbel(20) type c, "Reference Order for RETURNS
0008text(255) type c, "Internal Order Comment Text
end of t_excel.
data: t_excel_bckord like t_excel occurs 0 with header line,
t_excel_bcklog like t_excel occurs 0 with header line,
t_excel_blkord like t_excel occurs 0 with header line.
types: data1(1500) type c,
ty type table of data1.
data: it type ty with header line,
it_2 type ty with header line,
it_3 type ty with header line,
rec type sy-tfill,
deli(1) type c,
l_amt(18) type c.
data: begin of hex,
tab type x,
end of hex.
field-symbols: <fs> .
constants cns_09(2) type n value 09.
assign deli to <fs> type 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
data gv_sheet_name(20) type c .
* M A C R O Declaration
define ole_check_error.
if &1 ne 0.
message e001(zz) with &1.
exit.
endif.
end-of-definition.
t_excel_bckord-vkorg = 'ABC'.
t_excel_bckord-vbtyp = 'DEF'.
t_excel_bckord-auart = 'GHI'.
t_excel_bckord-ernam = 'JKL'.
t_excel_bckord-vbeln = 'MNO'.
t_excel_bckord-0008text = 'XYZ'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC1'.
t_excel_bckord-vbtyp = 'DEF1'.
t_excel_bckord-auart = 'GHI1'.
t_excel_bckord-ernam = 'JKL1'.
t_excel_bckord-vbeln = 'MNO1'.
t_excel_bckord-0008text = 'XYZ1'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC2'.
t_excel_bckord-vbtyp = 'DEF2'.
t_excel_bckord-auart = 'GHI2'.
t_excel_bckord-ernam = 'JKL2'.
t_excel_bckord-vbeln = 'MNO2'.
t_excel_bckord-0008text = 'XYZ2'.
append t_excel_bckord.
t_excel_bcklog-vkorg = 'ABC'.
t_excel_bcklog-vbtyp = 'DEF'.
t_excel_bcklog-auart = 'GHI'.
t_excel_bcklog-ernam = 'JKL'.
t_excel_bcklog-vbeln = 'MNO'.
t_excel_bcklog-0008text = 'XYZ'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC1'.
t_excel_bcklog-vbtyp = 'DEF1'.
t_excel_bcklog-auart = 'GHI1'.
t_excel_bcklog-ernam = 'JKL1'.
t_excel_bcklog-vbeln = 'MNO1'.
t_excel_bcklog-0008text = 'XYZ1'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC2'.
t_excel_bcklog-vbtyp = 'DEF2'.
t_excel_bcklog-auart = 'GHI2'.
t_excel_bcklog-ernam = 'JKL2'.
t_excel_bcklog-vbeln = 'MNO2'.
t_excel_bcklog-0008text = 'XYZ2'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC3'.
t_excel_bcklog-vbtyp = 'DEF3'..
t_excel_bcklog-auart = 'GHI3'.
t_excel_bcklog-ernam = 'JKL3'.
t_excel_bcklog-vbeln = 'MNO3'.
t_excel_bcklog-0008text = 'XYZ3'.
append t_excel_bcklog.
t_excel_blkord-vkorg = 'ABC'.
t_excel_blkord-vbtyp = 'DEF'.
t_excel_blkord-auart = 'GHI'.
t_excel_blkord-ernam = 'JKL'.
t_excel_blkord-vbeln = 'MNO'.
t_excel_blkord-0008text = 'XYZ'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC1'.
t_excel_blkord-vbtyp = 'DEF1'.
t_excel_blkord-auart = 'GHI1'.
t_excel_blkord-ernam = 'JKL1'.
t_excel_blkord-vbeln = 'MNO1'.
t_excel_blkord-0008text = 'XYZ1'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC2'.
t_excel_blkord-vbtyp = 'DEF2'.
t_excel_blkord-auart = 'GHI2'.
t_excel_blkord-ernam = 'JKL2'.
t_excel_blkord-vbeln = 'MNO2'.
t_excel_blkord-0008text = 'XYZ2'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC3'.
t_excel_blkord-vbtyp = 'DEF3'..
t_excel_blkord-auart = 'GHI3'.
t_excel_blkord-ernam = 'JKL3'.
t_excel_blkord-vbeln = 'MNO3'.
t_excel_blkord-0008text = 'XYZ3'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC4'.
t_excel_blkord-vbtyp = 'DEF4'..
t_excel_blkord-auart = 'GHI4'.
t_excel_blkord-ernam = 'JKL4'.
t_excel_blkord-vbeln = 'MNO4'.
t_excel_blkord-0008text = 'XYZ4'.
append t_excel_blkord.
loop at t_excel_bckord.
concatenate
t_excel_bckord-vkorg
t_excel_bckord-vbtyp
t_excel_bckord-auart
t_excel_bckord-ernam
t_excel_bckord-vbeln
t_excel_bckord-posnr
t_excel_bckord-erdat
t_excel_bckord-vdatu
t_excel_bckord-reqdat
t_excel_bckord-condat
t_excel_bckord-lifsk
t_excel_bckord-txt30
t_excel_bckord-lifsp
t_excel_bckord-dispo
t_excel_bckord-dsnam
t_excel_bckord-vmsta
t_excel_bckord-kunnr
t_excel_bckord-cname
t_excel_bckord-regio
t_excel_bckord-cufd
t_excel_bckord-bstnk
t_excel_bckord-bsark
t_excel_bckord-matnr
t_excel_bckord-maktx
t_excel_bckord-t200
t_excel_bckord-vtext
t_excel_bckord-matkl
t_excel_bckord-zzbomind
t_excel_bckord-ostat
t_excel_bckord-cmgst
t_excel_bckord-inco1
t_excel_bckord-oqty
t_excel_bckord-pqty
t_excel_bckord-unit
t_excel_bckord-onet
t_excel_bckord-pnet
t_excel_bckord-curr
t_excel_bckord-so_bezei
t_excel_bckord-sg_bezei
t_excel_bckord-bname
t_excel_bckord-contact
t_excel_bckord-telf1
t_excel_bckord-reqqty
t_excel_bckord-reqval
t_excel_bckord-conqty
t_excel_bckord-conval
t_excel_bckord-zzrev
t_excel_bckord-bezei
t_excel_bckord-vgbel
t_excel_bckord-0008text
into it
separated by deli.
append it.
clear it.
endloop.
loop at t_excel_bcklog.
concatenate
t_excel_bcklog-vkorg
t_excel_bcklog-vbtyp
t_excel_bcklog-auart
t_excel_bcklog-ernam
t_excel_bcklog-vbeln
t_excel_bcklog-posnr
t_excel_bcklog-erdat
t_excel_bcklog-vdatu
t_excel_bcklog-reqdat
t_excel_bcklog-condat
t_excel_bcklog-lifsk
t_excel_bcklog-txt30
t_excel_bcklog-lifsp
t_excel_bcklog-dispo
t_excel_bcklog-dsnam
t_excel_bcklog-vmsta
t_excel_bcklog-kunnr
t_excel_bcklog-cname
t_excel_bcklog-regio
t_excel_bcklog-cufd
t_excel_bcklog-bstnk
t_excel_bcklog-bsark
t_excel_bcklog-matnr
t_excel_bcklog-maktx
t_excel_bcklog-t200
t_excel_bcklog-vtext
t_excel_bcklog-matkl
t_excel_bcklog-zzbomind
t_excel_bcklog-ostat
t_excel_bcklog-cmgst
t_excel_bcklog-inco1
t_excel_bcklog-oqty
t_excel_bcklog-pqty
t_excel_bcklog-unit
t_excel_bcklog-onet
t_excel_bcklog-pnet
t_excel_bcklog-curr
t_excel_bcklog-so_bezei
t_excel_bcklog-sg_bezei
t_excel_bcklog-bname
t_excel_bcklog-contact
t_excel_bcklog-telf1
t_excel_bcklog-reqqty
t_excel_bcklog-reqval
t_excel_bcklog-conqty
t_excel_bcklog-conval
t_excel_bcklog-zzrev
t_excel_bcklog-bezei
t_excel_bcklog-vgbel
t_excel_bcklog-0008text
into it_2
separated by deli.
append it_2.
clear it_2.
endloop.
loop at t_excel_blkord.
concatenate
t_excel_blkord-vkorg
t_excel_blkord-vbtyp
t_excel_blkord-auart
t_excel_blkord-ernam
t_excel_blkord-vbeln
t_excel_blkord-posnr
t_excel_blkord-erdat
t_excel_blkord-vdatu
t_excel_blkord-reqdat
t_excel_blkord-condat
t_excel_blkord-lifsk
t_excel_blkord-txt30
t_excel_blkord-lifsp
t_excel_blkord-dispo
t_excel_blkord-dsnam
t_excel_blkord-vmsta
t_excel_blkord-kunnr
t_excel_blkord-cname
t_excel_blkord-regio
t_excel_blkord-cufd
t_excel_blkord-bstnk
t_excel_blkord-bsark
t_excel_blkord-matnr
t_excel_blkord-maktx
t_excel_blkord-t200
t_excel_blkord-vtext
t_excel_blkord-matkl
t_excel_blkord-zzbomind
t_excel_blkord-ostat
t_excel_blkord-cmgst
t_excel_blkord-inco1
t_excel_blkord-oqty
t_excel_blkord-pqty
t_excel_blkord-unit
t_excel_blkord-onet
t_excel_blkord-pnet
t_excel_blkord-curr
t_excel_blkord-so_bezei
t_excel_blkord-sg_bezei
t_excel_blkord-bname
t_excel_blkord-contact
t_excel_blkord-telf1
t_excel_blkord-reqqty
t_excel_blkord-reqval
t_excel_blkord-conqty
t_excel_blkord-conval
t_excel_blkord-zzrev
t_excel_blkord-bezei
t_excel_blkord-vgbel
t_excel_blkord-0008text
into it_3
separated by deli.
append it_3.
clear it_3.
endloop.
if h_excel-header = space or h_excel-handle = -1.
* start Excel
create object h_excel 'EXCEL.APPLICATION'.
endif.
* PERFORM err_hdl.
*--- get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
* PERFORM err_hdl.
set property of h_excel 'Visible' = 1.
* add a new workbook
call method of h_mapl 'Add' = h_map.
* PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.
gv_sheet_name = 'Back Orders'.
get property of h_excel 'ACTIVESHEET' = worksheet.
set property of worksheet 'Name' = gv_sheet_name .
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
data l_rc type i.
call method cl_gui_frontend_services=>clipboard_export
importing
data = it[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
* PERFORM err_hdl.
* CALL METHOD OF h_excel 'QUIT'.
*GV_SHEET_NAME = '2ND SHEET'.
gv_sheet_name = 'Backlog'.
get property of h_excel 'Sheets' = h_sheet2 .
call method of h_sheet2 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_2[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
*GV_SHEET_NAME = '3rd SHEET'.
gv_sheet_name = 'Blocked Orders'.
get property of h_excel 'Sheets' = h_sheet3 .
call method of h_sheet3 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_3[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
*--- disconnect from Excel
free object h_zl.
free object h_mapl.
free object h_map.
free object h_excel.
Regards
Sudheer -
Excel sheet attached mail when opened shows a error message
hi all,
i have created a report for sending the output to the sap inbox as excel attachment . my problem is ;it always shows an error message when ever the attachment is opened.
I have used the function 'SO_NEW_DOCUMENT_ATT_SEND_API1' and in the table parameters, TABLES
packing_list =
passing the .XLS format and excel sheet name.
please provide me a solution to stop the display of this error message having the contents 'this file is not in a recognizable format'.
thanks and regards\
Thomas
Coding :
FORM sub_output_timeadm USING lv_usrid TYPE gty_timhours-usrid.
DATA : lv_emp1(10) TYPE c,
lv_ename(40) TYPE c,
lv_hour(10) ,
lv_lgart(15),
lv_scc(10),
lv_rcc(10),
lv_order(15),
lv_ordtext(40),
lv_act(10).
DATA : lwa_content TYPE solisti1.
DATA : lit_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,"#EC *
lit_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
lit_objtxt LIKE solisti1 OCCURS 2 WITH HEADER LINE,
lit_reclist LIKE somlreci1 OCCURS 2 WITH HEADER LINE,
lwa_docdat LIKE sodocchgi1 OCCURS 1 WITH HEADER LINE,
lv_tab_lines LIKE sy-tabix.
DATA : lv_file LIKE rlgrap-filename,
lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
DATA : lwa_receivers TYPE somlreci1 .
*Object text details
PERFORM sub_objtxt_data TABLES lit_objtxt
lit_objpack
USING lv_tab_lines.
*Document data details
PERFORM sub_document_data TABLES lwa_docdat
lit_objtxt
USING lv_file
lv_tab_lines.
PERFORM sub_topofpage TABLES lit_objbin
USING lv_line
lv_vt.
PERFORM sub_fill_columnhead TABLES lit_objbin.
LOOP AT git_content INTO lwa_content.
lv_emp1 = lwa_content+2(10).
CONDENSE lv_emp1.
lv_ename = lwa_content+15(40).
SHIFT lv_ename LEFT.
* CONDENSE lv_ename.
IF lv_ename+0(7) = text-024.
WRITE lv_ename TO lv_ename RIGHT-JUSTIFIED.
ELSE.
CONDENSE lv_ename.
ENDIF.
lv_hour = lwa_content+58(10).
CONDENSE lv_hour.
lv_lgart = lwa_content+70(15).
CONDENSE lv_lgart.
lv_scc = lwa_content+90(10).
CONDENSE lv_scc.
lv_rcc = lwa_content+103(10).
CONDENSE lv_rcc.
lv_order = lwa_content+115(15).
CONDENSE lv_order.
lv_ordtext = lwa_content+132(40).
CONDENSE lv_ordtext.
lv_act = lwa_content+174(10).
CONDENSE lv_act.
CONCATENATE lv_emp1
lv_ename
lv_hour
lv_lgart
lv_scc
lv_rcc
lv_order
lv_ordtext
lv_act INTO lv_line SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO lit_objbin.
CLEAR :lv_emp1,
lv_ename,
lv_hour,
lv_lgart,
lv_scc,
lv_rcc,
lv_order,
lv_ordtext,
lv_act ,lv_line,lwa_content.
ENDLOOP.
DESCRIBE TABLE lit_objbin LINES lv_tab_lines.
lv_tab_lines = lv_tab_lines + 1.
* Object pack details
PERFORM sub_objpack_data TABLES lit_objbin
lit_objpack
USING lv_tab_lines
lv_file.
*Receiver list details
PERFORM sub_reclist_timeadm TABLES lit_reclist
USING lv_usrid.
READ TABLE lit_reclist INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_docdat
put_in_outbox = gc_x
commit_work = gc_x
TABLES
packing_list = lit_objpack
contents_bin = lit_objbin
contents_txt = lit_objtxt
receivers = lit_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
CASE sy-subrc.
* WHEN 0.
* MESSAGE i014.
* WHEN 1.
* MESSAGE i016.
* WHEN 2.
* MESSAGE i016.
* WHEN 4.
* MESSAGE i015.
* WHEN OTHERS.
* MESSAGE i017.
ENDCASE.
ENDIF.
REFRESH git_content.
CLEAR gwa_content.
FORM sub_objtxt_data TABLES xt_objtxt STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines .
DATA : lv_zdat(10) TYPE c,
lv_zdat2(10) TYPE c.
CONSTANTS: lc_hiphen(1) TYPE c VALUE '-'.
* write sy-datum to lv_zdat mm/dd/yyyy.
* concatenate text-022 lv_zdat into xt_objtxt separated by space.
* APPEND xt_objtxt.clear xt_objtxt.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
WRITE pnpendda TO lv_zdat2 MM/DD/YYYY.
CONCATENATE text-080
lv_zdat
lc_hiphen
lv_zdat2 INTO xt_objtxt SEPARATED BY space.
APPEND xt_objtxt.CLEAR xt_objtxt.
xt_objtxt = text-067.
APPEND xt_objtxt.CLEAR xt_objtxt.
CLEAR: lv_zdat,
lv_zdat2.
DESCRIBE TABLE xt_objtxt LINES xv_tab_lines.
READ TABLE xt_objtxt INDEX xv_tab_lines.
CLEAR xt_objpack-transf_bin.
xt_objpack-head_start = 1.
xt_objpack-head_num = 0.
xt_objpack-body_start = 1.
xt_objpack-body_num = xv_tab_lines.
xt_objpack-doc_type = gc_raw.
APPEND xt_objpack.
CLEAR xt_objpack.
ENDFORM. " sub_objtxt_data
*& Form sub_document_data
*To fix the size of the document
* -->XT_DOCDAT
* -->XT_OBJTXT
* -->XV_LV_FILE
* -->XV_TAB_LINES
FORM sub_document_data TABLES xt_docdat STRUCTURE sodocchgi1
xt_objtxt STRUCTURE solisti1
USING xv_lv_file
xv_tab_lines. "#EC *
DATA : lv_subject TYPE string,
lv_open TYPE c VALUE '(',
lv_close TYPE c VALUE ')',
lv_slash TYPE c VALUE '/'.
xt_docdat-obj_name = xv_lv_file.
CONCATENATE lv_open sy-sysid
lv_slash sy-mandt lv_close INTO lv_subject.
xt_docdat-obj_descr = lv_subject.
xt_docdat-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objtxt ).
ENDFORM. " sub_document_data
*& Form sub_topofpage
* text
* -->P_LIT_OBJBIN text
FORM sub_topofpage TABLES xt_objbin STRUCTURE solisti1
USING xv_lv_line
xv_vt.
DATA: lwa_line TYPE slis_listheader.
LOOP AT git_header INTO lwa_line.
CONCATENATE lwa_line-key lwa_line-info
INTO xv_lv_line SEPARATED BY xv_vt.
CONCATENATE gc_add xv_lv_line xv_vt
xv_vt "TAB space
xv_vt
xv_vt
xv_vt
xv_vt
xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
INTO xv_lv_line.
APPEND xv_lv_line TO xt_objbin.
ENDLOOP.
ENDFORM. " sub_topofpage
*& Form sub_fill_columnhead
* text
* --> p1 text
* <-- p2 text
FORM sub_fill_columnhead TABLES xt_objbin STRUCTURE solisti1.
DATA: lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
lv_zdat(10).
DATA : lv_line1(40),
lv_line2(10),
lv_line3(10),
lv_line4(3),
lv_line5(40).
lv_line1 = text-008.
WRITE sy-datum TO lv_zdat MM/DD/YYYY.
lv_line2 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_vt
lv_vt
lv_vt
* lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1, lv_line2, lv_zdat.
lv_line1 = text-009.
lv_line2 = text-010.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
lv_line3 = lv_zdat.
CLEAR lv_zdat.
lv_line4 = ' - '.
WRITE pnpendda TO lv_zdat MM/DD/YYYY.
lv_line5 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_line3
lv_line4
lv_line5
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1,
lv_line2,lv_line3,
lv_line4, lv_line5, lv_zdat.
CONCATENATE lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR lv_line.
CONCATENATE text-013
text-014
text-015
text-016
text-017
text-018
text-019
text-026
text-020
INTO lv_line
SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line
lv_vt "TAB space
INTO lv_line.
APPEND lv_line TO xt_objbin.
ENDFORM. " sub_fill_columnhead
*& Form sub_objpack_data
*To fix the actual document size
* -->XT_OBJBIN
* -->XT_OBJPACK
* -->XV_TAB_LINES
* -->XV_LV_FILE
FORM sub_objpack_data TABLES xt_objbin STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines
xv_lv_file. "#EC *
DATA : lwa_objpack TYPE sopcklsti1.
lwa_objpack-transf_bin = gc_x.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = xv_tab_lines.
lwa_objpack-doc_type = gc_xls.
lwa_objpack-obj_name = xv_lv_file.
lwa_objpack-obj_descr = gc_descr.
lwa_objpack-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objbin ).
APPEND lwa_objpack TO xt_objpack.
CLEAR lwa_objpack.
ENDFORM. " sub_objpack_data
*& Form sub_reclist_timeadm
* text
* -->P_LIT_RECLIST text
* -->P_LV_USRID text
FORM sub_reclist_timeadm TABLES xt_reclist STRUCTURE somlreci1
USING lp_usrid TYPE gty_timhours-usrid."#EC *
*local constant
CONSTANTS : lc_b TYPE c VALUE 'B'.
*local workarea.
DATA : lwa_receivers TYPE somlreci1 ,
lwa_usrid TYPE gty_usrid ,
lwa_docdata TYPE sodocchgi1.
REFRESH : git_receivers.":, LIT_DOCDATA .
CLEAR : lwa_receivers,lwa_docdata.
IF p_timadm EQ 'X'.
MOVE: lp_usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ELSEIF p_manger EQ 'X'.
READ TABLE git_usrid INTO lwa_usrid WITH KEY pernr = gwa_emphours-magpernr
usrty = '0001' BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE: lwa_usrid-usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ENDIF.
CLEAR : lwa_usrid .
ENDIF.Hi Tona,
Please go through the code and cross check....
REPORT zcyborg_5 NO STANDARD PAGE HEADING.
TABLES : eket.
DATA : p_date TYPE d.
DATA : w_lines TYPE sy-tabix.
TYPES : BEGIN OF types_eket,
ebeln TYPE eket-ebeln,
ebelp TYPE eket-ebelp,
eindt TYPE eket-eindt,
END OF types_eket.
DATA : t_eket TYPE STANDARD TABLE OF types_eket.
Declaration for ALV display *********************
DATA : w_grid TYPE REF TO cl_gui_alv_grid,
w_custom_container TYPE REF TO cl_gui_custom_container.
RANGES : r_eindt FOR eket-eindt.
FIELD-SYMBOLS: <fs_eket> TYPE types_eket.
INITIALIZATION.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
days = '60-'
months = '0'
start_date = sy-datum
IMPORTING
result_date = p_date.
r_eindt-low = p_date.
r_eindt-high = sy-datum.
r_eindt-sign = 'I'.
r_eindt-option = 'BT'.
APPEND r_eindt.
START-OF-SELECTION.
PERFORM get_data.
PERFORM disp_data.
PERFORM email_data.
perform disp_alv.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT ebeln
ebelp
eindt
FROM eket
INTO TABLE t_eket
WHERE eindt IN r_eindt.
ENDFORM. " get_data
*& Form disp_data
text
--> p1 text
<-- p2 text
FORM disp_data.
DESCRIBE TABLE t_eket LINES w_lines.
WRITE :/5 'No of rows : ', w_lines.
WRITE :/5 'EBELN', 30 'EBELP', 50 'EINDT'.
SORT t_eket DESCENDING BY eindt.
LOOP AT t_eket ASSIGNING <fs_eket>.
AT NEW ebeln.
ULINE.
ENDAT.
WRITE : /5 <fs_eket>-ebeln, 30 <fs_eket>-ebelp, 50 <fs_eket>-eindt.
ENDLOOP.
ENDFORM. " disp_data
call function 'SEND_TABLE_TO_EXCEL'
exporting
structure_name = 'EKET'
tables
exceltab = t_eket
FORM email_data.
*Structures and internal table used to send data vai mail
DATA : objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
tab_lines LIKE sy-tabix,
doc_chng LIKE sodocchgi1.
DATA : it_attach TYPE STANDARD TABLE OF solisti1,
w_attach TYPE solisti1.
CONSTANTS : c_car TYPE x VALUE '0D',
c_tab TYPE x VALUE '09'.
CONCATENATE 'EBELN'
c_tab
'EBELP'
c_tab
'EINDT'
c_car INTO w_attach.
APPEND w_attach TO it_attach.
LOOP AT t_eket INTO <fs_eket>.
CONCATENATE <fs_eket>-ebeln
c_tab
<fs_eket>-ebelp
c_tab
<fs_eket>-eindt
c_car INTO w_attach.
APPEND w_attach TO it_attach.
ENDLOOP.
MOVE it_attach[] TO objbin[].
*assign a name to the email document
doc_chng-obj_name = 'Output'.
doc_chng-obj_descr = 'Old Scheduling lines'."gives the subject line
objtxt-line = 'Regards'.
APPEND objtxt.
objtxt-line = 'Shivaji'.
APPEND objtxt.
*determine the size of the body of the email
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
*fill the fields of the packing list for the body of the email
*doc needs no header
objpack-head_start = 1.
objpack-head_num = 0.
*but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
*************fill the fields for packing list ***
for attachment ********
DESCRIBE TABLE objbin LINES tab_lines.
*************if it has no header ****************
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
*************if it has a body ********
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
objpack-obj_name = 'Attachement'.
objpack-obj_descr = 'file'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
************fill the mail recipient list*******
reclist-receiver = sy-uname.
**rec_type 'B' indicates sap user ,rec_type 'U' indicates internet user
reclist-rec_type = 'B'.
reclist-express = 'X'.
APPEND reclist.
Function Module to send the data as an excel attachement ****
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
OBJECT_HEADER =
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. -
To format an Excel worksheet invoked by oracle form using DDE functions
I'm exporting data from oracle form6 into excel sheet using DDE functions.
Is there any DDE functions to format the excel sheet.Maybe you can use format commands through DDE (if the DDE server suports them) but I personally don't know.
My approach is to record an excel macro which formats your sheet and then invoke the macro through DDE. You can fill cells with control numbers (like number of rows, number of cells) so you can make your macro even smarter by reading these numbers. -
Powershell / Scientific Notation Woes / Formatting Output to Live Excel Sheet
I have a WMI query in a script that dumps machine information to a live excel sheet.
I find when I query the model # of the machine using (this line of code from the script):
$Sheet.Cells.Item($count,4) = (Get-WmiObject win32_computersystem -ComputerName $computer).Model
The output almost always changes into Scientific Notation, because this is a typical model number : "3500-E52"
Is there a way to modify the formatting of the:
$Sheet.Cells.Item($count,4)
so that Excel uses "text" formatting for that cell? I know you can change the fonts etc... but have not been lucky in finding a powershell > excel reference
that explains how to change a cell or column's formatting beyond the basics.
I have seen recommendations to others to dump the results queries to a CSV first, and then import into Excel (which would allow a manual change of that column's format). I'm just
hoping to bypass the extra "hands on" and format more directly to a sheet in Excel.
If .csv is the best way to go, I'll muddle through it and change the code.
Any help is greatly appreciated.
Ben$sheet.Cells(1,1).NumberFormat
= "@"
¯\_(ツ)_/¯ -
Formatting problem when downloading classical report output to excel sheet.
Dear Experts,
My classical report o/p looks like:
SI Name ID
1 xyz 11
2 abc 22
3 eet 33
4 jnc 44
When I download the same to a excel sheet from List->Save->file->Spreadsheet and save it.
The formatting looks like this:
SI Name ID
1 xyz 11
2 abc 22
3 eet 33
4 inc 44
That is the heading and column entries are in different columns.
There is no GUI_Download used.
Kindly help what may be the issue.Hi,
In the report output the formatting looks fine. It is exactly below the heading. But only when I save it to excel, this alignment issue is coming. Even the columns after this column are are properly aligned and there is no issue at all. Only this column in the middle has issue. -
List format output to excel sheet
Hi,
I have a report output in list format. I need to download that into excel sheet. Is it possible to download a list format output to excel sheet or shall I need to convert that into grid format?
Thanks Barnita.HI,
Use Menu path
List->Save/Send->File path
Maybe you are looking for
-
How do I mark the entire contents of a RichTextBox (gRTbxInfo) with a background color of white? I have code that finds / marks words with a different color. Now I want to remove that color. I've started with the following, but cannot complete it.
-
Open file in 'Bridge' folder from Illustrator Script. How? (Mac)
I need to access a file in the Bridge directory, from a script in Illustrator. I can do this already for PC with a concrete reference like this: var loc = "C:/Program Files/Adobe/Adobe Bridge CS3/webaccesslib.dll" How do you construct a string to get
-
Plug-in Mismatch while starting OMS
Hi All, While starting the OMS using command "emctl start oms" fails by throwing an error stating. Plugin mismatch with repository. What might be the cause for this? Any ideas? Thanks, Wern
-
Hello, I'm having trouble with my ipod
hello, I'm having trouble with my ipod
-
Hi, I have this situation: There is a table. And multiple changes have been made in the development system (under multiple transport requests). Now what I want to do is, create just one transport request(to be transported to production) which will cl