To_date using ddth ?

Hi,
Oracle 10g r2.
I don't understand why this works :
select to_date('january 12 2011','MONTH DD YYYY HH24:MI:SS','nls_date_language=english') from dual
select to_date('january 12 2011','MONTH DDTH YYYY HH24:MI:SS','nls_date_language=english') from dualand this don't :
select to_date('january 12th 2011','MONTH DDTH YYYY HH24:MI:SS','nls_date_language=english') from dual=> ORA-01841: (full) year must be between -4713 and +9999, and not be 0
Is it possible to do the conversion without having to modify session parameters ?
Thanks.
Yann.

Hi,
thank you for your replies.
I display dates in my application depending on the application language, I have a function like :
function format_date_to_char(v_date in date) return varchar2 is
  if (langue = 'fr') then
    return lower(translate(to_char(v_date,'DD-MONTH-YYYY','nls_date_language=french'),'A- ','A '));
  elsif (langue = 'en') then
    return lower(translate(to_char(v_date,'MONTH-DDTH-YYYY','nls_date_language=english'),'A- ','A '));
  else
    return 'error, please choose a language';
  end if;
end;
Example :
English : format_date_to_char(sysdate) : "march 2nd 2011"
French : format_date_to_char(sysdate) : "2 mars 2011"
And I want to convert back that dates for insertion. I want to check the date format too.
I tried a is_valid_date function :
function is_valid_date(p_date in varchar2) return boolean is
  if (langue = 'fr') then
    v_date := to_date(p_date,'DD MONTH YYYY','nls_date_language=french');
  elsif (langue = 'en') then
    v_date := to_date(p_date,'MONTH DDTH YYYY','nls_date_language=english');
  else
  end if;
  return true;
exception when others then return false;
end;
Example :
English : is_valid_date('march 2nd 2011') : false because of exception ORA-01841
French : is_valid_date('2 mars 2011') : true
How can I check that date format ?

Similar Messages

  • To_date function not fetching the desired result.....

    Hi Gurus,
    I get varied results from the below 2 queries, I am pessimistic about using to_char instead prefer using to_date, but query doesn't seem to fetch the complete data while using the to_date but with to_char it works. Please can someone make this to_date used query below work for me.
    Main table structure:
    Column Name     ID     Pk     Null?     Data Type     Default     Histogram     Encryption Alg     Salt
    MINISTRY_CODE     1          Y     VARCHAR2 (15 Byte)          Yes          
    BILL_MONTH     2          Y     DATE          Yes          
    CUBIC     3          Y     NUMBER          Yes          
    GALLONS     4          Y     NUMBER          Yes          
    AMOUNTS     5          Y     NUMBER          Yes          
    MTR_TYPE     6          Y     CHAR (1 Byte)          Yes          1st query:
    SELECT ministry_code,
    DECODE(mtr_type, 'C','Billed Cubic',
    'G','Billed Gallons',
    'A','Billed OMR',
    'R','Collected',
    'U','Total Unpaid Bills') mtr_type,
    SUM(CASE
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month,'MMYYYY') = '012011' AND mtr_type = 'C' THEN cubic
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month,'MMYYYY') = '012011' AND mtr_type = 'G' THEN (gallons)
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month,'MMYYYY') = '012011' AND mtr_type = 'A' THEN amounts
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month,'MMYYYY') = '022011' AND mtr_type = 'R' THEN amounts
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month,'MMYYYY') <= '022011' AND mtr_type = 'U' THEN amounts ELSE 0 END) January
    FROM tmp_paew_month_gafu1 WHERE ministry_code IN
    (SELECT DISTINCT ministry_code FROM tmp_paew_month_gafu GROUP BY ministry_code)
    GROUP BY ministry_code,mtr_type
    ORDER BY 1,3 DESCSAMPLE OUTPUT:
    MINISTRY_CODE MTR_TYPE JANUARY
    001 Billed Gallons 5326252
    001 Billed Cubic 24210.2363636364
    001 Total Unpaid Bills 16402.5
    001 Billed OMR 13287.36
    001 Collected 10410.508
    002 Total Unpaid Bills 12089.99
    002 Billed Cubic 0
    002 Billed OMR 0
    002 Billed Gallons 0
    002 Collected 0
    003 Total Unpaid Bills 27418.711
    2nd query:
    SELECT ministry_code,
    DECODE(mtr_type, 'C','Billed Cubic',
    'G','Billed Gallons',
    'A','Billed OMR',
    'R','Collected',
    'U','Total Unpaid Bills') mtr_type,
    SUM(CASE
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_char(bill_month) = to_date('012011','MMYYYY') AND mtr_type = 'C' THEN cubic
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_date(bill_month) = to_date('012011','MMYYYY') AND mtr_type = 'G' THEN (gallons)
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_date(bill_month) = to_date('012011','MMYYYY') AND mtr_type = 'A' THEN amounts
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_date(bill_month) = to_date('022011','MMYYYY') AND mtr_type = 'R' THEN amounts
    WHEN mtr_type NOT IN ('C','G','A','R','U') THEN 0 WHEN to_date(bill_month) <= to_date('022011','MMYYYY') AND mtr_type = 'U' THEN amounts ELSE 0 END) January
    FROM tmp_paew_month_gafu1 WHERE ministry_code IN
    (SELECT DISTINCT ministry_code FROM tmp_paew_month_gafu GROUP BY ministry_code)
    GROUP BY ministry_code,mtr_type
    ORDER BY 1,3 DESCSample OUTPUT:
    MINISTRY_CODE MTR_TYPE JANUARY
    001 Total Unpaid Bills 106062.002
    001 Billed OMR 0
    001 Billed Cubic 0
    001 Billed Gallons 0
    001 Collected 0
    002 Total Unpaid Bills 42023.243
    002 Collected 0
    002 Billed Gallons 0
    002 Billed Cubic 0
    002 Billed OMR 0
    003 Total Unpaid Bills 133260.435

    What is the sense of to_date(bill_month) in the second query?
    bill_month is already a date. to_date function will expect a character parameter and convert it in a date value.
    So what will happen? First the bill_month will be implicitely converted to a character value.
    Second this character value will be converted back to a date. You gave no format string. So both conversions will be made will your setting of nls_date_format.
    I can only guess what you really want. Perhaps you want to trunc the bill_month with trunc(bill_month,'MM').
    Please give us
    - table create script
    - insert statements for test data
    - required output for these test data
    - description of your requirements
    Edited by: hm on 22.11.2012 23:16

  • Frm-40508

    Oracle Forms6i
    Hai All
    I have an error while iam inserting data into a table through my forms.
    I have two blocks in my form namely Leader, Member
    This is my statement in my save button
    If :Global.Mode = 'QUERY' then
    update hierarchy_tree set unitid = :unit_id,empl_leader= :empl_code,empl_member=:emplcode,
    fromdt=:from_date,todt =:to_Date;
    elsif :Global.Mode = 'ADD' then
         insert into hierarchy_tree (unitid,empl_leader,empl_member,fromdt,todt) values
         (:unit_id,:empl_code,:emplcode,:from_date,:to_date);
    end if;
    commit;
    I have taken data from two blocks.
    When i press the save button
    I have an error
    Frm-40508 oracle err unable to insert record.
    Thanks In Advance
    Srikkanth.M
    Edited by: Srikkanth.M on May 10, 2010 12:37 PM

    Srikkanth,
    Instead of
    insert into H_Table (unitid,empl_leader,empl_member,fromdt,todt) values (:unit_id,:empl_code,:emplcode,:from_date,:to_date);use
    FORMS_DDL('INSERT INTO H_TABLE(UNITID, EMPL_LEADER, EMPL_MEMBER, FROMDT, TODT) VALUES(''' || :UNIT_ID || ''', ''' || :EMPL_CODE || ''', ''' || :EMPLCODE || ''', TO_DATE(''' || TO_CHAR(:FROM_DATE, 'DD-MON-YYYY') || '''), TO_DATE(''' || TO_CHAR(:TO_DATE, 'DD-MON-YYYY') || '''))');So that we can change the insert / update statements as per our need. That means assign the insert statement in to a variable, and then run that insert statement using FORMS_DDL built-in.
    Hope you understand.
    Regards,
    Manu.

  • Please help me with this ABAP code!

    Here is my code:
    ===
    REPORT ZCFICO6010
             line-count 65
             line-size 132
             no standard page heading.
    tables: zsopshist, zsops.
    data: old_prezsops like zsops_prev.     "PJCHG10854
    data: new_prezsops like zsops_prev.     "PJCHG10854
    data: old_zzsops like zsops.            "PJCHG10854
    data: new_zzsops like zsops.            "PJCHG10854
    data: long_rec(900) type c.             "PJCHG10854
    data: old_lzsops like long_rec.         "PJCHG10854
    data: new_lzsops like long_rec.         "PJCHG10854
    data: curr_zsops like zsops,
          prev_zsops like zsops_prev.
    data: begin of i_key,
      kostl(5),
      aedat(8),
      cputm(6).
    data:   end of i_key.
    DATA: HEADER like zsops-oprcd,
          header1(92) type c.
        header1 like header.
    data: v_field(18) type c,
          v_old(20)  type c,
          v_new(20)  type c,
          user like zsops-uname,
          date like zsops-aedtm.
    data: begin of table occurs 0,
          text(20) type c,
          oprcd like zsops-oprcd,
          field(15) type c,
          user like zsops-uname,
          date like zsops-aedtm,
          v_old(20) ,
          v_new(20) ,
        end of table.
    data: text(30) type c.
    data: begin of itab occurs 0,
           srtfd like zsopshist-srtfd,
         end of itab.
    *data: ihist like old_zsops occurs 0 with header line,
         nhist like new_zsops occurs 0 with header line.
    data: ihist like zsops occurs 0 with header line,
          nhist like zsops occurs 0 with header line.
    *&      Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE TEXT-200.
    parameters: s_oprcd  like zsops-oprcd obligatory,
                s_oprcdh like zsops-oprcd .
                    s_cputm   for sy-uzeit.
    SELECTION-SCREEN END OF BLOCK one.
    SELECTION-SCREEN BEGIN OF BLOCK three WITH FRAME TITLE TEXT-300.
    parameters:s_aedtm  like zsops-aedtm obligatory,
    s_aedtmh like zsops-aedtm obligatory.
    SELECTION-SCREEN END OF BLOCK three.
    SELECTION-SCREEN BEGIN OF BLOCK TWO WITH FRAME TITLE TEXT-100.
    PARAMETERS: P_REGSRT RADIOBUTTON GROUP RADI,
                P_ACCSRT RADIOBUTTON GROUP RADI.
    SELECTION-SCREEN END OF BLOCK TWO.
    parameters: new_date like sy-datum obligatory default '20051214'.
    *&      Top-Of-Page
    top-of-page.
    BEGIN OF BLOCK INSERTED FOR                              "JJMM20040330
      DATA: CC_LOW LIKE ZSOPS-OPRCD,
            CC_HIGH LIKE ZSOPS-OPRCD,
            FROM_DATE(10) TYPE C,
            TO_DATE(10)   TYPE C.
      WRITE: S_OPRCD TO CC_LOW NO-ZERO,
             S_AEDTM TO FROM_DATE USING EDIT MASK '__/__/____',
             S_AEDTMH TO TO_DATE USING EDIT MASK '__/__/____'.
      IF S_OPRCDH = S_OPRCD.
        CONCATENATE: 'Cost Center'(T02) CC_LOW 'Changed On'(T04) FROM_DATE
                     'To'(T03) TO_DATE 'Sort By'(T05) text INTO HEADER1
                     separated by space.
      ELSE.
        WRITE: S_OPRCDH TO CC_HIGH NO-ZERO.
        CONCATENATE: 'Cost Center'(T02) CC_LOW 'To'(T03) CC_HIGH
                     'Changed On'(T04) FROM_DATE 'To'(T03) TO_DATE
                     'Sort By'(T05) text INTO HEADER1 separated by space.
      ENDIF.
    END OF BLOCK INSERTED FOR                                "JJMM20040330
      PERFORM DISPLAY_PAGE_HEADER(ZCLT0001) USING
                                          header1            "JJMM20040330
                                            HEADER
                                            TEXT-T01
                                            header1.           "JJMM20040330
      Write:/ 'Field Changed'(C01), 25 'Old Values'(C02),
               55 'New Values'(C03), 85 'Cost Center'(C04),
              105 'Changed By'(C05), 120 'Changed On'(C06).
      uline.
    start-of-selection.
      data: time(6),
            v_subrc like sy-subrc,
            prev_format(1),
            srtfd like zsopshist-srtfd,
            srtfdh like zsopshist-srtfd.
      srtfd0(5) = s_oprcd5(5).
      srtfd+5(8) = s_aedtm.
      srtfd+13(6) = '000000'.
       if s_oprcdh is initial.
         s_oprcdh = s_oprcd.
       endif.
      srtfdh0(5) = s_oprcdh5(5).
      srtfdh+5(8) = s_aedtmh.
      srtfdh+13(6) = '999999'.
      select srtfd from zsopshist into table itab
              WHERE  SRTFD >= SRTFD
              AND    SRTFD <= SRTFDH.
    sort itab by srtfd.
      loop at itab.
        IF ITAB+5(8) GE S_AEDTM  AND                            "IJHM00001
            ITAB+5(8) LE S_AEDTMH.                              "IJHM00001
          move: itab+0(5)          to i_key-kostl,
                itab+5(8)          to i_key-aedat,
                itab+13(6)         to i_key-cputm.
          clear: v_subrc, prev_format.
          if itab+5(8) lt new_date.
            prev_format = 'X'.
            perform import_record_prev changing v_subrc.      "PJCHG10854
          else.
            perform import_record changing v_subrc.           "PJCHG10854
          endif.
          if v_subrc = 0.                                     "PJCHG10854
            perform get_final_table.
          endif.
        ENDIF.                                                  "IJHM00001
      endloop.
      if p_regsrt = 'X'.
        sort table by oprcd field date descending.
        text = 'Cost Center'(C04).
      else.
        sort table by field oprcd date descending.
        text = 'Field Changed'(C01).
      endif.
       perform write_report.
          FORM get_final_table                                          *
    form get_final_table.
    move old_zsops to ihist.           "PJCHG10854
    move new_zsops to nhist.           "PJCHG10854
      if prev_format eq 'X'.              "PJCHG10854
        move old_prezsops to ihist.       "PJCHG10854
        move new_prezsops to nhist.       "PJCHG10854
      else.                               "PJCHG10854
        move old_zzsops to ihist.         "PJCHG10854
        move new_zzsops to nhist.         "PJCHG10854
      endif.                              "PJCHG10854
      if ihist-ivcrg ne nhist-ivcrg.
       table-text = 'Invst Charge Base'(F01).
       table-field = 'IVCRG'.
        table-v_old   = ihist-ivcrg.
        table-v_new   = nhist-ivcrg.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-mgtfp ne nhist-mgtfp.
        table-field = 'MGTFP'.
        table-text = 'Mgt Fee %'(F02).
        table-v_old(12)   = ihist-mgtfp.
        table-v_new(12)   = nhist-mgtfp.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-discd ne nhist-discd.
        table-field = 'DISCD'.
        table-text = 'Cash Disc. Passback'(F03).
        table-v_old   = ihist-discd.
        table-v_new   = nhist-discd.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-consc ne nhist-consc.
        table-field = 'CONSC'.
        table-text = 'Subsidy Calc'(F04).
        table-v_old   = ihist-consc.
        table-v_new   = nhist-consc.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-payfart ne nhist-payfart.
        table-field = 'PAYFART'.
        table-text = 'Payroll Fringe'(F05).
        table-v_old(12)   = ihist-payfart.
        table-v_new(12)   = nhist-payfart.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-frbpb ne nhist-frbpb.
        table-field = 'FRBPB'.
        table-text = 'Rebate Pass Back'(F06).
        table-v_old(12)   = ihist-frbpb.
        table-v_new(12)   = nhist-frbpb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-exlca ne nhist-exlca.
        table-field = 'EXLCA'.
        table-text = 'Excl Source27'(F07).
        table-v_old   = ihist-exlca.
        table-v_new   = nhist-exlca.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-exlcb ne nhist-exlcb.
        table-field = 'EXLCB'.
        table-text = 'Excl Source11'(F08).
        table-v_old   = ihist-exlcb.
        table-v_new   = nhist-exlcb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-trnrate ne nhist-trnrate.
        table-field = 'TRNRATE'.
        table-text = 'Payroll Training'(F09).
        table-v_old(12)   = ihist-trnrate.
        table-v_new(12)   = nhist-trnrate.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-mgffa ne nhist-mgffa.
        table-field = 'MGFFA'.
        table-text = 'Mgt Fee Amt'(F10).
        table-v_old(12)   = ihist-mgffa.
        table-v_new(12)   = nhist-mgffa.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-mgtfi ne nhist-mgtfi.
        table-field = 'MGTFI'.
        table-text = 'Mgt Fees Indicator'(F11).
        table-v_old   = ihist-mgtfi.
        table-v_new   = nhist-mgtfi.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-eqres ne nhist-eqres.
        table-field = 'EQRES'.
        table-text = 'Eqip Res Accrual'(F12).
      table-v_old = ihist-eqres.                             "JJMM20040331
      table-v_new = nhist-eqres.                             "JJMM20040331
        table-v_old(12) = ihist-eqres.                         "JJMM20040331
        table-v_new(12) = nhist-eqres.                         "JJMM20040331
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-ovrhd ne nhist-ovrhd.
        table-field = 'OVRHD'.
        table-text = 'OverHead Amt'(F13).
        table-v_old(12)   = ihist-ovrhd.
        table-v_new(12)   = nhist-ovrhd.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
        if ihist-xaccural ne nhist-xaccural.
        table-field = 'XACCUARAL'.
        table-text = 'Exclude Accrual'(F14).
        table-v_old(12)   = ihist-xaccural.
        table-v_new(12)   = nhist-xaccural.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-ovrrt ne nhist-ovrrt.
        table-field = 'OVRRT'.
        table-text = 'OverHead Rate'(F15).
        table-v_old(12)   = ihist-ovrrt.
        table-v_new(12)   = nhist-ovrrt.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
        if ihist-ztbd01 ne nhist-ztbd01.
        table-field = 'ZTBD01'.
      table-text = 'Char1'.                                  "JJMM20040330
        table-text = 'Meal Allowance'(F16).                    "JJMM20040330
        table-v_old   = ihist-ztbd01.
        table-v_new   = nhist-ztbd01.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    BEGIN OF BLOCK INSERTED FOR                            "JJMM20040330
      if ihist-earlybil ne nhist-earlybil.
        table-field = 'EARLYBIL'.
        table-text = 'Early Billing'(F17).
        table-v_old   = ihist-earlybil.
        table-v_new   = nhist-earlybil.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
      if ihist-combined ne nhist-combined.
        table-field = 'COMBINED'.
        table-text = 'Combined Billing'(F18).
        table-v_old   = ihist-COMBINED.
        table-v_new   = nhist-COMBINED.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    END OF BLOCK INSERTED FOR                                "JJMM20040330
        if ihist-rate1 ne nhist-rate1.
        table-field = 'RATE1'.
        table-text = 'Rate 1'(F19).
        table-v_old(12)   = ihist-rate1.
        table-v_new(12)  = nhist-rate1.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate2.                            "JJMM20040330
      table-field = 'RATE1'.                                 "JJMM20040330
    if ihist-rate2 ne nhist-rate2.                            "JJMM20040330
        table-field = 'RATE2'.                                 "JJMM20040330
        table-text = 'Rate 2'(F20).
        table-v_old(12)   = ihist-rate2.
        table-v_new(12)   = nhist-rate2.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate3.                            "JJMM20040330
    if ihist-rate3 ne nhist-rate3.                            "JJMM20040330
        table-field = 'RATE3'.
        table-text = 'Rate 3'(F21).
        table-v_old(12)   = ihist-rate3.
        table-v_new(12)   = nhist-rate3.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate4.                            "JJMM20040330
    if ihist-rate4 ne nhist-rate4.                            "JJMM20040330
        table-field = 'RATE4'.
        table-text = 'Rate 4'(F22).
        table-v_old(12)   = ihist-rate4.
        table-v_new(12)   = nhist-rate4.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate5.                            "JJMM20040330
    if ihist-rate5 ne nhist-rate5.                            "JJMM20040330
        table-field = 'RATE5'.
        table-text = 'Rate 5'(F23).
        table-v_old(12)   = ihist-rate5.
        table-v_new(12)   = nhist-rate5.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate6.                            "JJMM20040330
    if ihist-rate6 ne nhist-rate6.                            "JJMM20040330
        table-field = 'RATE6'.
        table-text = 'Rate 6'(F24).
        table-v_old(12)   = ihist-rate6.
        table-v_new(12)   = nhist-rate6.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate7.                            "JJMM20040330
    if ihist-rate7 ne nhist-rate7.                            "JJMM20040330
        table-field = 'RATE7'.
        table-text = 'Rate 7'(F25).
        table-v_old(12)   = ihist-rate7.
        table-v_new(12)   = nhist-rate7.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate8.                            "JJMM20040330
    if ihist-rate8 ne nhist-rate8.                            "JJMM20040330
        table-field = 'RATE8'.
        table-text = 'Rate 8'(F26).
        table-v_old(12)   = ihist-rate8.
        table-v_new(12)   = nhist-rate8.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate9.                            "JJMM20040330
    if ihist-rate9 ne nhist-rate9.                            "JJMM20040330
        table-field = 'RATE9'.
        table-text = 'Rate 9'(F27).
        table-v_old(12)   = ihist-rate9.
        table-v_new(12)   = nhist-rate9.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate10.                           "JJMM20040330
    if ihist-rate10 ne nhist-rate10.                          "JJMM20040330
        table-field = 'RATE10'.
        table-text = 'Rate 10'(F28).
        table-v_old(12)   = ihist-rate10.
        table-v_new(12)   = nhist-rate10.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate11.                           "JJMM20040330
    if ihist-rate11 ne nhist-rate11.                          "JJMM20040330
       table-field = 'RATE11'.
        table-text = 'Rate 11'(F29).
        table-v_old(12)   = ihist-rate11.
        table-v_new(12)   = nhist-rate11.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    The following lines of code have been added per change IJHM00001
    if ihist-rate12 ne nhist-rate12.
       table-field = 'RATE12'.
        table-text = 'Rate 12'(F30).
        table-v_old(12)   = ihist-rate12.
        table-v_new(12)   = nhist-rate12.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate13 ne nhist-rate13.
       table-field = 'RATE13'.
        table-text = 'Rate 13'(F31).
        table-v_old(12)   = ihist-rate13.
        table-v_new(12)   = nhist-rate13.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate14 ne nhist-rate14.
       table-field = 'RATE14'.
        table-text = 'Rate 14'(F32).
        table-v_old(12)   = ihist-rate14.
        table-v_new(12)   = nhist-rate14.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate15 ne nhist-rate15.
       table-field = 'RATE15'.
        table-text = 'Rate 15'(F33).
        table-v_old(12)   = ihist-rate15.
        table-v_new(12)   = nhist-rate15.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate16 ne nhist-rate16.
       table-field = 'RATE16'.
        table-text = 'Rate 16'(F34).
        table-v_old(12)   = ihist-rate16.
        table-v_new(12)   = nhist-rate16.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate17 ne nhist-rate17.
       table-field = 'RATE17'.
        table-text = 'Rate 17'(F35).
        table-v_old(12)   = ihist-rate17.
        table-v_new(12)   = nhist-rate17.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate18 ne nhist-rate18.
       table-field = 'RATE18'.
        table-text = 'Rate 18'(F36).
        table-v_old(12)   = ihist-rate18.
        table-v_new(12)   = nhist-rate18.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    The following lines of code have been added per change IJHM00002
    if ihist-rate19 ne nhist-rate19.
       table-field = 'RATE19'.
        table-text = 'Rate 19'(F37).
        table-v_old(12)   = ihist-rate19.
        table-v_new(12)   = nhist-rate19.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate20 ne nhist-rate20.
       table-field = 'RATE20'.
        table-text = 'Rate 20'(F38).
        table-v_old(12)   = ihist-rate20.
        table-v_new(12)   = nhist-rate20.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate21 ne nhist-rate21.
       table-field = 'RATE21'.
        table-text = 'Rate 21'(F39).
        table-v_old(12)   = ihist-rate21.
        table-v_new(12)   = nhist-rate21.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate22 ne nhist-rate22.
       table-field = 'RATE22'.
        table-text = 'Rate 22'(F40).
        table-v_old(12)   = ihist-rate22.
        table-v_new(12)   = nhist-rate22.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-intcrb ne nhist-intcrb.
       table-field = 'INTCRB'.
        table-text = 'Intcrb'(F47).                             "IJHM00002
       table-text = 'Intcrb'(F37).                            "IJHM00002
        table-v_old   = ihist-intcrb.
        table-v_new   = nhist-intcrb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-intcrr ne nhist-intcrr.
       table-field = 'INTCRR'.
        table-text = 'Intcrr'(F48).                             "IJHM00002
       table-text = 'Intcrr'(F38).                            "IJHM00002
        table-v_old(12)   = ihist-intcrr.
        table-v_new(12)   = nhist-intcrr.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-zwktran ne nhist-zwktran.
       table-field = 'ZWKTRAN'.
        table-text = 'Data Trans End Unit'(F49).                "IJHM00002
       table-text = 'Data Trans End Unit'(F39).               "IJHM00002
        table-v_old   = ihist-zwktran.
        table-v_new   = nhist-zwktran.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-zwkbud ne nhist-zwkbud.
       table-field = 'ZWKBUD'.
        table-text = 'Wkly Budget Ind'(F50).                    "IJHM00002
       table-text = 'Wkly Budget Ind'(F40).                   "IJHM00002
        table-v_old   = ihist-zwkbud.
        table-v_new   = nhist-zwkbud.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-bcycle ne nhist-bcycle.
       table-field = 'BCYCLE'.
        table-text = 'Bcycle'(F51).                             "IJHM00002
       table-text = 'Bcycle'(F41).                            "IJHM00002
        table-v_old   = ihist-bcycle.
        table-v_new   = nhist-bcycle.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-ovind ne nhist-ovind.
       table-field = 'OVIND'.
        table-text = 'Ovind'(F52).                              "IJHM00002
       table-text = 'Ovind'(F42).                             "IJHM00002
        table-v_old   = ihist-ovind.
        table-v_new   = nhist-ovind.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    *New code for PRSID -
    "ZN032106
      if ihist-prsid ne nhist-prsid.
       table-field = 'PRSID'.
        table-text = 'PRSID'(F53).
        table-v_old   = ihist-prsid.
        table-v_new   = nhist-prsid.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    *End of new code----
    "ZN032106
    endform.
          FORM write_report                                             *
    form write_report.
    loop at table.
      write:/1 table-text,   25 table-v_old(12) left-justified,
             55 table-v_new(12) left-justified, 85 table-oprcd,
             106 table-user, 120 table-date.
      uline.
    endloop.
    skip 5.                                                    "JJMM20040330
    write:/35 TEXT-R01.                                        "JJMM20040330
    reserve 1 lines.                                           "JJMM20040330
    endform.
    *&      Form  import_record
    form import_record changing p_subrc.
         import i_key
               old_zsops to old_zzsops
               new_zsops to new_zzsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record
    *&      Form  import_record_prev
    form import_record_prev changing p_subrc.
         import i_key
               old_zsops to old_prezsops
               new_zsops to new_prezsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record_prev
    *&      Form  import_record_long
    form import_record_long changing p_subrc.
         import i_key
               old_zsops to old_lzsops
               new_zsops to new_lzsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record_prev
    ===
    <b>Here is the dump I am getting:</b>
    ====================
      Error when attempting to IMPORT object "OLD_ZSOPS".
    An exception occurred that is explained in detail below.                      
    The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was  
      not caught in                                                                
    procedure "IMPORT_RECORD" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the         
    exception would occur, the current program is terminated.                     
    The reason for the exception is:                                              
    The object "OLD_ZSOPS" has a different object type in the dataset from        
    that in the target program "ZCFICO6010".                                      
       Try to find out why the type of the object is incorrect.                            
       There are various possible options:                                                                               
    1. The type of the imported object has changed in the Data Dictionary.              
          Make sure that the type of the imported object matches the type                  
          of the object in the Data Dictionary.                                            
          If the data cannot be restored from another source, the data must be             
          read by the 'old' structure, converted und again eported with the new            
          structure, so that future IMPORTs will always function with the new              
          structure.                                                                               
    2. A new program version is active, which no longer fits the dataset.               
          Try to solve the error generating the program "ZCFICO6010" again. This           
          works as follows: Select transaction SE38 in the SAP system. Enter               
          the program name "ZCFICO6010". Then activate the function 'Generate'.                                                                               
    If the error occures in a non-modified SAP program, you may be able to              
       find an interim solution in an SAP Note.                                            
       If you have access to SAP Notes, carry out a search with the following              
       keywords:                                                                               
    "CONNE_IMPORT_WRONG_OBJECT_TYPE" "CX_SY_IMPORT_MISMATCH_ERROR"                      
       "ZCFICO6010" or "ZCFICO6010"                                                        
       "IMPORT_RECORD"                                                                               
    If you cannot solve the problem yourself and want to send an error                  
       notification to SAP, include the following information:                                                                               
    1. The description of the current problem (short dump)                              
        To save the description, choose "System->List->Save->Local File           
    (Unconverted)".                                                                               
    2. Corresponding system log                                                                               
    Display the system log by calling transaction SM21.                       
        Restrict the time interval to 10 minutes before and five minutes          
    after the short dump. Then choose "System->List->Save->Local File            
    (Unconverted)".                                                                               
    3. If the problem occurs in a problem of your own or a modified SAP          
    program: The source code of the program                                      
        In the editor, choose "Utilities->More                                    
    Utilities->Upload/Download->Download".                                                                               
    4. Details about the conditions under which the error occurred or which      
    actions and input led to the error.                                                                               
    The exception must either be prevented, caught within proedure               
    "IMPORT_RECORD" "(FORM)", or its possible occurrence must be declared in the 
    RAISING clause of the procedure.                                             
    To prevent the exception, note the following:                                
    ==============
    Sorry forthis lengthy post but I was having difficulty explaining in previous post. All answers will be rewarded..
    Thanks.
    Mithun

    What is the structure for zsops ?
    There seems to be a compatibility issue....

  • Problem with apply changes on master-detail with respect to date handling

    dear sir,
    i have one tabler where in i have created from_Date and to_date as varchar2(30) each. I stored the from date as 'dd-mon-yyyy hh24:mi' I had written before header process for calculating no of days between from_Date and to_Date using the said format. If to_Date is null then first i store the value as
    to_char(sysdate,'dd-mon-yyyy hh24:mi') and then convert it as to_Date(substr(to_Date,1,17),'dd-mon-yyyy hh24:mi'). this calculation of days procedures works fine in sql command mode.
    when i am handling through master-detail page i works fine when there is null value inf to_Date vc2 column. if i store using date picker dd-mon-yyyy hh24:mi, the data is getting stored but subsequent edit through master detail give error as ora-01722 unable to fetch row. Manually if i set the to_Date as null pages works fine. I spent lots of time and unable to understand the mistake i do.
    if anybody could help me, i will be much obliged.
    thanking you,
    yours
    dr.s.raghunatha

    I think the best would be if you create an example on apex.oracle.com and I will debug it.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------

  • Date format in SQL statements

    Hi there !
    Please, can anyone help me find out what is going on with date format in my SQL Statements ?
    While in development, the date format in SQL statements were:
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10-DEC-2004'
    And works fine.
    After deploy to production server, we get ORACLE error: not a valid month
    So we change the format to
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10/12/2004'
    And it gets to works again.
    Yesterday, the net administrator updated the JAVAC / JSDK run-time with Java update tool, and AGAIN we get ORACLE error: not a valid month
    So we change the format AGAIN to
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10-DEZ-2004'
    And it gets to works again.
    What is going on ?
    JAVAC running on Windows2003.
    The application access the ORACLE DB directly through JDBC.
    There is no APPLICATION SERVER, like TOMCAT.
    The regedit (windows registry) ALWAYS was and are now :
    NLS_DATE_FORMAT = DD-MON-YYYY
    NLS_LANG = AMERICAN_AMERICA.WE8ISO8859P1
    Versions:
    DB Oracle 9.2.0.5.0
    JavaC 1.4.2.05
    Thanks.
    Juliano

    Somewhere, I'm willing to wager your NLS_DATE_FORMAT was/ is being changed. This is a client-side setting. Are you sure that the setting is the same on every client machine.
    This is one of the reasons that it is considered bad form to rely on implicit conversion. If you wrap your string literal in a TO_DATE, use the JDBC escape sequence {d }, or use a Date bind variable, you don't have this problem. The bind variable approach will also play much more nicely with your database's shared pool.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Help in ABAP code please!

    We have upgraded to ECC6.0 and I am trying to fix some syntax errors. Here is the piece of code with the problem:
    ====
    import i_key
               old_zsops to old_zzsops
               new_zsops to new_zzsops
               from database zsopshist(Z1)
               id i_key.
         import i_key
               old_zsops to old_prezsops
               new_zsops to new_prezsops
               from database zsopshist(Z1)
               id i_key.
    =====
    I am kind of new to ABAP and went throught the documentation but could someone please tell me what "old_zsops to old_zzsops" does?
    The code above is causing the dump with error "Error when attempting to IMPORT object "OLD_ZSOPS"". I went through the code and I found that old_zsops and new_zsops is not declared at all and it doesn't give any compilation errors! It goes to dump when I execute the problem. If it is required I would send the whole code but I see the following declarations in the code:
    data: old_prezsops like zsops_prev.     "PJCHG10854
    data: new_prezsops like zsops_prev.     "PJCHG10854
    data: old_zzsops like zsops.            "PJCHG10854
    data: new_zzsops like zsops.            "PJCHG10854
    data: long_rec(900) type c.             "PJCHG10854
    data: old_lzsops like long_rec.         "PJCHG10854
    data: new_lzsops like long_rec.         "PJCHG10854
    data: curr_zsops like zsops,
          prev_zsops like zsops_prev.
    Could someone please help me how to fix this problem? How do I declare "old_zsops and new_zsops" because they are used in 2 different import statements? All the answers will be rewarded.
    Thanks.
    Mithun

    Everything is in the same porgram. To avoid confusion I will send the whole code:
    ===
    REPORT ZCFICO6010
             line-count 65
             line-size 132
             no standard page heading.
    tables: zsopshist, zsops.
    *data: old_zsops like zsops,
         new_zsops like zsops.
    data: old_prezsops like zsops_prev.     "PJCHG10854
    data: new_prezsops like zsops_prev.     "PJCHG10854
    data: old_zzsops like zsops.            "PJCHG10854
    data: new_zzsops like zsops.            "PJCHG10854
    data: long_rec(900) type c.             "PJCHG10854
    data: old_lzsops like long_rec.         "PJCHG10854
    data: new_lzsops like long_rec.         "PJCHG10854
    data: curr_zsops like zsops,
          prev_zsops like zsops_prev.
    data: begin of i_key,
      kostl(5),
      aedat(8),
      cputm(6).
    data:   end of i_key.
    DATA: HEADER like zsops-oprcd,
          header1(92) type c.
        header1 like header.
    data: v_field(18) type c,
          v_old(20)  type c,
          v_new(20)  type c,
          user like zsops-uname,
          date like zsops-aedtm.
    data: begin of table occurs 0,
          text(20) type c,
          oprcd like zsops-oprcd,
          field(15) type c,
          user like zsops-uname,
          date like zsops-aedtm,
          v_old(20) ,
          v_new(20) ,
        end of table.
    data: text(30) type c.
    data: begin of itab occurs 0,
           srtfd like zsopshist-srtfd,
         end of itab.
    *data: ihist like old_zsops occurs 0 with header line,
         nhist like new_zsops occurs 0 with header line.
    data: ihist like zsops occurs 0 with header line,
          nhist like zsops occurs 0 with header line.
    *&      Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE TEXT-200.
    parameters: s_oprcd  like zsops-oprcd obligatory,
                s_oprcdh like zsops-oprcd .
                    s_cputm   for sy-uzeit.
    SELECTION-SCREEN END OF BLOCK one.
    SELECTION-SCREEN BEGIN OF BLOCK three WITH FRAME TITLE TEXT-300.
    parameters:s_aedtm  like zsops-aedtm obligatory,
    s_aedtmh like zsops-aedtm obligatory.
    SELECTION-SCREEN END OF BLOCK three.
    SELECTION-SCREEN BEGIN OF BLOCK TWO WITH FRAME TITLE TEXT-100.
    PARAMETERS: P_REGSRT RADIOBUTTON GROUP RADI,
                P_ACCSRT RADIOBUTTON GROUP RADI.
    SELECTION-SCREEN END OF BLOCK TWO.
    parameters: new_date like sy-datum obligatory default '20051214'.
    *&      Top-Of-Page
    top-of-page.
    BEGIN OF BLOCK INSERTED FOR                              "JJMM20040330
      DATA: CC_LOW LIKE ZSOPS-OPRCD,
            CC_HIGH LIKE ZSOPS-OPRCD,
            FROM_DATE(10) TYPE C,
            TO_DATE(10)   TYPE C.
      WRITE: S_OPRCD TO CC_LOW NO-ZERO,
             S_AEDTM TO FROM_DATE USING EDIT MASK '__/__/____',
             S_AEDTMH TO TO_DATE USING EDIT MASK '__/__/____'.
      IF S_OPRCDH = S_OPRCD.
        CONCATENATE: 'Cost Center'(T02) CC_LOW 'Changed On'(T04) FROM_DATE
                     'To'(T03) TO_DATE 'Sort By'(T05) text INTO HEADER1
                     separated by space.
      ELSE.
        WRITE: S_OPRCDH TO CC_HIGH NO-ZERO.
        CONCATENATE: 'Cost Center'(T02) CC_LOW 'To'(T03) CC_HIGH
                     'Changed On'(T04) FROM_DATE 'To'(T03) TO_DATE
                     'Sort By'(T05) text INTO HEADER1 separated by space.
      ENDIF.
    END OF BLOCK INSERTED FOR                                "JJMM20040330
      PERFORM DISPLAY_PAGE_HEADER(ZCLT0001) USING
                                          header1            "JJMM20040330
                                            HEADER
                                            TEXT-T01
                                            header1.           "JJMM20040330
    BEGIN OF BLOCK COMMENTED OUT FOR                         "JJMM20040330
    write:/5 'Cost Center'(T02), s_oprcd+5(5), 'To'(T03), s_oprcdh,
           40 'Changed On'(T04), s_aedtm, 'To'(T03), s_aedtmh,
           85 'Sort by'(T05), text.
    uline. skip.
    END OF BLOCK COMMENTED OUT FOR                           "JJMM20040330
      Write:/ 'Field Changed'(C01), 25 'Old Values'(C02),
               55 'New Values'(C03), 85 'Cost Center'(C04),
              105 'Changed By'(C05), 120 'Changed On'(C06).
      uline.
    start-of-selection.
      data: time(6),
            v_subrc like sy-subrc,
            prev_format(1),
            srtfd like zsopshist-srtfd,
            srtfdh like zsopshist-srtfd.
      srtfd0(5) = s_oprcd5(5).
      srtfd+5(8) = s_aedtm.
      srtfd+13(6) = '000000'.
       if s_oprcdh is initial.
         s_oprcdh = s_oprcd.
       endif.
      srtfdh0(5) = s_oprcdh5(5).
      srtfdh+5(8) = s_aedtmh.
      srtfdh+13(6) = '999999'.
      select srtfd from zsopshist into table itab
              WHERE  SRTFD >= SRTFD
              AND    SRTFD <= SRTFDH.
    sort itab by srtfd.
      loop at itab.
        IF ITAB+5(8) GE S_AEDTM  AND                            "IJHM00001
            ITAB+5(8) LE S_AEDTMH.                              "IJHM00001
          move: itab+0(5)          to i_key-kostl,
                itab+5(8)          to i_key-aedat,
                itab+13(6)         to i_key-cputm.
    /---  PJCHG10854 Begin commented/New code                     /
    /---  To change the import structure based on date the old    /
    /---  import was removed and following coded added.           /
          clear: v_subrc, prev_format.
          if itab+5(8) lt new_date.
            prev_format = 'X'.
            perform import_record_prev changing v_subrc.      "PJCHG10854
          else.
            perform import_record changing v_subrc.           "PJCHG10854
          endif.
         import i_key
              old_zsops
              new_zsops
              from database zsopshist(Z1)
              id i_key.
    /---   PJCHG10854 END commented/New code                /
          if v_subrc = 0.                                     "PJCHG10854
            perform get_final_table.
          endif.
        ENDIF.                                                  "IJHM00001
      endloop.
      if p_regsrt = 'X'.
        sort table by oprcd field date descending.
        text = 'Cost Center'(C04).
      else.
        sort table by field oprcd date descending.
        text = 'Field Changed'(C01).
      endif.
       perform write_report.
          FORM get_final_table                                          *
    form get_final_table.
    move old_zsops to ihist.           "PJCHG10854
    move new_zsops to nhist.           "PJCHG10854
      if prev_format eq 'X'.              "PJCHG10854
        move old_prezsops to ihist.       "PJCHG10854
        move new_prezsops to nhist.       "PJCHG10854
      else.                               "PJCHG10854
        move old_zzsops to ihist.         "PJCHG10854
        move new_zzsops to nhist.         "PJCHG10854
      endif.                              "PJCHG10854
      if ihist-ivcrg ne nhist-ivcrg.
       table-text = 'Invst Charge Base'(F01).
       table-field = 'IVCRG'.
        table-v_old   = ihist-ivcrg.
        table-v_new   = nhist-ivcrg.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-mgtfp ne nhist-mgtfp.
        table-field = 'MGTFP'.
        table-text = 'Mgt Fee %'(F02).
        table-v_old(12)   = ihist-mgtfp.
        table-v_new(12)   = nhist-mgtfp.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-discd ne nhist-discd.
        table-field = 'DISCD'.
        table-text = 'Cash Disc. Passback'(F03).
        table-v_old   = ihist-discd.
        table-v_new   = nhist-discd.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-consc ne nhist-consc.
        table-field = 'CONSC'.
        table-text = 'Subsidy Calc'(F04).
        table-v_old   = ihist-consc.
        table-v_new   = nhist-consc.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-payfart ne nhist-payfart.
        table-field = 'PAYFART'.
        table-text = 'Payroll Fringe'(F05).
        table-v_old(12)   = ihist-payfart.
        table-v_new(12)   = nhist-payfart.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-frbpb ne nhist-frbpb.
        table-field = 'FRBPB'.
        table-text = 'Rebate Pass Back'(F06).
        table-v_old(12)   = ihist-frbpb.
        table-v_new(12)   = nhist-frbpb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-exlca ne nhist-exlca.
        table-field = 'EXLCA'.
        table-text = 'Excl Source27'(F07).
        table-v_old   = ihist-exlca.
        table-v_new   = nhist-exlca.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-exlcb ne nhist-exlcb.
        table-field = 'EXLCB'.
        table-text = 'Excl Source11'(F08).
        table-v_old   = ihist-exlcb.
        table-v_new   = nhist-exlcb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-trnrate ne nhist-trnrate.
        table-field = 'TRNRATE'.
        table-text = 'Payroll Training'(F09).
        table-v_old(12)   = ihist-trnrate.
        table-v_new(12)   = nhist-trnrate.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-mgffa ne nhist-mgffa.
        table-field = 'MGFFA'.
        table-text = 'Mgt Fee Amt'(F10).
        table-v_old(12)   = ihist-mgffa.
        table-v_new(12)   = nhist-mgffa.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-mgtfi ne nhist-mgtfi.
        table-field = 'MGTFI'.
        table-text = 'Mgt Fees Indicator'(F11).
        table-v_old   = ihist-mgtfi.
        table-v_new   = nhist-mgtfi.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
      perform write_report.
        append table.
      endif.
      if ihist-eqres ne nhist-eqres.
        table-field = 'EQRES'.
        table-text = 'Eqip Res Accrual'(F12).
      table-v_old = ihist-eqres.                             "JJMM20040331
      table-v_new = nhist-eqres.                             "JJMM20040331
        table-v_old(12) = ihist-eqres.                         "JJMM20040331
        table-v_new(12) = nhist-eqres.                         "JJMM20040331
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-ovrhd ne nhist-ovrhd.
        table-field = 'OVRHD'.
        table-text = 'OverHead Amt'(F13).
        table-v_old(12)   = ihist-ovrhd.
        table-v_new(12)   = nhist-ovrhd.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
        if ihist-xaccural ne nhist-xaccural.
        table-field = 'XACCUARAL'.
        table-text = 'Exclude Accrual'(F14).
        table-v_old(12)   = ihist-xaccural.
        table-v_new(12)   = nhist-xaccural.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
      if ihist-ovrrt ne nhist-ovrrt.
        table-field = 'OVRRT'.
        table-text = 'OverHead Rate'(F15).
        table-v_old(12)   = ihist-ovrrt.
        table-v_new(12)   = nhist-ovrrt.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
        if ihist-ztbd01 ne nhist-ztbd01.
        table-field = 'ZTBD01'.
      table-text = 'Char1'.                                  "JJMM20040330
        table-text = 'Meal Allowance'(F16).                    "JJMM20040330
        table-v_old   = ihist-ztbd01.
        table-v_new   = nhist-ztbd01.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    BEGIN OF BLOCK INSERTED FOR                            "JJMM20040330
      if ihist-earlybil ne nhist-earlybil.
        table-field = 'EARLYBIL'.
        table-text = 'Early Billing'(F17).
        table-v_old   = ihist-earlybil.
        table-v_new   = nhist-earlybil.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
      if ihist-combined ne nhist-combined.
        table-field = 'COMBINED'.
        table-text = 'Combined Billing'(F18).
        table-v_old   = ihist-COMBINED.
        table-v_new   = nhist-COMBINED.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    END OF BLOCK INSERTED FOR                                "JJMM20040330
        if ihist-rate1 ne nhist-rate1.
        table-field = 'RATE1'.
        table-text = 'Rate 1'(F19).
        table-v_old(12)   = ihist-rate1.
        table-v_new(12)  = nhist-rate1.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate2.                            "JJMM20040330
      table-field = 'RATE1'.                                 "JJMM20040330
    if ihist-rate2 ne nhist-rate2.                            "JJMM20040330
        table-field = 'RATE2'.                                 "JJMM20040330
        table-text = 'Rate 2'(F20).
        table-v_old(12)   = ihist-rate2.
        table-v_new(12)   = nhist-rate2.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate3.                            "JJMM20040330
    if ihist-rate3 ne nhist-rate3.                            "JJMM20040330
        table-field = 'RATE3'.
        table-text = 'Rate 3'(F21).
        table-v_old(12)   = ihist-rate3.
        table-v_new(12)   = nhist-rate3.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate4.                            "JJMM20040330
    if ihist-rate4 ne nhist-rate4.                            "JJMM20040330
        table-field = 'RATE4'.
        table-text = 'Rate 4'(F22).
        table-v_old(12)   = ihist-rate4.
        table-v_new(12)   = nhist-rate4.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate5.                            "JJMM20040330
    if ihist-rate5 ne nhist-rate5.                            "JJMM20040330
        table-field = 'RATE5'.
        table-text = 'Rate 5'(F23).
        table-v_old(12)   = ihist-rate5.
        table-v_new(12)   = nhist-rate5.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate6.                            "JJMM20040330
    if ihist-rate6 ne nhist-rate6.                            "JJMM20040330
        table-field = 'RATE6'.
        table-text = 'Rate 6'(F24).
        table-v_old(12)   = ihist-rate6.
        table-v_new(12)   = nhist-rate6.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate7.                            "JJMM20040330
    if ihist-rate7 ne nhist-rate7.                            "JJMM20040330
        table-field = 'RATE7'.
        table-text = 'Rate 7'(F25).
        table-v_old(12)   = ihist-rate7.
        table-v_new(12)   = nhist-rate7.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate8.                            "JJMM20040330
    if ihist-rate8 ne nhist-rate8.                            "JJMM20040330
        table-field = 'RATE8'.
        table-text = 'Rate 8'(F26).
        table-v_old(12)   = ihist-rate8.
        table-v_new(12)   = nhist-rate8.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate9.                            "JJMM20040330
    if ihist-rate9 ne nhist-rate9.                            "JJMM20040330
        table-field = 'RATE9'.
        table-text = 'Rate 9'(F27).
        table-v_old(12)   = ihist-rate9.
        table-v_new(12)   = nhist-rate9.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate10.                           "JJMM20040330
    if ihist-rate10 ne nhist-rate10.                          "JJMM20040330
        table-field = 'RATE10'.
        table-text = 'Rate 10'(F28).
        table-v_old(12)   = ihist-rate10.
        table-v_new(12)   = nhist-rate10.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    *if ihist-rate1 ne nhist-rate11.                           "JJMM20040330
    if ihist-rate11 ne nhist-rate11.                          "JJMM20040330
       table-field = 'RATE11'.
        table-text = 'Rate 11'(F29).
        table-v_old(12)   = ihist-rate11.
        table-v_new(12)   = nhist-rate11.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      perform write_report.
      endif.
    The following lines of code have been added per change IJHM00001
    if ihist-rate12 ne nhist-rate12.
       table-field = 'RATE12'.
        table-text = 'Rate 12'(F30).
        table-v_old(12)   = ihist-rate12.
        table-v_new(12)   = nhist-rate12.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate13 ne nhist-rate13.
       table-field = 'RATE13'.
        table-text = 'Rate 13'(F31).
        table-v_old(12)   = ihist-rate13.
        table-v_new(12)   = nhist-rate13.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate14 ne nhist-rate14.
       table-field = 'RATE14'.
        table-text = 'Rate 14'(F32).
        table-v_old(12)   = ihist-rate14.
        table-v_new(12)   = nhist-rate14.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate15 ne nhist-rate15.
       table-field = 'RATE15'.
        table-text = 'Rate 15'(F33).
        table-v_old(12)   = ihist-rate15.
        table-v_new(12)   = nhist-rate15.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate16 ne nhist-rate16.
       table-field = 'RATE16'.
        table-text = 'Rate 16'(F34).
        table-v_old(12)   = ihist-rate16.
        table-v_new(12)   = nhist-rate16.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate17 ne nhist-rate17.
       table-field = 'RATE17'.
        table-text = 'Rate 17'(F35).
        table-v_old(12)   = ihist-rate17.
        table-v_new(12)   = nhist-rate17.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate18 ne nhist-rate18.
       table-field = 'RATE18'.
        table-text = 'Rate 18'(F36).
        table-v_old(12)   = ihist-rate18.
        table-v_new(12)   = nhist-rate18.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    The following lines of code have been added per change IJHM00002
    if ihist-rate19 ne nhist-rate19.
       table-field = 'RATE19'.
        table-text = 'Rate 19'(F37).
        table-v_old(12)   = ihist-rate19.
        table-v_new(12)   = nhist-rate19.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate20 ne nhist-rate20.
       table-field = 'RATE20'.
        table-text = 'Rate 20'(F38).
        table-v_old(12)   = ihist-rate20.
        table-v_new(12)   = nhist-rate20.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate21 ne nhist-rate21.
       table-field = 'RATE21'.
        table-text = 'Rate 21'(F39).
        table-v_old(12)   = ihist-rate21.
        table-v_new(12)   = nhist-rate21.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-rate22 ne nhist-rate22.
       table-field = 'RATE22'.
        table-text = 'Rate 22'(F40).
        table-v_old(12)   = ihist-rate22.
        table-v_new(12)   = nhist-rate22.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-intcrb ne nhist-intcrb.
       table-field = 'INTCRB'.
        table-text = 'Intcrb'(F47).                             "IJHM00002
       table-text = 'Intcrb'(F37).                            "IJHM00002
        table-v_old   = ihist-intcrb.
        table-v_new   = nhist-intcrb.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-intcrr ne nhist-intcrr.
       table-field = 'INTCRR'.
        table-text = 'Intcrr'(F48).                             "IJHM00002
       table-text = 'Intcrr'(F38).                            "IJHM00002
        table-v_old(12)   = ihist-intcrr.
        table-v_new(12)   = nhist-intcrr.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-zwktran ne nhist-zwktran.
       table-field = 'ZWKTRAN'.
        table-text = 'Data Trans End Unit'(F49).                "IJHM00002
       table-text = 'Data Trans End Unit'(F39).               "IJHM00002
        table-v_old   = ihist-zwktran.
        table-v_new   = nhist-zwktran.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-zwkbud ne nhist-zwkbud.
       table-field = 'ZWKBUD'.
        table-text = 'Wkly Budget Ind'(F50).                    "IJHM00002
       table-text = 'Wkly Budget Ind'(F40).                   "IJHM00002
        table-v_old   = ihist-zwkbud.
        table-v_new   = nhist-zwkbud.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-bcycle ne nhist-bcycle.
       table-field = 'BCYCLE'.
        table-text = 'Bcycle'(F51).                             "IJHM00002
       table-text = 'Bcycle'(F41).                            "IJHM00002
        table-v_old   = ihist-bcycle.
        table-v_new   = nhist-bcycle.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    if ihist-ovind ne nhist-ovind.
       table-field = 'OVIND'.
        table-text = 'Ovind'(F52).                              "IJHM00002
       table-text = 'Ovind'(F42).                             "IJHM00002
        table-v_old   = ihist-ovind.
        table-v_new   = nhist-ovind.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    *New code for PRSID -
    "ZN032106
      if ihist-prsid ne nhist-prsid.
       table-field = 'PRSID'.
        table-text = 'PRSID'(F53).
        table-v_old   = ihist-prsid.
        table-v_new   = nhist-prsid.
        table-user    = nhist-uname.
        table-date    = nhist-aedtm.
        table-oprcd = nhist-oprcd.
        append table.
      endif.
    *End of new code----
    "ZN032106
    endform.
          FORM write_report                                             *
    form write_report.
    loop at table.
      write:/1 table-text,   25 table-v_old(12) left-justified,
             55 table-v_new(12) left-justified, 85 table-oprcd,
             106 table-user, 120 table-date.
      uline.
    endloop.
    skip 5.                                                    "JJMM20040330
    write:/35 TEXT-R01.                                        "JJMM20040330
    reserve 1 lines.                                           "JJMM20040330
    endform.
    *&      Form  import_record
    form import_record changing p_subrc.
         import i_key
               old_zsops to old_zzsops
               new_zsops to new_zzsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record
    *&      Form  import_record_prev
    form import_record_prev changing p_subrc.
         import i_key
               old_zsops to old_prezsops
               new_zsops to new_prezsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record_prev
    *&      Form  import_record_long
    form import_record_long changing p_subrc.
         import i_key
               old_zsops to old_lzsops
               new_zsops to new_lzsops
               from database zsopshist(Z1)
               id i_key.
         p_subrc = sy-subrc.
    endform.                    " import_record_prev
    ========
    Thanks.
    Mithun

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

  • How to use quarter format in "to_date()" function?

    Hi,
    I'm trying to use to_date() function with quarter format. How do I specify the format?
    For example to convert '2002 quarter 1' using the to_date function.
    I tried to_date('20021', 'YYYYQ'), and I got ORA-01820 cannot appear in date input format.
    Please help, thank you!!!

    You cannot use Q when inputting data, only when retrieving data. When inputting, you must enter a valid date. Oracle has to store a date and if you just enter a quarter, it can't figure out what date to store. See the examples below:
    SQL> -- test table:
    SQL> CREATE TABLE test_table
      2    (test_date DATE)
      3  /
    Table created.
    SQL> -- the wrong way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
      3  /
    VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
    ERROR at line 2:
    ORA-01820: format code cannot appear in date input format
    SQL> -- the right way to input:
    SQL> INSERT INTO test_table (test_date)
      2  VALUES (TO_DATE ('27-OCT-2002', 'DD-MON-YYYY'))
      3  /
    1 row created.
    SQL> -- to output:
    SQL> COLUMN "Year and Quarter" FORMAT A16
    SQL> SELECT test_date,
      2         TO_CHAR (test_date, 'YYYY-Q') AS "Year and Quarter"
      3  FROM   test_table
      4  /
    TEST_DATE   Year and Quarter
    27-OCT-2002 2002-4
    1 row selected.

  • How to use TO_DATE function in OBI having MSSQL DB

    Hello Experts,
    I am facing a problem plz help me.....
    I've just created an business application using Oracle BI Administration Tool of Oracle BI Server version 10.1.3.4.1,with oracle DB.
    But currently we migrate from Oracle to MSSQL Server. Due to which I am facing problem regarding Date Column (TO_DATE(), timestamp).
    As I have created a report with 2 fields
    Incident_Number, TimeStampAdd(SQL_TSI_SECOND,Incident_D.Reported_Date,timestamp '1970-01-01 00:00:00')
    Incident_D.Reported_Date contains integer values which stores total seconds from date 01/01/1970 00:00:00 . I want to convert these seconds from 1970 to datetime.
    when I ran the report with Oracle source it works fine, But with MSSQL as Source it gives me following error ...........
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared.. [nQSError: 16001] ODBC error state: 37000 code: 195 message: [Microsoft][SQL Server Native Client 10.0][SQL Server]'TO_DATE' is not a recognized built-in function name.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000)
    SQL Issued: SELECT Incidents."Incident Number" saw_0, TIMESTAMPADD(SQL_TSI_SECOND, Incidents."Reported Date", timestamp '1970-01-01 00:00:00') saw_1
    FROM "ITSM Information" ORDER BY saw_0, saw_1
    The Sql query log generated is as follow :
    select distinct T728.INCIDENT_NUMBER as c1,
    ( CAST(TO_DATE('1970-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') as DATE) + ( T728.REPORTED_DATE / 86400 ) ) as c2
    from
    INCIDENT_D T728
    order by c1, c2
    +++Administrator:ce0000:ce0002:----2010-11-30 14:51:38
    -------------------- Query Status: Query Failed: [nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared..
    [nQSError: 16001] ODBC error state: 37000 code: 195 message: [Microsoft][SQL Server Native Client 10.0][SQL Server]'TO_DATE' is not a recognized built-in function name..
    [nQSError: 16002] Cannot obtain number of columns for the query result.
    Please Help me........
    Thanks and Regards,
    MJ

    I will give a try at it,TO_DATE is not recognised function by the SQLserver
    ( CAST(TO_DATE('1970-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') as DATE)Instead of it use to_Char and try it like this so on cast(year(your_date) as char) || '-'||cast(month(your_date) as char) OR use this nice blog by saichand http://varanasisaichand.blogspot.com/2010/05/evaluate-function.html
    it says like EVALUATE('TO_CHAR(%1,%2)' ,"Dim- Date".Start Date,'YYYY-MM-DD HH24:MI:SS')
    Hope it helps you.Mark points.
    By,
    KK

  • Equivalent of to_date function in Ms SQL and using it in Evaluate function

    Hi,
    I am trying to find out a function in MS SQL which is equivalent to to_date function in oracle. Please find below the advanced filter i am trying to use in OBIEE.
    Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY')>=Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY') and Evaluate('to_date(%1,%2)' as date ,SUBSTRING(TIMES.CALENDAR_MONTH_NAME FROM 1 FOR 3)||'-'||cast(TIMES.CALENDAR_YEAR as char(4)),'MON-YYYY') <=timestampadd(sql_tsi_month,4,Evaluate('to_date(%1,%2)' as date,'@{pv_mth}'||'@{pv_yr}','MON-YYYY'))
    The statement above works fines with oracle DB with to_date function. The same statement throws an error with MS SQL since to_date is not a built in function.
    With MS SQL I tried with CAST, not sure how to pass parameters %1 and %2.
    Please help me how to use Evaluate function and passing parameters along with to_date funtion in MS SQL.
    Regards!
    RR

    Hi,
    please refer to this thread for useful information on using to_char and to_date functions of oracle in MS SQL server:
    http://database.ittoolbox.com/groups/technical-functional/sql-server-l/how-to-write-to-to_char-and-to_date-sql-server-351831
    Hope this helps.
    Thanks,
    -Amith.

  • Bad performance due to the use of AGO and TO_DATE time series functions

    Hi all,
    I'm building an OBI EE Project on top of a 1TB DW, and i'm facing major performance problems due to the use of the AGO and TO_DATE time series functions in some of the Metrics included on the reports. I discovered that when a report with one of those metrics is submited to the DB, the resulting query/explain plan is just awful!... Apparently OBI EE is asking the DB to send everything it needs to do the calculations itself. The CPU cost goes to the roof!
    I've tried new indexes, updated statistics, MV's, but the result remains the same, i.e., if you happen to use AGO or TO_DATE in the report you'll get lousy query time...
    Please advise, if you have come across the same problem.
    Thanks in advance.

    Nico,
    Combining the solution to view the data in dense form (http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension), and the use of the lag function (http://gerardnico.com/wiki/dat/obiee/presentation_service/obiee_period_to_period_lag_lead_function) appears to be the best solution for us.
    Thanks very much.

  • Using to_date causes CBO to use wrong index

    I'm working on switching an application from using the Rule-based optimizer to use the Cost-based Optimizer on Oracle 9iR2. I'm having problems with the following query:
    select report_rsn, reports.facility_code,
           exams.facility_code
      from exams join reports using (report_rsn)
    where reports.transcribed_date
            between to_date('17-Mar-2005')
                and to_date('18-Mar-2005')
       and exams.dictated_for_rsn = 3323
       and exams.status IN ('S','T')There is an index on the reports.transcribed_date column and a compound index on (exams.dictated_for_rsn,exams.status).
    EXPLAIN PLAN tells me this query will use the transcribed_date as the driving index, but when I run the query through SQL_TRACE, tkprof says that it used the other index instead. That took a long time. (90 seconds)
    If I change the to_date() functions to be ANSI date literals (DATE '2005-03-17' and DATE '2005-03-18'), EXPLAIN PLAN says the same as before, and tkprof says that it actually used that plan. The query returned almost instantly.
    We have CURSOR_SHARING set to 'SIMILAR', and my best guess is that there is something involving the "bind parameter peeking" that is causing the problem. It appears as if the optimizer does not evaluate the to_date() function between "peeking" at the bind variable and determining the execution plan, so it does not know that the two dates are only a day apart. However, I haven't been able to find anything in the docs to confirm my suspicions.
    I've done a search for queries in our system that use the to_date() function as part of the where clause, and it doesn't look like a Herculean task to simply change them all, but I'm wondering two things:
    1) Is there a better way to solve the problem?
    2) Is there any information on this behavior out there that I can read to verify my suspicions? This might be the most important, because in order to finalize the switch to CBO, I need to be able to tell my supervisor that "this sort of thing" won't happen on our production box.
    -- Jeff Beal

    Jeff,
    Could you post your plan under both scenarios? WhatHere are the relevant* (different) portions of the execution plan (as given by TKPROF):
    * I actually ran TKProf against a much larger query, but the controlling part is the query that I included.
    When using DATE literal:
    Rows     Row Source Operation
          0               NESTED LOOPS 
          0                TABLE ACCESS BY INDEX ROWID REPORTS
          6                 INDEX RANGE SCAN IX_REPORTS_TRDATE (object id 109215)
          0                TABLE ACCESS BY INDEX ROWID EXAMS
          0                 INDEX RANGE SCAN IX_FK_EXAMS_11 (object id 96878)When using to_date function
    Rows     Row Source Operation
      46517                NESTED LOOPS 
      46517                 INLIST ITERATOR 
      46517                  TABLE ACCESS BY INDEX ROWID EXAMS
      46517                   INDEX RANGE SCAN IX_FK_EXAMS_4 (object id 139880)
          0                 TABLE ACCESS BY INDEX ROWID REPORTS
      46517                   INDEX UNIQUE SCAN PK_REPORTS (object id 109164)
    are the indexes on the tables and on what columns are
    they present?'ix_fk_exams_4' is a compound index on the exams table.  The first column is 'dictated_for_rsn' and the second is 'status'.  'pk_reports' is an index on reports.report_rsn - the primary key of the table.  'ix_reports_trdate' is on the reports.transcribed_date column.  'ix_fk_exams_11' is on exams.report_rsn (the foreign key to the reports table).
    Just to give you an idea on size, the exams table has about six million rows; the reports table has about 5.5 million.  I would categorize the transcribed_date column as evenly distributed, along with the values in dictated_for_rsn.  The status column is heavily skewed, with 'T' and 'S' being the two most common statuses.

  • Using = with to_date function fails to get the results

    Hello ALl,
    I have table for visits information. my table has two fields survey_id (Number) and visit_date(date).
    the visit_date also contain the visit time HH:MI:SS.
    when I query the table to find the information for one day and using the following qyery:
    select survey_id,visit_date
    from my_table
    where visit_date=to_date('26/04/2010','DD/MM/YYYY');
    The result is no data found
    but When I used another query such as
    select survey_id,visit_date
    from my_table
    where visit_date>to_date('25/04/2010','DD/MM/YYYY');
    there are some records in date 26/04/2010.
    In other words, always when I query the table for one day using
    visit_date=to_date(:my_date,'DD/MM/YYYY');
    there is no data returned although there is data in the table.
    is the problem because the time HH:MI:SS exisits in visit_date field.
    any help please.
    Edited by: M.Jabr on May 5, 2010 6:12 AM

    Oracle stores dates as a numeric (I think 9 digit) format which includes the time.
    When you use the = operator with a truncated string, it assumes zeros for the time elements.
    So your first query is looking for visits which were at exactly midnight.
    So your options are to use the trunc function as suggested or to use the 'between' syntax.

  • What is the use of To_date, to_char functions?

    what is the use of To_date, to_char functions?
    while i am using these in my day to day activities but never able to know the exact working of tehse.
    Message was edited by:
    437022

    Dates are stored and manipulated as coded (binary) values that always contain "century, year, month, date, hour, minute second"
    We don't want to see the date as stored. We want to see the characters (digits) that make up the date. So we use to_char(the-date-value)
    We want to tell the system a date, but have a heck of a time entering the binary. So we input the characters (digits) that make up the date and tell the system to convert that to a binary 'date' using to_date(our-string-that-respresents-dates)
    The magic Oracle has added is the format codes (see chapter 2 of the SQL Reference manual for the complete list). We can get the system to print out dates and times, including day of week (and so on) using format codes.
    The default format is to show us the date but not the time. Which leads a lot of people to believe that the time is not stored.

Maybe you are looking for