If statement comparing fields

Hello,
I have a field in which I am trying to compare two calculated fields, then enter one of two choices. Example
If A1 < B1 then enter A1.value, else enter B1.value
I know very little about scripting and thank goodness I've found most of what I need here on the forum.  What is the script I would need to use to accomplish this task?
Thank you!

A custom calculate script for the third calculated field could look like:
(function () {
    // Get the field values, as numbers
    var v1 = +getField("A1").value;
    var v2 = +getField("B1").value;
    // Set this field's value
    if (v1 < v2) {
        event.value = v1;
    } else {
        event.value = v2;
The "if" block could be simplified to just:
    // Set this field's value
    event.value = v1 < v2 ? v1 : v2

Similar Messages

  • Sorting techinque without using sort statement /Comparing table fields.

    Hi,
    How to achieve sorting techinque without using sort statement in tables.
    Also how to compare fields of 2 custom tables and check their compatability without using code ?

    Hi,
    Refer the below program, it will be helpful.
    types: begin of t_int,
             int type i,
            end of t_int.
    data: it_int type standard table of t_int,
           wa_int type t_int,
           wa_int1 type t_int.
    wa_int-int = 70.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 50.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 20.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 30.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 23.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 23.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 32.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 77.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 99.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 1.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 11.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 90.
    append wa_int to it_int.
    clear wa_int.
    wa_int-int = 40.
    append wa_int to it_int.
    clear wa_int.
    data: wk_line type i.
    data: cnt type i.
    data: cnt1 type i.
    describe table it_int lines wk_line.
    clear: cnt,cnt1.
    data wk_flag type c.
       clear wk_flag.
    while wk_line gt cnt1.
       cnt = cnt + 1.
       read table it_int into wa_int index cnt.
       cnt1 = cnt + 1.
       read table it_int into wa_int1 index cnt1.
       if wa_int-int lt wa_int1-int.
         modify it_int from wa_int index cnt1.
         modify it_int from wa_int1 index cnt.
         wk_flag = 'X'.
       endif.
       if cnt1 eq wk_line.
         clear: cnt, cnt1.
         if wk_flag eq 'X'.
         clear wk_flag.
         continue.
         else.
           exit.
         endif.
       endif.
    endwhile.
    loop at it_int into wa_int.
       write: / wa_int-int.
    endloop.

  • Compare fields in collection model to display which fields differ

    Hi all
    I have a previous post, which I may not have clearly enough stated my objective, and hence I feel as I may have been given an incorrect directive.
    Anyway, I aim to be able to compare fields in collection model to display which fields differ between records. Ie, in my collection model, the SQL query may return 3 records. I want to be able to compare field A (rowindex 1) to field A (rowindex 2). I want to do this, so that I can use some EL or other method to change the text color presented to the user.
    The problem here is that the SQL query has over 100 fields, so I definitely need a generic / reusable / programmatic way of doing this.
    My initial approach was to create a bean that referenced values in the current and previous record set / iterator. Really, I am looking for a validation of my approach or any other alternatives.
    My last resort will be to modify the SQL query, and duplicate each column with a 'changed flag'.
    Thanks in advance,
    Simo

    Sure,
    you should create a transient attribute in your VO and in method getters and setters in the view row class implement your bussiness logic. There are several posts in this forum about this subject. For example, how to create a transient attribute in a VO in r12
    Regards,

  • Spry:state="error" field is always visible?!

    I define layers to display the current spry:state, one for
    spry:state="loading", the second for spry:state="error" and the
    third for spry:state="ready". The problem is that
    spry:state="error" field is always visible along with
    spry:state="loading"?! Am I making some mistake or what? Here is a
    part of relevant code:
    <div id="vijesti" spry:region="pvVijestiMini"
    class="vijestimini">
    <div id="ucitavanjemini" spry:state="loading"
    class="indikator">
    <p>
    <span><img
    src="slike/pomocne/loader.gif"></span>
    <span>Podaci se učitavaju...</span>
    </p>
    </div>
    <div id="greskamini" spry:state="error"
    class="indikator">
    <p>
    <span><img
    src="slike/pomocne/loader2.gif"></span>
    <span>Podaci ne postoje ili su
    nedostupni...</span>
    </p>
    </div>
    <div id="podaci" spry:state="ready">
    <span class="vijestnaslov">Čikom vijesti
    [{ds_UnfilteredRowCount}]</span>
    <div id="redovimini" class="redovimini">
    <div class="red" spry:repeat="pvVijestiMini">
    <p class="podnaslov">
    <span>{datum}</span><br>
    <span class="naziv">{naziv}</span>
    </p>
    <p>
    <span>{ukratko}<a
    href="index.php?jezik=0&meni1=3&meni2=0&meni3=0"><img
    src="slike/pomocne/dalje.gif"
    class="dalje"></a></span>
    </p>
    </div>
    </div>
    <div id="navigacija">
    <div spry:if="{ds_UnfilteredRowCount} == 0">Nema
    podataka u tabeli "Vijesti"!</div>
    <div spry:if="{ds_UnfilteredRowCount} &gt; 0">
    <div><a href="#"
    onclick="pvVijestiMini.firstPage(); return
    false;">|&lt;</a><span> </span></div>
    <div><a href="#"
    onclick="pvVijestiMini.previousPage(); return
    false;">&lt;&lt;</a></div>
    <div> stranica {ds_PageNumber} od
    {ds_PageCount} </div>
    <div><a href="#" onclick="pvVijestiMini.nextPage();
    return
    false;">&gt;&gt;</a><span> </span></div>
    <div><a href="#" onclick="pvVijestiMini.lastPage();
    return false;">&gt;|</a></div>
    </div>
    </div>
    </div>
    </div>
    The second question: How do I hide region container until it
    gets filled with data?

    Look, you got me all wrong. I don't want to hide a main
    region, just the spry:state="error" appearing the same time as
    spry:state="loading"!!!
    <div id="ucitavanjemini" spry:state="loading"
    class="indikator">
    <p>
    <span><img
    src="slike/pomocne/loader.gif"></span>
    <span>Podaci se učitavaju...</span>
    </p>
    </div>
    <div id="greskamini" spry:state="error"
    class="indikator">
    <p>
    <span><img
    src="slike/pomocne/loader2.gif"></span>
    <span>Podaci ne postoje ili su
    nedostupni...</span>
    </p>
    </div>

  • SELECT statement comparing 2 fields in a table.

    Hi,
    Can someone help me out  in making a efficient SELECT statement for the follwing requirement.
    Say, I want to select all the records from a database table where the field, PLANT is equal to field SALESORG in the table (i.e., when both fields are equal select that record).
    Thanks & regards,
    Sree

    Hello,
    I think this is the answer to your question... if you explain a bit more we can formulate a query.
    Subquery
    Variants:
    1. ( select )
    2. ALL ( select )
    3. ANY ( select )
    4. SOME ( select )
    Effect
    A subquery is a SELECT statement select that occurs within a
    SELECT,
    OPEN CURSOR,
    UPDATE, or
    DELETE statement
    in the WHERE clause or HAVING clause, to check whether data from database tables or views meets certain criteria.
    Subqueries have a restricted syntax in comparison to the normal SELECT statement:
    SELECT result FROM source [WHERE where] [GROUP BY fields]       [HAVING having].
    Variant 1
    ( select )
    If the subquery returns a single value, you can use any relational operator except LIKE and BETWEEN.
    Example
    Selecting the flights with the most passengers:
    DATA: WA TYPE SFLIGHT.
    SELECT * FROM SFLIGHT
        INTO WA
        WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
      WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.
    ENDSELECT.
    Note
    If you use a subquery with a relational operator instead of EXISTS, you may only specify one column in the SELECT clause. This can be either a field from the database table or an aggregate expression. Subqueries of this kind are referred to as scalar subqueries.
    Variant 2
    ALL ( select )
    If the subquery returns several lines, each containing one value, you specify that the comparison should apply for all of the values it returns.
    Example
    This example shows how to use ALL. It displays a list of the customer IDs of the customer (or customers) who have made the most bookings:
    DATA: ID TYPE SBOOK-CUSTOMID, CNT TYPE I.
    SELECT CUSTOMID COUNT( * ) AS C FROM SBOOK
        INTO (ID, CNT)
        GROUP BY CUSTOMID
        HAVING COUNT( * ) >=
          ALL ( SELECT COUNT( * ) FROM SBOOK GROUP BY CUSTOMID ).
      WRITE: / ID, CNT.
    ENDSELECT.
    Variant 3
    ANY ( select )
    Variant 4
    SOME ( select )
    If the subquery returns several lines each containing one value, this variant specifies that the comparison should apply to at least one of the values returned. The IN operator is the same as the combination = ANY.
    &ABAP_HINT
    If you use a subquery with the EXISTS operator, the expression is true if the subquery selects at least one line. You can useuse * in the SELECT clause of subqueries that use EXISTS.
    Example
    Selecting all flights from Frankfurt to New York between 1.1.1999 and 31.3.1999 that are not yet full:
    DATA: WA_SFLIGHT TYPE SFLIGHT.
    SELECT * FROM SFLIGHT AS F INTO WA_SFLIGHT
        WHERE SEATSOCC < F~SEATSMAX
          AND EXISTS ( SELECT * FROM SPFLI
                        WHERE CARRID = F~CARRID
                           AND CONNID = F~CONNID
                           AND CITYFROM = 'FRANKFURT'
                           AND CITYTO = 'NEW YORK' )
          AND FLDATE BETWEEN '19990101' AND '19990331'.
      WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID,
               WA_SFLIGHT-FLDATE.
    ENDSELECT.
    Subqueries such as the one in this example, in which the WHERE clause uses fields from the main query, are known as correlated subqueries. Subqueries can be nested, and a given subquery may contain any fields from other, hierarchically-superior subqueries.
    In a correlated subquery, the subquery is executed for each line r returned by the main query. In the above example, the main query finds all flights in table SFLIGHT that are not full and that have a date that meets the selection criterion. The statement then performs the subquery for each of the records returned by the main query, using the corresponding values of CARRID and CONNID, to check whether the relevant flight operates between Frankfurt and New York.
    Additional help
    Subqueries

  • Comparing fields

    Hi,
    I am getting problem with comparing blank fields in table gt_in. Syntax is this...
    IF GT_IN-BSTART = ' ' AND GT_IN-BEND = ' ' AND GT_IN-FSTART = ' '
        GT_IN-FEND = ' ' AND GT_IN-ASTART = ' ' AND GT_IN-AEND = ' '.
    Error:
    Incorrect logical expression: Comparison / SELECT-OPTION can only be followed by "AND", "OR" or ")".          
    Regards
    Reddy

    IF GT_IN-BSTART = ' ' AND GT_IN-BEND = ' ' AND GT_IN-FSTART = ' ' <b>AND</b>
    GT_IN-FEND = ' ' AND GT_IN-ASTART = ' ' AND GT_IN-AEND = ' '.
    Surely you were missing the 'AND'in your above statement the other way to check blank is to use IS INITIAL check.
    IF GT_IN-BSTART IS INITIAL AND
       GT_IN-BEND IS INITIAL AND
       GT_IN-FSTART IS INITIAL AND
       GT_IN-FEND IS INITIAL AND
       GT_IN-ASTART IS INITIAL AND
       GT_IN-AEND IS INTIAL.
    ENDIF.

  • 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 modify state of fields on screen in PCUI through BADI

    Hi,
    Is there any way to modify the state of screen fields(such as greying out the fields) in PCUI, when a SAP backend BADI is being triggered??
    Appreciate if sample codes or programming guides can be given if you have.
    Thanks a lot!!!

    I guess the links below should help in your problem ..
    http://www.saptechies.com/how-to-create-table-maintenance-generator/
    Window size on SM30
    If these do not please tell ..
    Regards,
    Manthan

  • FF_5 - Import Bank Statements, Balancing field "Profit Center"

    Hi
    When importing the bank statement I get the error Error: (GLT2 201) Balancing field "Profit Center " in line item 001 not filled when using the NEW GL only.
    I know why I'm getting the error, the document is trying to determine a Profit Center, I do want it to determine for the balance sheet also. Also due to making it mandatory in document splitting rules I get this error.
    Now my problem is HOW DO I ASSIGN A PROFIT CENTER?? In the past in the classic GL I would use 3KEH and that would do the trick. It does not work now.
    How do we assign a profit center for bank import postings???
    Thanks in advance

    Hi
    Thanks, that solved it.
    Can you please tell me the one for the cost center?? It is also giving an error it can not determine cost center but I have entered it in OKB9.
    Then can you tell me the path for the profit center.
    Thank you for your assistance.

  • Problem With Insert statement using field symbols with unicode enabled

    I was writng a function module for dyanamic operations on the table. We are using the field symbols, function module is unicode enabled.
    Assign statements are working fine, with which we created work are <fs_wa_header> and internal table <fs_tb_item> dynamically based on the table name (IM_TB_HENAME) which we get as import parameter.
    we have query which is giving us dump.
    INSERT  (IM_TB_HENAME)  FROM <FS_WA_HEADER>.

    Hi
    INSERT (IM_TB_HENAME) FROM <FS_WA_HEADER> is good for inserting a line in the database, so IM_TB_HENAME has to have the name of dictionary table.
    U should write:
    INSERT  <FS_WA_HEADER> INTO (IM_TB_HENAME).
    But I believe you can't use the variable IM_TB_HENAME, you should use another field-symbols:
    ASSIGN (IM_TB_HNAME) TO <FS_TB_ITEM>.
    INSERT  <FS_WA_HEADER> INTO <FS_TB_ITEM>.
    Max

  • How to compare field symbols

    Dear experts,
    I have a piece of code like this..
    ASSIGN (lv_field)  TO <f1>.
          IF NOT <f1> IS INITIAL.
            CONCATENATE 'IS_BUS000_EEW' '-' lv_fieldname INTO lv_field.
            ASSIGN (lv_field)  TO <f1>.
            CONCATENATE 'LS_BUT000-' lv_fieldname INTO lv_field2.
            ASSIGN (lv_field2) TO <f2>.
            <f2> = <f1>.       "
          ENDIF.
    After assigning <f1> to <f2>, in runtime <f2> is getting a value '  .  .    '(like 'xx.xx.xxxx' spaces are missing when the question is posted). Now my requirement is that, if <f2> is '   .  .    '  i want to clear <f2>. So please let me know how do we compare the field symbols(for type DATS) with values like '  .  .    '.
    Edited by: Shwetha H S on Apr 2, 2008 6:56 AM

    Dear experts,
    I have a piece of code like this..
    ASSIGN (lv_field)  TO <f1>.
          IF NOT <f1> IS INITIAL.
            CONCATENATE 'IS_BUS000_EEW' '-' lv_fieldname INTO lv_field.
            ASSIGN (lv_field)  TO <f1>.
            CONCATENATE 'LS_BUT000-' lv_fieldname INTO lv_field2.
            ASSIGN (lv_field2) TO <f2>.
            <f2> = <f1>.       "
          ENDIF.
    After assigning <f1> to <f2>, in runtime <f2> is getting a value '  .  .    '(like 'xx.xx.xxxx' spaces are missing when the question is posted). Now my requirement is that, if <f2> is '   .  .    '  i want to clear <f2>. So please let me know how do we compare the field symbols(for type DATS) with values like '  .  .    '.
    Edited by: Shwetha H S on Apr 2, 2008 6:56 AM

  • Unicode error in statement Describe Field

    Hi,
    There is a statement in my program which is giving Unicode error.
    DESCRIBE FIELD t_mara-mfrpn LENGTH len.
    Here t_mara is internal table with header line. Unicode error which I am getting is 'In Unicode, Describe Length can only be used in Byte mode or IN....'.
    Kindly let me know how to remove this unicode error without affecting the functionality.
    Regards,
    Rajneesh

    syntax check always finds the error when the addition BYTE or CHARACTER MODE is missing in the statement DESCRIBE.
    And it will not cause any impact in functionality of your program

  • Compare fields

    Dear all,
    I will not use SE38 to create ABAP for simple problem below.
    I'd like to compare 2 fields in EKKO table. EKKO-AEDAT and EKKO-BEDAT.
    Is there a way to achieve that ? how about SQ01, SQ02, SE16, etc ...
    I believe there must be a way just for comparing content of two columns.
    Points will be awarded for sure.
    Regards,
    BWAS

    Yes, you can do it with the SQ01.
    Create a join on EKKO with EKKO (create aliase like EKKO_1 and table EKKO) and join them on your required dates.
    It will give you only those records which have both dates same.
    Regards,
    Naimesh Patel

  • Javascript help to compare fields

    Looking for some help with javascript to check values using if/then statements.
    I have 3 fields:
    JobTitle
    RateRange
    RateAmount
    JobTitle is a drop down with the following list items and corresponding values:
    List Item Text Value
    Manager 1
    Supervisor 2
    Rep 3
    RateRange is a drop down that gets its value from the JobTitle.I pass the rawValue to pull up the corresponding Rate. Here are the values:
    List Item Text Value
    $30 - $37 1
    $26 - $31 2
    $12 - $17 3
    This part works perfect. If I choose Manager then the RateRange shows me $30-$37.
    So the process is the user has selects the JobTitle and the RateRange auto populates, then they will enter the RateAmount. Once the RateAmount is entered, I want to have a script check to see if the amount entered is between the RateRange amounts. If it is not I want it to change the color of the field. Ive figured out how to change the color, but I cant get any if/then statements to work correctly. I figure its because how the RateRange field is set up.
    So Ive tried adding a field that will do the same thing as the RateRange except it will only pull the first value, instead of both values in the range, but Im having problems getting that to work.
    Any ideas?
    Also, how do you reference the display text of a drop down? I believe the binding value is the rawValue? What do you use to look at the display text value?
    Thank you in advance!

    try this:
    window.location.href = "mailto:[email protected]?subject=Subject&body=message%20goes%20here";
    Fouad Roumieh

  • IF statement (Compare column with String)

    Hi all,
    i want to compare the Content of a Column with a text but i always get an error message because of a Syntax error.
    It the Content of the column Approval Status is Approved the System should write in the calculated column the String "Approved"
    my code:
    =IF([ApprovalStatus]="Approved","Approved"," ")
    can you help me ? what is wrong here?
    thank you in advance

    Hi
    yes, because  you should numeric values
    Approval Status
    Value
    Approved
    0
    Rejected
    1
    Pending
    2
    Draft
    3
    Schedule
    4
    https://farhanfaiz.wordpress.com/2010/12/17/sharepoint-approval-status-value-of-publishing-pages/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

Maybe you are looking for

  • Audio Inputs no longer work after upgrade to 10.4.10

    Anyone else having trouble with audio inputs after upgrading to 10.4.10? Here's my deal: MacPro dual 2.66, 4GB RAM, running 10.4.10 as of this morning. Upgraded to 10.4.10 today and the mic on my Plantronics USB headset quit working. 'Phones still wo

  • Migration Monitor - How Are You Using It?

    Hello! In this short discussion, you can help us to better understand how you are using the Migration Monitor – this better understanding would help the team responsible for this tool to adapt their automated tests accordingly and would also influenc

  • SQL MAX QUERY / SQL COUNT QUERY

    Hi all, i would like to get the value of the number of rows i have, but i dun seem to work it out with the getRow statements. i think the syntax of my statement is ok, but maybe i am doing the wrong way to get the value out. I tried with COUNT, and i

  • ZEN AND XBOX

    Ok i have 2 questions first why is there no updates for the creative zen(not touch) nothing is listed in firmware, or when I do the autoupdate thingy. No2 can I get this to work with the xbox 360? thanks in advance andy.

  • How do I fake it out?

    Went to MSNBC to view Olympics video. Figures that it would require a Windows, or Intel Mac machine. I tried faking it out with the Devlop/Agents choices. NO luck. Is there a way to make it look like I have an Intel machine? Thanks.