Calculation based on Lookup code

Hello All,
We have many records in the DB for Look up code & VIN. EVtrip Dist & Trip Length are direct fields available in the DB.
I need to first calculate Avg EVtrip distance, Weekly average, EEMD & Cumulative EEMD based on millions of records.
How to do calculate considering 'N'  no of records and because i need to compare, not next or previous records but several records between.
Please find the sample data.
Cumulative Estimated EMD
Sold in week
Wk
LOOKUPCODE
VIN
EV
TRIP
DIST
TRIP
LENGTH
Avg EV Trip Distance
Wkly Avg
EEMD
Cumulative EEMD
Week 1
80
Wk1
TRIP_INFO_ALERT
1FADP5CU5DL525753
114
251
214
165.75
13260
13260
TRIP_INFO_ALERT
1FADP5CU5DL525753
100
120
TRIP_INFO_ALERT
3FA6P0PU6DR310101
63
102
63
TRIP_INFO_ALERT
1FADP5CU8DL555376
120
215
120
TRIP_INFO_ALERT
3FA6P0SU1DR332367
266
780
266
(165.75 *80)
Week 2
100
Wk2
TRIP_INFO_ALERT
1FADP5CU5DL525753
97
97
97
88.5
15930
29190
TRIP_INFO_ALERT
3FA6P0PU6DR310101
131
200
131
TRIP_INFO_ALERT
1FADP5CU8DL555376
39
39
39
TRIP_INFO_ALERT
3FA6P0SU1DR332367
87
87
87
Actual Number of vehicles that have been sold per that week
(88.5 *180)
(13260+15930)
Week1  -- Cumulative Estimated EMD = 13260
Week2  -- Cumulative Estimated EMD = 29190

Hi Sandeep,
Are you comfortable with SQL?
I believe Crystal Reports is a top down compiler meaning formulas in the next line will not be applied to the current line. There is one workaround using the previous and next functions, but they only extend to the immediate previous or next line. It would cause errors if there were three of the same VIN #'s in a row.

Similar Messages

  • Pull Value based on Lookup Code

    I have a form that displays multiple values from a suppliers table. I have an item call Supplier Name (LOV), depending what i choose, item displays data in the "Airport Origin" and "Forwarder". I also have another table call Destinations and Another Table call Rates. On my form (page 2) one of the requirements is to automatically display the "Cost Per KG". I need to display the Cost per KG by what ever i have in the 'Destination Field' and 'Airport Orign'?
    I have created 2 Processes: One for pulling multiple item values and the other for getting the value from the rates table.
    1)Set_Multi_Items
    DECLARE
    v_ORIGIN_AIRPORT_CODE VARCHAR2 (200);
    v_FORWARDER_CODE      VARCHAR2 (200);
    CURSOR cur_c
    IS
    SELECT ORIGIN_AIRPORT_CODE, FORWARDER_CODE
    FROM lfaf_SUPPLIERS
    WHERE LFAF_SUPPLY_ID = TO_NUMBER (v ('MULTI_TEMP_APPLICATION_ITEM'));
    BEGIN
    FOR c IN cur_c
    LOOP
    v_ORIGIN_AIRPORT_CODE := c.ORIGIN_AIRPORT_CODE;
    v_FORWARDER_CODE := c.FORWARDER_CODE;
    END LOOP;
    OWA_UTIL.mime_header ('text/xml', FALSE);
    HTP.p ('Cache-Control: no-cache');
    HTP.p ('Pragma: no-cache');
    OWA_UTIL.http_header_close;
    HTP.prn ('<body>');
    HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
    HTP.prn ('<item id="P2_ORIGIN_AIRPORT_CODE">' || v_ORIGIN_AIRPORT_CODE || '</item>');
    HTP.prn ('<item id="P2_FORWARDER_CODE">' || v_FORWARDER_CODE || '</item>');
    HTP.prn ('</body>');
    EXCEPTION
    WHEN OTHERS
    THEN
    OWA_UTIL.mime_header ('text/xml', FALSE);
    HTP.p ('Cache-Control: no-cache');
    HTP.p ('Pragma: no-cache');
    OWA_UTIL.http_header_close;
    HTP.prn ('<body>');
    HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
    HTP.prn ('<item id="P2_ORIGIN_AIRPORT_CODE">' || SQLERRM || '</item>');
    HTP.prn ('</body>');
    END;
    2)getDet
    DECLARE
    my_det NUMBER;
    BEGIN
    SELECT KGRM_RATE
    INTO my_det
    FROM LFAF_RATES
    WHERE ORIGIN_AIRPORT_CODE = :P2_ORIGIN_AIRPORT_CODE
    AND LFAF_DESTINATION_ID = :P2_LFAF_RATE_ID;
    HTP.prn (my_det);
    EXCEPTION
    WHEN OTHERS
    THEN
    HTP.PRN ('');
    END;
    ******I have a Javascript code in the header of the page*******
    <script language="JavaScript" type="text/javascript">
    <!--
    function pull_multi_value(pValue){
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=Set_Multi_Items',0);
    if(pValue){
    get.add('MULTI_TEMP_APPLICATION_ITEM',pValue)
    }else{
    get.add('MULTI_TEMP_APPLICATION_ITEM','null')
    gReturn = get.get('XML');
    if(gReturn){
    var l_Count = gReturn.getElementsByTagName("item").length;
    for(var i = 0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("item");
    var l_ID = l_Opt_Xml.getAttribute('id');
    var l_El = html_GetElement(l_ID);
    if(l_Opt_Xml.firstChild){
    var l_Value = l_Opt_Xml.firstChild.nodeValue;
    }else{
    var l_Value = '';
    if(l_El){
    if(l_El.tagName == 'INPUT'){
    l_El.value = l_Value;
    }else if(l_El.tagName == 'SPAN' &&
    l_El.className == 'grabber'){
    l_El.parentNode.innerHTML = l_Value;
    l_El.parentNode.id = l_ID;
    }else{
    l_El.innerHTML = l_Value;
    get = null;
    //-->
    </script>
    <script language="JavaScript" type="text/javascript">
    function f_getDet ()
    var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=getDet',0);
    get.add('P2_LFAF_RATE_ID',html_GetElement('P2_LFAF_RATE_ID').value)
    gReturn = get.get();
    if(gReturn)
    {  html_GetElement('P2_COST_PER_KG').value = gReturn  }
    else
    {  html_GetElement('P2_COST_PER_KG').value = ''  }
    get = null;
    </script>
    <script language="JavaScript" type="text/javascript">
    <!--
    function sumItems(){ 
         var actual_weight = 0;
         var volumetric_weight = 0;
    function getNumericVal(item){
              if($x(item).value != "") {
                   return parseFloat($x(item).value);
              } else {
                   return 0;
         if ($x('P2_GROSS_WEIGHT').value !="" && $x('P2_VOLUME').value !="" ) {
              if ($x('P2_WEIGHT_UOM').value == "LBS") {
                   actual_weight = getNumericVal('P2_GROSS_WEIGHT') / 2.2046;
              } else {
                   actual_weight = getNumericVal('P2_GROSS_WEIGHT');
              if ($x('P2_VOLUME_UOM').value == "CFT") {
                   volumetric_weight = getNumericVal('P2_VOLUME') / 35.314 / 0.006;
              } else {
                   volumetric_weight = getNumericVal('P2_VOLUME') / 0.006;
              if (volumetric_weight > actual_weight) {
                   $x('P2_CHARGABLE_WEIGHT').value = volumetric_weight.toFixed(2);
              } else {
                   $x('P2_CHARGABLE_WEIGHT').value = actual_weight.toFixed(2);
    </script>
    //-->
    <script>
    function mulItems(){
    function getVal(item){
    if($x(item).value != "")
    return parseFloat($x(item).value);
    else
    return 0;
    $x('P2_CHARGEABLE_COST').value =
    getVal('P2_COST_PER_KG') * getVal('P2_CHARGABLE_WEIGHT');
    </script>
    My question is can someone please help me pull the correct value from my rates table on my "Cost Per KG" based on the "Supplier Name" Item Name and "Destination" Item Name?
    See application:
    Username: demo
    password: demo
    http://apex.oracle.com/pls/otn/f?p=27562:1:1757574860234267:::::

    You need to create an OnDemand Process (PL/SQL) to get the description from your DB and an piece of Javascript to call that process (AJAX style).
    You can code everything yourself - there are numerous examples out there.
    Or use Scott's "AJAX Code Generator" on http://htmldb.oracle.com/pls/otn/f?p=33867:2
    BTW : In APEX 4.0 this can all be done declarative...no coding of ondemand process, javascript etc necessary..

  • Interest calculation based on Net Due Date

    Hi guys: I want the interest calculation based on net due date and not document date or posting date.
    I tried to check the box "ALWAYS CALCULATE INT FROM NET DUE DATE in prepare item interest calculation step, but system gives me message
    "Do not select "Calc.intrst from net due date" for this int.calc.type
    Message no. F7128"
    Here are my questions:
    1- how can i make the system to calculate interest only after the item is due for payment - right now its calculating anyday after the document date
    2- Is this the correct place in configuration to do this?  (ALWAYS CALCULATE INT FROM NET DUE DATE )
    3- Also in T code FINT, how can i run interest posting for only one item rather than all that show up in test run? I tried selecting/highlighting only one but it posts all.
    thanks much
    brian

    HI,
    The system always calculates the interest from the document date of the invoice,
    as of my knowledge there is no setting for the interest calculation from the net due date, so
    what u need to do is when u are running the open item interest run u specify the period of only the date
    from the net due date to required date as of u.
    if u  want to calculate the interest to paticular invoice and  having two invoices
    then u can run  as per the document date and other thing is u can block the invoice for dunnig.
    Regards,
    Padma

  • Freight Cost based on postal code from alternative partner (occasional)

    Hi SAP experts!
    In standard SAP, the freight cost is calculated based on the postal code from WE partner (goods receiver).
    But my client have a situation where he uses an one-time customer as a goods receiver. In this cases the freight cost is being calculated wrong, because the SAP uses the tariff zone from goods receiver (WE partner).
    Does anybody know if there is a standard partner function to be used in order to consider the zipcode from the one-time customer instead ?
    Does anybody knows if there is a standard solution for this issue in SAP?
    Exemple:
    sold to party - client X - postal code NNN
    ship to party - client X - postal code NNN
    goods receiver - client Y - postal code AAA
    Then the freight must be calculated based on the postal code AAA.
    Thanks!
    Edited by: Fesuster on Dec 10, 2009 6:10 PM
    Edited by: Fesuster on Dec 10, 2009 6:13 PM

    k

  • Query for Auto Calculation based on input of 2 Fields

    Hi,
    I would like to write a sql query to allow for auto calculation based on the Inputs of 2 other fields before Adding the Order.
    For example. A query on Sales Order where I have Item 040634 (Code for a Flower) and Quantity 200.
    I have a UDF (Bunching) where the value is 10, 15 or 20.
    Based on the Bunching the result should be given in another UDF (Noofsleeves).
    (Quantity) 200 / (Bunching) 10 = 10 (Noofsleeves)
    The Order will be having multiple items where the Bunching can differ for each item.
    Is it also possible to remove the calculated noofSleeves from Inventory.
    I am using 2007A SP01 PL05

    Hi ,
    You may try this: Apply this fms on other udf and auto refresh on the udf mentioned in the query (in your case Bunching).
    SELECT $[RDR1.Quantity.number] / $[RDR1.U_UDF.number]
    You may check these too.
    cALCULATION OF udf ON UNIT PRICE
    FMS
    Thanks,
    joseph
    Edited by: Joseph Antony on Jul 8, 2010 12:31 PM

  • Automatic assignment of Partner Function (Dealer) based on Postal Code?

    Hi Experts,
    We are realizing a project in the Bathroom-Product Industry. Responsible for the service to the end-clients are authorized dealer. When creating a service ticket the responsible dealer has to be assigned automatically to the ticket on the basis of the postal code where the IBase (the product) is installed.
    The process is:
    1. The client is calling the Interaction Centre and first the IC Agent has to identify the account and the Installed Base (The     installed base contains the postal code where the product of the client is installed) of this account.
    2. An Interaction Record is created to record this inbound call.
    3. Afterwards a Service Ticket is created as a follow-up Document of the Interaction Record. In the moment of the creation of the Service Ticket the correct dealer has to be assigned automatically to the Service Ticket (as a Partner Function not as a Service Organization) on the basis of the postal code of the installed base.
    I have the following question! Which are the steps to assign automatically a Business Partner Function to a Service Ticket? We also need to create a Z-Table with the postal codes for which every dealer is responsible.
    Example:
    Dealer 1 is responsible for the postal codes: 08040 - 08045 and 08056 - 08059. If a client is calling and his product (Installed Base) is installed in Postal Code 08042 or 08054 the dealer 1 has to be assigned to the service ticket.
    I hope I could make myself clear ;-)? Anybody can give me a hint how to do that? What are the basic steps?

    Slightly similiar, originally being an R/3 customer before implementing CRM our dealer equated to sales office.
    In the CRM Org model (PPOMA_CRM) in the attributes of the sales office we entered the Regions & Postal codes for that dealer (pain in the arse to do) and in CRM the sales office in the org creates a BP.
    We used a org rule for the IR record based on country, region, postal code to determine the appropriate sales org, DC, div, and sales office based onthe zip code.  We created a custom partner function to represent the partner number of the  BP from the org model.  Then we configured a custom relationship "ZORG" "Is partner of sales office" and went into the BP master and assigned the actual dealer number as a partner to BP from the org model that = sales office.  From that we configured a custom access sequence to pull the actual dealer number from the org model office relationships.
    We looked at territory management, but our dealer is an "org BP" and territory management appeared to want to drive to a person BP number.

  • OB52 based on Company Code

    Dear All,
           As we are having several company codes and want users only to be able to open and close periods from transaction code OB52 belonging to their posting period with respect to company codes how can I restrict and allow them open & close periods based on company code repectively. Is there any process this be done.
    I tried with the notes I got from one sap-img link. But it did not work & there something is missing. Kindly if anyone have done this before send be step by step process. Awaiting for you reply...
    regards,
    Raj B...

    How about trying it this way?
    1. Remove access to OB52
    2. Create a maintenance view similar to V_T001B specific for each company.
    3. Create a TCODE for each of these views.
    4. Use this TCODE for authorization assignment.
    This should be simple but your number of views would be increasing with respect to the number of companies.
    ~Eswar

  • Gl a/c short and long text based on company code

    Hello Friends,
    In table skat the gl account description is given based on chart of accounts but what if i want the description based on company code.
    I want the table where i can get the gl account description based on company code??
    Pls suggest.
    Regards,
    Sunny

    Hi,
    you can look at the database view for requirement
    GL_ACCT_CC_TEXT
    regards\
    Mahesh

  • Table for finding rate based on part code and material

    Hi Experts
         I am an ABAP consultant with ltd knowledge on SD . Please tell me in which table  I can find the rate based on party code and material .

    Hi
    The standard table is A305. But usually these tables can be customized based on the requirement. So if you are aware about the Condition type for which this Price/Rate is maintained you can find the same in VK13.
    In transaction code VK13, maintain the condition type and click on "Condition information" icon. Now dont maintain any input date. Just click on Execute icon or F8. System will give the list of all the tables and data maintained based on the combination.
    Select the required table.In SE11, maintain this table with prefix as A. You can get all the required information.
    Regards
    Vamsi

  • Can I get multiple sums in a single column based on a "code" I place.

    After importing a file of check/debit card activity from my bank, can I 'code' the line items based on tax categories ie Utilities, Medical expenses, Auto expenses, etc. and then get sums for each based on that code I placed in a single column? That would mean multiple sums in a single column based on the code used for each tax related expense. For instance, I would put UT in the column for utilities expenses and MED in the same column if it were a medical expense. I would then want the sum for all items in that column for each item code. Is this possible or do I need to use a different approach to get this information.

    My guess is that the SUMIF function may be your friend.
    It's well described in the *iWork Formulas and Functions User Guid*e which every user may download from the Help menu.
    Yvan KOENIG (VALLAURIS, France) samedi 2 janvier 2010 21:56:39

  • How to change lookup code  with Access Level as 'System'

    Hi,
    I need to append new lookup codes in a lookup type having access level as 'SYSTEM'. Is there any standard way to do the same or just updating the customization level column will do ? Please let me know if you have any solution for this.
    Regards
    Girish

    You can also change the meaning on that value to something like "*** DO NOT USE***". This will make it obvious to the user that he/she should not choose it.
    You can try to add a when-validate-record personalization to show error if someone selected a disabled value.
    You can also try to modify the list of values associated with the field using personalizations.
    If nothing else works, you can use a SQL to uncheck the enabled flag. The risks involved in this are well known.
    Hope this answers your question
    Sandeep Gandhi
    Independent Consultant
    513-325-9026

  • SKF transactional values based on company code

    Can anybody let me know the logic how we can seggregate transactional value passed to statistical key figure based on company code or is there anytable where we can direclty find SKF transactions involved based on company code ?
    Need to upload SKF transactional figures from one SAP system to another.Hence require process for extraction and uploading of the same

    Hi Amogh
    Hope you are looking for actual SKF quantities posted. kindly check s_alr_87013611 CC report, I think on the lower part this comes. This time I am not in front of system so you please check.
    Regards
    Rajneesh

  • Decimal places adjustment based on company code or currency

    Hi experts,
        my requirement is i have to adjust the decimal places in amount fields of internal table based on company code or currency given by user.
    suppose for example in my internal tables having 5 amount fields like 1.50 1.234 1.45 1.34, 1.67  for  company code is in01
    the same values for VN01 should be like this
    150 1234 145 134  167  ....
    can any body plz tell me any functional module is there to covert or abapcode?
    Thanks in advance,
    veena.

    That code is a bad idea.  Why would you hard-code that type of action for currency/amount handling?
    @poster: If the output is based on the local currency defined for the specified company code or one specified by the user, then use it.  SAP handles amount output automatically with a currency specification because the currency definition identifies where/how the decimal is output. 
    Just use WRITE as Florian indicated but  use the CURRENCY extension instead of DECIMALS.  You can do this dynamically based on the company code easily...
    A simple 3 line program shows you how this works:
    PARAMETERS: p_wrbtr type wrbtr.
    write:/ p_wrbtr CURRENCY 'USD'.
    write:/ p_wrbtr CURRENCY 'JPY'.
    Edited by: Brad Bohn on May 12, 2011 1:07 PM

  • Restriction of Tcode SQ01 based on Company code

    We are running one customized query using Tcode SQ01.  We need to restrict Tcode SQ01 in company code level.  We have checked about authorization object in st01. But there is no check of authorization object. Can anybody help to restrict SQ01 based on company code level?
    Regards
    Auroshikha

    Hi Auroshikha,
    Itu2019s very easy to maintain authorization in your Infoset Query report. I got and implemented similar requirement i.e. restriction /authorization as per company code.
    You need to use authority check for authorization object  P_ORGIN in your infoset.
    Please follow the bellow steps:
    -->Go to SQ02, Enter your Infoset name and click on Change button.
    -->Click on 'Code' (Shift+F8) icon dispalyed on application toolbar, you will be moved to Code Section of Infoset that lists different events.
    -->Choose Record Processing event from code section.
    -->Write the following code in 'Record processing' event of your Infoset.
    AUTHORITY-CHECK OBJECT 'P_ORGIN'
    *ID 'INFTY' FIELD '*'
    *ID 'SUBTY' FIELD '*'
    ID 'AUTHC' FIELD 'R' "read
    ID 'PERSA' FIELD P0001-WERKS
    *ID 'PERSG' FIELD DUMMY
    *ID 'PERSK' FIELD DUMMY
    *ID 'VDSK1' FIELD DUMMY.
    CHECK Sy-SUBRC EQ 0.
    Note: PERSA field used in this Authorization object plays an importan role , if you are in different module other that HR , then pass here table_name-companycode_field
    -->Genetare Infoset
    -->Go to SQ01 (in a new session) , Click on exeute or 'Test button' to check authorization is working for report
    Let me know if you need any more details.
    Thank you.
    Regards,
    Dinesh Tiwari

  • Any option to restrict SE16 record level access based on company code?

    Hi All,
    I have a requirement to restrict record level access in SE16 based on company code.
    Our SAP system has two company codes. The requirement is that users of one company code should not be able to see records of other company code in SE16.
    Is it possible through some exits/badis/other methods?
    Thanks in advance.
    Regards,
    Arun Mohan

    You could write a small front end that accepts the company code, applies custom authorization code for each value and retains or removes, then calls the transaction and enters the selections the user requested and that your authorization check resulting in "passing"....  Of course, you'd have to block those users from "pure" SE16...   I once worked in situation similar, users in one country couldn't see USA data, etc. I think someone wrote an entire new program, called by ZSE16, for that.

Maybe you are looking for