Group by with date range.

Hi,
I am looking for effective usage of Group by against date range.
I have a transaction table as below.
Date            customer_no      amount_paid
01-Dec-13     001                  500
02-Dec-13     001                  360
09-Dec-13     001                  200
02-Nov-13     001                  360
09-Nov-13     001                  200
02-Nov-13     001                  360
09-Oct-13     001                  200
02-Oct-13     001                  360
09-Oct-13     001                  200
02-Sep-13     001                  360
09-Sep-13     001                  200
............... etc.
I would like to see sum(amount_paid) by past date ranges 1-30 days, 31-60 days, 61-90 days.
Below are expected results.
Customer          Duration       amount_paid
001                    1-30             980
001                    31-60           450
001                    61-90          1200
002                    1-30             300
002                    31-60           490
002                    61-90           320
003                    1-30             450
......................etc.
I have to group by customer no and date range (1-30, 31-60, 61-90..etc).
Can someone help me getting query for this.
Thanks...
Sreeram.

SQL> with t
  2  as
  3  (
  4  select to_date('01-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 500 amount_paid from dual
  5    union all
  6  select to_date('02-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
  7    union all
  8  select to_date('09-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
  9    union all
10  select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
11    union all
12  select to_date('09-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
13    union all
14  select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
15    union all
16  select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
17    union all
18  select to_date('02-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
19    union all
20  select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
21    union all
22  select to_date('02-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
23    union all
24  select to_date('09-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
25  )
26  select customer_no
27       , ((grp_val - 1) * 30) + 1 start_val
28       , grp_val * 30 end_val
29       , sum(amount_paid) amount_paid
30    from (
31            select dt
32                 , customer_no
33                 , amount_paid
34                 , ceil(sum(dt_interval) over(partition by customer_no order by dt)/30) grp_val
35              from (
36                      select dt
37                           , customer_no
38                           , amount_paid
39                           , nvl(dt - lag(dt) over(partition by customer_no order by dt), 1) dt_interval
40                        from t
41                   )
42         )
43   group
44      by customer_no
45       , grp_val
46   order
47      by grp_val;
CUS  START_VAL    END_VAL AMOUNT_PAID
001          1         30         560
001         31         60         760
001         61         90         920
001         91        120        1060
SQL>

Similar Messages

  • Check a number range with date range.

    i have table test which is having column
    Start Range
    End Range
    Start Date
    End date
    how can i check start range and end range does not exists b/w existing record also with date range of this record.
    end date can be blank also.

    990690 wrote:
    i have table test which is having column
    Start Range
    End Range
    Start Date
    End date
    how can i check start range and end range does not exists b/w existing record also with date range of this record.
    end date can be blank also.Your question makes absolutely no sense whatsoever. We could make guesses, but then we may be wrong in our guesses.
    Please provide sufficient details for people to be able to help you. Read the FAQ: {message:id=9360002}

  • MDX Filter with date range

    Hi,
    my requirement is to create a calculated member to calculate Total unique customers who has sales > 0 within the date range.
    Below mdx works normally with single date
    DistinctCount(FILTER([Customer_Sales].[Outlet ID].[Outlet ID].members,
    ([Measures].[distribution],
    [Date].[CalendarWeek].CurrentMember
    )=1))
    I'm looking for something like below with date range,
    DistinctCount(FILTER([Customer_Sales].[Outlet ID].[Outlet ID].members,
    ([Measures].[distribution],
    WTD([Date].[CalendarWeek].CurrentMember
    ))=1))
    Above MDX fails with the error: String of numeric expression expected, Tuple set expression was used.
    Appreciate your immediate response.
    Thanks in advance

    Hi Chandima,
    Thanks for the response.
    I tried your code, it works but the results are not correct.  As per manual calculations, there are 28 unique customers who has positive sales on Week to date (2014-11-03), but result shows only 19.
    For the first day of week (2014-11-01), there are 9 unique customers, which is correct. But for the following days it is not giving correct result.
    Further, performance of this approach is very poor
    Thanks,

  • Oracle 10g - Problem with Date Ranges using Between

    I am keeping track of patients who have not been contacted during a date range. if a nurse adds an event or note and the note is type 1,3,4 then this is a contact. The following works but if the event or note was made on the same day as the report is run, the current contact is not printed. Any help to improve the query and identify the problem would be appreciated. Also, if you add '1' to' n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)' so it is ' n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE) + 1'. It works. What is wrong?
    SELECT upper(symptom_text),
      COUNT(UNIQUE(c.patient_id)) ,
      COUNT(UNIQUE(
      CASE
        WHEN e.eventdate BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)
        OR (n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)
        AND n.note_type_id                                             IN (1,3,4))
        THEN c.patient_id
        ELSE 0
      END)) - 1
    FROM patient c,
      cust_info ci,
      event e,
      note n
    WHERE c.physician_id = 74
    AND c.patient_id      = ci.patient_id
    AND ci.info_type_id    = 32
    AND ci.symptom_text      IS NOT NULL
    AND c.patient_id      = e.patient_id(+)
    AND c.patient_id      = n.pk_id(+)
    AND n.table_name(+)    = 'patient'
    GROUP BY upper(symptom_text)
    ORDER BY DECODE(upper(symptom_text), 'A+', 1, 'A', 2, 'B', 3, 'C', 4, 'D', 5, 99)I suspect the end date is not inclusive. Fields are Date data types. Thanks for any help.

    Hi,
    achtung wrote:
    Understood. Frank was correct. Do you mean about the dates? Is that issue solved now?
    It would help a lot if you posted some sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Simplify as much as possible. For example, if everything involving the e and n tables is working correctly, forget about them for now. Post a question that only invloves the c and ci tables.
    But, additionally, when a record in the cust_info doesn't exist my contact count is inaccurate. How can you explain this conceptually. I understand the query path is checking for this record due to the predicate. Perhaps the query should be redesigned. Thanks for your input!Again, you can see the results, and you know what they should be. Nobody else has that information. Please post some sample data and the results you want from that data.
    In your earlier message you said
    Could there be a problem if a record does not exist in the ci table?The condition:
    AND ci.symptom_text IS NOT NULL
    filters for this right? Maybe this could be part of the problem. why I'm not seeing records when a note is added to a patient's doc. How would this be technically be explained? You're doing a inner join between c and ci:
        AND c.patient_id      = ci.patient_id
        AND ci.info_type_id   = 32
        AND ci.symptom_text   IS NOT NULL ...Rows from c will be included only if there is a row in ci with the same patiend_id: even more, that matching row in ci must also have info_type_id=32 in a non-NULL symptom_text, otherwise, the row from c will be ignored.
    If you want rows from c to be included even if there is no matching row in ci, then do an outer join, like you're already doing with the e and n tables:
      WHERE c.physician_id = 74
        AND c.patient_id         = ci.patient_id (+)
        AND ci.info_type_id (+)  = 32
        AND ci.symptom_text (+)  IS NOT NULL
        AND c.patient_id         = e.patient_id(+)
        AND c.patient_id         = n.pk_id(+)
        AND n.table_name(+)      = 'patient'

  • Grouping totals by date ranges

    Hi All,
    I have an ASP.NET application, in which I have to get totals from a table using different criteria, which I do like this:
    SELECT DISTINCT
    SUM(CASE WHEN MYCONDITION1 THEN 1 ELSE 0 END) AS TOTAL1,
    SUM(CASE WHEN MYCONDITION2 THEN 1 ELSE 0 END) AS TOTAL2
    FROM TABLE1, TABLE2
    WHERE COMMON_CONDITION1 AND COMMON_CONDITION2
    AND BETWEEN DATE1 AND DATE2;
    This works fine and I get the intended result.
    Now, I have to repeat this for every week for the last 12 months, excluding holidays period. So, I generate a set of date ranges which will be used in the queries. So, I repeat the above sql statement for all the date ranges, which is a lengthy process.
    I have to get the totals for every week. For example from 26-Sep-2010 to 02-Oct-2010, 19-Sep-2010 to 25-Sep-2010, 12-Sep-2010 to 18-Sep-2010, etc.. How should I put those ranges in the group by and select statement, because, I don't have them in a table.
    How can I do that in a single shot and get all totals for each date range. Please help me with sql.
    Thank you.
    Edited by: 800729 on Oct 7, 2010 4:33 AM

    Hi,
    Welcome to the forum!
    800729 wrote:
    Hi All,
    I have an ASP.NET application, in which I have to get totals from a table using different criteria, which I do like this:
    SELECT DISTINCT
    SUM(CASE WHEN MYCONDITION1 THEN 1 ELSE 0 END) AS TOTAL1,
    SUM(CASE WHEN MYCONDITION2 THEN 1 ELSE 0 END) AS TOTAL2
    FROM TABLE1, TABLE2
    WHERE COMMON_CONDITION1 AND COMMON_CONDITION2
    AND BETWEEN DATE1 AND DATE2;Does that really work? Don't you have to do something like
    AND     date_column  BETWEEN DATE1 AND DATE2Post actual code, simplified if necessary, but still something that you can run.
    This works fine and I get the intended result.
    Now, I have to repeat this for every week for the last 12 months, excluding holidays period. So, I generate a set of date ranges which will be used in the queries. So, I repeat the above sql statement for all the date ranges, which is a lengthy process.
    I have to get the totals for every week. For example from 26-Sep-2010 to 02-Oct-2010, 19-Sep-2010 to 25-Sep-2010, 12-Sep-2010 to 18-Sep-2010, etc.. How should I put those ranges in the group by and select statement, because, I don't have them in a table.Are you saying your current query produces 1 row, but you want something that has 53 rows, one for each week in the last year?
    If so, add a "GROUP BY x" clause, as Sabnkar suggested, where x is a distinct value for each week.
    You will probably *not" want to use TO_CHAR (date_column, 'WW'), especially if all of the output is not in the same calendar year.
    If your weeks always begin on Sunday, then TRUNC (date_column, 'D') would be a better GROUP BY exptression, but it depeneds on your NLS settings.
    GROUP BY TRUNC (date_column + 1, 'IW') - 1 will do the same thing, regardless of your NLS settings.
    You may not need a table tha has one row per week, but if you do, Sauhik showed you how to generate a result set that will work just as well.
    How can I do that in a single shot and get all totals for each date range. Please help me with sql.I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data, as Saubhik requested.
    Include examples of holidays: it's very unclear how you want to handle them. What is a "holday period"? How do you know if a given date is in one or not?
    Simplify the problem as much as possible. For example, post a problem that gets the last 3 weeks, instead of the last 53 weeks. Anyone who suggests a solution will show you how to change it for 53 weeks, if necessary.

  • Stock report with date range

    Hi Experts.
    Material stock report (unrestricted, blocked, quality) with in date range.
    getting information in T-CODE:  MB52 but not in date range.
    In mard table i did't find the date for unrestricted, blocked and quality.
    from where can i get that information and how should i link all
    Need a psudo code for it.
    If any one worked on this kind of object plz send me the code.
    Points assured..
    Regards..
    Ravi Reddy.

    Hi
    Check this sample code hope it will helpfull for you
    *DATA: ED TYPE F.
    DATA : ED(15) TYPE N .
    TABLES: EKKO, EKBE, EKPO, KONH , KONV ,LFA1 ,ESLL.
    TYPE-POOLS: SLIS.
    DATA: val1  like konh-vakey.
    Data:GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
         G_REPID LIKE SY-REPID,
         G_GRID_TITLE TYPE LVC_TITLE.
    Data:G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
    DATA:G_TABNAME TYPE SLIS_TABNAME VALUE 'ITAB1',
    G_SAVE .
    DATA:GS_VARIANT LIKE DISVARIANT.
    DATA:LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA:GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
         G_SAVE = 'A'.
    DATA: BEGIN OF ITAB OCCURS 10,
              EBELN LIKE EKKO-EBELN,
    *          LIFNR  like p_vendor,
              LIFNR LIKE EKKO-LIFNR,
              NAME1 LIKE LFA1-NAME1,
              NAME2 LIKE LFA1-NAME2,
    *          EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
              VGABE LIKE EKBE-VGABE,
              GJAHR LIKE EKBE-GJAHR,
              KNUMV LIKE EKKO-KNUMV,
              EKORG LIKE EKKO-EKORG,
              BEDAT LIKE EKKO-BEDAT,
    *          VAKEY LIKE KONH-VAKEY,
         END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 10,
              NAME1 LIKE LFA1-NAME1,
              NAME2 LIKE LFA1-NAME2,
              EBELN LIKE EKPO-EBELN,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKPO-EBELP,
    *          EBELP LIKE EKBE-EBELP,
              KNUMH LIKE KONH-KNUMH,
              BELNR LIKE EKBE-BELNR,
              MATNR LIKE EKPO-MATNR,
              TXZ01 LIKE EKPO-TXZ01,
              PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
              EXTROW LIKE ESLL-EXTROW,
              SRVPOS LIKE ESLL-SRVPOS,
              KTEXT1 LIKE ESLL-KTEXT1,
              KOSTL LIKE EKKN-KOSTL,
              NETPR LIKE EKPO-NETPR,
              NETWR LIKE EKPO-NETWR,
              ED1  TYPE p decimals 2,
              KBETR2 LIKE KONV-KBETR,
              KBETR1 LIKE KONV-KBETR,
              KBETR LIKE KONV-KBETR,
    *          KBETR3 LIKE KONV-KBETR,
              KWERT LIKE KONV-KWERT, " THIS IS FOR FREIGHT
              KWERT1 LIKE KONV-KWERT, " THIS IS FOR PBXX OR PB00
              KWERT2 LIKE KONV-KWERT, " THIS FOR OTHER CONDITION
              MENGE LIKE EKPO-MENGE,
    *          TOTAL(15) type  .
              TOTAL TYPE p decimals 2,
              VAKEY LIKE KONH-VAKEY,
              WERKS LIKE EKPO-WERKS,
              MWSKZ LIKE EKPO-MWSKZ,
              PACKNO LIKE EKPO-PACKNO,
              KNUMV LIKE KONV-KNUMV,
              SUB_PACKNO LIKE ESLL-SUB_PACKNO,
              GJAHR LIKE RSEG-GJAHR,
          END OF ITAB1.
    DATA: BEGIN OF ITAB2 OCCURS 10,
             EBELN LIKE EKKN-EBELN,
             EBELP LIKE EKKN-EBELP,
             PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
             KOSTL      LIKE EKKN-KOSTL,
          END OF ITAB2.
    data: begin of itab3 occurs 10,
            KNUMH LIKE KONH-KNUMH,
            KSCHL LIKE KONH-KSCHL,
         end of itab3.
    data: begin of itab4 occurs 10,
            KBETR LIKE KONP-KBETR,
          end of itab4.
    data: begin of itab5 occurs 10,
            KPOSN LIKE KONV-KPOSN,
            KNUMV LIKE KONV-KNUMV,
            KSCHL LIKE KONV-KSCHL,
            KBETR LIKE KONV-KBETR,
            KWERT LIKE KONV-KWERT, " THIS IS FOR FREIGHT
    *          KAWRT LIKE KONV-KAWRT,
         end of itab5.
    DATA: BEGIN OF ITAB6 OCCURS 10,
    *          PACKNO LIKE EKPO-PACKNO,
              SUB_PACKNO LIKE ESLL-SUB_PACKNO,
            END OF ITAB6.
    DATA: BEGIN OF ITAB7 OCCURS 10,
           BELNR LIKE RSEG-BELNR,
           GJAHR LIKE RSEG-GJAHR,
    END OF ITAB7.
    DATA: BEGIN OF ITAB8 OCCURS 10,
           SUB_PACKNO LIKE ESLL-SUB_PACKNO,
           SRVPOS LIKE ESLL-SRVPOS,
           EXTROW LIKE ESLL-EXTROW,
           KTEXT1 LIKE ESLL-KTEXT1,
    END OF ITAB8.
    *selection-screen
    *SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *SELECTION-SCREEN SKIP 2.
    *SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN COMMENT 25(23) text-002.
    **SELECT-OPTIONS: s_lifnr FOR ekko-lifnr.
    *PARAMETERS:p_lifnr LIKE ekko-lifnr obligatory.
    *SELECTION-SCREEN END OF LINE.
    *SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM get_data.
    *  PERFORM field_catalog.
    *  PERFORM display_data.
    END-OF-SELECTION.
    **&      Form  display_data
    **       text
    *FORM display_data.
    *data: new(15) TYPE N.
    *  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    *    EXPORTING
    *      i_callback_program = sy-repid
    *      it_fieldcat        = int_cat[]
    *    TABLES
    *      t_outtab           = int_out
    *    EXCEPTIONS
    *      program_error      = 1
    *      OTHERS             = 2.
    *ENDFORM.                    "display_data
    PERFORM GET_DATA.
    PERFORM CALL_ALV_GRID.
    FORM CALL_ALV_GRID.
    PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM                = G_repid
          I_CALLBACK_USER_COMMAND           = G_USER_COMMAND
          I_GRID_TITLE                      = G_GRID_TITLE
          IT_FIELDCAT                       = GT_FIELDCAT[]
          I_DEFAULT                         = 'X'
          I_SAVE                            =  G_SAVE
          IS_VARIANT                        =  Gs_VARIANT
        TABLES
          T_OUTTAB                          = ITAB1.
    ENDFORM.
    FORM FIELDCAT_INIT
           USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-seltext_l     = 'Vendo No'.
      LS_FIELDCAT-FIELDNAME     = 'LIFNR'.
      LS_FIELDCAT-REF_FIELDNAME = 'LIFNR'.
      LS_FIELDCAT-REF_TABNAME   = 'EKKO'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L  = 'Vendor Name'.
      LS_FIELDCAT-FIELDNAME     = 'NAME1'.
      LS_FIELDCAT-REF_FIELDNAME = 'NAME1'.
      LS_FIELDCAT-REF_TABNAME   = 'LFA1'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    * CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-FIELDNAME     = 'NAME2'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'NAME2'.
    *  LS_FIELDCAT-REF_TABNAME   = 'LFA1'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-seltext_l   = 'Purchase Document No'.
      LS_FIELDCAT-FIELDNAME     = 'EBELN'.
      LS_FIELDCAT-REF_FIELDNAME = 'EBELN'.
      LS_FIELDCAT-REF_TABNAME   = 'EKKO'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *  CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-FIELDNAME     = 'VGABE'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'VGABE'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKBE'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L     = 'Item No'.
      LS_FIELDCAT-FIELDNAME     = 'EBELP'.
      LS_FIELDCAT-REF_FIELDNAME = 'EBELP'.
      LS_FIELDCAT-REF_TABNAME   = 'EKPO'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *  CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-FIELDNAME     = 'BELNR'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'BELNR'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKBE'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L     = 'Document Con'.
      LS_FIELDCAT-FIELDNAME     = 'KNUMH'.
      LS_FIELDCAT-REF_FIELDNAME = 'KNUMH'.
      LS_FIELDCAT-REF_TABNAME   = 'KONH'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L = 'Service/Material No'.
    *  LS_FIELDCAT-FIELDNAME     = 'MATNR'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'MATNR'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKPO'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L = 'Service / Material description' .
    *  LS_FIELDCAT-FIELDNAME     = 'TXZ01'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'TXZ01'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKPO'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L =  'WBS Element' .
    *  LS_FIELDCAT-FIELDNAME     = 'PS_PSP_PNR'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'PS_PSP_PNR'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKKN'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L =  'Serial Number' .
    *  LS_FIELDCAT-FIELDNAME     = 'EXTROW'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'PACKNO'.
    *  LS_FIELDCAT-REF_TABNAME   = 'ESLL'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *  CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L =  'Service Number' .
    *  LS_FIELDCAT-FIELDNAME     = 'SRVPOS'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'SRVPOS'.
    *  LS_FIELDCAT-REF_TABNAME   = 'ESLL'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L =  'Dscription' .
    *  LS_FIELDCAT-FIELDNAME     = 'KTEXT1'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'KTEXT1'.
    *  LS_FIELDCAT-REF_TABNAME   = 'ESLL'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *   CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *    LS_FIELDCAT-SELTEXT_L = 'Cost Center'.
    *  LS_FIELDCAT-FIELDNAME     = 'KOSTL'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'KOSTL'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKKN'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-FIELDNAME     = 'NETWR'.
      LS_FIELDCAT-FIELDNAME     = 'NETPR'.
      LS_FIELDCAT-reptext_ddic = 'Basic'.
    *  LS_FIELDCAT-SELTEXT_L    = 'Basic'.
       LS_FIELDCAT-REF_FIELDNAME = 'NETPR'.
      LS_FIELDCAT-REF_TABNAME   = 'EKPO'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-FIELDNAME     = 'NETWR'.
    *  LS_FIELDCAT-FIELDNAME     = 'NETPR'.
    *  LS_FIELDCAT-reptext_ddic = ''.
    *  LS_FIELDCAT-SELTEXT_L    = 'Basic'.
       LS_FIELDCAT-REF_FIELDNAME = 'NETWR'.
      LS_FIELDCAT-REF_TABNAME   = 'EKPO'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
        LS_FIELDCAT-SELTEXT_L = 'Excise'.
      LS_FIELDCAT-FIELDNAME     = 'ED1'.
      LS_FIELDCAT-REF_FIELDNAME = 'ED1'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKKN'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
       CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L = 'Insurance'.
      LS_FIELDCAT-FIELDNAME     = 'KBETR2'.
        LS_FIELDCAT-REF_FIELDNAME = 'KBETR'.
      LS_FIELDCAT-REF_TABNAME   = 'KONV'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L     = 'Frieght'.
      LS_FIELDCAT-FIELDNAME     = 'KWERT'.
      LS_FIELDCAT-REF_FIELDNAME = 'KWERT'.
      LS_FIELDCAT-REF_TABNAME   = 'KONV'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    * CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L     = '' .
    *  LS_FIELDCAT-FIELDNAME     = 'KBETR1'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'KBETR'.
    *  LS_FIELDCAT-REF_TABNAME   = 'KONV'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    *CLEAR LS_FIELDCAT.
    *  LS_FIELDCAT-TABNAME       = G_TABNAME.
    *  LS_FIELDCAT-SELTEXT_L     = 'PBXX'.
    *  LS_FIELDCAT-FIELDNAME     = 'KWERT1'.
    *  LS_FIELDCAT-REF_FIELDNAME = 'KWERT'.
    *  LS_FIELDCAT-REF_TABNAME   = 'KONV'.
    *  APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L     = 'VAT/ST '.
      LS_FIELDCAT-FIELDNAME     = 'KBETR'.
      LS_FIELDCAT-REF_FIELDNAME = "KBETR".
      LS_FIELDCAT-REF_TABNAME   = 'KONV'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L     = 'OTHER '.
      LS_FIELDCAT-FIELDNAME     = 'KWERT2'.
      LS_FIELDCAT-REF_FIELDNAME = "KWERT".
      LS_FIELDCAT-REF_TABNAME   = 'KONV'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-TABNAME       = G_TABNAME.
      LS_FIELDCAT-SELTEXT_L = 'TOTAL'.
      LS_FIELDCAT-FIELDNAME     = 'TOTAL'.
      LS_FIELDCAT-REF_FIELDNAME = 'TOTAL'.
    *  LS_FIELDCAT-REF_TABNAME   = 'EKKN'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
       ENDFORM.                    " FIELDCAT_INIT
       FORM GET_DATA.
       SELECT  A~EBELN A~LIFNR  A~EKORG A~KNUMV B~VGABE  B~GJAHR B~BELNR
               L~NAME1 L~NAME2
            FROM  EKKO AS A
                          INNER JOIN EKBE  AS B ON  B~EBELN = A~EBELN
                          INNER JOIN LFA1 AS L ON L~LIFNR = A~LIFNR
                          INTO  CORRESPONDING
                          FIELDS OF TABLE ITAB.
    *                      WHERE B~VGABE = '2'.
    SELECT EKPO~EBELN EKPO~EBELP EKPO~MATNR EKPO~TXZ01 EKPO~WERKS
              EKPO~NETWR EKPO~MENGE EKPO~MWSKZ  EKPO~NETPR EKPO~PACKNO
              FROM EKPO
                        INTO CORRESPONDING FIELDS OF TABLE ITAB1
                        FOR ALL ENTRIES IN ITAB
                        WHERE EKPO~EBELN = ITAB-EBELN and
                              EKPO~BUKRS = 'company code'.
       SELECT EKKN~EBELN EKKN~EBELP EKKN~KOSTL EKKN~PS_PSP_PNR
          FROM EKKN
                   INTO CORRESPONDING FIELDS OF TABLE ITAB2
                   FOR ALL ENTRIES IN ITAB1
                   WHERE EKKN~EBELN = ITAB1-EBELN  AND
                         EKKN~EBELP = ITAB1-EBELP.
       SELECT KONV~KNUMV KONV~KSCHL KONV~KBETR KONV~KWERT KONV~KWERT
                  KONV~KPOSN
          FROM KONV
              INTO CORRESPONDING FIELDS OF TABLE ITAB5
              WHERE KONV~KNUMV =   ITAB1-KNUMV AND
                    KONV~KPOSN = ITAB1-EBELP.
    *    SELECT LFA1~NAME1 LFA1~NAME2 FROM LFA1
    *    INTO CORRESPONDING FIELDS OF TABLE ITAB1
    *    WHERE  LFA1~LIFNR = ITAB-LIFNR.
    *  SELECT ESLL~SUB_PACKNO ESLL~SRVPOS
    *           ESLL~EXTROW  ESLL~KTEXT1 FROM ESLL
    *       INTO CORRESPONDING FIELDS OF TABLE ITAB6
    *       FOR ALL ENTRIES IN ITAB1
    *       WHERE ESLL~PACKNO = ITAB1-PACKNO .
    **         SELECT ESLL~SUB_PACKNO FROM ESLL
    **       INTO CORRESPONDING FIELDS OF TABLE ITAB6
    **       FOR ALL ENTRIES IN ITAB1
    **       WHERE ESLL~PACKNO = ITAB1-PACKNO.
    *        SELECT ESLL~SUB_PACKNO ESLL~SRVPOS
    *           ESLL~EXTROW  ESLL~KTEXT1 FROM ESLL
    *       INTO CORRESPONDING FIELDS OF TABLE ITAB8
    *       FOR ALL ENTRIES IN ITAB6
    *       WHERE ESLL~PACKNO = ITAB6-SUB_PACKNO .
    * SELECT RSEG~BELNR RSEG~GJAHR FROM RSEG
    *        INTO CORRESPONDING FIELDS OF TABLE  ITAB7
    *        FOR ALL ENTRIES IN ITAB
    *        WHERE RSEG~BELNR = ITAB-BELNR AND
    *              RSEG~GJAHR = ITAB-GJAHR.
    *LOOP AT ITAB1.
    LOOP AT ITAB.
                  READ TABLE ITAB1 WITH KEY EBELN = ITAB-EBELN.
    *         IF ITAB1-EBELN = ITAB-EBELN.
                    IF sy-subrc eq 0.
    *                          ITAB1-EBELN = ITAB-EBELN.
                              ITAB1-LIFNR = ITAB-LIFNR.
    *                          ITAB1-EBELP = ITAB-EBELP.
                              ITAB1-BELNR = ITAB-BELNR.
                              ITAB1-KNUMV = ITAB-KNUMV.
                              ITAB1-NAME1  = ITAB-NAME1.
                              ITAB-NAME2 = ITAB-NAME2.
                              ITAB1-GJAHR = ITAB-GJAHR.
                    modify itab1 index   sy-tabix.
            ENDIF.
    ENDLOOP.
    *LOOP AT ITAB2.
    *         READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN.
    *          IF sy-subrc eq 0.
    *              ITAB1-EBELN = ITAB2-EBELN.
    *              ITAB1-PS_PSP_PNR = ITAB2-PS_PSP_PNR.
    *              ITAB1-KOSTL = ITAB2-KOSTL.
    *               modify itab1 transporting ps_psp_pnr kostl
    *               where ebeln = Itab2-ebeln AND EBELP = ITAB2-EBELP.
    *          ENDIF.
    *ENDLOOP.
    LOOP AT ITAB1.
    **ON CHANGE OF   ITAB1-ebeln or itab1-ebelp.
    *     concatenate itab1-werks itab1-lifnr itab1-matnr
    *         into val1.
    *   MOVE VAL1 TO ITAB1-VAKEY.
    *   MODIFY ITAB1.
    *    SELECT KONH~KNUMH KONH~KSCHL FROM KONH
    *        INTO  CORRESPONDING FIELDS OF TABLE ITAB3
    *        FOR ALL ENTRIES IN ITAB1
    *        WHERE KONH~VAKEY = ITAB1-VAKEY.
    **endon.
    **        sort Itab3 by kschl descending.
    **        Select konp-kbetr  from konp into itab4 where
    **        KONP~KNUMH = ITAB3-KNUMH AND KONP~KSCHL = ITAB3-KSCHL.
    **ON CHANGE OF  ITAB1-ebelp.
    **LOOP AT ITAB3
    **  ON CHANGE OF  ITAB1-ebelp.
    *              itab1-knumh = itab3-knumh.
    **              SELECT  KONP~KBETR FROM KONP INTO CORRESPONDING FIELDS
    **              OF  TABLE  ITAB4
    **              FOR ALL ENTRIES IN ITAB3   WHERE
    **              KONP~KNUMH = ITAB3-KNUMH AND KONP~KSCHL = ITAB3-KSCHL .
    **              IF ITAB3-KSCHL = 'JMOP' .
    **               ED = ITAB4-KBETR / 1000 * ITAB1-NETWR .
    **              ENDIF.
    **             IF ITAB3-KSCHL = 'JEC1'.
    **              Itab1-ed1 = ITAB4-KBETR / 1000 * ED.
    **              ADD ED TO ITAB1-ED1.
    **             modify  ITAB1 transporting ed1.
    **             ENDIF.
    *              IF ITAB3-KSCHL = 'JMOP' .
    *               ED = 16 / 100 * ITAB1-NETWR .
    *              ENDIF.
    *             IF ITAB3-KSCHL = 'JEC1'.
    *              Itab1-ed1 = 2 / 100 * ED.
    *              ADD ED TO ITAB1-ED1.
    *             modify  ITAB1 transporting ed1.
    *             ENDIF.
    **        ENDLOOP.
    **endon.
    modify  ITAB1.
    *endon.
      LOOP AT ITAB5.
         IF ITAB5-KSCHL = 'NAVS' OR ITAB5-KSCHL = 'NAVM'.
                ITAB1-KBETR = ITAB5-KBETR.
                 modify  ITAB1 transporting KBETR
                 where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP .
               ELSEIF ITAB5-KSCHL = 'FRA1' OR ITAB5-KSCHL = 'FRC1' OR
                    ITAB5-KSCHL = 'FRB1'.
                       ITAB1-KWERT = ITAB5-KWERT .
                       modify  ITAB1 transporting KWERT
                       where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    *               IF ITAB5-KSCHL = 'FRA1'.
    *                    ITAB1-KBETR1 = ITAB5-KBETR / 1000 * ITAB1-NETWR .
    *                   modify  ITAB1 transporting KBETR1
    *                   where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    *                 ELSEIF ITAB5-KSCHL = 'FRC1' .
    *                   ITAB1-KBETR1 = ITAB5-KBETR * ITAB1-MENGE .
    *                   modify  ITAB1 transporting KBETR1
    *                   where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    *                 ELSEIF ITAB5-KSCHL = 'FRB1' .
    *                    ITAB1-KBETR1 = ITAB5-KBETR .
    *                   modify  ITAB1 transporting KBETR1
    *                   where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    *              ENDIF.
    *           **THIS  CODE IS FOR iNSURANCE  CONDITION
               ELSEIF ITAB5-KSCHL = 'ZGIN' OR ITAB5-KSCHL = 'ZIN2'.
                       ITAB1-KBETR2 = ITAB5-KBETR.
                       modify  ITAB1 transporting KBETR2
                       where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    *           **THIS  CODE IS FOR PBXX OR PB00  CONDITION
    *          ELSEIF ITAB5-KSCHL = 'PBXX' OR ITAB5-KSCHL = 'PB00'.
    *                   ITAB1-KWERT1 = ITAB5-KWERT1.
    *                   modify  ITAB1 transporting KWERT1
    *                   where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
    **          ELSEIF ITAB5-KSCHL = 'JOCM' OR ITAB5-KSCHL = 'RA00' OR
    **                 ITAB5-KSCHL = 'RA01' OR ITAB5-KSCHL = 'RB00' OR
    **                 ITAB5-KSCHL = 'RC00' OR
    **THIS  CODE IS FOR OTHER CONDITION
               ELSEIF ITAB5-KSCHL = 'RL01' OR ITAB5-KSCHL = 'ZA00' OR
                     ITAB5-KSCHL = 'ZA01' OR ITAB5-KSCHL = 'ZAE1' OR
                     ITAB5-KSCHL = 'ZAED' OR
                     ITAB5-KSCHL = 'ZAFR' OR ITAB5-KSCHL = 'ZB00' OR
                     ITAB5-KSCHL = 'ZBCH' OR ITAB5-KSCHL = 'ZBED' OR
                     ITAB5-KSCHL = 'ZC00' OR
                     ITAB5-KSCHL = 'ZCEX' OR ITAB5-KSCHL = 'ZCIF' OR
                     ITAB5-KSCHL = 'ZHC1' OR ITAB5-KSCHL = 'ZHC2' OR
                     ITAB5-KSCHL = 'ZHCT' OR
                     ITAB5-KSCHL = 'ZHCV' OR ITAB5-KSCHL = 'ZJOC' OR
                     ITAB5-KSCHL = 'ZOTH' OR ITAB5-KSCHL = 'ZOTP' OR
                     ITAB5-KSCHL = 'ZOTT' OR
                     ITAB5-KSCHL = 'ZPK1' OR ITAB5-KSCHL = 'ZPK2' OR
                     ITAB5-KSCHL = 'ZPK3' OR ITAB5-KSCHL = 'ZPK4' OR
                     ITAB5-KSCHL = 'ZRPO' OR
                     ITAB5-KSCHL = 'ZSE1' OR ITAB5-KSCHL = 'ZSED' OR
                     ITAB5-KSCHL = 'ZSFR' OR ITAB5-KSCHL = 'ZSTX' OR
                     ITAB5-KSCHL = 'ZTPI' OR
                     ITAB5-KSCHL = 'ZTPV' OR ITAB5-KSCHL = 'ZTRD' OR
                     ITAB5-KSCHL = 'ZWCT'.
                       ITAB1-KWERT2 = ITAB5-KWERT.
                       modify  ITAB1 transporting KWERT2
                       where  KNUMV =  ITAB1-KNUMV AND EBELP = ITAB1-EBELP
              modify itab1.
           ENDIF.
    ENDLOOP .
    ITAB1-TOTAL = ITAB1-NETWR + ITAB1-KWERT2 + ITAB1-KWERT + ITAB1-KBETR.
    *              ITAB1-TOTAL = ITAB1-NETWR + ITAB1-ED1 + ITAB1-KBETR2 +
    *                     ITAB1-KBETR1 + ITAB1-KBETR + ITAB1-KWERT   .
                     modify  ITAB1 transporting TOTAL.
    LOOP AT ITAB6.
              ITAB1-SUB_PACKNO = ITAB6-SUB_PACKNO.
    *           modify  ITAB1.
    ENDLOOP.
    LOOP AT ITAB7.
            ITAB1-BELNR = ITAB7-BELNR.
            ITAB1-GJAHR = ITAB7-GJAHR.
      ENDLOOP.
    LOOP AT ITAB8.
              ITAB1-SUB_PACKNO = ITAB8-SUB_PACKNO.
              ITAB1-SRVPOS  = ITAB8-SRVPOS.
              ITAB1-EXTROW = ITAB8-EXTROW.
              ITAB1-KTEXT1 = ITAB8-KTEXT1.
              modify  ITAB1.
    ENDLOOP.
    * SELECT ESLL~PACKNO ESLL~SUB_PACKNO ESLL~SRVPOS ESLL~KTEXT1
    *          FROM ESLL
    *          INTO CORRESPONDING FIELDS OF TABLE ITAB6
    *          WHERE ESLL~PACKNO = ITAB1-PACKNO.
    ** delete  adjacent  duplicates  from itab1 comparing EBELN .
    modify  ITAB1.
    endloop.
    sort Itab1 by EBELN Ascending.
            SELECT KONV~KBETR FROM KONV
            INTO ITAB1-KBETR
            WHERE KONV~KSCHL =  'NAVS' OR KONV~KSCHL = 'NAVM'.
            ENDSELECT.
            ITAB1-KBETR = ITAB5-KBETR.
    *ENDLOOP.
    *ENDLOOP.
    *ENDLOOP.
    ENDFORM.
    Reward all helpfull answers
    Regards
    Pavan

  • Neen help with date range searches for Table Sources

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 24-MAR-07, 22-SEP-), 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Need help with date range searches for Table Sources in SES

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks very much, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Cascading Pick List with date range as first,  second pick list is dynamic

    Specifically, how is this accomplished?
    It does not seem possible to make first pick list static. If allowed this would be perfect.
    The system seems to only allow the first parameter to be dynamic if the second parameter is dynamic. No range seems to be available for date when second parameter is  dynamic.

    Consider a 3rd-party tool as a solution (for a list of such tools, see http://www.kenhamady.com/bookmarks.html).
    There is at least one Crystal report viewer with its own special implementation of dynamic & cascading parameters.  It would allow you to use any type of parameter within the cascade.  However, you will need to create a separate rpt to implement each dynamic parameter.  So in your case, you will have one main report, using a dynamic parameter that's implemented as a separate rpt, which has a date range parameter. 
    Cheers,
    - ido

  • Help with Date Range

    Hi,
    I have an Oracle form which allows users to enter :start_date_active(mandatory) and :end_date_active (can be null).
    I need to check in form using SQL if there already exists a record for this date range or if there is any overlapping date ranges for the value entered and disallow user from entering that.
    I have my query as follows:
    SELECT (1)
    FROM <table> xsv
    WHERE 1=1
    AND ( (:START_DATE_ACTIVE >= xsv.start_date_active) AND
    (:START_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))
    OR
         (:END_DATE_ACTIVE >= xsv.start_date_active) AND
    (:END_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))
    But, this incorrectly allows me to enter over lapping date ranges when the :end_date_active is null.
    It should work as follows :
    eg.
    start_date_active end_date_active
    01-Apr-2009 allowed
    01-Mar-2009 10-Mar-2009 allowed
    01-feb-2009 Not allowed, as it overlaps with 1st record
    10-feb-2009 05-Mar-2009 Not allowed, as it overlaps with 2nd record
    05-Mar-2009 20-mar-2009 Not allowed, as it overlaps with 2nd record
    and so on.
    How do I modify my query to deal with null end dates ?
    Many Thanks
    Shankar

    Hi, Shankar,
    Whenever you have a question, it helps to post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (You posted this. It would be better if it were formatted.)
    (4) Your best attempt so far (formatted) (You posted this, but since it's unformated, it's very hard to read.)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    Formatted tabular output is okay for (3). Type these 6 characters
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    Use different names for the parameters and the columns. For example, if the column is called start_date_active, call the corresponding parameter :p_start_date_active. It will help to keep them straight.
    In this statement, if the column end_date_active IS NULL, you're treating it as an impossibly late date:
    (:END_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))That's good. (You should really use TO_DATE ('31-DEC-4712', 'DD-MON-YYYY'), though.)
    If it's possible for the parameter :end_date_active to be NULL, you should use NVL in the same way, to equate it with some appropriate date.
    The correct way to see if the range a to b (a <= b) overlaps with x to y (x <= y) is:
    WHERE   b >= x
    AND     a <= yIf you want an expression that's TRUE when they do not overlap, then say
    WHERE   NOT (    b >= x
                AND  a <= y
                )or, equivalently,
    WHERE   b < x
    OR      a > y

  • Report with date range where the daily customer receipt profit centre wise

    Hi Experts,
    Could you please suggest me is there any developed  standard report or t-cod eis available  with which i can get date range where the daily customer receipt profit centre wise can be obtained............
    Thanks in Advance........
    Santosh Gupta...

    Hi:
              For this purpose you can develop Z report. There is no such standard report for it. Copy FBL5N to make a Z copy of it and use the table FAGLFLEXA for each document posted in BSEG/BKPF. You can also make use of BTE 1650.
    Regards

  • Query problem with date range

    I have a query that needs to pull data between a date range.
    I've tried several things and nothing seems to work.
    Any help would be greatly appreciated.
    Here's the code:
    <cftransaction>
    <cfquery name="QryFollowUp"
    datasource="NBProdReports">
    SELECT TblContractInfo_SubMenuTable.User_ID,
    TblContractInfo_SubMenuTable.Contract_Number,
    TblContractInfo_SubMenuTable.Transaction_Type,
    TblContractInfo_SubMenuTable.Notes,
    TblContractInfo_SubMenuTable.Num_Checks_Trans,
    TblMasterTrans.Date_Opened
    from TblContractInfo_SubMenuTable ,tblMasterTrans
    WHERE Transaction_Type = 'FollowUp'
    And TblContractInfo_SubMenuTable.Task_Number =
    tblMasterTrans.Task_Number
    And TblMasterTrans.Date_Opened BETWEEN #form.StartDate# AND
    #form.EndDate#
    ORDER BY TblMasterTrans.Date_Opened ASC,
    TblContractInfo_SubMenuTable.User_id ASC
    </cfquery>
    </cftransaction>

    Any help would be greatly appreciated.
    Ok, why are you using a <cftransaction...> around a
    single select query?
    It should be unnecessary.
    This is probably not helpful to your original question. There
    is
    nothing obviously wrong with your query at least to my glance
    through.
    Thus this important question, the one without which you are
    unlikely to
    get any helpful advice, "How does this not work?" Error
    Messages? No
    Data? Wrong Data? Serves you coffee instead of tea?
    It would also probably be helpful to know how your date data
    is
    represented in the database and the form controls, depending
    on what
    your difficulties are.

  • Dimention values with date range

    Hi All
    We have a requirement to have dimensions which have date ranges like
    today's
    yesterdays
    last week
    last month etc
    When tried to add dimension I can see only string integer and float values
    Do anybody knows how to add Date with the range??
    TIA
    Lalit

    The solution we've worked with in the past is to convert the dates to YYYYMMDD and store in the index as Integer values. Thus you can use range filters by converting any incoming values to the same format. Your interface layer will have to written to accommodate those mappings.

  • FMLA standard hours infotype 2001 not editable when working with date range

    Hi All,
    The issue described below arises at the Juncture between FMLA Workbench and Absence Infotype IT2001.
    When we try to tie a FMLA Request to Absences the process takes us to the Infotype PA2001 screen wherein we would like the Absence Hours Field to be Editable so that we could enter Hours (less than full day).
    The process works fine when the FMLA absence is for a single day, i.e. if an employee availed a FMLA leave on a day (whether full day or part of a day) the Absence Hours field (PA2001-STDAZ) is editable and the user can enter any number of hours of his choice.
    But the process faces a glitch when the FMLA absence spans over a period of time (i.e. an employee availed a FMLA leave for over a period wherein each day may or may not be a full day absence, in this scenario it would be best if the system allow the user to enter Absence Hours so that the User could enter the exact number of Absence hours correctly. But unfortunately, when an absence spans multiple days the Infotype 2001 screen dynamically turns the Absence Hours field (PA2001-STDAZ) uneditable (grayed out) and the system forcefully enters hours equal to the sum of the work schedule hours for each working day covered in the span of period for which we are trying to enter FMLA Absence Hours.
    I have used the USER EXIT and the BADI route and tried to change the Screen Table to editable, but with no luck.
    Wondering, if anyone of you could help me out of this glitch.
    Thanks in Advance.

    Hi,
       I don't think this is possible.
       You cannot make the Hours field editable for a date range.
       I don't think its feasible to enter absence hours on a day basis given a date range.
       Better think of creating a custom infotype to enter absence hours .
       (Design would be : based on the date range entered , say 01.01.2011 to 05.01.2011 , you should get five input enabled
         boxes(dynamically) for five days to enter the absence hours , this is not possible in standard infotype ..... )
    Regards,
    Srini.

  • Keep Group headings with data - control your page breaks

    Trying to keep the group heading with the appropriate transaction information.  Currently, get a group heading at the bottom of a page and then the transactions print on the next page.   Difficult to determine what the transaction information is without the appropriate group headings displayed.   The amount of transaction data is not static, it varies from page to page.  Some of the reports can be close to 100 pages.   Please advise.

    Hi Kim,
    You can use the option u201CNew Page Afteru201D in Section Expert for Group Footer section so that the new group Header will display on the next page.
    Regards,
    Alpana

Maybe you are looking for

  • How do I get into my iCloud mail on someone else's PC

    I have to access a boarding pass soming to my email tomorrow and I will be away from my laptop at someone else's office all day -  need to print it at their office, filled with PCs, and don't know how to get iCloud.com mail on the web.  Can someone p

  • Vat code in MRKO

    Hi, I have created a consignement record with vat code. When I m doing the MRKO the system doesn't take the vat from consignement info record but another one. I don't know where THE VAT is from Anybody have an idea? Thanks for your help Regards Elmka

  • Adding WBS element to level-2 in existing project

    Hi all, I have a new WBS Element created in a project which already has 2 wbs elements created in a level 2 hierarchy before . Now , this new element is created at level-1 by default .I want to modify the project hierarchy adding the newly created el

  • Eurotherm 2704 connection via serial port with ModBus

    Hello guys, first some words about my problem: I have to develop a software which allows reading and writing the temperature (we have 3 Eurotherm 2704) (I think some of you know this problem yet ). I wrote already the program and it works, but I used

  • Lost all photos installing Lion but see photos on another drive

    I installed Lion and when complete there were a small number of icons on dock. Didn't see iPhoto, Aperture, iDisk, and other apps purchased in the past. I then thought I could use Time Machine to recover something but it was empty. Will make a long s