Code or idea of adding date range parameters

Thanks guys for answering all my past queries.
Another question arises
I don't know how to write code for date range value parameters for a report.
i-e
I have a report that takes a start date and end date range parameter.
I can pass all the other parameters to CrystalReportViewer through code but dont know how to write code to pass date range parameters.
Please help!

Hi,
I assume you are using JRC on CR XI or XI R2.
For Single Range Values:
Calendar calendar1 = Calendar.getInstance();
calendar1.clear();
calendar1.set(yyyy,mm,dd);
Date date1 = calendar1.getTime();
Calendar calendar2 = Calendar.getInstance();
calendar1.clear();
calendar.set(yyyy,mm,dd);
Date date2 = calendar2.getTime();
// use yyyy,mm,dd,hh,mm,ss for DateTime parameter.
ParameterFieldValue rangeVal = createSingleRangeVal(date1, date2, RangeValueBoundType.inclusive, RangeValueBoundType.inclusive);
paramFieldController.setCurrentValue("", "<Parameter Name>", rangeVal);
For Multiple Range Values:
Object [] beginVals = {date1, date2, date3};
Object [] endVals = {date4, date5, date6};
//Where  date1 - date4 is range 1, date2 - date5 is range 2 and date3 - date 6 is range 3.
RangeValueBoundType [] beginBoundTypes = {RangeValueBoundType.inclusive, RangeValueBoundType.exclusive, RangeValueBoundType.noBound};
RangeValueBoundType [] endBoundTypes = {RangeValueBoundType.noBound, RangeValueBoundType.inclusive, RangeValueBoundType.exclusive};
ParameterFieldValue [] multiRangeVal = createMultiValRangeParameter(beginVals, endVals, beginBoundTypes, endBoundTypes);
paramFieldController.setCurrentValues("", "<Parameter Name>", multiRangeVal);
I hope this helps.
Thanks
Aasavari

Similar Messages

  • Optional date range parameters

    Hi All,
    I have a 2 parameters from date and to date.When I didn't selected anything in parameters list then it should show all dates data.
    Please suggest how to create a optional parameter for date range parameters.

    Hi Sastry,
    For getting optional date parameter we are using formula like this  in record selection
    Not(hasvalue({?Date})) OR ({employee.Date} = {?Date})
    But the solution you provided doesn't contain not .Can you please suggest what is the difference.

  • Creating Date Range Parameters

    Hi,
    I have created the date range parameter using the parameter fields, but when I refresh the report the data does not get affected. It gives the same result as it would have given without the date parameter. What needs to be done in order for the parameter to actually work.?
    Thanks

    By adding a parameter you just defined a variable/ condition. Now when you want to display your results based on the values selected, you mean to implement a condition , similar to where clause in usual queries.
    For this we use the record selection formula, meaning to say the records would be selected based on those conditions.
    For eg. You are using the date range and you want to display data falling within those date range. That is you need to create a condition :
    1. What condition u2013 you have already created the parameters
    2. Implement that in where clause u2013 you need to create a record selection formula (menu Report -> Selection Formulas -> Record )
    You may probably need to use something like : in {?DateFrom} to {?DateTo}

  • **PLEASE HELP**Need Help adding date ranges to form

    I have designed a form with approximately 28 user defined date fields. I want the user to be able put in the first date range and then seautomaticaly fill in the other dates sequencially.
    ie,.... the user puts in 08/01/2007 then the following date field populates with 08/02/2007, then 08/03/2007 and so on....

    The following script can be used for the "exit" action so the basic action to get the start date's number and then it can be used to compute the next days field values by adding the appropriate number of days. A more experienced user could use a control loop t0 modify the field names and number of days to add to the start date's day number for the additional date fields.
    // Script for exit from date select field
    // perform calculation only if an input date has been selected
    if (HasValue(cInputDate)) then
    // format string for the date fields
    var cDateFormat = "MMM D, YYYY"
    // intermediate information start - optional
    xfa.host.messageBox(Concat("The input date formatted value is: ", cInputDate.formattedValue, "
    The input date's numeric value: ", Date2Num($.formattedValue, cDateFormat), "
    The adjusted date number is: ", (Date2Num($.formattedValue, cDateFormat) + 1), "
    The adjusted date is: ", Num2Date(Date2Num($.formattedValue, cDateFormat) + 1) ),
    "Intermediate Detail", 3, 0)
    // intermediate information end - optional
    var StartDateNumber = Date2Num($.formattedValue, cDateFormat)
    // add 1 day to StartDateNumber
    cAdjustDate = Num2Date(StartDateNumber + 1, cDateFormat)
    // add code for additional date fields here adding appropriate number of days for date
    else
    cAdjustDate = "" // no input keep field blank
    // add code for additional date fields here
    endif

  • Howto add date range parameters to linechart?

    I'm using SQL Server 2014 and SSDT 12. I have a linechart generated using three fields - FCP, NFS (both integers) and TimeIndex (the datetime over 30 days).
    I see how to add parameters but how do I allow users to specify a date range? For example to only view data from 01/12/2014 - 07/12/2014.
    Thanks in advance
    Adam

    Found this myself eventually in case anyone else needs it:
    http://100rov.blogspot.co.uk/2012/12/create-calendar-parameter-with-start.html

  • Date range parameters are off by one day

    I have a Start Date and End Date parameter in my SSRS report.  The results are off by 1 day.  For example if I enter 4/2/2015 and 4/20/2015 it will return a few results from 4/1/2015 to 4/19/2015.  I think maybe it's a problem with my date
    conversion in T-SQL, but thought someone more experienced than me would have seen this before.
    Thanks

    Yes 
    The safest way to write a date range comparison would be as below
    WHERE DateField >= @StartDate
    AND DateField < DATEADD(dd,1,@EndDate)
    If you want results with @EndDate inclusive
    see more details here
    http://visakhm.blogspot.ae/2012/12/different-ways-to-implement-date-range.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Passing date range parameters in MDX Query

    Following is my mdx query
    SELECT NON EMPTY
        [Measures].[Cache Attendees Count]
    ON COLUMNS,
    NON EMPTY
        ([Cache Attendees].[Visit Id].[Visit Id].ALLMEMBERS *
        [Cache Attendees].[User Id].[User Id].ALLMEMBERS *
        [Cache Attendees].[Screen Name].[Screen Name].ALLMEMBERS *
        [Cache Attendees].[User Type Id].[User Type Id].ALLMEMBERS *
        [Cache Attendees].[User Type Name].[User Type Name].ALLMEMBERS *
        [Cache Attendees].[Group Date Count].[Group Date Count].ALLMEMBERS *
        [Cache Attendees].[Insert Time Stamp].[Insert Time Stamp].ALLMEMBERS )
        DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM
        SELECT
                STRTOMEMBER(@FromCacheAttendeesInsertTimeStamp) : STRTOMEMBER(@ToCacheAttendeesInsertTimeStamp)
            ) ON COLUMNS FROM (
            SELECT
                STRTOSET(@CacheAttendeesConferenceId) ) ON COLUMNS FROM [Cube_Attendee])
            WHERE ( IIF( STRTOSET(@CacheAttendeesConferenceId).Count = 1, STRTOSET(@CacheAttendeesConferenceId), [Cache Attendees].[Conference Id].currentmember ) )
    CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
    I want to filter my cube with three parameters
    1. @CacheAttendeesConferenceId
    2. @FromCacheAttendeesInsertTimeStamp
    3. @ToCacheAttendeesInsertTimeStamp
    When i pass following parameters
    ConferenceId = 1, StartDate='2010-01-28T00:00:00', EndDate='2010-02-03T00:00:00'
    Then it show records
    But When i pass following parameters
    ConferenceId = 1, StartDate='2010-01-27T00:00:00', EndDate='2010-02-03T00:00:00'
    Then it display message No Data Available
    PLease help me on this issue why not FromDate & ToDate range works properly.

    Step1:- First i create a SSAS datasource. Then i create a cube for my table CacheAttendees.
    It has following columns:-
    [Cache Attendees].[Conference Id]
    [Cache Attendees].[Group Date Count]
    [Cache Attendees].[Insert Time Stamp]
    [Cache Attendees].[Screen Name]
    [Cache Attendees].[User Id]
    [Cache Attendees].[User Type Id]
    [Cache Attendees].[User Type Name]
    [Cache Attendees].[Visit Id]
    Step2:- Then i create a dimension with this cube with all columns.
    Step3:- Then i deploy my SSAS project.
    Step4:- Use SSAS datasource in my SSRS datasource.
    Step5:- Create a report with chart control. Add a parameter ConferenceId. Set default to 1. When i preview my report then it show Cache Attendees].[Conference Id].[1] in header of report instead of that, When i pass the parameter value as 1 then report cannot show & throw an error. I want to pass this parameter at runtime.
    Step6:- Please help me how is it possible to pass parameter at runtime.

  • Schedule a report with passing range parameters

    I have wrote a program to run the crystal report in BO server and email to the user. The program can pass the parameter to the crystal report and generate different result/ report. It works well with string parameters, int parameter and date parameter. But when I pass the date range parameters, the CR in BO always displays error "Information is needed before this report can be processed. ", and in the CR history, the Parameters field is "No Parameter"
    For single parameters, I will use the setValue() of IReportParameterSingleValue to set the param value
    IReportParameterSingleValue v = prompt.getCurrentValues().addSingleValue();
    v.setValue(paramValueArray<i>);
    but I dunno how to set the date range value. Anyone ve ideas on this?
    Here is some of my sample code.
    rangeValue.setBeginValue(dateValue1);
    rangeValue.setEndValue(dateValue1);
    rangeValue.getEndValue());
    rangeValue.setLowerBoundType(RangeValueBoundType.inclusive);
    rangeValue.setUpperBoundType(RangeValueBoundType.inclusive);
    newParam.getCurrentValues().add(rangeValue);

    I am not sure if you are using RAS or Enterprise SDK, but here are some code snippets to set range report parameters:
    For scheduling:
    // oReport is IReport object holding the crystal report.
    oReportParameter = oReport.getReportParameters().get(i);
    currentRangeValue = oReportParameter.getCurrentValues().addRangeValue();
    currentRangeValue.getFromValue().setValue(dateParameter);
    currentRangeValue.getToValue().setValue(dateParameter);
    For viewing:
    ParameterFieldRangeValue pfrv = new ParameterFieldRangeValue();
    pfrv.setBeginValue(dateTimeValue);
    pfrv.setEndValue(dateTimeValue1);
    pfrv.setLowerBoundType(RangeValueBoundType.inclusive);
    pfrv.setUpperBoundType(RangeValueBoundType.inclusive);
    pf.getCurrentValues().add(pfrv);
    f.add(pf);
    f is Fields object and pass that to viewer.

  • 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

  • Date range to be displayed  & Displaying multiple values on the report

    Hi,
    I have date range parameters, but I also need it to be displayed it on the report. Is there any way I can display it. E.G If a parameter is created one can drag and drop it on the report if it needs to be displayed on the report, I tried to do the same for the date range parameter but it does not work.
    Also If a parameter is created by selecting the option 'Allow Multiple Values', and if you drag and drop it on the report only the first value is displayed and the rest does not show. Has anyone tried this before and been successful in displaying multiple values in the report.
    Thanks in advance.

    Hi,
    A multi-value parameter is actually treated as an array in Crystal Reports.
    To display the values selected in the parameter, create a formula from the Field Explorer and type this code:
    Join({?ParameterName},",");
    Place this formula on the header or the footer sections of the report.
    Regarding the date range issue, please follow Sastry's advice and it should work fine.
    Make sure you're using the parameter in the Minimum and Maximum functions. For eg: If I was to create a date range parameter called OrderDate, my formula to show the start date would look like this:
    Minimum({?OrderDate})
    -Abhilash

  • Date Range Parameter's Restriction

    Could you someone please tell me how BO restricts date range parameter when the users tries to run a query?  Often times, users simultaneously try to get several years of data dumped into a single query.  Some users even forget to enforce the date range, which causes the query to try to get the data from the beginning of time. 
    How do we as a BO developer create some sort of date range restriction so that it can prevent users from overloading a query?  If the users want to get several years of data, he/she has to run a query in batches instead of doing it all at once.
    I hope there is a way that we can create a custom informational error message for each report to prevent users from trying to query too many months or years of data.  Some reports may hit small and well-indexed tables that allow large date range queries.  But, some reports query against large and poorly indexed tables, which can potentially cause adverse effect on performance without date range restriction. 
    Any thoughts or advices on how to implement such things (if possible).  I am also afraid that the answer will be "currently not doable".  If so, any ideas if the next version of BO will allow such functionality, or if it is at least in the plan at all?  Thank you so much for your insight and sharing.  Have a great day!

    Dear Amr,
    Thanks so much for your quick reply!  The field I want to create a restriction on is called RESULT_DT_TM.  When I saw the "where" section of the field, I just don't see how I can apply my START_DT_TM and END_DT_TM parameters on this field so that START_DT_TM and END_DT_TM cannot be more than 365 days apart.  If my query does not use parameters called START_DT_TM and END_DT_TM, this "where" section will not be valid? 
    I don't think the solution has to be on the field itself but rather on the parameter START_DT_TM and END_DT_TM.  What I want is that as long as START_DT_TM and END_DT_TM are more than 365 days apart, it does not matter what field these parameters are running against. The screen would then display something saying "your date range parameters for this report must be within 365 days.  Please revise your date range on query".
    Sorry, I am PL/SQL report programmer, and not familiar with what BO can do.  So, is there anyway that can make my dream come true?  Thanks a bunch again, Amr.

  • Date range by week based on input parameters

    Afternoon folks -- I need to produce a report which will be displayed based on weeks.
    There are two input parameters: P_FROM_DATE and P_TO_DATE
    I need to find the date ranges in weeks starting on THURSDAY and ending on a WEDNESDAY. For example, if my P_FROM_DATE is 01-AUG-2012 and P_TO_DATE is 11-SEP-2012, I need to show the following weeks in this fashion:
    02-AUG-2012 - 08-AUG-2012
    09-AUG-2012 - 15-AUG-2012
    16-AUG-2012 - 22-AUG-2012
    23-AUG-2012 - 29-AUG-2012
    30-AUG-2012 - 05-SEP-2012
    06-SEP-2012 - 12-SEP-2012So, the idea is to start the first THURSDAY following the P_FROM_DATE and end on the WEDNESDAY preceding the P_END_DATE..
    Thanks!

    Hi,
    here's one way:
    WITH     params          AS
         SELECT  DATE '2012-08-01'     AS p_from_date
         ,     DATE '2012-09-19'     AS p_to_date
         FROM     dual
    ,     end_points     AS
         SELECT     TRUNC ( p_from_date + 4
                    , 'IW'
                    ) + 3          AS first_thursday
         ,     TRUNC ( p_to_date + 4
                    , 'IW'
                    ) - 5          AS last_wednesday
         FROM    params
    SELECT     first_thursday + (7 * (LEVEL - 1))     AS week_start_date
    ,     first_thursday + (7 * LEVEL) - 1     AS week_end_date
    FROM     end_points
    CONNECT BY     LEVEL     <= ( last_wednesday
                      + 1
                      - first_thursday
                      ) / 7
    ;TRUNC (dt) is the beginning of the ISO week that contains the DATE dt.
    The "magic number" 4 is used because the ISO week begins on Monday, 4 days later than your week begins, so
    TRUNC ( dt + 4
          , 'IW'
          )is the Monday in the same Thursday-Wednesday week as dt.

  • Date range selection in abap code in infopackage

    Hi!
    I have a field called "OPEN_DATE".
    When the infopackage is runned, I need the abap code to fint the current date, and from that, make a date range from the first day of current month to the last day of current month
    Ex:
    Current date = 12.12.2008
    Abap code should extract 01.12.2008 - 31.12.2008
    Thanks!

    Hi helge,
    Data: l_idx like sy-tabix.
    Data: date_low like sy-datum,
             date_high like sy-datum.
    Date_low = sy-datum.
    date_low+6(2) = '01'.
    CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
      EXPORTING
        DAY_IN                  = Date_low
    IMPORTING
       LAST_DAY_OF_MONTH       = date_high
    read table l_t_range with key
    fieldname = 'OPEN_DATE'.
    l_idx = sy-tabix.
    Pass Range values to L_T_Range Table.
    Move date_low to L_T_Range -Low.
    Move date_high to L_T_Range -High.
    L_T_Range -Sign = u2018Iu2019. *****(Here: I u2013 Include, E u2013 Exclude)
    L_T_Range -Option = u2018BTu2019.****( Here: BT u2013 Between )
    modify l_t_range index l_idx.
    p_subrc = 0.
    Regards,

  • Getting Record Count From Date Range - IDE: PLSQL Developer

    I would like to count the number of member records that fall within a specified date range based on the members effective and expiration dates and their 'elg_code'. I have posted the SQL for some sample data. What I would like to see returned is three columns of counts where the members eff_date exp_date fall within the date range specified by the SQL and have an Elg_code of ' ' (one blank space).
    So, what I would like is all members with elg_code ' ' where there eff_dt and exp_dt range falls within APR 2012, MAY 2012 & JUN 2012. So, based on the sample data I posted, Mark, where his elg_code record is ' ', his eff_dt is 1/1/2011 and his exp_dt is within APR 2012 (4/30/2012). Mark's range falls within APR 2012, but not MAY or JUNE of 2012. Marty would tally for both APR and MAY since his eff_dt is before MAY 2012 and his exp is within MAY 2012. etc..
    Based on the data below, the results should look like:
    APR MAY JUN
    4 3 2
    APR should have FRANK, MARK, MARTY, MARY,
    MAY should have FRANK, MARTY, MARY
    JUN should have FRANK and MARY
    NOAM and JEAN should not show up as their records with elg_code ' ' do not have eff_dt and exp_dt records that fall within APR-JUN 2012.
    So what I tried without success as it appears I have some kind of Cartesian issue (?), is:
    select count(m1.mbr_name) APR,
    count(m2.mbr_name) MAY,
    count(m3.mbr_name) JUN
    from mbr2 m1,
    mbr2 m2,
    mbr2 m3
    where m1.eff_dt < '01-may-2012'
    and m1.exp_dt > '01-apr-2012'
    and m1.elg_code = ' '
    and m2.eff_dt < '01-jun-2012'
    and m2.exp_dt > '01-may-2012'
    and m2.elg_code = ' '
    and m3.eff_dt < '01-jul-2012'
    and m3.exp_dt > '01-jun-2012'
    and m3.elg_code = ' '
    Below is the DML
    Thanks for any assistance!
    create table mbr2 (mbr_name varchar(10), grpid varchar(1), eff_dt date, exp_dt date, elg_code varchar(1))
    commit
    insert into mbr2 values ('MARK', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('04-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARK', 'A', to_date('05-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('MARTY', 'A', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('05-31-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARTY', 'A', to_date('06-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('FRANK', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('FRANK', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('MARY', 'B', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('06-30-2012', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('MARY', 'B', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('JEAN', 'C', to_date('01-01-2011', 'MM-DD-YYYY'), to_date('07-01-2011', 'MM-DD-YYYY'), ' ')
    insert into mbr2 values ('JEAN', 'C', to_date('07-01-2011', 'MM-DD-YYYY'), to_date('01-01-2012', 'MM-DD-YYYY'), 'C')
    insert into mbr2 values ('NOAM', 'D', to_date('07-01-2012', 'MM-DD-YYYY'), to_date('12-31-2013', 'MM-DD-YYYY'), ' ')
    commit

    Hi,
    Here's one way:
    WITH     all_months     AS
         SELECT     LEVEL                         AS month_num
         ,     ADD_MONTHS (first_month, LEVEL - 1)     AS month_begin
         ,     ADD_MONTHS (first_month, LEVEL)           AS next_month_begin
         FROM     (
                   SELECT  TO_DATE ('04-01-2012', 'MM-DD-YYYY')     AS first_month
                   ,     TO_DATE ('06-01-2012', 'MM-DD-YYYY')     AS last_month
                   FROM     dual
         CONNECT BY     level     <= 1 + MONTHS_BETWEEN (last_month, first_month)
    SELECT    COUNT (CASE WHEN month_num = 1 THEN 1 END)     AS month_1
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS month_2
    ,       COUNT (CASE WHEN month_num = 3 THEN 1 END)     AS month_3
    FROM       all_months  a
    JOIN       mbr2        m  ON  a.month_begin       <= m.exp_dt
                            AND a.next_month_begin      >  m.eff_dt
    WHERE     m.elg_code      = ' '
    ;This assumes you know how many months will be in the output. If you want to derive that from the data, or to give the columns meaningful aliases (such as APR-2011 instead of MONTH_1), then you'll need dynamic SQL (to get separate columns for each month) or string aggregation (if you don't mind one big VARCHAR2 column, formatted to look like several columns). See {message:id=3527823}
    If you don't mind modifying the query a little every time you run it, you can hard-code the number of columns and the month names. In the main query, put exactly as many lines as you need, with the alias you want at the end. That is, instead of
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS month_2say
    ,       COUNT (CASE WHEN month_num = 2 THEN 1 END)     AS may_2012I'm not sure exactly what the problem was with the query you posted. It looks like this site cut off parts of the query.
    One thing that is definitely a mistake is that you're comparing DATE columns to VARCHAR2 literals. Never compare a DATE to a VARCHAR2; compare DATEs to DATEs (or compare VARCHAR2s to VARCHAR2s). So instead of
    and m1.exp_dt > '01-apr-2012'you should say
    and m1.exp_dt > TO_DATE ('01-apr-2012', 'dd-mon-yyyy')Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
    Edited by: Frank Kulash on Jun 26, 2012 3:32 PM

  • Date parameters for Date range

    Hi,
    I got a report with 2 parameters From Date and To Date and i have 2 columns items in the report absence start date and absence end date.
    i have to make sure that the date range satisfies all case's
    what is the best way that I can these validation rules in discoverer on these dates...?
    case's are something like this:
    1 (absence start date > from date; absence end date > to date)
    2 (absence start date > from date; absence end date < to date)
    3 (absence start date < from date; absence end date > to date)
    4 (absence start date > from date; absence end date < to date)
    Any help would be really appreciated.

    Using conditions in Discoverer is just like specifying a where clause in SQL with AND and OR. You should be able to use conditions for what is being described below.
    Are you not able to do that using conditions in your report ?

Maybe you are looking for