Date TO_CHAR Formatting Issues

Hi Team,
I'm a newbie and this is my first post here so please bear with me. I'm having an issue with converting a date column to string using the TO_CHAR function. See below for a few examples:
ORACLE_DATE;     DATE_CHAR;     DUMP(ORACLE_DATE);
31-DEC-02;     0000-00-00 00:00:00;     Typ=12 Len=7: 100,100,1,0,1,1,1;
16-JAN-97;     1197-01-16 00:00:00;     Typ=12 Len=7: 111,197,1,16,1,1,1;
01-DEC-06;     0006-12-01 00:00:00;     Typ=12 Len=7: 100,106,12,1,1,1,1;
01-JUL-66;     1966-07-01 22:52:44;     Typ=12 Len=7: 119,166,7,1,23,53,45;
Is there any way I can determine what the actual date recorded is from the data provided?
Thanks
Edited by: user11181700 on Sep 22, 2010 12:59 PM

Hi Frank,
Here's what I understand about the data:
1. All dates should start past the year 1950. For this analysis I picked everything below year 1900 to start out with the low hanging fruit.
2. The date issue spreads across 30 total fields, 14 tables, with a total of 3,358 records of interest.
Please see below for a further data snippet: (thanks for the code update)
ORACLE_DATE_TYPE     DATE_CHAR     TABLE_NAME     COLUMN_NAME     DATA_TYPE     DATA_LENGTH     DUMP(ORACLE_DATE_TYPE)     TO_CHAR(ORACLE_DATE_TYPE)
30-DEC-99     1899-12-30 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 118,199,12,30,1,1,1     1899-12-30 00:00:00
30-DEC-99     1899-12-30 00:00:00     ST1     DA_DATE     DATE     7     Typ=12 Len=7: 118,199,12,30,1,1,1     1899-12-30 00:00:00
30-DEC-99     1899-12-30 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 118,199,12,30,1,1,1     1899-12-30 00:00:00
11-JAN-01     1401-01-11 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 114,101,1,11,1,1,1     1401-01-11 00:00:00
11-JAN-01     1401-01-11 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 114,101,1,11,1,1,1     1401-01-11 00:00:00
02-JAN-00     1200-01-02 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 112,100,1,2,1,1,1     1200-01-02 00:00:00
02-JAN-00     1200-01-02 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 112,100,1,2,1,1,1     1200-01-02 00:00:00
16-JAN-97     1197-01-16 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,197,1,16,1,1,1     1197-01-16 00:00:00
16-JAN-97     1197-01-16 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,197,1,16,1,1,1     1197-01-16 00:00:00
12-AUG-15     1115-08-12 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,115,8,12,1,1,1     1115-08-12 00:00:00
12-AUG-15     1115-08-12 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,115,8,12,1,1,1     1115-08-12 00:00:00
12-AUG-15     1115-08-12 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,115,8,12,1,1,1     1115-08-12 00:00:00
12-AUG-15     1115-08-12 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,115,8,12,1,1,1     1115-08-12 00:00:00
12-AUG-15     1115-08-12 00:00:00     HE1     PU_DATE     DATE     7     Typ=12 Len=7: 111,115,8,12,1,1,1     1115-08-12 00:00:00
03-MAR-04     1104-03-03 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 111,104,3,3,1,1,1     1104-03-03 00:00:00
03-MAR-04     1104-03-03 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 111,104,3,3,1,1,1     1104-03-03 00:00:00
17-APR-07     1007-04-17 00:00:00     SN1     TE_DATE     DATE     7     Typ=12 Len=7: 110,107,4,17,1,1,1     1007-04-17 00:00:00
17-APR-07     1007-04-17 00:00:00     HE1     TE_DATE     DATE     7     Typ=12 Len=7: 110,107,4,17,1,1,1     1007-04-17 00:00:00
17-APR-07     1007-04-17 00:00:00     HE1     TE_DATE     DATE     7     Typ=12 Len=7: 110,107,4,17,1,1,1     1007-04-17 00:00:00
10-APR-07     0907-04-10 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 109,107,4,10,1,1,1     0907-04-10 00:00:00
10-APR-07     0907-04-10 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 109,107,4,10,1,1,1     0907-04-10 00:00:00
02-JAN-03     0303-01-02 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 103,103,1,2,1,1,1     0303-01-02 00:00:00
02-JAN-03     0303-01-02 00:00:00     HE1     AP_DATE     DATE     7     Typ=12 Len=7: 103,103,1,2,1,1,1     0303-01-02 00:00:00
01-DEC-16     0216-12-01 00:00:00     SN1     PR_DATE     DATE     7     Typ=12 Len=7: 102,116,12,1,1,1,1     0216-12-01 00:00:00
01-DEC-16     0216-12-01 00:00:00     HE1     PI_DATE     DATE     7     Typ=12 Len=7: 102,116,12,1,1,1,1     0216-12-01 00:00:00 We imported the data from a handful of .dmp files and two USERS0X.DBF files. Do you think the issue could lie in the import process, or do you think it's a better bet that the data is corrupt?
Thanks
Edited by: frankstuartbrowne on Sep 23, 2010 5:33 PM
Edited by: frankstuartbrowne on Sep 23, 2010 5:34 PM

Similar Messages

  • Date time formatting issues!!!!

    guys,
    I am trying to format date and time in the same variable.
    heres my code...
    <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD
    h:mm:ss')>
    the problem is, that it gives me the year month and day
    correctly.... the hour correctly, but where the minute is supposed
    to go, it gives me the month again (which makes sense cuz obviously
    its the same characters)... and then seconds are ok too. how do i
    fix it so it gives me the correct minutes? Thanks in advance!!!!
    JE

    A limitation of CF functions there is not a single date &
    time format
    function you have to combine the two.
    <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD') & ' '
    LSTimeFormat(now(),'h:mm:ss')>
    johnegbert wrote:
    > guys,
    > I am trying to format date and time in the same
    variable. heres my code...
    >
    > <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD
    h:mm:ss')>
    >
    > the problem is, that it gives me the year month and day
    correctly.... the
    > hour correctly, but where the minute is supposed to go,
    it gives me the month
    > again (which makes sense cuz obviously its the same
    characters)... and then
    > seconds are ok too. how do i fix it so it gives me the
    correct minutes?
    > Thanks in advance!!!!
    > JE
    >

  • Export to PDF, Excel, Excel (Data Only) formatting issues

    Hi Community
    I have a report that consists of 5 subreports. Out of the 5 subreports, 3 of them have a similar format whereas the other 2 are different.
    Iu2019m currently facing an issue whereby the exports to excel works fine, but excel (data only) has some alignment issues(i.e. the data appears below the correct columns). However, when the report is tweaked to make export to excel (data only) appear correctly, the export to excel had its data shifted out of alignment. There is no impact to pdf exporting at the moment.
    Are there any people who are facing similar issues? Is there any resolution or workaround? I appreciate any help. Thanks.
    FYI, the version of crystal reports is Crystal reports is Crystal reports 2008 and we are using the crystal report viewer interface to export into excel and pdf formats. The excel version is 2007.
    Regards

    DW, i've also run into issues with multiple sub reports. I resolved it by putting each sub report into it's own section, and then suppressing the sub report (Note, if ur trying to export subreport data to excel, I don't think its going to work. You'd need to create shared variables and then bring those sub report shared variables into your main report).
    Once you bring your shared variables into the main report, suppress your sub reports, and then export to excel, you're still left with a dataset that has missing rows. This is ok. You can solve it easily within the excel file itself by sorting the data on a unique ID like Account #. This removes the extra rows.
    Not the most elegant solution, but it works.

  • Date Prompt Format issue in OBIEE

    Hi,
    I am using a Date column in a Dashboard prompt. When i select a date in Calendar its showing up the Date in a correct format *'D/M/YYYY'*. But as soon as i click on GO button the format changes to *'YYYY-MM-DD HH:MM:SS'*.
    This format is passed to report and report throw an error *'A date value was expected (received "2010-01-26 00:00:00")'*.
    I searched metalink and blogs and got a patch to resolve this issue. But still after running that patch i am getting the same error. None of the workarounds given are working.
    Please respond if you have any solution for this.
    Thanks
    Swami

    Hi,
    What is the data format for the colum, you are comparing with the dashboard prompt, in the Answers request? Specify it to custom and use [FMT:dateShort] for Custom Date Format.
    Thanks
    Mahesh

  • CRS 2008 Web Services: Date parameter format issue

    Hi All,
    I have CRS 2008 installations (Dev environment and TEST environment) on two machine (both are on the build 12.1.0.882). I have a web application that runs crystal reports deployed to these servers using web services. On the DEV Server , the report works fine when the reports input parameters are formatted to mm/dd/yyyy format.  But TEST server (which is a new installation) does not accept a date parameter value for this report in this format and returns a "could not set date parameter" error.  The report runs fine if I pass the parameter in yyyy/dd/dd format from the web-application.
    I compared the regional language settings and Business Objects registry entries on both these machines, CMC settings, and they all seem to match. Am I missing something in the configuration or environment setup that is causing this issue? Appreciate any hints on solving this issue. Thanks so much.
    Regards
    Ajith

    Hi Siva,
    may i know how to do it?
    as i did try to code in the begining by using String for my startDate and endDate. and it is able to consume, but currently if i change the startDate and endDate to Date. it is still able to consume when i change the date from "2008-01-30T10:00:50.342Z" to just "2008-01-30". but when i try to use adobe interactive form. the startDate and endDate i am using the Date/Time Field Type. and the Data Format is as Date. so it will just return "2008-01-30" only.
    the part where i have error is when i try to do a parameter mapping from the interactive form to the web service. it is unable to map as they keep prompting that cannot map a Date to a Time Stamp.
    that is why i stuck at this part.. so i try to find out how to overcome this errors now..
    Regards
    Jia Jun

  • Data display Format issue.

    Hi ,
    I have the following columns for a single item(SingleVO),
    ItemNo, SugQty, OrdQty, Description,
    I would like to display the data in a table(Normal table or in a Advanced Table) with the
    following format. If there are 50 items, First row should display the First Item's
    itemno, sugqty, orgqty and the secondrow should display the description of the first item and third row should display the Second item's itemno, sugqty, orgqty and the fourthrow should display the description of the second item ....etc.
    Column Names:
    |-------------------------------------------------------|
    |Itemno |     SugQty     |     OrdQty     |     
    |-------------------------------------------------------|     
    |<---------Description--------------------------------> |
    |-------------------------------------------------------|
    Data:
    |-------------------------------------------------------|
    |12344 |     63 |     60     |     
    |-------------------------------------------------------|     
    |<---------Dulux Paint No2----------------------------> |
    |-------------------------------------------------------|
    |12345 | 98     |     100 |     
    |-------------------------------------------------------|     
    |<---------Table set ------------------------> |
    |-------------------------------------------------------|
    I tried with advanced table merging functionality, i couldn't get this type of display.
    Pointers are appreciated.
    (Since we are doing this application for Mobile devices we need to get this kind of display)
    Thanks.
    With Regards,
    Kali.
    OSSI.
    Format change.
    Message was edited by:
    Kalimuthu V
    Message was edited by:
    Kalimuthu V

    Thanks Ranjit,
    We build the table dynamically using rows and columns with the required spans.
    So that we could achieve the same display format.
    Thanks.
    With Regards,
    Kali.
    OSSI.

  • Planning Data from formatting issue with Smart view in 11.1.2

    Hi,
    We are facing one strange issue in Smart view.
    We have created a dataform in Planning as follows:
    Columns:
    FY10 FY10 FY10
    Budget Budget Budget
    Jan Feb Mar
    But when we open this in Smart view, we are getting the columns as follows:
    FY10
    Budget
    Jan Feb Mar
    i.e. year and scenario are spreading across months instead coming at each column level.
    We are using Hyperion Planning 11.1.2, Smart View 11.1.2 and Office 2003.
    Please help us.
    Thanks,
    Naveen Suram

    Are you saying you want the dimension members FY10 and Budget to be repeated in each column?
    I think that can be done for Ad-Hoc Analysis mode, but not where you have opened up a Planning form.
    Cheers

  • Data Formatting issues

    Hi All,
    I have some formatting issues in a query.
    For example if there is a single column with dats as follows:
    testcol_
    0
    5
    10
    10.55123
    10.678
    (note: they are all percentage values)
    The data should look like this
    testcol_
    0.00
    5.00
    10.00
    10.55
    10.67
    (Note: 2 decimal places, not rounded)
    I wrote a query just like below
    select to_char(trunc(test_col, 2), '0.99') from test
    The data I got is:
    0.00
    5.00
    Then I changed the query like this:
    select to_char(trunc(test_col, 2), '00.99') from test
    The data I got was
    00.00
    05.00
    10.00
    10.55
    10.67
    But in this case the issue is the first two rows.
    They should be just
    0.00
    5.00
    Is there any possible way that I can write a query so that the data will exactly look like below:
    0.00
    5.00
    10.00
    10.55
    10.67
    It would be great if anyone could help me out.
    Thank You,
    Varma

    with test as (
                  select 0 test_col from dual union all
                  select 5 from dual union all
                  select 10 from dual union all
                  select 10.55123 from dual union all
                  select 10.678 from dual
    -- end of on-the-fly data sample
    select  to_char(trunc(test_col, 2),'FM90.00')
      from  test
    TO_CHA
    0.00
    5.00
    10.00
    10.55
    10.67
    SQL> SY.

  • Date Format Issue with Pre-Insert trigger

    I have created a form wherein creation_date and last_update_date are columns in a table that needs to be populated with sysdate (in format mm/dd/yyyy hh:mi:ss am) at time of saving.
    In pre-insert triiger, if I assign date as follows , it works:
    :creation_date=sysdate;
    However this creates date in format yyyy/mm/dd.
    I would like to set it in format mm/dd/yyyy hh:mi:ss am.
    How can this be done-I tried using to_date and to_char but wont work.
    Any ideas?

    hi
    u may try this too.
    when-new-form-instance trigger:
    set_application_property(PLSQL_date_FORMAT,'DDMMYYYY HH12:MI:SS');
    set_application_property(BUILTIN_date_FORMAT,'DDMMYYYY HH12:MI:SS');
    forms_ddl('ALTER SESSION SET NLS_date_FORMAT=''DDMMYYYY HH12:MI:SS'''); sarah

  • Error 10000 Date format issue

    Hi all,
    Has anyone seen the following error please or has a troubleshooting hint: -
    "[NT AUTHORITY\SYSTEM (15/10/2012 18:35:12) - Service request cancelled due to an error.
    Error Code: 10000
    Error Description: Failed to create lease requisition.
    Fault code: soap:Server
    Fault string: Service Form Field: 'WarningDate2' has Date format issue.
    Fault details: REQ_0024Service Form Field: 'WarningDate2' has Date format issue.
    CIAC = 3.01
    Date and Time format on the CCP, CPO, vmware and SQL servers all Italian (dd/mm/yy)
    This only happens when we add a Lease Time on the request.
    Do they all have to be set to the US format for this to work?
    If this is a regional setting thing, do I have to change the format on all of the servers (CIAC components)?
    Cheers
    md

    This test program might help...
    import java.util.*;
    import java.text.*;
    public class ExpandYear
        public static void main(String[] args) throws ParseException
         SimpleDateFormat sdf_2dyear = new SimpleDateFormat("MM/dd/yy");
         SimpleDateFormat sdf_4dyear = new SimpleDateFormat("MM/dd/yyyy");
         String test1 = "3/21/00";
         System.out.println("test1: " + test1 + " to : " +
                      sdf_4dyear.format(sdf_2dyear.parse(test1)));
         String test2 = "4/9/99";
         System.out.println("test2: " + test2 + " to : " +
                      sdf_4dyear.format(sdf_2dyear.parse(test2)));

  • Date Format Issue With Sharepoint DateTime Control

    I Have a Web part where in create child control I am creating my controls.
    Where I have SharePoint date time control and I want to change the format of the control on change in the browser languages settings.
    Currenlt I am doing it by setting localID of the control as  DateTime.LocalID=Thread.CurrentThread.CurrentCulture.LCID.
    But it is not working , It always take UK format.
    Please suggest ....!!!!
    Thanks.

    Check this
    http://www.matdesmarais.com/2011/12/changing-the-date-display-format-in-sharepoint-2010/

  • Another date formatting issue

    Apologies if this has been covered before but my search has not produced anything.
    I am using BIP in EBS and have a template with the following:
    <?format-date:DATE_NOTIFICATION;'dd/MM/yyyy';'Europe/London'?>
    <?format-date:DATE_START;'dd/MM/yyyy';'Europe/London'?>
    <?format-date:DATE_END;'dd/MM/yyyy';'Europe/London'?>
    XML for this is:
    <DATE_NOTIFICATION>2010-01-14T00:00:00.000+00:00</DATE_NOTIFICATION>
    <SICKNESS_START_DATE>2010-01-04T00:00:00.000+00:00</SICKNESS_START_DATE>
    <SICKNESS_END_DATE>2010-01-06T00:00:00.000+00:00</SICKNESS_END_DATE>
    When the concurrent request runs output is produced in either excel (most likely) or pdf. View the output from the concurrent request and everything is fine.
    However if you view the excel output and then save it to your PC as MS EXCEL XML or MS Excel Workbook format, then open that local copy of the spreadsheet in MS Excel some of the dates are formatted incorrectly as follows:
    Notified Date 14/01/2010 - CORRECT
    Actual Absence Start Date 01/04/2010 - INCORRECT not the transposition of the day and month to the US format mm/dd/yyyy
    Actual Absence End Date 01/06/2010 - INCORRECT not the transposition of the day and month to the US format mm/dd/yyyy
    I am guessing this is something to do with the nationality which would be US in EBS but UK on the local PC, however what I don't understand is the inconsistency, if all dates were incorrectly formatted then fine you can work with it but when some are correct and others are not it gets a bit tricky to deal with.
    Has anyone seen this before, is it a known bug?
    Cheers,
    Dave

    Osgood gave you the above that you said works.
    .paragraph_spacing {
    margin: 1px 1px 1px 1px;
    padding: 1px 1px 1px 1px;
    you need to set up another class if you want it to have
    different styles....
    .specialparagraph {
    margin-bottom: whatever px you want here;}
    and then apply the class to the one paragraph
    <p class="specialparagraph"> whatever text here
    </p>
    Nadia
    Adobe® Community Expert : Dreamweaver
    Tutorials |SEO |Templates
    http://www.DreamweaverResources.com
    http://www.perrelink.com.au
    CSS Tutorials for Dreamweaver
    http://www.adobe.com/devnet/dreamweaver/css.html
    "Beverly" <[email protected]> wrote in message
    news:eo4ho4$qe9$[email protected]..
    > Works great! One more question for you...
    >
    > The CSS works great for all my standard paragraphs. Now,
    I have one
    > paragraph that I want to make a slight deviation to - I
    want to drop the
    > bottom margin on just one of the paragraphs. Do I have
    to create an
    > entirely new CSS style with all of the elements from the
    current style and
    > make the modification on the bottom margin - or is there
    someway to just
    > quickly drop that bottom margin, but only for this one
    paragraph?
    >
    > Thanks!!
    >

  • HELP: Strange Number Formatting Issue

    G'day All,
    I have a stored procedure which is available via the web which generarates a customer report. I've just noticed that my number fields that have decimal values are being rounded to the nearest whole number.
    The SQL that grabs the data to be used in generating this specific table uses TO_CHAR(decimal_field, '9990.00') etc a number of times. example values are:
    0.27 becomes 0.00
    45.44 becomes 45.00
    I've double checked the underlying data and the values definitely have decimal values as the examples I listed above are from. When I run similar queries via the SQL COMMANDs web page the data is correctly formatted. It just appears to be with in the stored procedure.
    BUGGER I've just noticed that it is happing on "Report Regions" where I have also used TO_CHAR(decimal_Value, '99990.00') etc.
    Does anyone know WTF I've done or not done. I'm pulling my bloody hair out as "IT SHOULD JUST WORK!!" :(
    Regards
    Mark

    G'day Chrissy,
    Thanks for you response, I've just logged it the demo application on my local instance of apex v 3.0.1 on Oracle XE and and as you would have it, I cannot for the life of me get the Number Formatting issue to occur at home.
    So when I get back into work, I'll give your suggestion a go.
    That said, I've modified the DEMO application specifically the TOP 10 Product report using every combination of the TO_CHAR (your way, the ways that I believe I'm using) and it works fine. I've created a new table with decimal values and a new report and it works fine. I even tries putting records with null values in the decimal field, but it worked fine.
    I've just switched themes (even though themes have no influence of a dynamically create html page via procedure) annnnnd it works fine.
    AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!
    Just maybe, just maybe it was Friday-itise and when I get in Monday it will just work, unless I get stung by Monday-itise :)
    I'll keep plodding along,
    Mark

  • Crystal for VS 2010 - formatting issues in viewer (extra space) again

    We're having the same problem as the one in this thread link:[Crystal 2008 for VS 2010 - Report formatting issues in viewer (extra space);. There's no resolution in the thread and it's been closed. I'm hoping that creating a new thread may cause someone to answer this problem.
    We have a Windows App that we just converted to .NET 4.0 and updated the viewer to the Crystal Reports Viewer in VS 2010. When we open a report that has a large block of static text in paragraphs left-aligned the spacing around punctuation is awful - there's almost a tab's worth of space between the last letter and the period. U.S. looks like US. This happens both with reports that were created in VS2008 and ones that were created in VS2010. It is only a problem in the viewer's display - if we print to a printer or export to PDF the spacing around punctuation is fine. It's also not a problem on our development workstations which are running Windows 7, but is a problem on our test servers which are running Windows 2003 Server. I ran the modules tool and found that the version of usp10.dll does match what the previous thread said it should be and it's coming from the c:\program files\sap businessobjects\crystal reports for .net framework 4.0\common\sap businessobjects enterprise xi 4.0\win32_x86\ folder. On my development machine when I run the modules tool I notice that a second instance of usp10.dll is called which is the version installed with Windows 7. We've tried changing fonts but none of the ones we've tried (originally in Times New Roman, 12, tried Arial, Times and various sizes) have made a difference. We also tried changing the print options with no improvement. The only thing that makes it slightly better is full-alignment but our customer insists that it be left-aligned.

    Re. the other thread. I never did receive a sample of the report to test with. Perhaps I can get one from you? I need you to ensure that the issue occurs with a "saved data" report. If it does, let me know if you can share it and I'll contact you via email. My comment in the other thread re. available time, priorities, etc., still applies. Also, just to be clear. Service Pack 2 for CRVS2010 is closed now. Thus if I am able to reproduce the issue the fix will be targeted for October \ November time frame - no guarantees though...
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Format issue in opening an XLS attachment sent through email by ABAP2XLSX

    I have downloaded the ABAP2XLSX nuggets and tried to send an attachment in the email using the SAP. But when opening the attachment it is giving up an format issue and not able to view the content. I am able to save the XLSX file on the PC and able to read it but when I  send it to email it doesn't open correctly and it is in a non readable format. Please find the code that I have been using. Can someone help me on this.
    TYPES: BEGIN OF tp_zzrule,
             zzprog     TYPE zzfunc,
             zzdata     TYPE zzcri1,
             zzseq      TYPE zzseq,
             zzkey1     TYPE zzkey1,
             zzkey2     TYPE zzkey2,
         END OF tp_zzrule.
    DATA: w_zzrule   TYPE tp_zzrule,
          t_zzrule   TYPE TABLE OF zzourule.
    TYPE-POOLS: abap.
    DATA:   v_document            TYPE REF TO cl_document_bcs,
            v_recipient           TYPE REF TO if_recipient_bcs,
            v_main_text           TYPE bcsy_text,
            v_send_request        TYPE REF TO cl_bcs,
            v_msub                TYPE so_obj_des,
             v_size               TYPE so_obj_len,
            v_string2             TYPE string,
            v_attsub              TYPE sood-objdes,
            v_mailid              TYPE ad_smtpadr,
            v_sent(1)             type c,
            v_sent_to_all         TYPE os_boolean,
            v_string              TYPE string,
            v_repid               TYPE sy-repid,
            v_title               TYPE so_text255,
            v_dochead             TYPE so_text255.
    DATA lt_test TYPE TABLE OF sflight.
    DATA: lo_excel                TYPE REF TO zcl_excel,
          lo_excel_writer         TYPE REF TO zif_excel_writer,
          lo_worksheet            TYPE REF TO zcl_excel_worksheet,
          column_dimension        TYPE REF TO zcl_excel_worksheet_columndime.
    DATA: ls_table_settings       TYPE zexcel_s_table_settings.
    DATA: lv_file                 TYPE xstring,
          lv_bytecount            TYPE i,
          lt_file_tab             TYPE solix_tab,
          t_objtxt  like solisti1   occurs 0 with header line,
          t_objbin  like solisti1   occurs 0 with header line,
          t_objpack like sopcklsti1 occurs 0 with header line,
          t_reclist like table of somlreci1 with header line.
    DATA: lv_full_path      TYPE string,
          lv_workdir        TYPE string,
          lv_file_separator TYPE c.
    CONSTANTS: lv_default_file_name TYPE string VALUE 'multi sheet test.xlsx'.
    PARAMETERS: p_path  TYPE zexcel_export_dir,
                p_empty TYPE flag.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
      lv_workdir = p_path.
      cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder  = lv_workdir
                                                  CHANGING  selected_folder = lv_workdir ).
      p_path = lv_workdir.
    INITIALIZATION.
      cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
      cl_gui_cfw=>flush( ).
      p_path = lv_workdir.
    START-OF-SELECTION.
      IF p_path IS INITIAL.
        p_path = lv_workdir.
      ENDIF.
      cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
      CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
    SELECT *
        INTO TABLE t_zzrule
       FROM zzourule
      WHERE zzprog  = 'RV63A999'.
        SELECT * FROM sflight INTO TABLE lt_test.
      " Creates active sheet
      CREATE OBJECT lo_excel.
    For first Sheet in the excel workbook
      " Get active sheet
      lo_worksheet = lo_excel->get_active_worksheet( ).
      lo_worksheet->set_title( ip_title = 'Test sheet one').
      ls_table_settings-table_style  = zcl_excel_table=>builtinstyle_medium2.
      ls_table_settings-show_row_stripes = abap_true.
      lo_worksheet->bind_table( ip_table          = lt_test
                                is_table_settings = ls_table_settings ).
      lo_worksheet->freeze_panes( ip_num_rows = 3 ). "freeze column headers when scrolling
      column_dimension = lo_worksheet->get_column_dimension( ip_column = 'E' ). "make date field a bit wider
      column_dimension->set_width( ip_width = 20 ).
    For second Sheet in the excel workbook
      lo_worksheet = lo_excel->add_new_worksheet( ).
      lo_worksheet->set_title( ip_title = 'Second sheet' ).
      lo_worksheet->set_cell( ip_column = 'B' ip_row = 2
               ip_value = 'This is the test for second sheet by Pavan' ).
      ls_table_settings-table_style  = zcl_excel_table=>builtinstyle_medium2.
      ls_table_settings-show_row_stripes = abap_true.
      lo_worksheet->bind_table( ip_table          = t_zzrule
                                is_table_settings = ls_table_settings ).
    This will create excel.
    CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
      lv_file = lo_excel_writer->write_file( lo_excel ).
    " Convert to binary
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          buffer        = lv_file
        IMPORTING
          output_length = lv_bytecount
        TABLES
          binary_tab    = lt_file_tab.
    Save the file on to the PC
      cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
                                                        filename     = lv_full_path
                                                        filetype     = 'BIN'
                                               CHANGING data_tab     = lt_file_tab ).
    *--Create and set document with attachment.
    v_main_text-line  = 'This is the main text not sure where this would print'.
    append v_main_text.
      TRY.
        v_send_request = cl_bcs=>create_persistent( ).      "#EC .., bzw.
        CATCH cx_send_req_bcs . "#EC NO_HANDLER
      ENDTRY.
      v_msub       = 'Test excel with multi sheets.XLS'.
      TRY.
          v_document = cl_document_bcs=>create_document(
          i_type     = 'RAW'
          i_text     = v_main_text
          i_subject  = v_msub ).
        CATCH cx_document_bcs . "#EC NO_HANDLER
      ENDTRY.
        v_size = lv_bytecount.
    *--Add the attachment.
      TRY.
          v_document->add_attachment(                          "#EC .., bzw
                i_attachment_type    = 'EXT'
               i_attachment_type    = 'XLS'
               i_attachment_type    = 'RAW'
                i_attachment_subject = v_attsub
                i_attachment_size    = v_size
               i_att_content_hex    = lt_file_tab ).    "#EC .., bzw.
               i_att_content_hex    = lt_file_tab ).    "#EC .., bzw.
        CATCH cx_document_bcs . "#EC NO_HANDLER
      ENDTRY.
    *--Add document object to send request.
      TRY.
          v_send_request->set_document( v_document ).         "#EC .., bzw.
        CATCH cx_send_req_bcs . "#EC NO_HANDLER
      ENDTRY.
    *--E-mail recipent list
      t_reclist-rec_type = 'U'.
      t_reclist-receiver = <email Id here>.
      APPEND t_reclist.
      CLEAR t_reclist.
      LOOP AT t_reclist.
        CLEAR v_mailid.
        v_mailid = t_reclist-receiver.
    *--Create mail recipient object.
        TRY.
          v_recipient = cl_cam_address_bcs=>create_internet_address( v_mailid ). "#EC .., bzw.
           CATCH cx_address_bcs . "#EC NO_HANDLER
          ENDTRY.
    *--Add recipient object to send request.
        TRY.
            v_send_request->add_recipient( v_recipient ).     "#EC .., bzw.
          CATCH cx_send_req_bcs . "#EC NO_HANDLER
        ENDTRY.
      ENDLOOP.
    **--Add recipient object to send request.
      TRY.
        v_sent_to_all = v_send_request->send( i_with_error_screen = 'X' ).
    CATCH cx_send_req_bcs . "#EC NO_HANDLER
      ENDTRY.
    *--Send document.
      COMMIT WORK.
      IF sy-subrc = 0.
       MESSAGE s999(zou01) WITH text-020.
        v_sent = 'X'.
      ENDIF.

    I realize this is an old post, but am wondering if you ever resolved this.  I'm having the same issue.  Download an xlsx file locally opens fine, but attaching the seemingly exact same file throw errors/warnings when trying to open via an email attachment.

Maybe you are looking for

  • Unable to download windows 10 preview

    I have been attempting to download windows 10 preview since LAST WEEK when it was first made available.  I've had an MSDN subscription for YEARS, but recently the DVD shipment stopped, so I have to DOWNLOAD everything now.  Unfortunately, it looks li

  • Webutil config issue

    Hi all, OAS 10.1.2 When i run forms from client to server specifying config=webutil in the URL,nothing happens.Only a message "applet started" comes at the left bottom of teh client browser . It is only with webutil. When i run with my own created co

  • Parameters in Function-Exit

    Hi all,   I am using one Function-exit to read two screen fields and to pass a default value to another field. But in the function-exit there is no parameter for first field but i have parameters for second field and for the field which i need to exp

  • Help me about Illustrator CS3

    anyone can help me to put the definition of this : http://farm1.static.flickr.com/196/519573598_11f4a6397f_o.jpg for example; Zoom Tools- The Zoom tool allows us to enlarge or reduce the view of artwork we are viewing or when we want to edit everythi

  • How to get Runtime for each statement in abap program

    Is there any tool which tells the runtime of each statement in our program..apart from sto5 and se30 Thanks in advance PRASANNA