Problem in If-Then-Else formula in report

Hello guys!
I use an If-Then-Else statement in a Calculated Key Figure (Cf. <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm">Conditional Calculations</a> ) and it works great with basic calculations.
I have a query (done in BI 7.0) where I display, for each calendar months (via 0CALMONTH), the usage (stored in a normal key figure in hours) of several products.
I need to take into account only the products that have been used for at least 60% of the time of the highest product for each month. I a single product, for a month, has been used less than 60% of the highest one, it should be considered as not being used at all (so the calculated usage would be = 0), otherwise, its usage is counted as normal.
In order to achieve this, I thought I would display the normal usage (the regular key figure) in column A, a calculated key figure that determines the MAXimum usage for each month in column B (which should be the same for all products) and another calculated key figure that displays the result of the If-Then-Else statement in column C.
In rows, I have 0CALMONTH and the products.
HOWEVER, when I do this, the result is incorrect. This is probably because to determine the MAX usage, I use a local calculation option, which displays the correct maximum usage on each row but it's not correct when used somewhere else.
<b>MY QUESTION IS: HOW can I display the maximum usage for a month on all rows without using the calculation option (and therefore would be correctly used by the If-Then-Else statement. I tried an aggregation exception but it doesn't really work (it works only on the total, but I need to do the calculation on each individual row).</b>
<u><b>Any useful comment will be greatly appreciated </b></u>
Thanks in advance!

Hi Francal ,
Have you tried it . The constant selection will work if you have defined the calculated key figure correctly i.e. Aggreagtiomn "Max" with "product" as ref characteristic. Then you have to use this calculated key figure in your query , restrict it by "product" and make it a constant selection.
The calculated key figure it self  will bring the highest usage for Month + product + ( any other characteristic you have in query ) but this will only apply to result . If you use constant seelction on top of it it will make sure that you see same value for all product for a particular month( and other characteristic combinations if you have ).
I have built similar queries and it works . By the way which versions of backend and frontend you have ??
Regards
Sanjay

Similar Messages

  • Problem with if-then-else using BI Answers dataset

    Hi, I'm having issues using the if-then-else logic with a BI Answers dataset. I'm running two versions of a report - one that access the SH schema tables directly, and one that uses a BI Answers dataset based on the SH schema.
    My problem is with the if-then-else operator. It works fine against the relational tables when I use the following syntax:
    <?xdofx:if CUST_GENDER = 'M' then 'Mr.' else 'Ms.' end if?>
    However, when I go against a BI Answers report, the name of the field changes from CUST_GENDER to Customers._Cust_Gender_. If I make an exact find and replace on the if-then-else code, it doesn't work (nothing at all displays)
    <?xdofx:if Customers._Cust_Gender_ = 'M' then 'Mr.' else 'Ms.' end if?>
    Can anyone help?
    Thanks,
    Scott

    Is it possible that any of the fields have null values?  If so, see my blog post about null handling in Crystal for more information:  What is Null and Why is it Important for Crystal Reports | SAP BI BLOG
    -Dell

  • Problem with IF THEN ELSE in RTF template

    HI ALL,
    I have two layouts in the RTF template. Based on the parameter value it has to show the value.
    For example if P_State='United States' then first layout should come. else second one should come.
    I tried to use the IF Then else logic through the form field but i am getting error.
    Please help on this to get it.
    Regards
    Boopathi

    You can do that.
    i guess, the syntax you are using is wrong.
    please refer documentation or this forum for choose:
    Use choose statement. it s better.
    Or send me the template to my id in my profile. or upload it here http://apps2fusion.com/forums/viewforum.php?f=60

  • Problems with IF then ELSE IF then ELSE

    I am trying to take this logic:
    if :detail_status > 0 then
    return 0;
    elsif :released in ('D','N') then
    return 0;
    else
    return :amount;
    end if;
    end;
    and put it in a form field in my rtf.
    <?xdofx:if DETAIL_STATUS = 0 then sum(AMOUNT) else if RELEASED not in ('D', 'N') then sum(AMOUNT) else
    sum(AMOUNT) end if?>
    I should be getting a value, but instead I get 0 (zero).
    If I do this:
    <?xdofx:if DETAIL_STATUS > 0 then 0 else if RELEASED in ('D', 'N') then 0 else
    sum(AMOUNT) end if?>
    again, I get no value.
    If I do this, I get two values of the same.
    <?if:DETAIL_STATUS = 0 ?><?sum(AMOUNT)?><?end if?>
    <?if:RELEASED != ('D' ,'N')?><?sum(AMOUNT)?><?end if?>
    Help!
    Susie

    Here is my xml data: I do want to let you know that I do get a value for the condition that I am setting for the sum(AMOUNT), but only if it is greater than zero.
    <G_MAIN>
    <LEASE1>107735</LEASE1>
    <LSE_CODE1>28</LSE_CODE1>
    <KELEASE>003-107735-28</KELEASE>
    <DOCUMENT1>89224</DOCUMENT1>
    <BILL_CYCLE>3183</BILL_CYCLE>
    <YEAR_BILLED>2006</YEAR_BILLED>
    <DOC_TYPE>RA</DOC_TYPE>
    <DOC_TYPE_DESC>RENTAL ONLY</DOC_TYPE_DESC>
    <ROLODEX>4228</ROLODEX>
    <LNAME>PEORIA UNIFIED SCHOOL DISTRICT</LNAME>
    <EFFDATE>2004-08-10T00:00:00.000-07:00</EFFDATE>
    <AMEND>0</AMEND>
    <EXPDATE>2079-08-09T00:00:00.000-07:00</EXPDATE>
    <BILLING_CODE>0</BILLING_CODE>
    <BILLING_CODE_DESC />
    <LAST_MAINT>2006-03-29T12:33:46.000-07:00</LAST_MAINT>
    <BILL_PURP>0</BILL_PURP>
    <TOT_AUS>0</TOT_AUS>
    <BILL_PURP_DESC />
    <PURP_CODE2 />
    <PURP_CODE2_DESC />
    <DATE_BILLED>2006-05-31T00:00:00.000-07:00</DATE_BILLED>
    <BILLED_FROM>2006-08-10T00:00:00.000-07:00</BILLED_FROM>
    <PURP_CODE3 />
    <PURP_CODE3_DESC />
    <DUE_DATE>2006-08-10T00:00:00.000-07:00</DUE_DATE>
    <BILLED_THRU>2007-08-09T00:00:00.000-07:00</BILLED_THRU>
    <PURP_CODE4 />
    <PURP_CODE4_DESC />
    <PURP_CODE5 />
    <PURP_CODE5_DESC />
    <TOT_ACRES>56.18</TOT_ACRES>
    <KELEASE_STATUS />
    <DETAIL_STATUS>1</DETAIL_STATUS>
    <COUNT_HELD>0</COUNT_HELD>
    <COUNT_DELETE>0</COUNT_DELETE>
    <RELEASED>Y</RELEASED>
    <TOT_AR_AMOUNT />
    - <LIST_G_DETAIL>
    - <G_DETAIL>
    <FUND>0</FUND>
    <SUB>4</SUB>
    <DOCUMENT2>89224</DOCUMENT2>
    <AMOUNT>0</AMOUNT>
    <CALCULATED>N</CALCULATED>
    <LAST_MAINT_2>2006-03-29T12:33:46.000-07:00</LAST_MAINT_2>
    <MANUALLY_ADDED>N</MANUALLY_ADDED>
    <ERROR_STATUS>106</ERROR_STATUS>
    <STATUS>0</STATUS>
    <ERROR_FLAG>< < < E R R O R > > ></ERROR_FLAG>
    <ERROR_DESC>REQ $ RENT/ROYALTY/ADM FEE</ERROR_DESC>
    </G_DETAIL>
    </LIST_G_DETAIL>
    </G_MAIN>
    for-each G_MAIN
    for-each G_DETAIL
    end G_DETAIL
    I have this condition in a text form field for sum(AMOUNT) after the end G_DETAIL and before end G_MAIN.
    <?if:DETAIL_STATUS = 0?><?if:RELEASED != 'D' and RELEASED != 'N'?> <?xdoxslt:sum(G_DETAIL/AMOUNT)?> <?end if?><?end if?>
    end G_MAIN
    I do want to thank you for helping me out.

  • Problem in using  Nested  IF-ELSE in Crystal Report  formula

    Hi Experts ,
                         I am having some problem using  Nested IF-ELSE in Crystal Report formula ,
    there is no error in the formula but only one condition is working. other condition is not working
    i am using this concept in formula workshop :-
    ' if{EXCISE_INVOICE;1.Basic Excise Duty BED@10 %}<>0 and{EXCISE_INVOICE;1.Education Cess @2%}<>0 and {EXCISE_INVOICE;1.Secondary Education Cess @1%}<>0 and {EXCISE_INVOICE;1.Central Sales Tax(CST)@2%}<>0
    then
    Sum ({EXCISE_INVOICE;1.Amount}) + {EXCISE_INVOICE;1.BedAmount@10%} + {EXCISE_INVOICE;1.EcessAmount@2%} + {EXCISE_INVOICE;1.SecCessAmount@1%} + {EXCISE_INVOICE;1.CSTAmount@2%}
    else
    if {EXCISE_INVOICE;1.Basic Excise Duty BED@10 %}<>0 and {EXCISE_INVOICE;1.Education Cess @2%}<>0 and  {EXCISE_INVOICE;1.Secondary Education Cess @1%}<>0 and   {EXCISE_INVOICE;1.Input VAT@5%}<>0  and {EXCISE_INVOICE;1.Addtional Tax@1%}<>0
    then
    Sum ({EXCISE_INVOICE;1.Amount}) + {EXCISE_INVOICE;1.BedAmount@10%} + {EXCISE_INVOICE;1.EcessAmount@2%}+{EXCISE_INVOICE;1.SecCessAmount@1% } + {EXCISE_INVOICE;1.VATAmount@5%} +{EXCISE_INVOICE;1.AddTaxAmount@1%(for VAT@4)}
    I want that  all conditions  should work and the condition which is applicable there according to formula it display the result,  if i add another condition then it should also work.
    kindly tell me the solution of this problem
    Regards
    Rahul

    Try this logic:
    if{EXCISE_INVOICE;1.Basic Excise Duty BED@10 %}!=0 and{EXCISE_INVOICE;1.Education Cess @2%} !=0 and {EXCISE_INVOICE;1.Secondary Education Cess @1%} !=0
    then
    Sum ({EXCISE_INVOICE;1.Amount}) + {EXCISE_INVOICE;1.BedAmount@10%} + {EXCISE_INVOICE;1.EcessAmount@2%} + {EXCISE_INVOICE;1.SecCessAmount@1%}
    else
    0
    +
    IF {EXCISE_INVOICE;1.Central Sales Tax(CST)@2%} !=0
    then
    {EXCISE_INVOICE;1.CSTAmount@2%}
    else
    IF  {EXCISE_INVOICE;1.Central Sales Tax(CST)@5%} !=0
    then
    {EXCISE_INVOICE;1.CSTAmount@5%}
    +
    if {EXCISE_INVOICE;1.Addtional Tax@1%} !=0
    then
    EXCISE_INVOICE;1.AddTaxAmount@1%(for VAT@4)}
    else
    0
    If not work, try SQL command.
    Thanks,
    Gordon

  • Problem in Insertion into table through After Report Parameter form trigger

    Hi All,
    I am getting problem in inserting some data into temp table through Report.
    My requirement is like that, I have to do a calculation based on user parameters, and then insert the data into the temp table. I wanted to do this into After Report Parameter form trigger function. I have done all the calculation and wrote all the insert statement in that function. There is no problem in compilation. then I am taking value from this temp table in my formula columns.
    When I run this report, it hangs, don't understand what is the problem.Can anybody help me out in this.
    Thanks,
    Nidhi

    The code is as follows:
    function AfterPForm return boolean is
    CURSOR CUR_RECEIPT(RECEIPT_NUM_FROM NUMBER, RECEIPT_NUM_TO NUMBER) IS
    SELECT DISTINCT receipt, item_no FROM xxeeg.xxeeg_1229_sp_putaway WHERE RECEIPT BETWEEN
    RECEIPT_NUM_FROM AND RECEIPT_NUM_TO ;
    V_CUR_RECEIPT CUR_RECEIPT%ROWTYPE;
    begin
    OPEN CUR_RECEIPT(:RECEIPT_NUM_FROM, :RECEIPT_NUM_TO);
    FETCH CUR_RECEIPT
    INTO V_CUR_RECEIPT;
    LOOP
    EXIT WHEN CUR_RECEIPT%NOTFOUND;
    IF V_CUR_RECEIPT.ITEM_NO = 'TEST1' AND V_CUR_RECEIPT.RECEIPT = '12' THEN
    INSERT INTO SP_TEMP
    (RECEIPT, ITEM_NO, LOCATION1)
    VALUES
    (V_CUR_RECEIPT.RECEIPT, V_CUR_RECEIPT.ITEM_NO, 10);
    UPDATE SP_TEMP
    SET LOCATION2 = 12
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION3 = 13
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION4 = 14
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    ELSE
    IF V_CUR_RECEIPT.ITEM_NO = 'TEST2' AND V_CUR_RECEIPT.RECEIPT = '12' THEN
    INSERT INTO SP_TEMP
    (RECEIPT, ITEM_NO, LOCATION1)
    VALUES
    (V_CUR_RECEIPT.RECEIPT, V_CUR_RECEIPT.ITEM_NO, 10);
    UPDATE SP_TEMP
    SET LOCATION2 = 16
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION3 = 17
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO =V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION4 = 18
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    ELSE
    INSERT INTO SP_TEMP
    (RECEIPT, ITEM_NO, LOCATION1)
    VALUES
    (V_CUR_RECEIPT.RECEIPT, V_CUR_RECEIPT.ITEM_NO, 10);
    UPDATE SP_TEMP
    SET LOCATION2 = 19
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION3 = 20
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO =V_CUR_RECEIPT.ITEM_NO;
    UPDATE SP_TEMP
    SET LOCATION4 = 21
    WHERE RECEIPT = V_CUR_RECEIPT.RECEIPT AND ITEM_NO = V_CUR_RECEIPT.ITEM_NO;
    END IF;
    END IF;
    END LOOP;
    COMMIT;
    CLOSE CUR_RECEIPT;
    return(TRUE);
    end;
    .....................................................................................................................

  • Sum function within if/then/else (xdofx:if)

    I'm attempting to display a total at a particular group within my report. This total is conditional and should choose to display a placeholder value or the sum of another placeholder value (in a child group).
    I have been able to vary my output based on the value I want to check: FIXED_QUOTE_FLAG - I have the if/then/else working in a simplified fashion
    I can display literals and some placeholders correctlly eg. print a literal value of 00110011 or the value of placeholder QUOTED_PRICE
    I can also display a calculated placeholder, using sum within the group I am concerned with: sum (current-group()/ACTIVITY_CHRG)
    But when I try to get everythign working together ...
    I cannot get the sum to work inside the if/then/else condition. The result is NULL (blank in HTML output).
    The following is the snippet which is not working correctly:
    <?xdofx:if FIXED_QUOTE_FLAG = 'Y' then QUOTED_PRICE else sum (current-group()/ACTIVITY_CHRG) end if?>
    Message was edited by:
    gareth_adamson

    To answer you first question, perhaps sum is not a supported function in the xdofx namespace. It's annoying when this problem comes up because xdofx namespace seems to be the only way to do if then else clauses. I'm not entirely certain on the above, but you could resort to using BI Publisher's built-in if statement.
    For your problem, something like this:
    <?if: FIXED_QUOTE_FLAG='Y'?>
    QUOTED_PRICE
    <?end if?>
    <?if: FIXED_QUOTE_FLAG!='Y'?>
    <?sum(current-group()/ACTIVITY_CHRG)?>
    <?end if?>
    EDIT:
    There is a way to do if else without xdofx namespace. It is done with <?choose:?> <?when:?> and <?otherwise:?> tags. Here is example syntax copied from Tim Dexter's blog:
    <?choose:?>
    <?when:count(TRX_NUMBER) > 0?>
    Invoice Table
    <?end when?>
    <?otherwise:?>
    No Data Found
    <?end otherwise?>
    <?end choose?>
    To answer the second question about a running total, you will need to use the <?xdoxslt:set_variable($_XDOCTX,'var_name',var_value)?> and the <?xdoxslt:get_variable($_XDOCTX,'var_name')?>. This method of working with variables is the only method that allows you to update a variable. This makes it good for running totals. Consult the official user guide under "Creating an RTF Template" the section about using variables and calculating running totals.
    So, in your problem, once you get the first part working, you will have to add that value to your running total. It will look something like this:
    <?xdoxslt:set_variable($_XDOCTX,'running_total',xdoxslt:get_variable($_XDOCTX,'running_total') + conditional_value)?>
    Remember to initialize the running total to zero! Hope this helps.
    Thanks,
    Matt Soukup
    Message was edited by:
    Matt Soukup

  • "Failed to open the connection" problem related to multiple tables in the report?

    Post Author: Gadow
    CA Forum: Data Connectivity and SQL
    System specifics:
    Web environment using ASP.Net 2.0 (from Visual Studio 2005 Professional)
    Crystal Reports 2008, v. 12.0.0.549, Full
    We have set up the following method for displaying reports via our website:
    User is sent to a report-specific page. The user is given some filtering options specific to the report that will be viewed. When the user has specified the data filters, the user clicks a button.
    The page wraps up the report parameters -- selection query, formula values, report location, the name to be displayed, etc. -- into a class which gets put into the Session object.
    The page redirects to DisplayReport.aspx. ALL reports redirect to this page.
    DisplayReport.aspx retrieves the report parameters from Session. A ReportDocument object is created and loaded, then set with the data from the parameters class.
    A ConnectionInfo object is created and set with the relevant log on credentials. All of the reports draw from the same database, so the connection information is hard-coded as the same for all reports. The page then iterates through all of the tables in the Database.Tables collection of the ReportDocument and calls ApplyLogOnInfo to each table using the ConnectionInfo object.
    The page is rendered and the user gets the filtered report.
    We currently have seven reports. Five reports work fine and display the correctly filtered data with no error messages. Two reports generate a Failed to open the connection error and do not display. I have verified that the queries being sent to DisplayReport.aspx are valid, and as I said the connection information itself is hard-coded in the one page that displays the reports and this is identical to all reports.
    The five reports that do work all have a single data table, either an actual database table or a single view. The two reports that do not work all have multiple tables. As far as I can tell, this is the only difference between the sets; all seven reports are based on the same DSN and I have verified the database on all of the reports. All of the reports were written using Crystal Reports 8, and all of the reports display fine in a Windows app I wrote some years ago using Crystal Reports 8. Again, the only difference between those reports that do work and those that do not is the number of tables used in the report: one table or view in the reports that display, more than one table (tables only, none use views) in the reports that do not display.
    As for the code I am using, below are the relevant methods. The function MakeConnectionInfo simply parses out the components of a standard SQL connection string into a ConnectionInfo object. DisplayedReport is the ID of the CrystalReportViewer on the page.Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim o As Object = Session("ReportParams")
            Dim ReportURL As String = ""
            'Verify that there is a ReportParameters object
            If o Is Nothing OrElse o.GetType IsNot GetType(ReportParameters) Then 'Redirect to the error page
                Response.Redirect("/errors/MissingReport.aspx")
            End If
            ReportParams = CType(o, ReportParameters)
            'Verify that the report exists
            ReportURL = "/Reports/ReportFiles/" + ReportParams.ReportName
            ReportPath = Server.MapPath(ReportURL)
            If Not File.Exists(ReportPath) Then
                Response.Redirect("/errors/MissingReport.aspx?Report=" + ReportParams.ReportTitle)
            End If
            InitializeReport()       
        End Sub
        Protected Sub InitializeReport()
            Dim RD As New ReportDocument
            Dim CI As ConnectionInfo = MakeConnectionInfo(DB_Bonus)
            Dim RPF As CrystalDecisions.Shared.ParameterField = Nothing
            RD.Load(ReportPath)
            If ReportParams.SelectString <> "" Then
                Dim Adapt As New SqlDataAdapter(ReportParams.SelectString, DB_Bonus)
                Dim DS As New Data.DataSet
                Adapt.Fill(DS)
                RD.SetDataSource(DS.Tables(0))
            End If
            For Each kvp As KeyValuePair(Of String, String) In ReportParams.Formulas
                Dim FFD As FormulaFieldDefinition = Nothing
                Try
                    FFD = RD.DataDefinition.FormulaFields(kvp.Key)
                Catch ex As Exception
                    'Do nothing
                End Try
                If FFD IsNot Nothing Then
                    Select Case FFD.ValueType
                        Case FieldValueType.DateField, FieldValueType.DateTimeField
                            If IsDate(kvp.Value) Then
                                FFD.Text = String.Format("Date()", Convert.ToDateTime(kvp.Value).ToString("yyyy, MM, dd"))
                            Else
                                FFD.Text = "Date(1960, 01, 01)"
                            End If
                        Case FieldValueType.StringField
                            FFD.Text = String.Format("""""", kvp.Value)
                        Case Else
                            'For now, treat these as if they were strings. If things blow up here,
                            'we will need to add the appropriate formatting for the field type.
                            FFD.Text = String.Format("""""", kvp.Value)
                    End Select
                End If
            Next
            For Each T As CrystalDecisions.CrystalReports.Engine.Table In RD.Database.Tables
                Dim TLI As TableLogOnInfo = T.LogOnInfo
                TLI.ConnectionInfo = CI
                T.ApplyLogOnInfo(TLI)
            Next
            DisplayedReport.ReportSource = RD
        End Sub
    Does this approach not work with reports containing multiple tables, or is there something I'm missing? Any meaningful suggestions would be much appreciated.

    Dear Dixit,
    Please refer to the Crystal report landing page to get the details
    information about the support for crystal report issues.
    Please use the following thread to post your questions related to
    crystal report.
    SAP Business One and Crystal Reports
    Regards,
    Rakesh Pati
    SAP Business One Forum Team.

  • Select in CASE statement or in IF-THEN-ELSE

    I have been struggling for a week with a problem and still can't solve the way I want.
    Given four text fields in page : p1_name, p1_place_name, p1_place_number and p1_place_init_letter - where user types text and press 'Search' button to see the results.
    p1_name finds results in table EMPLOYEES
    p1_place_name, p1_place_number and p1_place_init_letter find results in table PLACES
    the two tables are linked by id_place field
    I would like reports to be shown depending on search results:
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist AND EMPLOYEES.id_place = PLACES.id_place then a single report shows only employee row
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist AND EMPLOYEES.id_place # PLACES.id_place then two reports showing 1) employees with name = :p1_name and 2) places with name, number and init_letter = :p1_.....
    - if p1_name not exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist then a message with 'NO EMPLOYEE' and report shows only places where name, number and init_letter = :p1_.....
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) not exist then report shows only employee row where name = :p1_name and message with 'NO PLACE'
    - if p1_name not exists and (p1_place_name and p1_place_number and p1_place_init_letter) not exist then messages 'NO EMPLOYEE' and 'NO PLACE'
    I do NOT know if it is possible, and if it is, then what do I have to use : IF - THEN - ELSE or CASE ?
    I tried to build HTML report region conditionally shown for each situation, but they do not work the way I want.
    Could you please help me ?
    Thank you in advance !

    Agree with Dan. Use a dedicated report region for a unique query. Use a rendering condition to determine if that reporting region must be rendered (i.e. whether or not that reporting query must be executed ).
    The alternative is creating a function that constructs the SQL query dynamically, based on the user supplied values for page items. Use the function as the source for the reporting region, instead of a SQL statement. (this is similar to creating a ref cursor for a client, minus the actual step to create the ref cursor - instead the source SQL for that ref cursor is returned).
    Also consider asking your Apex questions in the dedicated Apex forum on OTN.

  • Query if-then-else logic with calculation

    Hello,
    I want to calculate within a BEX-formula.
    I have two key-figures:
    - Quantity
    - Value
    The logic should be like this:
    IF Value > 0 THEN Value / Quantity ELSE 0
    ( / means: divided)
    How can I reach this?
    The URL
    http://help.sap.com/saphelp_nw70ehp1/helpdata/de/e3/e60138fede083de10000009b38f8cf/frameset.htm
    does not help me.
    Thanks for your help,
    Thomas

    That is the way to perform if then else...
    As long as boolean operations returns 0 or 1 you must play with that in order to get the desired result.
    In case you have DIV problems you can use this operator:
    NDIV0 (x): Is equal to 0 with division by 0, otherwise x.
       NDIV(<Expression>)
    Delivers 0 if the expression named in <Expression> gives a division by 0 in
    the calculation. Otherwise, the result is the value of the expression.
    Is used to
      - Avoid the output of an error message
      - Continue calculating with a defined result
    Please give an example if I am missing something.
    Regards,
    Sebastian,.

  • How to write Boolean function (If Then Else) For Date Caluclation.

    Dear All,
    I have a scenario where i need to calculate Position time hold by an employee in an organisation.
    I have 2 date Char ( DATE FROM & DATE TO), the problem is that is , If an employee is having
    2/3 position in an organisation its current position End Date is always 31.12.999 as its End date is
    not know. For previous position End Date is maintained.
    My requirement is to calculate Position hold time including Current position.
    Can it be done directly in formula variable with If Then Else condition.
    or i need to write user exit if its exit,
    please guide me for ABAP Code.
    Thanks V V much.
    Regards,

    Hi,
    Following options are available for you:
    1. Is the valid to, valid from dates available as a result of standard time dependency of navigational attributes? if yes , you can not use them in calculations, in such case you may have to write a full fledged routine at formula variable, using uxer exit.
    2. Another simple method, that i would suggest would be using temporal joins (infoSets), that precisely fits you case.
    Helpful links:
    About Infosets:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/ed/084e3ce0f9fe3fe10000000a114084/frameset.htm]
    About Temporal joins:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/11/723c3b35703079e10000000a114084/frameset.htm]
    Hope this helps.
    Cheers,
    Sumit

  • Constant Checking in Row Formula for Report Writer

    Dear All,
    Please advice what is the format to check a constant (string) in the row formula for Report Writer.
    Let's say if I want to check the cost center group -->
    If '&1KOSET' = 'ABC' then .... else......
    So, what is the format for ABC? Because if i put 'ABC' it will be treated as cell. But if i do not put the ' ', then i get system error.
    Thanks a million for your advice.
    Best Regards,
    CW

    Hi John Lee,
    The logic that you would want , can be implemented through a column set. That is, as per your logic written in the set, your column values differ.
    First in your set, keep your account number in the first set line. ie. 5000000.
    Then you enter the following formula in the second line of a set defined for a report column:
    IF u2018001u2019 > 5000000 THEN u2018001u2019 ELSE 0
    If the value in the first column (set line 001) is greater than 5000000, then this value displays in the second column; if the value in the first column is less than 1000, the value 0 displays in the second column.
    Revert if you need any additional help.
    Regards,
    Subin John

  • Nested if-then-else with double condition

    Hi everybody, I tried to see on the forum how to build a complex if-then-else statement....but I didn't still find an answer
    So, I'll explain my situation:
    First I have to check if the field PROJ_DT_TO is null or not and then the language parameter:
    1. if the field PROJ_DT_TO IS NULL then I have to check the language parameter:
    a) if this last one is equal to 'English' I want to write inside my template 'Today',
    b) if instead is equal to 'Greek' I want to write 'Σήμερα'
    2. else if the field PROJ_DT_TO IS NOT NULL, again, I have to check the language parameter:
    a) if this last one is equal to 'English' I have to write <?format-date:PROJ_DT_TO;'MMMM yyyy'?>
    b) if instead is equal to 'Greek' I have to write <?format-date-and-calendar:PROJ_DT_FR;‘MMMM yyyy’;'GREGORIAN';'Europe/Athens'?>
    I used the following syntax...but it didn't work...
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?>
    <?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?><?end when?>
    <?otherwise@inlines:?>
    <?xdofx:if $p_language = 'Ελληνικά' then <?format-date-and-calendar:PROJ_DT_FR;‘MMMM yyyy’;'GREGORIAN';'Europe/Athens'?> else if $p_language = 'Αγγλικά' then <?format-date:PROJ_DT_TO;'MMMM yyyy'?> end if?>
    <?end otherwise?>
    <?end choose?>
    The first piece, until the first <?end when?> instruction works....it's the <?otherwise@inlines:?> and the rest which doesn't work.....
    If, instead, I use (without reaching my goal):
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?><?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?><?end when?>
    <?otherwise@inlines:?>
    <?format-date:PROJ_DT_TO;'MMMM yyyy'?><?end otherwise?>
    <?end choose?>
    I see the date PROJ_DT_TO even if always in the date format 'MMMM yyyy'
    Anybody knows how can I rewrite my statement in order to reach the if-then-else situation I metioned above ?
    Thanks in advance
    Best Regards
    Alex

    Hi Vetsrini, thaks for your answer and your hint !!
    I tried your code, but without the command 'when@inlines' doesn't work...
    So I tried this :
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?>
    <?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?>
    <?end when?>
    <?otherwise@inlines:?>
    <?format-date:PROJ_DT_TO;'MMMM yyyy'?>
    <?end otherwise?>
    <?end choose?>
    and It works..
    But, look at this ! I discovered on the manual that inside the Preferences it's possible to set the Report Locale with the language you want.....and if I set my Report Locale in Greek, using the code above I correctly see all dates in Greek....but ALWAYS !!
    I need to see dates in Greek or English dinamically according to the value of the parameter p_language passed inside the template at the beginnig (<?param@begin:p_language?>).
    Even if inside the code there is the double condition ($planguage = 'Ελληνικά' or $p_language = 'Αγγλικά') for the two cases PROJ_DT_TO='' or PROJ_DT_TO !='', I see ALWAYS dates in the language set inside the Locale Report....
    Is there a way to manipulate the Report Locale Setting and make it dinamic ?
    Thanks in advance
    Alex
    So this preference is static, even if inside my report I have the parameter p_language I can see the data and headings with

  • Question regarding the If-then-else function

    Hi folks ,
    I have been constantly putting threads on this subject for the past day,  hope it doesn't annoy any one here.
    My scenario is really simple, and i am  almost close to the solution, but there is just 1 thing missing and i know that is a very small thing, could be the context too. Hope some one can help by pointing it out>
    Mapping:
    In my source i have a header(0-unbounded) & detail(0-unbounded). At a given instant either header / detail will occur in source, depending on that the target node "response" will occur(0-n times)
    i have achieved this in the mapping.
    the problem is this:
    Both the Header/Detail have a field in it called Sequence# which is mandatory and can occur only once in the Header/Detail node.
    Now depending on what occurs: ie Header/Detail i need to map that particular seq# into my Target Respone's SEQ_#.
    I have done the mapping for this and have done a standalone testing.
    Mapping: Check if HEADER EXISTS, if yes? then map the HEADER.Seq# to TARGET.Seq#
    Here are my findings:
    Scenario1: 3 header nodes(No Detaili) each with a seq # in it. Out put 3 Target node each with 3 seq # in it.
    Scenario2: 2 Detail Nodes(No header) each with a seq # in it. Output fails to produce the 2nd Target Structure's Seq# and Fails
    When i look into the Display Queue in the mapping , i examine the iF-Then-Else function:
    Since HEADER doesn't exist i c 1 Suppress in my If-Condition hence the if condition becomes FALSE., now since its false its supposed to map the seq# from my detail. (This case i have 2 ).
    But in the output of the IF-Then Else, i get out only 1 seq # which is the 1st one,
    What i am thinking is that the exists condition is giving out only 1 FALSE instead of 2, If there were 2 false from the exists then i would have had both the seq # in my output,
    I hope my question is clear, Would appreciate anysort of help . And i apologize if I seem to be brigning up the same question over again experts.
    I don't wnt to create a UDF for this matter because i know there is something i am not doing right,
    Hank

    Sorry I could not give my udf in my last post.
    Udf1:
    Create a context udf and name it as RemoveSuppress. Take two input arguments a and b. Imports: java.*;
    Add this code:
       //write your code here
    boolean found = false;
    for (int i=0;i<a.length;i++) {
         if (a<i>.equals(b[0])) {
         found = true;
         break;
    if (found == true)
         result.addValue("true");
    else
         result.addValue("false");
    Then it should work.
    Regards,
    ---Satish

  • How to write IF-THEN-ELSE in query (syntx)

    Dear Experts,
    As the decode syntx is Oracel's, is there any syntx could be used for IF-THen-Else function in query generator?
    Thanks.
    Emily

    Morning, Gouri,
    It works!!  Thanks very much!
    BTW, in Inventory menu, the report 'Inventory Posting  List, does it pull data from table 'OINM' ?
    It looks like OINM does not link with tables of ODLN (PL/delivery) and OPOR (PO), is it correct?
    If I would like link OINM to ODLN and OPOR, which table interrelated between them??
    Pls kinldy asdvise.
    Thanks in advance.
    Emily

Maybe you are looking for

  • After upgrade to iphone OS 4.0 (and then 4.1) correct sync stop working

    After upgrade to iphone OS 4.0 (and then 4.1) synchronization of calendar, contacts, bookmarks of safari STOP working. For example I check checkbox "synchronize calendar" and press "apply". Then iTunes DELETE check in the checkbox ("synchronize calen

  • Recovery from hard drive

    I was instructed to reset my notebook to repair fingerprint device. Thought I had backup of data on external hard drive, but not. Computer illiterate, but wanted to know if it is possible to recover data from hard drive? Thanks

  • Touch is frozen after trying to install 2.0 update

    I just unpacked my refurbished 16gb ipod touch, installed the latest version of itunes and even was able to throw a few songs on it. Trouble stuck when I tried dloading (purchased and paid for!) the 2.0 update so I could install the free games and ap

  • Cant accept agreement?

    On my notebook it wont go all the way down to the accept button to agree. I really hate having to go to town to print sumthing, please help solve this problem

  • Hardening Linux for Oracle 10g

    I have been working on creating a bare-bones RHEL 5 installation which will act as an Oracle 10g database server. For hardening Linux, I have restricted to a bare minimum of packages to make it more secure. This installation did not have X-Windows, G