Optimization of getting the Discount from KONV table

Sir\Gurus ; Im having trouble on optimizing of my sales report when i put the discounts data from KONV table . I hope you can help about this as it took so long to generate the report or worse it gets runtime error when i included the KONV table. Hope you can help me find a better way of getting the discount Below is my codes:
  select single kbetr kwert krech
      into (ls_data-zp01, ls_data-zp01v, ls_data-zp01t)
       from konv
      where knumv eq ls_data-knumv
        and kposn eq ls_data-posnr
        and kschl eq 'ZP01'.            "FA - Price Off Disc
    if ls_data-zp01t = 'A'.   "percentage
      ls_data-zp01 = ls_data-zp01 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp02, ls_data-zp02v, ls_data-zp02t)
       from konv
      where knumv eq ls_data-knumv
        and kposn eq ls_data-posnr
        and kschl eq 'ZP02'.    "Volume Discount
    if ls_data-zp02t = 'A'.   "percentage
      ls_data-zp02 = ls_data-zp02 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp03, ls_data-zp03v, ls_data-zp03t)
    from konv
   where knumv eq ls_data-knumv
     and kposn eq ls_data-posnr
     and kschl eq 'ZP03'.              "Opening Support Disc
    if ls_data-zp03t = 'A'.   "percentage
      ls_data-zp03 = ls_data-zp03 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp04, ls_data-zp04v, ls_data-zp04t)
     from konv
    where knumv eq ls_data-knumv
      and kposn eq ls_data-posnr
      and kschl eq 'ZP04'.              "Introductory Discount
    if ls_data-zp04t = 'A'.   "percentage
      ls_data-zp04 = ls_data-zp04 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp05, ls_data-zp05v, ls_data-zp05t)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZP05'.             "Mailer Discount
    if ls_data-zp05t = 'A'.            "percentage
      ls_data-zp05 = ls_data-zp05 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp06, ls_data-zp06v, ls_data-zp06t)
   from konv
  where knumv eq ls_data-knumv
    and kposn eq ls_data-posnr
    and kschl eq 'ZP06'.              "%Price Off Disc
    ls_data-zp06 = ls_data-zp06 / 10.   "convert to percentage display  "+dv 8mar2011
    if ls_data-zp06t = 'A'.   "percentage
      ls_data-zp06 = ls_data-zp06 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp07, ls_data-zp07v, ls_data-zp07t)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZP07'.       "Christmas Basket
    if ls_data-zp07t = 'A'.   "percentage
      ls_data-zp07 = ls_data-zp07 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp08, ls_data-zp08v, ls_data-zp08t)
     from konv
    where knumv eq ls_data-knumv
      and kposn eq ls_data-posnr
      and kschl eq 'ZP08'.         "Move Out Disc
    if ls_data-zp08t = 'A'.   "percentage
      ls_data-zp08 = ls_data-zp08 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zp09, ls_data-zp09v, ls_data-zp09t)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZP09'.         "Other Promotional Disc
    if ls_data-zp09t = 'A'.   "percentage
      ls_data-zp09 = ls_data-zp09 / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zsdt, ls_data-zsdtv, ls_data-zsdtt)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZSDT'.       "Subdi. Trade Disc
    if ls_data-zsdtt = 'A'.   "percentage
      ls_data-zsdt = ls_data-zsdt / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-ztrd, ls_data-ztrdv, ls_data-ztrdt)
     from konv
    where knumv eq ls_data-knumv
      and kposn eq ls_data-posnr
      and kschl eq 'ZTRD'.        "% Trade Discount
    if ls_data-ztrdt = 'A'.   "percentage
      ls_data-ztrd = ls_data-ztrd / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-ztrf, ls_data-ztrfv, ls_data-ztrft)
     from konv
    where knumv eq ls_data-knumv
      and kposn eq ls_data-posnr
      and kschl eq 'ZTRF'.       "FA Trade Discount
    if ls_data-ztrft = 'A'.   "percentage
      ls_data-ztrf = ls_data-ztrf / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zvol, ls_data-zvolv, ls_data-zvolt)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZVOL'.      "Volume Discount
    if ls_data-zvolt = 'A'.   "percentage
      ls_data-zvol = ls_data-zvol / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zwho, ls_data-zwhov, ls_data-zwhot)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZWHO'.      "Whole Sale Discount
    if ls_data-zwhot = 'A'.   "percentage
      ls_data-zwho = ls_data-zwho / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zsbo, ls_data-zsbov, ls_data-zsbot)
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZSBO'.       "Subdi .BO Allowance
    if ls_data-zsbot = 'A'.   "percentage
      ls_data-zsbo = ls_data-zsbo / 10.   "convert to percentage display
    endif.
    select single kbetr kwert krech
      into (ls_data-zrnd, ls_data-zrndv, ls_data-zrndt)
    from konv
   where knumv eq ls_data-knumv
     and kposn eq ls_data-posnr
     and kschl eq 'ZRND'.          "Rounding Discount
    if ls_data-zrndt = 'A'.   "percentage
      ls_data-zrnd = ls_data-zrnd / 10.   "convert to percentage display
    endif.
    "Freight
    select single kwert
      into ls_data-zhd0
      from konv
     where knumv eq ls_data-knumv
       and kposn eq ls_data-posnr
       and kschl eq 'ZHD0'.          "Freight
    "+dv 3mar2011
    " Depending on Price Procedure, Get gross price
    data: lc_kwert type konv-kwert.
    case ls_data-kalsm.
      when 'ZBENBY' or 'ZRETRN'.
        "Gross Price
        clear lc_kwert.
        select single kwert
          into lc_kwert
          from konv
         where knumv eq ls_data-knumv
           and kposn eq ls_data-posnr
           and kschl eq 'PR01'.
        ls_data-gross_price = lc_kwert.
        "Net Price
        ls_data-kzwi3 = ls_data-netwr.
        "Gross Price net of disc  as is kzwi2(subtotal)
      when 'ZRVA01'.
        "Gross Price
        clear lc_kwert.
        select single kwert
          into lc_kwert
          from konv
         where knumv eq ls_data-knumv
           and kposn eq ls_data-posnr
           and kschl eq 'PR00'.
        ls_data-gross_price = lc_kwert.
        "Net Price
        ls_data-kzwi3 = ls_data-netwr.
        "Promo
        clear ls_data-kzwi1.
        "Trade
        clear ls_data-kzwi6.
        "Gross Price net of disc
     ls_data-kzwi2 = ls_data-netwr + ls_data-mwsbp.  "-dv 8mar2011
        ls_data-kzwi2 = ls_data-netwr - ls_data-zhd0.    "+dv 8mar2011
    endcase.
Thanks & God Bless
Moderator message : Duplicate post locked.
Edited by: Vinod Kumar on Oct 10, 2011 1:51 PM

sql>select * from t22;
ID C_DT M_DT 
1  27-DEC-06  06-JAN-07 
1  06-JAN-07  11-JAN-07 
1  12-JAN-07  14-JAN-07 
1  15-JAN-07  16-JAN-07
sql>
select sum(decode(to_char(c_dt,'mon'),'jan',1,0))/count(*) c_per,sum(decode(to_char(m_dt,'mon'),'jan',1,0))/count(*) m_per
from t22;
C_PER M_PER
.75  1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to get the data from Pooled Table T157E.

    Hi Experts,
    How to get the data from Pooled Table T157E.
    Any help.
    Thanks in Advance,
    Ur's Harsha.

    create some internal table similar to T157E and pass all data as per SPRAS.
    After that use internal table in your program as per the requirement.
    Regds,
    Anil

  • Get the values from a table comparing fields of different data types

    Hi Experts,
    I want to fetch AFVC-AUFPL and AFVC- APLZL by passing WBS element from a ztable.
    select aufpl aplzl
      from  afvc
      into TABLE gt_afvc
      FOR ALL ENTRIES IN gt_boq
      where projn = gt_boq-posid.
    AFVC-PROJN - NUMC 8  (WBC ELEMENT)
    ZTABLE-POSID - CHAR24 (WBC ELEMENT)
    How to get aufpl and aplzl by comparing those 2?
    Regards
    Mani

    WBS element does have an conversion routine at the domain level. So sometimes you work with one format (8 digits) and sometimes with 24 digits.
    You use FMs
    CONVERSION_EXIT_ABPSP_INPUT
    CONVERSION_EXIT_ABPSP_OUTPUT
    to convert between values. Do your conversion before your select and do not forget to use a large enough data element for the field, which gets the 24-digits long value of the field.

  • How to get the value from Advanced table

    Hi,
    In the Advanced table have 2 LOV fields, I need LOV field value dynamically in the controller to validate the save button, if iam not selected any value in lov save button will not allow to save the data. In the table i am using 'Add another row'. How to get the lov field value in the process form request??? and how to do this requirement
    Thanks
    Naresh

    1. You can specify required property on LOV field to "yes". For events where you wish to disable the client side validations, set the property disable client side validation to "true".
    2. If above behavior is not what you are looking for, then you need to handle in AM and not CO.
    a. Call an AM method from CO.
    b. In that AM method, get handle of VO.
    c. Iterate the VO Rows and check for your validation rules.
    -Prince
    http://www.princekapoor82.blogspot.com

  • How to get the links from Master table

    Hi,
    I need to show url on the jsp page which should be taken from Backend "Master Table".
    say an example like some value CRM_IMAGE =  ZWEB CRMIMAGE.I need to show CRM_IMAGE as  Hyperlink on the product detail.jsp.
    Can anyone help me for this.
    Regards,
    Deepika
    Edited by: Ecom Dev on Dec 21, 2009 11:05 AM

    Hi Ecom,
    To retrieve value on product detail page you have to develop your custom code in which you have to create BO, BOM, BEI and BEO to access Your master table data from ISA page.
    You also need to create Custom RFC in which you pass porduct ID and retrieve related value from Master Table.
    You can find example in ISA tutorial how to get value from Back-end via JCO.
    eCommerce Developer
    Edited by: Ecommerce Developer on Dec 21, 2009 11:44 AM

  • How to get the select * from emp table output on the console  using java

    public class software {
          * @param args
         static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
         static final String DATABASE_URL = "jdbc:oracle:abc";
         private static Connection connection;
         private static Statement statement;
         public static void main(String[] args) {
              // TODO Auto-generated method stub
         try {
              System.out.println("-------THIS IS THE Class.forNameJDBC_DRIVER");
                   Class.forName(JDBC_DRIVER);
                   System.out.println("THIS IS THE Class.forNameJDBC_DRIVER");
                   connection = DriverManager.getConnection(DATABASE_URL, "abc",
                   "abc");
                   System.out.println("THIS IS THE connection abc ,abc");
                   statement = connection.createStatement();
                   //Query to find the values in the EMP table.
                   ResultSet resultSet = statement.executeQuery("SELECT * from EMP");
                   if(resultSet.next()){
                   System.out.println("THESE ARE THE VALUES IN EMP TABLE:"+resultSet);  /// How can i get all the values record wise on the  console ??????
                   resultSet.close();
         catch (ClassNotFoundException classNotFound) {
                   System.out.println("Driver not Found"+classNotFound.getMessage());
              } catch (SQLException sqlException) {
                   System.out.println("SQL Exception - bad sql");
                   System.out.println(sqlException.getMessage());
    }

    1sai
    Please assign the dukes here and in your previous threads.
    See [http://wikis.sun.com/display/SunForums/Duke+Stars+Program+-+How+it+Works]
    You are currently the all time career leader in un-awarded dukes, with including this thread 75 unawarded dukes for questions you marked as answered.
    It's even worse when you look and see that you have awarded many dukes as well. So you do know how to do it. You're just too lazy and rude to be bothered.
    Don't be a lazy wank.

  • How Can i get the data From A Table that use DefaultTableModel

    Hi and sorry for my bad english. The problem that i have is that i used this code to fill a table. Now i want when i select a row and click in a button , get the value of that row that i select so then i can update or delete that data in my dataBasesServer.
    private void consulta(){
              Connection c = ConectarSQL.conexionSQL();
              try {
                   Statement s = c.createStatement();
                   ResultSet ar = s.executeQuery("Select Apellido, Nombre FROM Personas");
                   DefaultTableModel modelo = new DefaultTableModel();
                   this.Tabla.setModel(modelo);
                   modelo.addColumn("Apellido");
                   modelo.addColumn("Nombre");
                   while (ar.next()) {
                      Object [] fila = new Object[2];
                      for (int i=0;i<2;i++)
                         fila[i] = ar.getObject(i+1);
                      modelo.addRow(fila);
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }

    Dont worry kevinaworkman, the thing is that a read it and is really usefull, but i was looking other kind of solution. But i welcome your answer and interested to solve my problem.
    I find the answer.
    To retrive the data i have to use the following instruction:
    Tabla.getValueAt(Tabla.getSelectedColumn(),Tabla.getSelectedRow);

  • How to get the data from a table cell

    Could somebody suggest me how I can get the data value from a table cell if I set that cell a Double object previously.
    Thanks very much

    Thanks for camickr's information.
    And thanks uhrand,
    I haven't got it sloved. I am sick on this problem.
    I have the methods to let the table editable. My tableModel code is from Sun Tutorial.
    It has the code like this:
    public int getColumnCount() {
                return columnNames.length;
             public int getRowCount() {
                return data.length;
              public String getColumnName(int col) {
                return columnNames[col];
             public Object getValueAt(int row, int col) {
                return data[row][col];
             * JTable uses this method to determine the default renderer/
             * editor for each cell.  If we didn't implement this method,
             * then the last column would contain text ("true"/"false"),
             * rather than a check box.
            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
             * Don't need to implement this method unless your table's
             * editable.
            public boolean isCellEditable(int row, int col) {
                //Note that the data/cell address is constant,
                //no matter where the cell appears onscreen.
                if (col < 1) {
                    return false;
                } else {
                    return true;
             * Don't need to implement this method unless your table's
             * data can change.
            public void setValueAt(Object value, int row, int col) {
                if (DEBUG) {
                    System.out.println("Setting value at " + row + "," + col
                                       + " to " + value
                                       + " (an instance of "
                                       + value.getClass() + ")");
                data[row][col] = value;
                fireTableCellUpdated(row, col);
                if (DEBUG) {
                    System.out.println("New value of data:");
                    printDebugData();
            public void printDebugData() {
                int numRows = getRowCount();
                int numCols = getColumnCount();
                for (int i=0; i < numRows; i++) {
                    System.out.print("    row " + i + ":");
                    for (int j=0; j < numCols; j++) {
                        System.out.print("  " + data[i][j]);
                    System.out.println();
                System.out.println("--------------------------");
            }

  • API to get the SUBSTATE from wftask table

    Hi
    How to get the SubState value from wftask table. Any method is available?
    Regards
    Balaji S

    1. You can specify required property on LOV field to "yes". For events where you wish to disable the client side validations, set the property disable client side validation to "true".
    2. If above behavior is not what you are looking for, then you need to handle in AM and not CO.
    a. Call an AM method from CO.
    b. In that AM method, get handle of VO.
    c. Iterate the VO Rows and check for your validation rules.
    -Prince
    http://www.princekapoor82.blogspot.com

  • How to get the rows from a table having some column has any letter

    Hi All,
    suppose i have a table having columns id(number), code(varchar).
    code has alphanumeric characters (ex. ABC123, 67B56 etc).
    some codes are only numbers (2344, 7898 etc).
    how can i get the rows which have alphabets in the code.
    ex:
    id code
    1 AB45
    2 456
    3 890
    4 67B7
    how can i write a query such that it should give me the ids 1 and 4 (as they have alphabets in code)
    thanks in advance to all

    Thanks to one and all.
    i am gettig my required output.
    But i have a doubt in the operator.
    If i add or remove '[]' in the operator, i am getting different ouputs.
    There is a count difference in the result of the operators used.
    REGEXP_LIKE(<column>,'[[:lower:]]')
    REGEXP_LIKE(<column>,'[[[:lower:]]]')
    REGEXP_LIKE(<column>,'[:lower:]')
    Can anybody please explain what is the difference in using '[]', in the operator?
    What is the correct syntax, whether i have to use two '[]'s or one '[]'.
    Also, can i use REGEXP_LIKE() in oracle 8i version.( I am unable to use the operator in 8i)?
    Any query to get the required output in 8i version?
    Thanks in advance to all.

  • How to get the StatusText from XMII_JCOMESSAGES Table

    Hi all,
    I need to show the Status as well as StatusText from XMII_JCOMESSAGES table for a particular message in a custom User Interface. I have checked through Read Message action block and Query Message action block. Read Message action block returns two XML structure like JCOMessage and MessageDocumentXML. JCOMessage xml does not contain the StatusText field. The structure of JCOMessage is like
    <JCOMessage>
    <MessageId/>
    <JcoServerName/>
    <MessageName/>
    <Category/>
    <MessageType/>
    <Status/>
    <DocNumber/>
    <DocCount/>
    <Function/>
    <PacketID/>
    <ProcessingTimeStamp/>
    <ReceivedTime/>
    </JCOMessage>
    But I have checked the XMII_JCOMESSAGES table from NWA  and the structure of XMII_JCOMESSAGES table is
    MESSAGEID
    RECEIVEDDATETIME
    JCOSERVERID
    MESSAGETYPE
    MESSAGENAME
    PROCESSINGDATETIME
    DOCNUMBER
    DOCXML
    CATEGORY
    PACKETID
    STATUS
    STATUSTEXT
    SERVER
    So, how can I fetch the STATUSTEXT field. Can anybody help me.
    Thanks in advance
    Chandan

    Aside from the Update Message block status text (integer values 1 - 4 coincide with the options in the drop down box on the configure dialog) that you can see in the link editor, you may need to use the Message Monitor status flag on the web page to determine what the number means in relation to friendly status text.
    Probably worth logging a ticket for consideration to add this into the actions.  I would assume this string might be translated into a local languague for the user but I'm not sure.

  • How to get the data from one table and insert into another table

    Hi,
    We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
    For the above requirement what the best way to implement in OAF.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    Thanks

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • Get the values from a table

    Hi,
    I am new to webdynpro. I have created one table with four columns in MAX DB. I have to write a webdynpro application such that when the first page loads, all the records will be display.
    How to proceed for this using webdynpro for java..Please give the procedure so that I will try..
    Thanks & Regards,
    Mastanvali Shaik.

    Hello Mastan,
    i would suggest you next steps:
    1) Define a new DataSource in your JDBC service setting in Visual Admin app.
        This new DataSource should be pointed to your MAX DB. There you should select an Java class (sort of driver) to work with this DB type.
    <b>Then you have 2 possibilities:</b>
    2a) You can build an SQL script to read your DB and send it via jdbc connection:
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup(jdbc/<your DS alias>);
    Connection cn = ds.getConnection();
    PreparedStatement stm = cn.prepareStatement("Your SQL");
    ResultSet rsl = stm.executeQuery();
    Then you go through your ResultSet and fill-in some of your context nodes (datasource for an TableView).
    2b) Or you can define a new dictionary project, create your table in there and deply. Don't forget to set right DS alias. And then you can import and use that dict. object in your WD application. From programming point of view it's even easier because you can use it as data Model.
    Hope it helps.
    regards.
    mz

  • How to get the data from a table which are availble in MD04

    Hello,
    Can you please let me know the tables in which the 'data available in MD04' are stored.
    I would like to have the data pertaining to the customer order/Item with requirements available in MD04.
    Thanks and Regards,
    Jana.

    Probably the easiest way in this case is to run the performance trace (System/Utilities/Performance trace). Start transaction MD04, put on the trace in another window, press enter to see the stock/requirements list, then stop the trace and list the results. Then you'll see which tables were accesses with which queries.

  • How to get the data from AUSP TABLE

    Hi Experts,
    Select * from AUSP where atinn = w_attin
                                  And   klart = ‘001’
                                  And  atwrt between w_low  and w_high.
    Endselect.
    Here I am using this select to retrive data from ausp where atwrt in between 00000[w_low] and 09999[w_high].
    In EPC it displays an error like data types incompatability..
    Because atwrt is character field of length 30 and w_low and w_high are integer fields.
    How to rectify this problem.

    <b>Hi
    Code like this
    data: v_low type AUSP-ATWRT,
    v_high        type AUSP-ATWRT.
    v_low = w_low .
    v_high = w_high.
    Select * from AUSP into corresponding fields of table itab where atinn = w_attin
    And klart = ‘001’
    And atwrt between v_low and v_high.
    DONT USE SELECT...ENDSELECT as performance issues is there rather use into table.
    Mark points if helpful.
    Regs
    Manas Ranjan Panda</b>

Maybe you are looking for