How to do IF THEN  ELSE logic in Workflow?

I need to do "if then else" logic in Workflow. The key part of the probem is that there are several "else" (elsif) possibilities, so I can't use a Boolean or Yes/No as a return result code. When I use a function, I can't see a way to "check" the value before it passes to a next process. HELP!

Whether you are using a function as your comparator or the Standard WF Compare Operators, this can be done. I will explain two scenarios, one with your own written functions as the comparator and the other using the standard Compare Text function.
Create a PL/SQL procedure that returns a boolean. In this procedure you would pull two attributes from the workflow, the test case and the value you want to compare to. You would check to see if they are equal and return true, otherwise false. I do not know what you are trying to compare in your if statement, but whatever it is, if its true, return true, otherwise false.
Now in the workflow, you would put a couple of these in your process diagram representing each if statement. Set the two (or more) attributes in the Node Attributes tab of each function node to the values you want to compare. For the first node, have the <true> transition go to whatever you want done and then to an END node. Have the <default> or <false> transition point to the next function node you have. Do the same for each one except at the last one, its only transition would be <default> and that would go to END. This way if the first function resolves true, it will do whatever should be done and then skip the rest of the conditions. If its false, it will go to the next conditional. The last one will be gotten to only if every other conditional was false that would be your final else statement.
To do this with the Compare Text option, have the same set up in your workflow diagram exception have the <EQUALS> be your true path and the <DEFAULT> transition go to the next compare text node.
-->O-{default}->O-{default}->O->default
     |                 |                 |             |
    true           true            true           |
     |                 |                 |             |
  doWork     doWork     doWork      else
     |                 |                 |             |
      ---------------->---------------->------------|
                                                      |
                                                  end

Similar Messages

  • 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 a if else logic expression for this condition

    Hai All
    I have written some if else logic for for my condition
    If the time is betweeb 0145 and 0630 and timeout is a column in a table is null than update sysdate-1
    then if time is bet0645 and 0900 then timein is null then insert into timein in table called dail_att
    and time bet 1130 and 1300 then if barcode null then insert timein else update timeout
    and bet 1645 and1730 then if barcode null and timein null then insert timein or update time out
    this is my condition for generating attendance. Ive tried some logic and pls tell case executed faster than ifelse logic
    and give me a soluton
    This is my coding
    if :bartime between 0145 and 0630 and :barcode is not null then
    update dail_att
    set timeout = :bartime
    where barcode= :barcode
    and timein is not null
    and ATTEND_DATE = :BARDATE-1;
    else if :bartime between 0645 and 0900 and :barcode is null then
    insert into dail_att(barcode,timein,attend_date)
    values(:barcode,:bartime,:bardate);
    else if     :bartime between 1145 and 1300 and :barcode is null then
         insert into dail_att(barcode,timein,attend_date)
    values(:barcode,:bartime,:bardate);
    else
         update dail_att
    set timeout = :bartime
    where barcode= :barcode
    and ATTEND_DATE = :BARDATE ;
    end if;
    else if :bartime between 1645 and 1730 and :barcode is null then
              insert into dail_att(barcode,timein,attend_date)
    values(:barcode,:bartime,:bardate);
    else
         update dail_att
    set timeout = :bartime
    where barcode= :barcode
    and ATTEND_DATE = :BARDATE ;
    end if;
    else :bartime > 1730 and :barcode is null then
         update dail_att
    set timeout = :bartime
    where barcode= :barcode
    and ATTEND_DATE = :BARDATE ;
    end if ;
    EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE' OR :BARCODE IS NULL;
    NEXT_RECORD;
    forms_ddl('commit');
    end loop;
    Regards
    Srikkanth.M

    Hai Sir
    I am storing time in 24hrs format and its datatype is varchar.Pls tell me we can write an if else with in a elseif
    Regards
    Srikkanth.M

  • How to use if-then-else-end if in template building?

    hi,
    I am not able to use the "if-then-else-end if" in my template. I want to display a data based on a condition. My requirement is as follows:
    if bal_for_vd < 0 then
    bal_for_vd * no_of_days
    else 0
    end if
    I tried using
    1.<?if: BAL_FOR_VD < 0 then BAL_FOR_VD*NO_OF_DAYS else 0 end if?>
    2.<?xdofx:if BAL_FOR_VD < 0 then BAL_FOR_VD * NO_OF_DAYS end if?>
    3.<?choose:?>
    <?when:BAL_FOR_VD < 0?> <?BAL_FOR_VD * NO_OF_DAYS ?>
    <?end when?>
    <?otherwise?>0
    <?end otherwise?>
    <?end choose?>
    4.<?if:BAL_FOR_VD < 0?><?BAL_FOR_VD*NO_OF_DAYS?><end if?>
    but ended up getting errors or nothing is getting displayed.
    When i used <?BAL_FOR_VD * NO_OF_DAYS ?> alone its working fine and correct getting result. But on giving condition its erring out.
    I will be glad if i get some solution for this.
    Regards,
    Vishnu T Ramakrishnan

    Hi..
    Below syntax should work..I tried with a sample xml..
    <?xdofx:if BAL_FOR_VD < 0 then BAL_FOR_VD * NO_OF_DAYS
      else
    0
    end if?>HTH..

  • 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

  • How to implement "if/then/else" or "case" logic in a Statement Expression?

    I need a loop in my test sequence, so I define a Locals.LoopIndex which is of type Number, and I also define a Locals.PromptMessage, which is of type String. Within the loop body, have a statement step, in which I want to assign Locals.PromptMessage different strings according to the value of Locals.LoopIndex. The logic is like this (in suedo code)
    case Locals.LoopIndex:
    1: Locals.PromptMessage = "string1";
    break;
    2: Locals.PromptMessage = "string2";
    break;
    or
    if (Locals.LoopIndex == 1)
    then Locals.PromptMessage = "string1";
    else if (Locals.LoopIndex == 2)
    then Locals.PromptMessage = "string2";
    How can I implement this in the Statement Expression?
    Thanks!

    You can use the conditional expression (not sure what it is called). Syntax is Locals.variable=(BooleanExpression?ValueIfTrue:ValueIfFalse). To implement your pseudo code it would look like this:
    Locals.PromptMessage=(Locals.LoopIndex==1?"string1":"string2")
    This means the same as:
    If Locals.LoopIndex=1 then
    Locals.PromptMessage = "string1"
    Else
    Locals.PromptMessage = "string2"
    End If
    Another way to do it is like this, but the first method is preferred:
    Locals.LoopIndex==1?(Locals.PromptMessage="string1")Locals.PromptMessage="string2") -- must use parenthesis as shown
    This syntax is BooleanExpression?(Statement if BooleanExpression is true)Statement if BooleanExpression is false)
    You can nest the expression to create ElseIf conditions:
    Locals.PromptMessage=(Locals.LoopIndex==1?"string1"Locals.LoopIndex==2?"string2":"string3"))
    This means the same as:
    If Locals.LoopIndex=1 then
    Locals.PromptMessage = "string1"
    ElseIf Locals.LoopIndex=2 then
    Locals.PromptMessage = "string2"
    Else
    Locals.PromptMessage = "string3"
    End If
    I don't know if there is a limit to the nesting.
    Hope this helps.
    - tbob
    Inventor of the WORM Global

  • If else logic in select statement

    Hi,
    Can someone kindly explain me how can i use if-else logic in the place of case statement in the below query.
    SELECT deptno, empno, ename, sal,
                 CASE
                    WHEN deptno = 10
                       THEN sal * 0.05
                    WHEN deptno = 20
                       THEN sal * 0.10
                 END AS new_sal
            FROM emp;Thanks in advance!!

    CREATE OR REPLACE PROCEDURE calsal
    IS
       new_sal number;
       CURSOR sal_cursor
       IS
          SELECT deptno, empno, ename, sal
            FROM emp;
    BEGIN
       FOR i IN sal_cursor
       LOOP
              if i.deptno = 10 then
                   new_sal := i.sal *0.05 ;
               DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                                || i.empno
                                || ' is '
                                || (new_sal)
           elsif i.deptno = 20 then
                   new_sal := i.sal *0.1 ;
               DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                                || i.empno
                                || ' is '
                                || (new_sal)
           else
                     new_sal := 0 ;
               DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                                || i.empno
                                || ' is '
                                || (new_sal)
           end if;
       END LOOP;
    END;
    / Are you learning Oracle or sql or pl/sql ?
    The syntax and example of if in oracle is easily awailable in bunch of documents provided in google search results..
    Regards,
    Dipali..

  • IF THEN ELSE in DATA TEMPLATE NOT IN RTF

    Hi,
    Can any one tell me How to Implement IF THEN ELSE or DECODE or CASE Logic in a DATA TEMPLATE not in RTF
    as I saw loads of Post about implementing them in RTF not in the Template itself.
    I have a requirement please click this below for the Detailed Version of this Post, Else Please Just give me a Snippet from which i can Implement the IF THEN ELSE Logic in a DATA TEMPLATE( the .xml file) bu please not via a RTF not using PL/SQL Package
    Logic to select Report name based on User's input.
    Thanks
    vasanthanand

    Hello
    I am looking to do the same type of thing did you ever get an answer without having to use a RTF format perhaps in another forum or through investigation?

  • 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

  • Using if the else logic in regards to a select statement for a report

    Hi all,
    I've a question regarding if then else logic in Oracle.
    I'm developing a report application which contains 3 selectlists
    - ProductGroup - SubGroup - Manufacturer
    Each one containing several values. And are based on eachother, meaning if you select an item from the PG list, you only get the SG items regarding the PG item you've choosen before. The process logic should be as the following:
    When a user selects one item from for example the PG list, the query will be:
    select * from x where PG = :P_PG
    and the report displays all the items in the PG category selected
    The other two bindvariables would be null as the user didn't pick them
    If he then proceeds and selects one item from the SG list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG
    and the report displays all the items in the PG and SG category selected
    If he then proceeds and selects one item from the MA list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG and MA =:P_MA
    and the report displays all the items in the PG and SG and MA category selected
    Now, I've read some documentation about the decode function, but I can't figure it out, please help.
    Peter

    Okay, Chet, have set it up on htmldb, so you can see my problem, will go in high detail, it is not producing what I want. Example on htmldb:
    DEMO/test
    http://htmldb.oracle.com/pls/otn/f?p=33229:6
    Defenitions:
    3 LOV's, namely:
    - LOVPG - select distinct productgroep, productgroep pg from plijst
    - LOVSG - select distinct subgroep, subgroep sg from plijst where productgroep = :P6_LOVPG
    - LOVLE- select distinct leverancier, leverancier le from plijst where productgroep = :P6_LOVPG and subgroep = :P6_LOVSG
    3 Selectitems with submit, namely:
    - :P6_LOVPG
    - :P6_LOVSG
    - :P6_LOVLE
    Report region select statement:
    select * from plijst where (productgroep = :P6_LOVPG or :P6_LOVPG IS NULL) and (subgroep = :P6_LOVSG or :P6_LOVSG IS NULL) and (leverancier = :P6_LOVLE or :P6_LOVLE IS NULL)
    Branch to:
    Branche to page on submit after processing
    What it should do is:
    When you select an item from the first selectlist, productgroep, the report should show all rows containing the specified productgroep.
    When the user selects the next item in the subgroep selectlist, the report should show all rows containing the previously selected prodctgroup and the just selected subgroep.
    When the user selects the final item , the report should show all rows based on all three selected itemvalues, productgroep, subgroep, leverancier.
    The problem is that with this setup the report is only generated after the final selectlist choice of the user. But the user should see a report before that, going deeper into the structure. Hope, you see my problem?
    Sincerely,
    Pete

  • 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

  • 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

  • How to total 2 colums with an -If then else- statement each

    Hello,
    I have 2 colums A en B who generate data based on an “If then else” statement.
    Colum A
    <?xdofx:if (OMZET_YTD_VJ )!='' then ((OMZET_YTD_VJ) * (BM_YTD - BM_YTD_VJ)) div 100 else 0 end if?>
    Colum B
    <?xdofx:if (BM_YTD)!='' then ((BM_YTD) * (OMZET_YTD - OMZET_YTD_VJ)) div 100 else 0 end if?>
    Colum C needs to be the sum of both. Who can help me?
    Thanks a lot.

    Can you send me the RTF template and xml file to [email protected]? I can take a look and try to help.
    Thanks,
    Bipuser

  • Implementing if then else condition

    Hi! All
    It would be very helpful if i can get answer of how to implement the condition below, using the functions available in graphical mapping editor....
    I need to map 2 source fields to 1 Target field, based on the condition that field(source) is populated in the target field only if field 1 is null.
    Source----->Target
    part_id1----
    >part_num(if part_id1 is null,then part_id2)
    part_id2----
    >
    I tried using if then else function, it is working fine but errors out when part_id is null....need to make it work even when part_id1 or part_id2 is null.If both fields are null it should not populate anything.The boolean function is not accepting null inputs...
    Please, let me know if there is a better way to implement this logic...Thanks a lot!
    Regards,
    Patrick

    Jones,
    Have this logic in your mapping:
    part_id1>exists>and
    part_id1>equals(textfunction)>null(take constant and dont put any value in it)>equals(text funciton)>false
    Give the above two to if
    Then in the then part give part_id1 and in the else part give part_id2.
    So in the above if part_id1 exists and equals to null then part_id2 will be output and part_id1 exists and not equals to null then part_id1 will be the output and part_id1 doesnot exist then part_id2 will be the output.
    Regards,
    ---Satish

  • If Then Else Statement in SAP R/3 BW

    Hi,
    Does anyone know how to create an If Then Else statement in BEX?
    Thanks,
    Mounika.

    Hi mounika,
    do this way
    If 'material number' > 0.
    rslt = 'enter into table'.
    else.
    rslt = 15.
    endif.
    A True condition always evaluates to 1, a False condition evaluates to 0.
    for more quieries in bw ..pls go through  the link
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw
    pls reward if helps,
    regards.

Maybe you are looking for

  • Activate Office 2011 after formatting HD

    Hi all, I'm going to format my main partition in order to re-install SL. I have already installed and activated Office 2011 Business. What do you suggest: Backup the apps folder and restore it after the format or reinstall Office? I want to proceed w

  • Select in an internal table

    I realize that you can't do a select on an internal table but I need to do something identical to that.  I need to replicate the following code: SELECT * FROM it_detail INTO it_temp WHERE matnr = wa_detail-matnr. it_detail is of type ty_detail which

  • USB Switch for P1006?

    Please help!  I probably need to learn to set up a network, but for now I am trying to use  a Belkin F1U200 4-port  switch so that my HP P1006 Laserjet can work from two computers.  I am getting a "USB Device Not Recognized" message in my icon tray a

  • How do I remove duplicate photos on my iMac

    HOw can I remove duplicate photos I seem to have done something wrong and have 5 duplicates of everything

  • Deserialization Failed when testing BAPI exposed as a web service

    Hello, I have created a webservice by expoing BAPI_EQMT_MODIFY. I am planning on using this service to add partner information to an equipment from a .Net UI. When I test the service from the web service home page, I get an error message: "Deserializ