Skip to Content
author's profile photo Former Member
Former Member

How to create formula when we want to go for if..else statement

Hi All,

I have some doubt about creating a formula at query level if we want to go for If..Else like below

IF WA_SALESREP-INCOTERMS1 EQ 'DDP'.

WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP - WA_SALESREP-FREIGHTDISCOUNT ).

ELSE.

WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES.

ENDIF.


I know how to do for the below statement

WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP - WA_SALESREP-FREIGHTDISCOUNT ).


But I want to know how to write if it is with IF Else statement in formula.


Is there any where else can we write such type of statement? How?




Thanks,

Seshu

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2014 at 08:58 AM

    Hi Seshu,

    Use this, It should work in Bex analyser formula.

    (WA_SALESREP-INCOTERMS1 = 'DDP' *

    WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP - WA_SALESREP-FREIGHTDISCOUNT ).

    + WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES

    Use * for 'THEN', + for 'ELSE'

    Regards

    Devesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2014 at 10:51 AM

    Hi Sesha,

    IF WA_SALESREP-INCOTERMS1 EQ 'DDP'.

    WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP - WA_SALESREP-FREIGHTDISCOUNT ).

    ELSE.

    WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES.

    ENDIF.


    I know how to do for the below statement

    WA_SALESREP-NETSALES = WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP -WA_SALESREP-FREIGHTDISCOUNT ).



    Create a CKF

    If

    (A = B * C ) = C

    Else

    D

    Endif.




    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Sesha,

      You need to split what you want....

      I will give an example...based on that you write the IF Else Statement.

      If Order Type = C (Closed) and O (Open) in your case its 'DDP'.

      I will create a RKF1 with Order Type C and Net Quantity.

      I will create a RKF2 with Order Type O and Total Quantity.

      IF Delivery Date > Cal Day * RKF1 (Net Quantity)

      +

      Delivery Date < Cal Day * RKF2.(Total Quantity

      Here based on the Status of the Order you want to do calculations..i.e.e net and Total Quantity based on the Date Condition.

      I hope you got an idea...try to break up the KPIs...it wud be easy..

      regards

      SVU123

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2014 at 12:11 PM

    Hi Sesha,

    I am assuming WA_SALESREP-INCOTERMS1 is available in query drill-down in output.

    Step-1: Create a dummy CKF (DDP_CKF1) and in formula pane keep '1' .

    Step-2: Create a RKF (DDP_RKF1) on above created CKF with restriction of WA_SALESREP-INCOTERMS1 = DDP .

    Step-3: Now keep this RKF in keyfigure pane and hide it.

    Step-4: Now create formula like below

    (DDP_RKF1 = 1 * (WA_SALESREP-GROSSSALES - ( WA_SALESREP-FREIGHTDDP - WA_SALESREP-FREIGHTDISCOUNT )) + WA_SALESREP-GROSSSALES

    Hope this will give you direction to achieve your requirement.

    Note: DDP_RKF1 is RKF which we created in formula we just need to keep calculation "WA_SALESREP-NETSALES" is not required because this

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jain,

      Thanks for ur reply.

      when i am trying to do in the same way as u said, getting double the value.

      It's getting sales value double means its not executing else.

      Please let me know further.

      Thanks.

      Seshu

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.