Arithmatic Operations

1) Can we declare the variables in the script ?
2)I have two variables in the driver program.
Depending on the conditions, i want to perform some arithmatic operations like Addition or subtraction in the script. How to do that ?

hi,
  You can use the perform statement in the script for calculations in the script.
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (‘First page’, ‘Next page’, ‘Last page’) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY ‘PAGE’.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = ‘|’. "First page
ELSE.
OUT_PAR-VALUE = ‘||’. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
regards,
Veeresh

Similar Messages

  • Arithmatic operations on fields in tables

    Hello Members,
    My query might seem pretty basic, but seems uphill to me, as i have no idea how to perform arithmatic operations between fields in tables.
    I have two tables temp1 and temp2. each of these tables have 2 fields : account no. and balance
    the data would resemble the following, in each of the tables:
    6.28899273 0
    6.28899274 0
    6.28899275 0
    6.28899289 625.12
    6.28899292 2666.24
    Can you please give me an idea how to go about doing the following:
    1. Compare the tables temp1 and temp2 for their respective account numbers and balances
    2. Copy the results in a new table temp3, which will have 2 columns :
    account no ( common to temp1 and temp2 )
    deviation: subtracted balance of temp1 and temp2
    regards,
    novice82

    user8635888 wrote:
    Will be great if someone can give me a headstart on the following:
    I have two tables temp1 and temp2 ( tables belonging to 2 different databases ) with two feilds
    account no., ( Common in both tables )
    balance ( float data type ).
    1. I want to compare the balance feilds in temp1 and temp2.
    print out the no. of accounts and percentage of match and mismatch.
    2. output the a/c nos. whose balances dont match into a seperate table..Hello, this might be one approach for you:
    First, identify those accounts that are different, and INSERT them into the table
    INSERT /*+ APPEND */ INTO target_table
    SELECT t1.account_no, t1.balance, t2.balance
      FROM table1 t1
      JOIN table2@db_link t2 ON (t1.account_no = t2.account_no)
    WHERE NVL(t1.balance, -99999999999) != NVL(t2.balance, -99999999999);This assumes that -99999999999 can never be a valid balance.
    Then, you can cycle through this table and print out the mismatches:
    set serveroutput on size 100000 (or set serveroutput on size unlimited)
    BEGIN
      FOR cur_rec IN (SELECT account_no, (t1.balance / CASE t2.balance WHEN 0 THEN NULL END) * 100 percent_mismatch FROM target_table)
        LOOP
          DBMS_OUTPUT.PUT_LINE('Account No: ' || cur_rec.account_no || ', Percent Mismatch: ' || cur_rec.percent_mismatch);
        END LOOP;
    END;
    /If you have a lot of records this may not be a feasible approach, and you'd be better looking at UTL_FILE if you to capture the anomolies in a file.
    And alternative would be to do the whole lot in SQL:
    set pagesize 5000
    set linesize 300
    set colsep ','
    spool /tmp/your_file.csv
    SELECT t1.account_no, t1.balance, t2.balance, (t1.balance / CASE t2.balance WHEN 0 THEN NULL END) * 100 percent_mismatch
      FROM table1 t1
      JOIN table2@db_link t2 ON (t1.account_no = t2.account_no)
    WHERE NVL(t1.balance, -99999999999) != NVL(t2.balance, -99999999999);
    user8635888 wrote:another question, that I have is, how does sql handle the computation, if a value in a particular field is divided by 0 You'll see from the code that if the divisor is zero, I'm substiting NULL, which means that the percent_mismatch will be NULL.

  • Arithmatic Operation

    class Arithmatic{
    public static void main(String[] Args){
    int x = 1;
    int y = 1;
    int z = (x++)*2;
    System.out.println(y);
    System.out.println(x++ * 2);
    //First output will be 2 and Second is 4 !!! Why!!!
    }

    System.out.println(x++ * 2);
    Same thing. The println() happens BEFORE x is incremented. So that's actually saying:
    System.out.println(x*2);
    x++;Not really. In the first statement, the x variable is incremented before the println(). It's just that the value of the x++ expression is the value of x before it's incremented. The println() happens AFTER x is incremented, but the result of the "x++ * 2" expression is the pre-incremented value of x times 2.
    So it prints 2*2, then increments x to 3.Not with the first statement.The two snippets of code are not the same thing. It may look that way from the output, but that's not how the statements are executed.
    Just to be clear, the order is (extraneous steps omitted):
    System.out.println(x++ * 2); // assume x == 2 prior to this statement1) Evaluate x++ => 2 (the variable x is incremented to 3)
    2) Evaluate int literal 2 => 2
    3) Evaluate 2 * 2 => 4
    4) Call println(4)
    ~

  • Arithmatic operations on field values jasper reports

    Hi,
    I want to calculate some percentages in the report based on some Field values present in the report. To achieve this I need to make some divisions and multiplications, is it possible to divide or multiply two variables while filling the report using jasper.
    Please help me...
    Thnks
    Veera.

    jaumev wrote:
    I have exactly th e same problem.
    Have someone solved it?
    Thanks in advancePlease, don't resurrect old threads. Start a new thread if you have a specific question. I'm locking this one.
    Kaj

  • Arithmatic(add, sub, mult) operations using radiobutton Selection

    Hi,
    I want to create simple arithmatic operation program, in that I want to use radiobutton for selection of type of arithmatic( addition or subtraction etc) and display output. This output is concerned about the selection of radioutton. please anyone give me idea about this.

    Hi,
    this is an example (sum and subtract) that you could extend
       DATA W_NUM TYPE I.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-001.
    PARAMETERS: P_NUM1 TYPE I OBLIGATORY,
                P_NUM2 TYPE I OBLIGATORY.
    SELECTION-SCREEN SKIP.
    PARAMETERS : P_ADD RADIOBUTTON GROUP GR1, "sum
                 P_SUB RADIOBUTTON GROUP GR1. "subtract
    SELECTION-SCREEN END OF BLOCK BL1.
    START-OF-SELECTION.
      CLEAR W_NUM.
      PERFORM CALCULATE USING P_NUM1 P_NUM2.
      WRITE W_NUM.
    *&      Form  CALCULATE
    FORM CALCULATE  USING  PR_NUM1
                           PR_NUM2.
      IF P_ADD EQ ABAP_ON.
        COMPUTE W_NUM = PR_NUM1 + PR_NUM2.
      ENDIF.
      IF P_SUB EQ ABAP_ON.
        COMPUTE W_NUM = PR_NUM1 - PR_NUM2.
      ENDIF.
    *others operation
    ENDFORM.                    " CALCULATE
    Regards
    Ivan

  • Executing a Arithmatic formula stored in Variable

    Hi all,
      I need solution to execute a arithmatic operation which is stored in a variable.
    For Example:
    data : var type string.
    var = ABS('-3').
    Now by means of the variable var i need to get the absolute value of -3
    ie my output should be 3 if i print the variable "var".
    Please help.
    Regards,
    Vijayakumar

    Hello,
    Do like this.
    REPORT ZV_SDN_3 .
    DATA: STR TYPE STRING.
    DATA: STR1 LIKE STR,
          INT TYPE I,
          LEN TYPE I.
    STR = ABS('-3')..
    LEN = STRLEN( STR ).
    DO LEN TIMES.
      IF NOT STR+INT(1) IS INITIAL.
        IF STR+INT(1) CA '0123456789'.
          CONCATENATE STR1 STR+INT(1) INTO STR1.
        ENDIF.
      ENDIF.
      ADD 1 TO INT.
    ENDDO.
    WRITE: STR1.
    Hope this will solve ur issue.
    Cheers,
    Vasanth

  • Arithmetic Operation Within OpenSQL

    In Oracle, I can
    <b>
    SELECT
    fiscper,
    debit + credit AS NET
    FROM MyTab;
    </b>
    Can I do something similar in OpenSQL?  I get an error message when using the same syntax.
    Thanks.

    I don't think so.
    Get all data into an internal table - Fiscal Period, Fiscal Year, Amount, Debit / Credit Indicator.
    Loop at this table and do the arithmatic operations.

  • Dump in the transaction J2I6 in ECC 6.0

    Dear all,
    I am getting a dump in the transaction J2I6 when i select the radiobutton RG23D and then give the excise group,start date and enddate.When I select the radiobutton Excel Format ,it throws a dump as follows:-
    Packed field contains incorrect BCD format.
    Error anakysis says that ''An arithmatic operation in the current program J_2IRG23 attemps to process a field of type P that contains an invalid BCD format.
    What can i do?plz help

    Hi,
    There are some OSS notes related to your problem.
    Pls check the OSS NOte 1096189. It may resolve your problem. Other related notes are 1155341.
    Please check which one is relevant to your system.
    Regrads,
    Lokesh./
    Edited by: Lokesh Tarey on Apr 22, 2010 3:24 PM

  • Detailed Report on Unit Cost Planning.

    Hi friends,
    I am doing Unit Costing in my Project in Version 1.
    Is there any standard report where I can get a display of all the Materials & services or (say) any Misc cost obtained thru Arithmatic Operation in the Unit Costing?
    That is to say the detailed report of whatever is done in the Unit Cost Planning.
    I am only getting the report of Planned Cost on Overall Basis.
    Secondly, in Unit Costing if I do any arithmatic Operation on the total value or on a particular row, then the value obtained from the arithmatic operation is not getting displayed in the cost Planning report.
    Thanks in advance.
    Regards,
    Abhra Bose.

    Hi Abhra,
    UC Method is only to plan the project cost estimates. There is no such standard report to get the detailed plan report in terms of material, resources and Miscellaneous (tru Arithmatic calculations) except cost element report ( that to interms of cost only). 
    As you said, you can only get the Overall Planned total in Hierarchical report (i.e like S_ALR_87013532 - Plan/Actual/Variance ) including arithmatic calculations. but If you check in Cost element report ( i.e like S_ALR_87013542 - Actual/Commitment/Total/Plan in CO Area Currency ) you can get all planned cost that is planned against specific cost element, since it is a cost elements based report only.) If you want the planned cost tru arithmatic calculations also, you need to specify a cost element against that line item either in BPO or at WBS level.
    Hope this will help you some extent.
    Appreciated for giving points.
    Regards,
    Hari Krishna.K

  • Table data element related

    Hi ,
    i want to create one field in table which must contain  value  range between -1000 to 1000 through SM30. i will have to do some arithmatic operation on it through another program.what type of domain i should define while creating table.can u plz tell me.

    Hi,
    If you want to restrict at the domain Level, Itsn ot possible to restrict to -1000 to 1000.
    As at the domain level you will give the length and the length can be 3 or 4, if you give 3 it will be -999 to 999 and if you 4 it will be -9999 to 9999. So -1000 to 1000 is not possible at the domain Level.
    Regards,
    Sesh

  • Why doesn't this update work?

    Why doesn't this update work? Can't I sum up two select count(*) in such a subquery?
    Thanks
    update sales T
    set T.field2 = ((select count(*)
    from sales t
    where t.field1 = trunc(sysdate)) + (select count((*)
    from sales t2
    where t2.field2 is null));
    I get
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    with the * under the +
    In other words I want to run
    update sales set field = ((select count(*) ..... ) + (select count(*) ..... ))
    Edited by: Mark1970 on 26-mar-2010 1.37
    Edited by: Mark1970 on 26-mar-2010 1.38

    My problem is to undestand why I got a syntax error about parenthesis.Because you cannot perform arithmatic operation with a value coming from a subquery in a SET clause of UPDATE
    SQL> update emp
      2  set sal=(select 1 from dual)+1;
    set sal=(select 1 from dual)+1
    ERROR at line 2:
    ORA-00933: SQL command not properly ended
    SQL> select sal from emp
      2  where deptno=(select 10 from dual)+10;
           SAL
           800
          2975
          3000
          1100
          3000
    SQL>  select deptno,sal from emp
      2   where deptno=(select 10 from dual)+10;
        DEPTNO        SAL
            20        800
            20       2975
            20       3000
            20       1100
            20       3000Try such few examples..
    Twinkle

  • El Exception - attemp to coerce a value

    I need to perform some arithmatic operation on the value which is from a vo. I tried the below code for it.
    "#{(bindings.XxWorkExpDetailsVO1ExperienceMonths mod '2')}"
    But am getting the exception
    javax.faces.el.EvaluationException: com.sun.faces.el.impl.ElException: Attempt to coerce a value of type "oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding" to type "java.lang.Long"
    I tried by removing single quotes also. But getting the same error. Kindly help.

    Hi,
    it all boils down to knowing what you do.
    1. #{bindings.XxWorkExpDetailsVO1ExperienceMonths} accesses an attribute binding. This is not a scalar type nor can it converted to one
    2. "#{bindings.XxWorkExpDetailsVO1ExperienceMonths.inputValue} accesses the exposed value of an attribute binding. If its a numeric value in ADF BC then either its BigDecinal (11.1.2) or oracle jbo.domain.Number (11.1.1.x)
    3. If it is oracle.jbo.domain.Number then this object has a method "longValue" to cast it to type long. So your expression - in theory - need to be #{bindings.XxWorkExpDetailsVO1ExperienceMonths.inputValue.longValue}. This however doesn't work with EL because EL value expressions look for properties and not methods.
    The solution to your problem is like explained in this thread
    https://forums.oracle.com/forums/thread.jspa?threadID=717868
    Create a managed bean to perform the calculation
    {code}
    long calculatedVal;
    public void setCalculatedVal(long v){}
    public long getCalculatedVal(){
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    AttributeBinding expMonth = (AttributeBinding) bindings.get("XxWorkExpDetailsVO1ExperienceMonths");
    long attrValue = ((oracle.jbo.domain.Number)expMonth.getInputValue()).longValue();
    return (attrValue % 2);
    {code}
    You then reference the managed bean property #{bean.calculatedVal} in your page
    Frank

  • Compute total based on separate iterator bindings

    I have two view objects which are each producing a single value exposed on a page. I want to add those two values together to show the total. The values are exposed on the page with the following EL expressions:
    <af:outputText value="#{bindings.SumAmount1.inputValue}" id="ot36">
    <af:convertNumber groupingUsed="false"
         pattern="#{bindings.SumAmount1.format}"/>
    </af:outputText>
    <af:outputText value="#{bindings.SumAmount2.inputValue}"
    id="ot38">
    <af:convertNumber groupingUsed="false"
    pattern="#{bindings.SumAmount2.format}"/>
    </af:outputText>
    I want to show the total as the addition of the SumAmount1 and SumAmount2 values.
    Doing the following only works when there is no format type:
    <af:outputText id="totalAmount"
    value="#{bindings.SumAmount1.inputValue.value + bindings.SumAmount2.inputValue.value}"/>
    How can I easily achieve what I want while still using a control hints -> format type on the attributes?
    Thanks,
    Stephen
    Edited by: 910447 on Jul 11, 2012 8:30 AM

    Surendranath Kumar wrote:
    Try this.
    <af:outputText id="totalAmount" value="#{bindings.SumAmount1.inputValue.value} + #{ bindings.SumAmount2.inputValue.value}"/>That won't work. That statement prints out a literal "+". To do arithmatic operations it needs to all be in the same expression #{}.
    There is something I am not getting about EL expressions and type conversion. Without any sort of convertNumber format the values are being used as Numbers like I want, but once I apply a convertNumber format to them the inputValue property seems to come back as a String. I tried putting a convertNumber on the outputText where I'm generating the total, but I wind up getting a NumberFormatException:
    <RegistrationConfigurator> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
    java.lang.NumberFormatException: For input string: "-23,692"

  • Error named like "CONVERSION ERROR"

    I am creating one Module Pool Program with the Screen Painter. There is total 10 Tab Strips used in the Screen Painter.
    When I select the Last Tab, I get the Error with the message " CONVERSION ERROR"
    Can you guide me why this error can occurs?

    Hi,
    Check whether you are entering false values in a field which is not belong to that type.
    For example, if you enter characteristic value into a numeric field and doing arithmatic operations.
    CONVERSION ERROR occurs in this case.
    Please check for above.
    Regards,
    Rajesh

  • Formatted search which perform calculation

    hi all,
    i want to design formatted search which does Arithmatic calculation of two user defind field  and display result in third UDF.
    i have designed formatted search but it gives internal error .
    Is there diff. syntax for using arithmatic operator in formatted search.
    i want to add,sub,mul runtime values from two UDF and display result in third UDF.
    please give me example.
    TIA.
    Chetan.

    Hi Chetan,
    Use the following syntax after eliminating / from it,
    /$[/$38.U_UDF1.Number]-/$[/$38.U_UDF2.Number]
    Regards,
    /Siddiq

Maybe you are looking for

  • Create the file from data base

    iam trying to upload material master data using direct input method in lsmw. i want one input text file which contains the information about material master data. can any one pls help me how to create this material master txt file from the data base.

  • Burn a DVD

    I have a movie on DV cassette. I loaded it into an Apple notebook (OS X Tiger) using the Firewire connection. I edited it in iMovie and saved it in Quicktime format. When I try to burn it to a DVD-R, iDVD wants to add all sorts of "Garbage" project s

  • How to install Taskman in E: ?

    Most appls give me the choice to select what drive i want to install, but Taskman and some others do not. Is there anything i can do to force them to be installed on E: ? ( like ini file or anything else ). Thanks. N97 RM-507 code 0575400 / 0580761 f

  • How to use tcRequestOperationsIntf API to create a self-request?

    According to documentation, I can use tcRequestOperationsIntf API methods to create and manage requests. How can I use these methods to initiate a self-request (for provisioning user a new resource)? Because when I create a usual request, it's equiva

  • Please Help. Broken References?

    I tried to share my iMovie with iDvd, and nothing happens. My movie doesn't share for some reason. There is a exlamation point next to my 'play' button in my dvd menu. And when I try to play it, I get this image of a broken chain. I tried to click an