Case, end case statement

Hi all,
name of my internal table is my_tab.i need to calculate the discounts depending upon the condition types(KSCHL) FROM KONV TABLE.
WHEN KSCHL = ZDO1 calulation procedure is in percentage
            KSCHL= ZD02   calculation procedure is in fixed amount.
            and so on.....
my_tab has fields
my_tab-total
my_tab-discount
if kschl = ZD01, discount = my_tab-total - my_tab-discount
if kschl = ZD02, discount =  my_tab-total * my_tab-discount/100.
i wanted to know how to use this in CASE AND END CASE statement.
regards
akmal

Hi akmal,
chek out this code.
Case kshcl.
when 'ZD01'.
discount = my_tab-total - my_tab-discount.
when 'ZD02'.
if kschl = ZD02, discount = my_tab-total * my_tab-discount/100.
end case.
if you ar looping through the internal table sthen  you can do the same af ter the when statements.
regards,
sateesh.

Similar Messages

  • Left joins : Case or if statement

    Hi
    I want to know if one can build in a case or if statement into a left join. I want to multiply a value with -1 if the condition is met.

    I think it is not possible in SELECT statement...but you can do the below to resolve it.
    add a field for FKART in your internal table.
    TYPES: BEGIN OF tab ,
           kunag LIKE vbrk-kunag,
           fkdat like vbrk-fkdat,
           matnr LIKE vbrp-matnr,
           werks LIKE vbrp-werks,
           fkart like vbrk-fkart,
           volum LIKE vbrp-volum,
           END OF tab.
    DATA: wa_outtab TYPE table of tab WITH HEADER LINE.
    SELECT akunag  afkdat
           bmatnr bwerks a~fkart
           SUM( b~volum )
       INTO  table wa_outtab
    FROM vbrk AS a
    INNER JOIN vbrp AS b
          ON  avbeln  = bvbeln
    WHERE
    avbeln = bvbeln                                                                               
    AND ( afkart LIKE 'F2' OR afkart LIKE 'RE' )
    GROUP BY  akunag afkdat bmatnr bwerks a~fkart.
    sort wa_outtab.
    Loop at wa_outtab.
      if wa_outtab-fkart = 'RE'.
        lpos = lpos +  wa_outtab-volum.
      else.
        lneg = lneg +  wa_outtab-volum.
      endif.
      at end of werks.
         lvaule = lpos - lneg.
        lpos = lneg = 0.
      endat.
    endloop.

  • Use of Case in Select statement

    Hi All,
    Can anyone tell me whats wrong im doing in the following select statement. I am selecting most this fields from Global Temperory Table and few from normal DB tables.
    select h.Taskid,h.Flowid,fd.DESCRIPTION Flowname,h.Stepid, sd.DESCRIPTION Stepname,h.Lockby,ud.USERNAME,h.Status,case Date_initiated when (Currval.Testid = Nextval.Testid) Then Date_initiated := NULL Else Date_initiated := Date_initiated End case,case UserTime When ((Currval-1).Testid IS NULL or Currval.Testid <> (Currval-1).Testid) Then UserTime := StartTime When (Currval.Testid = (Currval-1).Testid or Currval.Testid <> Nextval.Testid or Nextval.Testid IS NULL) Then UserTime = (Currval-1).Endtime End case,case StartTime When(Currval.Stepid = Nextval.Stepid or Currval.Stepid=9999) Then StartTime := NULL Else StartTime := StartTime End case,h.EndTime,h.LockTime,h.Drawer,h.FileNo,h.DocType from GlobalTempTest h inner join USERDEFINITION ud on h.Lockby=ud.USERID inner join FLOWDEFINITION fd on h.Flowid=fd.FLOWID inner join STEPDEFINITION sd on (h.Stepid=sd.STEPID and h.Flowid=sd.FLOWID)
    Hope so get some response soon.
    Thanks in Advance

    You have to rewrite your code like this:
    CASE WHEN (Currval.Testid = Nextval.Testid) THEN NULL
                                                ELSE Date_initiated
                                                END New_Date_initiatedCurrval/Nextval as shown in your example will not work. Please explain what you mean by previous value comparison.
    C.

  • Case in Select Statement - Ramya

    Hi All,
    Could any body help me out ,how to use the CASE in select Statement
    Thanks in Advance

    here is an example:
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> select empno,
      2         ename,
      3         job,
      4         case when job = 'PRESIDENT' then 1
      5              when job = 'MANAGER' then 2
      6              when job = 'SUPERVISOR' then 3
      7              else 4
      8         end rank
      9    from emp;
         EMPNO ENAME      JOB             RANK
          7566 JONES      MANAGER            2
          7902 FORD       ANALYST            4
          7839 KING       PRESIDENT          1
          7698 BLAKE      MANAGER            2
          7782 CLARK      MANAGER            2
          7369 SMITH      CLERK              4
          7499 ALLEN      SALESMAN           4
          7521 WARD       SALESMAN           4
          7654 MARTIN     SALESMAN           4
          7788 SCOTT      ANALYST            4
          7844 TURNER     SALESMAN           4
          7876 ADAMS      CLERK              4
          7900 JAMES      CLERK              4
          7934 MILLER     CLERK              4
    14 rows selected.
    SQL>

  • When Case End;

    Hi,
    I tryed to write a cursor with When Case End; construct insted of using Decode, But It is not taking the When Case End; construct inseide a pl/sql cursor. But it is working with simple sql construct.

    The reason for the odd message you got is that Oracle 9iDB is introducing a CASE statement of its own, although why Oracle have bothered is beyond me: IF...ELSIF...ELSE is a case construct in all but name.
    APC

  • DO CASE ..... END CASE in PL/SQL

    HI all,
    Is there any equivalent commanad in pl/sql to get the conditional statement which you can get it from DO CASE ... END CASE statements in any other language..
    Thanx
    Mayur

    You can use DECODE if you simply want to return a value based on what was sent in. Otherwise, I think the key way is to just use IF and ELSIF to get done what you need. I don't think there is a CASE or SWITCH, but I could be wrong.

  • Case in Update statement

    hi,
    How to use the case or decode statement in Update statement.

    Welcome to Oracle Technology network!
    This forum is for SQL*Developer issues - things realed directly to Oracle's SQL*Developer product. Your quesiton about CASE statements in UPDATES is a general SQL question. You will get a better answer if you close this thread and open it again in the SQL and PL/SQL forum which is for SQL questions

  • Case in insert  statement

    I am trying to use an case staemnet in oracle
    create table test1 (Status varchar2(10);
    declare
    Status varchar2(02);
    begin
    Status := '1'
    insert into test1 values (case Status when '1' then 'CREATE' when '2' then 'UPDATE' when '3' then 'DELETE else 'INVALID' end case);
    end;
    /

    I'm assuming you're getting a bunch of syntax errors:
    SQL> create table test1 (Status varchar2(10));
    Table created.
    SQL>
    SQL> declare
      2  Status varchar2(02);
      3  begin
      4  Status := '1';
      5  insert into test1 values (case Status
      6                                 when '1' then 'CREATE'
      7                                 when '2' then 'UPDATE'
      8                                 when '3' then 'DELETE'
      9                                 else 'INVALID'
    10                            end);
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> select * from test1;
    STATUS
    CREATE

  • Use event to jump to a case in a state machine

    How would I use an event to force a jump to a certain case in a state machine? For example, in the attached VI, I have a state machine that will simply blink a green LED indicator on and off for five seconds. I have a case in which the LED turns red for five seconds and a button which I would like to use to jump to this case. In other words, if the state machine is currently halfway (2.5 seconds) through my "Green_Light_ON" case when the button is pressed, I would like the state machine to immediately jump out of the "Green_Light_ON" case and into the "Red_Light_ON" case. This is not my ACTUAL VI, but it's a simplified example that will work for finding my solution. Thank you very much in advance for your help! 
    Attachments:
    DemoStateMachine.zip ‏18 KB

    Sounds like the classic "Producer-Consumer (Events)" design pattern.  File>>New...>>VI from template.  There is a good shipping example as well as the comments on the template vi
    Jeff

  • End of Statement error

    I have the a query that keeps coming up with an error when I try to place in in a form as VBA. The following is the code:
    txtOperationID = "SELECT TOP 1 [idsOpSymbolID] & " " & Format([txtOperationSub#]+1,"0000") AS NewOpID " & _
    "FROM tblOperations LEFT JOIN tblOperationsSUB ON tblOperations.idsOpSymbolID = tblOperationsSUB.idrOpSymbolID " & _
    "WHERE (((tblOperations.idsOpSymbolID) = [Forms]![frmNewProjectOperationTrackingNumber]![Combo91])) " & _
    "ORDER BY tblOperationsSUB.[txtOperationSub#] DESC"
    I am given the following error:  Compile Error, Expected end of statement.  Any suggestions?

    Yes,
    You have to neutralize " in string:
    txtOperationID = "SELECT TOP 1 [idsOpSymbolID] & "" "" & Format([txtOperationSub#]+1,""0000"") AS NewOpID " & _
    "FROM tblOperations LEFT JOIN tblOperationsSUB ON tblOperations.idsOpSymbolID = tblOperationsSUB.idrOpSymbolID " & _
    "WHERE (((tblOperations.idsOpSymbolID) = [Forms]![frmNewProjectOperationTrackingNumber]![Combo91])) " & _
    "ORDER BY tblOperationsSUB.[txtOperationSub#] DESC"
    Michał

  • Expected End Of Statement Error

    I created an SQL statement which runs fine in MS-SQL2000. I
    paste the code in a DW 8 recordset that I create and run a test to
    make sure it works. No problem. Returns resutls as expected. I can
    also access the fields in the recordset. When I test the Web page I
    get:
    Error Type:
    Microsoft VBScript compilation (0x800A0401)
    Expected end of statement
    /cssmetrics/dallas/scorecard.asp, line 10, column 2647
    See Attachment. I am baffled to what it is looking forward.
    Your help is greatly appreciated.

    'VERSION 5.00
    'Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "Mscomm32.ocx"
    Begin VB.Form FrmMain
    Your code is not VB .Net.  You may be able to find some assistance with your problem from the resources listed here: 
    VB6 and older

  • Getting end of statement error in SAP CRM bp script

    Hi
    When I run the code below without the for loop everything runs perfectly ok. However when I add the for loop I get the error statement end of statement I think it has something to do with handling of the code inside the for loop but I have  no clue how to solve it
    Somebody any idea?
    I know the code is not working correctly I need to add variable to fill in the values however I need to first tackle the end of statement issue
    If Not IsObject(application) Then
       Set SapGuiAuto  = GetObject("SAPGUI")
       Set application = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(connection) Then
       Set connection = application.Children(0)
    End If
    If Not IsObject(session) Then
       Set session    = connection.Children(0)
    End If
    If IsObject(WScript) Then
       WScript.ConnectObject session,     "on"
       WScript.ConnectObject application, "on"
    End If
    Dim objExcel
    Dim objSheet, intRow, i, d
    Set objExcel = GetObject(, "Excel.Application")
    Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
    session.findById("wnd[0]").resizeWorkingPane 132,30,false
    Dim total_row
    total_row = objSheet.UsedRange.Rows.Count
    For i = 1 To CInt(total_row)
         session.findById("wnd[0]/tbar[0]/okcd").text = "/nbp"
         session.findById("wnd[0]").sendVKey 0
         session.findById("wnd[0]/tbar[1]/btn[17]").press
         session.findById("wnd[1]/usr/ctxtBUS_JOEL_MAIN-OPEN_NUMBER").text = "19496"
         session.findById("wnd[1]/usr/ctxtBUS_JOEL_MAIN-OPEN_NUMBER").caretPosition = 5
         session.findById("wnd[1]/tbar[0]/btn[0]").press
         session.findById("wnd[1]/tbar[0]/btn[0]").press
         Dim strScreen
         strScreen = "wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04"
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04").select
         session.findById("wnd[0]").sendVKey 6
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7002/subA02P01:SAPLBUD0:1500/tblSAPLBUD0TCTRL_BUT0BK/ctxtGT_BUT0BK-BANKL[2,0]").text = "B000000003"
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7002/subA02P01:SAPLBUD0:1500/tblSAPLBUD0TCTRL_BUT0BK/ctxtGT_BUT0BK-BANKL[2,0]").setFocus
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7002/subA02P01:SAPLBUD0:1500/tblSAPLBUD0TCTRL_BUT0BK/ctxtGT_BUT0BK-BANKL[2,0]").caretPosition = 10
         session.findById("wnd[0]").sendVKey 0
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7002/subA02P01:SAPLBUD0:1500/tblSAPLBUD0TCTRL_BUT0BK/btnPUSH_BUP_IBAN[5,0]").setFocus
         session.findById("wnd[0]/usr/subSCREEN_3000_RESIZING_AREA:SAPLBUS_LOCATOR:2000/subSCREEN_1010_RIGHT_AREA:SAPLBUPA_DIALOG_JOEL:1000/ssubSCREEN_1000_WORKAREA_AREA:SAPLBUPA_DIALOG_JOEL:1100/ssubSCREEN_1100_MAIN_AREA:SAPLBUPA_DIALOG_JOEL:1101/tabsGS_SCREEN_1100_TABSTRIP/tabpSCREEN_1100_TAB_04/ssubSCREEN_1100_TABSTRIP_AREA:SAPLBUSS:0028/ssubGENSUB:SAPLBUSS:7002/subA02P01:SAPLBUD0:1500/tblSAPLBUD0TCTRL_BUT0BK/btnPUSH_BUP_IBAN[5,0]").press     session.findById("wnd[1]/tbar[0]/btn[0]").press
         session.findById("wnd[0]/tbar[0]/btn[11]").press
    Next i
    Edited by: R. Brouwer on Dec 23, 2010 3:31 PM

    Hi,
    i think nothing can be followed by the command "Next" in VBS. Your example would be the right way in VB or VBA.
    Regards,
    ScriptMan

  • Passing multiple fields as addition to  "end at " statement

    Hi All
    I dont think I can pass multiple fields to END AT statement.
    I need to sum at end of few field values in table .what is the best method of acheving this.
    Thanks in Advance
    Regards
    Vinay Kolla

    have different control blocks, and make sure you sort on all of the fields which you are using the control statements.

  • How to create a case in case management with QM02 link?

    Dear Gurus,
    I have to create a case in case management with link to t-code QM02. Any help would be appreciated.
    Thanks,
    GSM

    Hi..
    Easy transaction to Case Management customizing is SCASE_CUSTOMIZING. There you have an overview of the customizing of case management.
    Also carryon these steps one by one...
    Case Management Basic Settings :
    Define Number Range Intervals for Case
    Define Case Types
    Determine Permitted values for attribute
    Create values for "Category" attribute
    Create values for "Cause" attributes
    Create values for "Priority" attribute
    Create values for "Reason" for escalation attribute
    Assign escalation reasons to an attribute profile
    Create values for "Authorization level" attribute
    System Modifications
    Create status profile
    Create Text profile
    Create Text Ids
    Create Text Profile
    Define Logical system for external objects
    Enhanced System modifications
    Note About Enhanced System Modifications
    Define Processes
    Set up registry
    Create/Change Case Record Model
    Create Profiles
    Create attribute profile
    Create function profile
    Create terminology profile
    Create Activities for authorization check
    Activate application log
    Define processes
    Create/Change Case Record Model
    When u open the Transaction SCASE_CUSTOMIZING , there will be Registry Steps...
    Follow them step by step.
    Regards,
    Eswari.

  • SQL0104N  An unexpected token "END-OF-STATEMENT"

    Hello,
    for some audits we should run the following command:
    DB2 SELECT DISTINCT GRANTEE FROM SYSCAT.TABAUTH
    WHERE CONTROLAUTH = 'Y' OR 'G'
    UNION
    SELECT DISTINCT GRANTEE FROM SYSCAT.TABAUTH
    WHERE ALTERAUTH = 'Y' OR 'G'
    UNION
    SELECT DISTINCT GRANTEE FROM SYSCAT.TABAUTH
    WHERE DELETEAUTH = 'Y' OR 'G'
    UNION
    SELECT DISTINCT GRANTEE FROM SYSCAT.TABAUTH
    WHERE UPDATEAUTH = 'Y' OR 'G'
    UNION
    SELECT DISTINCT GRANTEE FROM SYSCAT.TABAUTH
    WHERE INSERTAUTH = 'Y' OR 'G' > all_users_auth.txt
    This does not work. When I run a single step I get the following message:
    db2 "select distinct grantee from syscat.tabauth where controlauth = 'Y' or 'G'"
    SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "rolauth
    = 'Y' or 'G'".  Expected tokens may include:  "<interval_qualifier>". 
    SQLSTATE=42601
    But what kind of interval_qualifier is needed???
    Regards
    Olaf

    Hello Olaf,
    You can try to run the following SQL statement.
    db2 "select distinct grantee from syscat.tabauth where controlauth in ('Y','G')"
    Regards,
    Masako

Maybe you are looking for

  • Whenever I try to open itunes, it says MSVCR80.dll file is missing

    I tried update itunes and it said "Service Apple Mobile Device failed to start.  Verify that you have sufficient priveleges to start system services.  It gave me an ignore option, so I clicked ignore and now when I try to open itunes it says "MSVCR80

  • How to read the statistics graph?

    Hi, I'm trying to troubleshoot some network issues. I have an AirPort Express connected to a DSL modem and acting as a wireless router. One computer connected is a Mac Pro with an AirPort Extreme card, and the other is a PC laptop with an Intel 2200B

  • HT201302 trying to import photos from an iPod to my Mac

    Please help - i am trying to imprt photos from my ipod to my imac. I have tried to get the imac to recognise the ipod using image capture without success and all that happens when i connect ipod is that itunes starts up. Looking at image capture thro

  • Laptop screen randomly stopped working.

    I was using my laptop - HP G61-320CA no problem all day like I usually do, and I went to go eat dinner. So I closed the lid of the laptop and went to eat, when I came back to the laptop, opened it up and the screen was just all black. My first assump

  • Change of number over time

    is there any standard FM to calculate change of number over time . where Z is my number.i have to find change of Z over a time period. i.e I have to find dZ. Any idea. Thanks in advance. Message was edited by:         Maya Vinothini