Syntax for CASE / WHEN in SNP Macros.

Dear APO Gurus,
I'm having problems using CASE when in SNP macros, even though I've tried quite  a few syntaxes.
could someone please tell me how to Use CASE WHEN (WHEN WHEN WHEN...) ENDCASE in macros ? this would save me an awful lot of IF
Thanks in advance,
Hugues

Hi,
you can import an example macro to see how the CASE usage works. In order to do so, perform the following.
1.) Enter Makro Builder and enter your new macro book
2.) In the Menu, choose "Edit" -> "Import macros"
3.) Choose "SAP Example and template macros" as reference book
4.) use "Using the Case statement" as reference macro.
This will import the example macro which you can take as reference.
Best regards
Rico Frenzel

Similar Messages

  • Syntax for CASE Function when multiple values equates to the same result?

    Tried using the 'IN' keyword with the CASE function but it does not work, does each case have to be stated separately? trying to save some lines..
    tried:
    case me607.rmc_code
    when in ('M','MS','MP') then 'H311'
    end as carrier_code
    Do i have to do:
    case me607.rmc_code
    when 'M' then 'H311'
    when 'MS' then 'H311'
    when 'MP' then 'H311'
    end as carrier_code,
    etc..
    Thanks for any help..

    One other thing forgot to ask, how do you do a second case selection as:
    case when me607.rmc_code
    in ('M','MP','MS') then 'H311'
    case when me607.rmc_code
    in ('1','2') then 'H252'
    end as carrier code
    wanting to keep the results in carrier_code..
    Thanks..
    Edited by: user12296489 on Dec 10, 2009 3:53 PM

  • Pro C syntax and CASE WHEN

    Hi
    I'm developping an application using Pro C* in a C program. I have a problem, I would like to use a CASE WHEN statement inside a SELECT statement. I try the following code with compilation error:
    EXEC SQL PREPARE pr_avor_annul FROM
    INSERT INTO avor (NO_AVOR,MT_TOTL_AVOR,CD_DEVS,AC_STAT_AVOR,NO_FACT,MT_FRAS,
    MT_ARTC,AC_AVOR,NO_COMP,MT_FRAS_CONT_REMB,DT_AVOR)
    SELECT :vavor, mt_totl_fact + cout_livr + nvl(mt_fras_cont_remb,0), cd_devs,:vemis ,no_fact,cout_livr , mt_totl_fact, :vacavor, :vcomp, mt_fras_cont_remb,DECODE( (SELECT 0 FROM fact WHERE TO_CHAR(dt_fact)<TO_CHAR(sysdate)
    AND no_fact= :vfact),dt_fact, sysdate, dt_fact)
    FROM fact
    WHERE no_fact = :vfact;
    This code seems to be wrong but I don't know where...
    Somebody can help me??
    Thans a lot

    Hi,
    I'm not clear on the distinction you're making for type of access.
    Well, to be honest, now that I've re-read that this morning I'm not completely sure what I had in mind either. I think I was thinking about using the collection in what I believe the documentation calls "slices". However, given the other information you've posted it doesn't seem like that would be a feasible alternative in any case.
    I understand what you mean about varray and nested-table with the upper-bound limit for the varray's... I've not actually compared the two for performance so my idea that there may be a difference could be completely incorrect. Beyond that, creating code that only works in batches (or slices) may be less performant than what you currently have.
    I hope I've not detracted from the thread and maybe someone else with more experience will have an "ah ha!" sort of observation.
    Regards,
    Mark

  • What is the correct syntax for Sumif when condition is for a text string?

    B2 and b3 both contain the text "Grc".
    C2 contains 1 and C3 contains 2.
    F2 contains a Sumif that reads as: =SUMIF(B2:B10, "=Grc", C2:C10)
    The result is "0" when it should yield 3
    I can't figure out what happened.

    Hi ishii,
    Your screen shots make no sense to me. I am using Numbers'09 on a MacBook Pro running OS X. Please tell us what device, operating system and app you are using. You still have not told us.
    This forum is for Numbers on a Mac running OS X. Is your screen shot from an iOS device?
    I don't know anything about Numbers for iOS.
    Or are you using Excel?
    I can not help you. If you are using an iPad, you will get a better answer in this forum:
    https://discussions.apple.com/community/app_store/iwork_for_ios?view=discussions
    Regards,
    Ian.

  • Filter in business model using case when

    Dear Gurus,
    I have written this syntax on business logical layer WHERE CLAUSE:
    case  when 'All' = 'All' then upper(substring(Fact_Medication.DOCUMENT_ID_EXT from 1 for 3))
    else 'All' end
    *= upper(substring(Fact_Medication.DOCUMENT_ID_EXT from 1 for 3)*
    But, it was take too long to appear in dashboard, I'm afraid the syntax not proper.
    Does anyone know how to show all the data in oracle pl sql / obiee syntax ?
    I mean in Microsoft SQL we can use this Select * from A where column=''
    Please help this is urgent
    Regards
    JOE

    Hi,
    Thank for reply.
    This is my syntax (Revised):
    case when VALUEOF(NQ_SESSION."LOGIN")= 'All' then upper(substring(Fact_Medication.DOCUMENT_ID_EXT from 1 for 3))
    else VALUEOF(NQ_SESSION."LOGIN") end
    = upper(substring(Fact_Medication.DOCUMENT_ID_EXT from 1 for 3)
    I want if Login variable='All' then show all data, if not then show specific data.
    I though my query is right but it takes too long to appear in dashboard.
    Please help
    Regards
    JOE

  • Case when question

    Hi All,
    Is it possible to use case-when statement in this SQL query?
    select SUB_ID, count(T_ID),sum(TIME)
    from TABLE_A
    where SUB_ID <> ' '
    and STARTDATE between :P6_DATE_FROM and :P6_DATE_TO
    CASE :P6_FILTER_BY
    WHEN '1' THEN 'and SUB_ID like :P6_FILTER_BY_TEXT || ''@%'' '
    WHEN '2' THEN 'having sum(TIME) >= :P6_FILTER_BY_TEXT '
    END
    group by SUB_ID
    as it is it seems not to work...
    thanks
    Liron

    Hi,
    Is it possible to use case-when statement in this SQL query?Yes
    First of all you are using the wrong syntax of CASE.
    The correct syntax is :
       CASE
            WHEN var1 = 1  THEN
                       'One'
            WHEN var 2 = 2 THEN
                 'Two'
         ELSE
            'Three'
         ENDTell us your requirement we might suggest something ?
    Regards

  • Syntax for the macro - request suggestions...

    Dear All, Good morning..
    I request your help in craking the below issue..
    <i><b>Description:</b></i>
    Calculation of a KF based on the following formula:
    <b>Dlr Inv(M01/2007)= Max( ( sp.plan(m01/2007)+Dlr Inv(M12/2006) ) ; Threshold Dlr Inv(M01/2007) )- Un constrained sales( M01/2007)</b>
    If you observe in the above calculation, for calculating current month Dlr Inv, we are using previous months Dlr Inv..OK.
    <i><b>Requiremet:</b></i> Calculation of the above , plus, the above calculation may produce a negative number...So, when there is negative number generated in the curent month calculation, i should make it to zero, display zero and carry  that zero for next months calculation...
    I wrote a macro, which is doing above calculation perfectly(as it is simple )...except carrying zero to next month's calculation...As long as the above calculation is generating positive value, there is no issue at all..
    <i><b>Issue:</b></i> In some cases , the above formula results a negative number, in that case, i am able to make it zero,  and able to carry that zero for next calculation, if the negative is generated for the first column..problem is , if there is any negative generated in between,let us say, for  June/2006,  then its making it zero, but that zero is displayed for the subsequent months from there onwards, irrespective of  the result is positive or negative..If i chage any number at that period for any KF, and execute macro, then it is working..Here i used auxiliary row...
    I have written 3  macros with diff logic...If you want i can post them again ....
    I would like to know the following things regarding macro syntax..
    <b>1)Can we go for a condition after a result in the same step...?
    </b>
    <b>Example: 
    Step:(M01/2007-M12/2007)(12 iterations)
    Row 1= Row2 -Row 3
    IF
    Row 1 < 0
    Row 1 = 0
    ENDIF</b>
    If i execute IF condition in another step,It won't serve my purpose because, it comes to second step after completing all iterations in first step...I want , <b>IF</b> condtion to be checked after the first iteration..
    In my case, macro successfully activated  but no result for that condition..It is executed only up to result for the first time when i tested in Utilities--->test Macros..in the macro builder..if i execute it for the second time, then it gives result..Surprised..!!!
    2) <b>Is it possible to write syntax in the following way..</b>
    IF
    (condition)
    ( Row  1 + Row 2) < 0
    ResulT : Row 3=0
    In my case,
    It is not accepting +, - .....
    Kindly suggest...
    I am confident that i crack this with your mighty help..
    Thanks for reading..
    regards,
    umamahesh
    Message was edited by: Uma Mahesh
            Uma Maheswar kumar
    Message was edited by:
            Uma Maheswar kumar

    HI Vinayak,
    Thanks very much for responding..
    I appreciate your reply and time spent on this...
    Your solution goes to indefinate internal loop..
    In your solution, Vi-2 is the previuos years cell ref: which again needs calculation...
    Your solution works good if i have to use current motns calculation of one  KF in another...
    say
    A= B+C;(current month)
    D=AE( current momth)...then instead of AE, better we use, D=(BC) E...Actually i am not facing any problem in taking the previous months updated value...i am facing problem with IF loop in case of negative...
    I will try your option and come back to you...

  • What is the syntax for a CASE statement in Crystal XI

    I'm having difficulty locating documentation for the use of CASE statements in Crystal syntax. My database administrator does not allow me to write SQL expressions so I need to covert the SQL below to Crystal Syntax. Can anyone help me? Thank you very much!!
    Select
       CASE
             WHEN projects.ProjType like 'S%' then 'Shopping Center'
             WHEN projects.ProjType like 'I%' then 'Industrial'
             WHEN projects.ProjType like 'O%' then 'Office Building'
             ELSE 'Other'
       END
    from projects

    Let's assume column XYZ has both numbers (1), and letters (any alphabet).
    I have a case statement on SQL to turn any value that's not 1 into 0, then I am getting a sum of that column.
    I am also grouping by Row A, B etc to get aggregated sum of column XYZ for those group.
    Now on Crystal Reports function, I need to sum up values under column XYZ for all the groups.
    If I try using sum function like below, I get an error stating:
    "A number field or currency amount field is required here"
    (sum({Command.XYZ}))
    So I thought if I can use a case statement to change the non-numbers to 0 prior to sum that will probably resolve it. But I could not get the below case statement to work either (Error: A string is required). 
    SELECT {Command.XYZ}
       Case 1:
          1 
       Default:
          0;

  • CASE WHEN syntax error - Dreamweaver MX

    Hi Gurus,
    I am trying to use the statement in the Recordset creator tool Advanced Mode:
    select PayDay,
    case when getdate() > PayDay
    then 'Out of Time'
    Else 'On Time'
    End
    From tPayment
    But I get the error:
    Microsoft OLE DB Provider for ODBC Drivers erro '80040e14'
    [Microsoft][Driver ODBC Microsoft Access] Syntax error (Operator missing).
    Anyone help me, please!
    Thanks is advance.

    Hi bregent,
    Thank you very much for your response.
    1) Tell us which verison of Access you are using
    - I am using Access 2007
    2) Use the app dev forum for these questions
    - I couldn't find this forum here
    3)  I didn't think Access supported CASE statements outside of VBA.
    - If there insn't, could be any other workable instead this one
    4) I've never seen CASE/WHEN. Can you refer me to documentation that supports this syntax?
    - I use case/when on MSSQL, I need one that works with Dreamweaver in the recorset creator. What can I use to know if:
    Today is greater than PayDay in the tPayment table then It is must tell me that it is Out of Time (case when getdate() > PayDay then 'Out of Time')
    If the PayDay in the tPayment table is greater than today then it must tell me that it is is On Time (Else'On Time' End).
    That is what I am looking for.
    Thanks a lot!

  • Ssrs 2008 the report instead of showing Emp # want to show Emp Name , how i can write case when syntax

    working on SSRS report , pulling the data with Emp # I want to show with emp Name instead,
    is there way to write case when syntax so it can show only emp name instead of emp #
    for example
    Emp #        Emp Name
    144                 Kevin
    want report to pick the name as Kevin instead of 144
    any help will be great
    thansk

    thanks for reply RSingh
    I tried changing the query as you suggested
    SELECT [EMP #], [EMP NAME], FIELD1, FIELD2 FROM TABLENAME
    it did not work,  getting error message
    empLid  table name JMGPAYEMPLOYEE  and there is no emp name field
    when I modify the query as per above getting error message
    because I have 2 data set
    1.  Projid
    2. Projgroupid
    3.  parameter I have date
    below is my query
    SELECT        PROJTABLE.PROJID, PROJTABLE.PROJGROUPID, PROJTABLE.DATAAREAID, JMGPAYEMPLOYEE.EMPLID, PROJTRANSPOSTING.QTY, JMGPAYEMPLOYEE.PRICE,
                             PROJTABLE.DIMENSION2_, PROJTRANSPOSTING.POSTINGTYPE, PROJTRANSPOSTING.COSTSALES, PROJTRANSPOSTING.PROJTRANSDATE,
                             CATEGORYTABLE.CATEGORYNAME
    FROM            PROJTABLE INNER JOIN
                             PROJTRANSPOSTING ON PROJTABLE.PROJID = PROJTRANSPOSTING.PROJID AND PROJTABLE.DATAAREAID = PROJTRANSPOSTING.DATAAREAID
    INNER JOIN
                             JMGPAYEMPLOYEE ON PROJTRANSPOSTING.DATAAREAID = JMGPAYEMPLOYEE.DATAAREAID AND
                             PROJTRANSPOSTING.EMPLITEMID = JMGPAYEMPLOYEE.EMPLID INNER JOIN
                             CATEGORYTABLE ON JMGPAYEMPLOYEE.DATAAREAID = CATEGORYTABLE.DATAAREAID AND
                             JMGPAYEMPLOYEE.EMPLID = CATEGORYTABLE.CATEGORYID
    WHERE        (PROJTRANSPOSTING.COSTSALES = 1) AND (PROJTRANSPOSTING.POSTINGTYPE = 121) AND (PROJTRANSPOSTING.PROJTRANSDATE >= @Paramfromdate) AND
                             (PROJTRANSPOSTING.PROJTRANSDATE <= @ParamTodate)
    any advise will be helpful
    thanks

  • Using CASE WHEN for Essbase column in OBIEE 11g

    Hi all,
    I have a business model in OBIEE 11g, taking the source from Essbase 11. The measures of the Essbase cube in the physical layer is flattened, and the aggregations for the measures are set to SUM.
    The Product dimension has 5 generations. In Product logical table, I created a logical column called "Product Grouping" using a simple CASE WHEN formula:
    CASE
    WHEN "TEST"."Product"."Gen5,Product" IN ('100-10', '100-20', '200-10', '300-10') THEN 'Group 1'
    WHEN "TEST"."Product"."Gen5,Product" IN ('100-30', '200-20') THEN 'Group 2'
    ELSE 'Group 3'
    END
    Problems:
    1. If I don't place this "Product Grouping" in the logical level/hierarchy, I got error in the report when I simply show Product Grouping and a measure.
    2. If I place this "Product Grouping" in the logical level/hierarchy (on the 5th level), no more error in the report when I simply show "Product Grouping" and a measure. The measure value also shows the correct SUM (group by). However, when I add "Gen1,Product" the "Product Grouping" and the measure value suddenly becomes not grouped by.
    Has anyone ever tried and encountered something like this? Any thoughts?
    Thank you very much!

    Hi Deepak, thansk for the suggestion.
    However, I can't use calculated item for this report because:
    1. incorrect result will be shown when my measures involve a formula to derive a percentage value.
    2. calculated item is not available if we do "combine requests" (or union) in 11g.
    Any thoughts anyone on how to solve this? Is this just me, or it's a bug?
    Thank you very much.

  • Need help converting Excel IF statement into CASE WHEN statement for Oracle

    Hi,
    Hope someone can help I have tried various ways of getting this to work, to no avail!
    Bascially I have some figures that are minus figures, and I need to add them together to get a movement figure, but I need to treat the minus figures as minus, if that makes sense, rather than the usual... a minus and a minus makes a plus.
    For example:- Budget Figure = -1% and Actual Figure = -68% so the movement needs to be -69%.
    The IF statement I have been using in Excel is the following:-
    =IF(FO110<0,(FP110-(IF(FO110=0,1,FO110)*-1)),FP110-IF(FO110=0,1,FO110))
    Which when using the figures as above = -69%
    Cell FO = The Budget Figure
    Cell FP = The Actual Figure
    However, when I created the CASE statement in Oracle, the figure in the query comes back as -0.67, which is oviously not what I want to happen when both actual and budget are minus figures; however when they are a minus and a plus, it works perfectly fine.
    Any help on this would be most appreciated!
    Kind regards,
    Annmarie

    Happy I did'n mess something up :)
    Nevertheless, don't show it too much around because
    case when budget < 0
         then actual - case when budget = 0  /* will never happen */
                            then 1           /* will never happen */
                            else budget
                       end * (-1)            /* -budget * (-1) remains only */
         else actual - case when budget = 0
                            then 1
                            else budget
                       end
    endso at least try the following (if case is more readable as decode for you). Let's hope it works as I don't have a Database at hand
    case when budget < 0
         then actual + budget
         else actual - case when budget = 0
                            then 1
                            else budget
                       end
    end Regards
    Etbin

  • Loop  wirh for using case when

    Hello,
    i wanna use a loop over a select
    but this select depend on a variable value
    so, here is what i did:
    CREATE OR REPLACE Procedure dispatch_pat(perId in number,shortlist_ID in number,orId in number, typeDonnee in number) is
    orVar number(7);
    test number;
    begin
    for orVar in (case when (orId <> 0) then (select OR_ID as id from ordre_regrpmt where or_id=orId) else (select OR_ID as id from ordre_regrpmt where or_id in ( select or_id from DETAIL_SHORT_LIST where ORSHORTLIST_ID=shortlist_ID)) end) loop
    select count(*) into test from ajust_pat where (OR_ID=orVar) and (PER_ID=perId);
    if (test=0) then
    insert into ajust_pat (OR_ID,PER_ID,GENE_ID) values (orVar.id,perId,typeDonnee);
    end if;
    end loop;
    end;
    but i got this error :
    On line: 5
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    Regards
    Sallemel

    Try this code
    /* Formatted on 2009/03/06 08:23 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PROCEDURE dispatch_pat (
       perid          IN   NUMBER,
       shortlist_id   IN   NUMBER,
       orid           IN   NUMBER,
       typedonnee     IN   NUMBER
    IS
       orvar   NUMBER (7);
       TEST    NUMBER;
    BEGIN
       IF orid = 0
       THEN
          FOR orvar IN (SELECT or_id AS ID
                          FROM ordre_regrpmt
                         WHERE or_id = orid)
          LOOP
             SELECT COUNT (*)
               INTO TEST
               FROM ajust_pat
              WHERE (or_id = orvar) AND (per_id = perid);
             IF (TEST = 0)
             THEN
                INSERT INTO ajust_pat
                            (or_id, per_id, gene_id
                     VALUES (orvar.ID, perid, typedonnee
             END IF;
          END LOOP;
       ELSE
          FOR orvar IN (SELECT or_id AS ID
                          FROM ordre_regrpmt
                         WHERE or_id IN (SELECT or_id
                                           FROM detail_short_list
                                          WHERE orshortlist_id = shortlist_id))
          LOOP
             SELECT COUNT (*)
               INTO TEST
               FROM ajust_pat
              WHERE (or_id = orvar) AND (per_id = perid);
             IF (TEST = 0)
             THEN
                INSERT INTO ajust_pat
                            (or_id, per_id, gene_id
                     VALUES (orvar.ID, perid, typedonnee
             END IF;
          END LOOP;
       END IF;
    END;
    /

  • Macro syntax for non-negativity

    Hi,
    Could some one copy past the syntax for non-negativity like this
    If KF1 < 0, then KF1 = 0 else KF1
    This condition needs to be applied on top of existing macro for KF1 that does some arithmatic whose result could be < 0.
    would appreciate if you copy paste the steps.. that you may already have in any of your macro books.
    I also take this opportunity to request the macro experts to compile a wiki document on macro syntax.. A piecemeal approach would also do without relating to WHERE such a macro could be used. I find this learning the macro syntax by trial and error a rather unproductive and painful experience.
    If some of you could volunteer lets build a fantastic reference document on the macros where everyone can contribute and come with with something really useful.
    The final list can then be classified into artithmatical, conditional, control, abap macros. A brief description alongside each macro and some expert comments on possible application can be later expanded. newer and alternate ways of realzing the same macro creatively and in lesser steps could be regularly appended. I could moderate if such a thing is correct and agreeable
    Regards,
    Loknath

    I cant have more than 10 questions open. so closing this though there arent any responses

  • Equivlent CASE WHEN query for Oracle 8.05

    Is there a way to construct a query similar to the statement below in Oracle version 8.05?
    SELECT ename, CASE WHEN empid>10000 THEN 'Old Timer' ELSE 'New Comer' END
    FROM employees;
    I would like to use a single select query to handle such situations. Thanks for any suggestions.
    Roger

    sql>select empid,
      2         decode(sign(10001 - empid), 1, 'Newcomer', 'Oldtimer') description
      3    from foo
      4   order by empid;
        EMPID DESCRIPT
         9999 Newcomer
        10000 Newcomer
        10001 Oldtimer
        10002 Oldtimer

Maybe you are looking for

  • Links in a document library

    I am developing a document library where resources/documents can either be 'real' documents or just links to documents on the web. Is it possible to have this kind of amalgamation (both links and documents) inside document library? If I remember it c

  • Workitem is not generating for an Inbound Idoc

    Hi All, The problem I am facing, when inbound idoc is processing in SAP, if there are any errors occurred, it would generate a work item and that will be sent to user Inbox (SBWP) as per the workflow. Here it is not generating a work item for an inbo

  • Conversion error removes entered values in the form

    I have like 10 blocks of data in my jsf page. In my 7th block my date field gives a conversion error, then some of the fields entered above 7th block are removed and some of them after 7th block. why this happens??

  • Can I use imovie 4 on leopard

    Hi, Have just tried the new imovie8 and it can't do what the old one can. Can I download iMovie 4 and use it on leopard? iMovie 6hd requires me to reinstall iLife 8 and I am traveling and can't do it for a couple of weeks. My next hope is Imovie 4. A

  • Blue Snowflake Mic won't recognize on Snow Leopard

    I just purchased a Brand New Blue USB Snowflake Mic, and when I plug it into my 2006 Mac Pro running OS X 10.6.5, it won't show up in the Sound System Preferences. I do not know what to do. It says it works with OS X, but I can't get my Mac to see it