To get the sum of column of SAPScript based upon condition

Hi,
I was first asked to get two new columns in ZF140_ACC_STAT_01 script with ZRFKORD10 print program. I did so by the writing the below code. Now, based on Document-Type (RV,DR,DZ,SA), all the amount with same Document Type are needed to be summed and assigned to separate variables.
How to get that done????? Please help me out.
PRINT-PROGRAM:-
FORM sep_amt_open TABLES in_par STRUCTURE itcsy
                     out_par STRUCTURE itcsy.
DATA: wf_temp_amt_open TYPE string,"rf140-wrshb,
       amount_open TYPE string,
       amt_shkzg_open TYPE bsid-shkzg,
       doc_desc TYPE t003t-ltext.
READ TABLE in_par WITH KEY name = 'RF140-BELEGNUM'.   " document no
   IF SY-SUBRC = 0.
   SELECT SINGLE SHKZG FROM BSID INTO (amt_shkzg_open)
     WHERE BELNR = IN_PAR-VALUE.
ENDIF.
READ TABLE in_par WITH KEY name = 'T003T-BLART'.     " document description
   IF sy-subrc = 0.
    SELECT SINGLE LTEXT FROM T003T INTO (doc_desc)
      WHERE SPRAS = 'E' AND BLART = IN_PAR-VALUE.
   IF sy-subrc = 0.
     READ TABLE out_par WITH KEY name = 'DOC_DESC'.
      IF SY-SUBRC = 0.
        OUT_PAR-VALUE = DOC_DESC.
        MODIFY OUT_PAR INDEX SY-TABIX.
      ENDIF.
   ENDIF.
  ENDIF.
  READ TABLE in_par WITH KEY name = 'RF140-WRSHB'.    " Amount
    IF sy-subrc = 0.
     wf_temp_amt_open = in_par-value.
   ENDIF.
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input         = wf_temp_amt_open
   IMPORTING
     OUTPUT        = amount_open
IF amt_shkzg_open = 'S'.
    READ TABLE out_par WITH KEY name = 'DEBIT_OPEN'.
     IF SY-SUBRC = 0.
       out_par-value = amount_open.
       MODIFY out_par INDEX sy-tabix.
       CLEAR out_par.
     ENDIF.
ELSEIF amt_shkzg_open = 'H'.
    READ TABLE out_par WITH KEY name = 'CREDIT_OPEN'.
     IF SY-SUBRC = 0.
       out_par-value = amount_open.
       MODIFY out_par INDEX sy-tabix.
       CLEAR out_par.
     ENDIF.
  ENDIF.
ENDFORM.
SAPSCRIPT:-
/:DEFINE &DEBIT_OPEN& = ' '
/:DEFINE &CREDIT_CLEAR& = ' '
/:DEFINE &DOC_DESC& = ' '
/:PERFORM SEP_AMT_OPEN IN PROGRAM ZF27_DRIVER_PROGRAM
/:USING &RF140-BELEGNUM&
/:USING &T003T-BLART&
/:USING &RF140-WRSHB&
/:CHANGING &DEBIT_OPEN&
/:CHANGING &CREDIT_OPEN&
/:CHANGING &DOC_DESC&
/:ENDPERFORM
T1 &RF140-BELEGNUM&,,&BSID-BLDAT&,,&T003T-BLART&,,&BSID-WAERS&,,&DOC_DESC&
=  ,, &DEBIT_OPEN&,,&CREDIT_OPEN&,,
T1 ,,&BSID-SGTXT&
Thanks & Regards,
Rakesh Nair

If you are mentioning about table/advanced table region you can enable totalling in those regions. Please check the Table / Advanced Table section as appropriate in Chapter 4 of the dev guide.
If it is not a table / advancedTable then you will have to programmatically total the column value and display it in the appropriate cell.

Similar Messages

  • How do you get the sum of two columns multipied together?

    I can't seem to figure out how to get the sum of two columns multiplied together without having to manually type out each location (example: A1*B1+A2*B2+A3*B3, etc..).  Though the idea seems to be rather simple, everything I have tried has only given me an error.  I know there must be an easier way of doing this, but I get lost in the explanations given in 'help' area of numbers, can someone help me?

    C3=SUMPRODUCT(A3:A18, B3:B18)
    the function SUMPRODUCT() takes ranges and multiplies corresponding cells in the ranges, then adds them together.
    I the case I show SUMPRODUCT() performs:
    A3*B3 + A4*B4 + A5*B5 + A6*B6 + ... +  A18*B18
    If you want to perform the same operation on the whole column (s) you could modify the formula:
    C3=SUMPRODUCT(A, B)

  • Get the sum/product of two UDF rows before adding A/R Invoice

    Hi Everyone,
    I am making some tests here where I am trying to get the sum or product of two UDF rows in a service type A/R invoice where I need to get the product before i even add the document.
    The query goes like:
    SELECT T0.[U_UDF1] * T0.[U_UDF2] FROM INV1 T0 WHERE T0.[U_UDF1] = $[INV1.U_UDF1]
    It did not work. Is this possible?
    Thanks,
    Derrick

    Before you add a transaction, the values you specify in the screen are not stored into the database. In an FS you can use SQL statements but in these statements you can refer only to the actual header or row level data with the special expressions starting with $. The system replaces these expressions with a constant containing the actual value before executing the SQL string.
    So there is no possibility to sum the columns with FS before adding the document.
    Sorry, I didnu2019t read carefully your question and probably misunderstood it.
    Edited by: István K#rös on Jan 13, 2011 11:27 AM

  • Get the sum currency wise.

    hi all,
    i am using report 6i.
    i have written query like below in data model and data is coming correct.
    SELECT
         bft_company
    ,     bft_reference
    ,     bft_charge_code
    ,     bft_chg_basis
    ,     bft_quantity
    ,     bft_currency
    ,     bft_local_amount
    ,     bft_mode
    ,       bft_remarks
    FROM
         Bdl_Freight
    WHERE bft_mode = 'C'i want sum(bft_local_amount) group by currency. page wise total and grand total, at the end of the report.
    my problem is i am not able to get the pagewise sum.
    i have formula like below
    SELECT bft_currency, sum(bft_local_amount)
    FROM Bdl_Freight
    WHERE bft_company = :bft_company
    AND bft_reference = :bft_reference
    group by bft_currency;from the above forumula i am getting grand total, but i am not able to get the page wise column. due to lack of "reset at" property.
    How can i get the pagewise total baseed on the currency.
    Please help.
    Thanks..

    Hi
    In Report you can get sum values based on group values/full report.
    In case if you want per page- i think you should do manually like predefined rows. But is not advisable way.
    Please check below link, you may have some idea
    How to display pagewise total in Oracle reports?
    Edited by: AppsLearner on Aug 1, 2012 9:11 AM

  • How to get the sum total of just one row in the dashboard

    How do I get the sum total of one row in the compound layer results. This is 11g
    Does anyone know?
    may be sales, I need the total at the bottom of the row..
    thx
    Chuck

    I fnd the answer,
    in the table view, click edit then nxt to the columns and measures there is total sum icon. Click that, and choose after

  • How to get the number of columns in a result set???

    hi everyone..
    i am trying to establish a servlet applet communication....
    my applet send the sql query to the servlet as serialised string and then the servlet executes the query...
    Since i need to pass the result back to the applet, i thaught of passing the whole reult set to the applet..but that seems to be not possible..
    so i thaught of storing my result set data in a vector and then pass the vector,but the first problem that i came across is that how to get the number of colums in a result set....
    so is there a way to get the number of columns in a result set...???
    and also i would like to know if it possible to send my whole result set to the applet bye serialization or by any method...???
    thanx in advance

    You shouldn't do. It expenses resources (you should always close the ResultSet and the Statement as fast as possible). Simply gently process it into a Collection or Map of DTO's. Those are serializable.

  • Getting the sum of all members in a hierarchy....

    Hi,
    I want to get the sum of each member in a hierarchy....
    The hierarchy is defined in the table strdet:
    create table strdet
    (costcenterms varchar2(20),     // parent
    costcenterdet varchar2(20),    // child
    lev varchar2(1))The values for each object/material per costcenter(child) is defined in the table details_det:
    create table details_det
    (costcenterms varchar2(20),
    eppid varchar2(30) ,
    purchcontyear0 number(4,1) )Some sample data:
    insert into strdet values ('1' , '1.1','2')
    insert into strdet values ('1' , '1.2','2')
    insert into strdet values ('1.1' , '1.1.1','3')
    insert into strdet values ('1.1' , '1.1.2','3')
    insert into strdet values ('1.2' , '1.2.1','3')
    insert into strdet values ('1.2' , '1.2.2','3')
    insert into strdet values ('1.2' , '1.2.3','3')
    insert into strdet values ('1.1.1' , '1.1.1.1','4')
    insert into strdet values ('1.1.1' , '1.1.1.2','4')
    insert into strdet values ('1.1.2' , '1.1.2.1','4')
    insert into strdet values ('1.2.1' , '1.2.1.1','4')
    insert into strdet values ('1.2.1' , '1.2.1.2','4')
    COMMIT;
    insert into details_det values('1.1.1.1','epp1',10);
    insert into details_det values('1.1.1.1','epp2',20);
    insert into details_det values('1.1.1.1','epp3',0);
    insert into details_det values('1.1.1.2','epp1',0);
    insert into details_det values('1.1.2.1','epp2',5);
    insert into details_det values('1.1.2.1','epp4',15);
    insert into details_det values('1.2.1.1','epp1',65);
    insert into details_det values('1.2.1.1','epp2',95);
    insert into details_det values('1.2.1.2','epp1',5);
    commit;The output of the desired sql stmt must be like this:
    costcenter             val
    1                        220
    1.1                       55
    1.2                     165
    1.1.1                    30
    1.1.2                    20
    1.2.1                  165I have written the following , so far.....
    SQL> select distinct s.costcenterms , sum(purchcontyear0) over(partition by s.costcenterms order by s.costcenterms)
      2        from details_det d , strdet s
      3        where s.costcenterdet=d.costcenterms(+)
      4        start with s.costcenterms='1'
      5             connect by  s.costcenterms = prior s.costcenterdet
      6        order by s.costcenterms
      7  /
    COSTCENTERMS                                                 SUM(PURCHCONTYEAR0)OVER(PARTIT
    1.2                                                         
    1.2.1                                                                                   165
    1.1.1                                                                                    30
    1.1.2                                                                                    20
    1                                                           
    1.1                                                         
    6 rows selectedHow should i modify the above sql stmt to get the desired result...????
    Note: I use OracleDB 10g. v.2
    Thanks, a lot
    Sim

    I' m grateful to all.....!!!!
    I connected as user SYS so as to give the appropriate privileges to SCOTT schema ....
    SQL*Plus: Release 10.2.0.1.0 - Production on Êõñ Óåð 14 11:03:44 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    SQL> connect sys/***@info as sysdba;
    Connected
    SQL> grant create materialized view to scott;
    Grant succedded
    SQL> grant alter any materialized view to scott with admin option;
    Grant succedded
    SQL> connect scott/tiger@info;
    Connected
    SQL> create materialized view mv 
      2  as
      3  select s.costcenterms , sum(connect_by_root d.purchcontyear0) sum_cbr
      4   from details_det d  , strdet s
      5   where s.costcenterdet = d.costcenterms(+)
      6  connect by s.costcenterdet = prior s.costcenterms
      7  group by s.costcenterms
      8  order by length(s.costcenterms) , s.costcenterms ;
    create materialized view mv
    Error in line 1
    ORA-30361: unrecognized string type
    SQL> create materialized view x_mv
      2  as
      3  select grp, sum(purchcontyear0)
      4  from (
      5  select connect_by_root s.costcenterms grp, d.purchcontyear0
      6   from strdet s, details_det d
      7  where s.costcenterdet=d.costcenterms(+)
      8  connect by s.costcenterms = prior s.costcenterdet
      9  )
    10  group by grp
    11  /
    Materialized view created
    SQL> create materialized view mv 
      2  as
      3  select s.costcenterms , sum(connect_by_root d.purchcontyear0) sum_cbr
      4   from details_det d  , strdet s
      5   where s.costcenterdet = d.costcenterms(+)
      6  connect by s.costcenterdet = prior s.costcenterms
      7  group by s.costcenterms ;
    create materialized view mv
    Error in line 1
    ORA-30361: unrecognized string typeTo sum up.....
    Rob's version of definition of mv is unsuccessful... even when i omit the order by clause.... whereas SY's version is successful..... Can you imagine why since... as Rob posted above , it is successful in his environment......!!!!!
    Note: As regards the ORA- error , the cause and action of Oracle is as follows:
    Cause: An internal Oracle error occured.
        Action: Report the problem through your normal support channels. Thanks again,
    Sim

  • Getting the sum of the elements in an array

    Hello all,
    Any ideas on how to easily get the sum of the elements of an array of floating points (or any data type for that matter ) this is to be part of a method.
    arrayName (float [] floaters)
    Thanks

    int total=0;
    for(int a=0; a<array.length; a++){
      total=total+array[a];
    }now is that so hard?
    or even as a method
    public int addUp(int[] array){
       int total=0;
       for(int a=0; a<array.length; a++){
          total=total+array[a];
       return total;
    }to be used as
    int total=addUp(array);just write your own!

  • I've downloaded movies from the iTunes store to my iPad but when I want to play them, I get the message... iTunes Store Terms and Conditions but when I follow the link it still doesn't let me play my movies. What am I doing wrong?

    I've downloaded movies from the iTunes store to my iPad but when I want to play them, I get the message... iTunes Store Terms and Conditions... but when I follow the link it still doesn't let me play my movies. What am I doing wrong?

    Easy maybe, but a lot of users are used to playing the movies in iTunes on their computers so that is the first place they turn to on the iPad.
    Enjoy the show!

  • Can't get a text field to atuo populate based upon a dropdown selection

    I have a drop down box with 3 values that can be selected:
    Dropdown2 = 101-3 subd.A
                          101-3 subd.B
                          101-3 subd.C
    I am trying to get a text field to auto populate based upon the selection:
    if Dropdown2 = 101-3 subd.A then Text4 = "ValueA"
    if Dropdown2 = 101-3 subd.B then Text4 = "ValueB"
    if Dropdown2 = 101-3 subd.C then Text4 = "ValueC"
    I have tried to create a custom calculation script for Text4:
    var v= getfiled("Dropdown2").value;
    if (v="101-3 subd.A") event.value = "ValueA";
         else if (v="101-3 subd.B") event.value = "ValueB";
         else if (v="101-3 subd.C") event.value = "ValueC";
         else event.value = " ";
    I have entered this script and the syntax appears to be correct.(At least to Acrobat XI.  I'm know programmer and have just enough knowledge to be dangerous).  When I select a value in Dropdown2 nothing happens.  No value appears in Text4.  I have checked the "commit selected value immediately" in the option of Dropdown2 per some google'ing.  I just can not understand why the values do not appear.  Any help would be appreciated.
    Thanks

    I made the changes and added the == to my if statements.  When I select a value in Dropdown2, Nothing appears in Text4.  I don't understand.  Is there something else that I need to do beside event.value="Some Value";?
    I know it has to be something simple that I am missing, but I just can't seem to see it.
    Text4 - Custom Calculation Script:
    var v= getfiled("Dropdown2").value;
    if (v=="101-3 subd.A") event.value = "ValueA";
         else if (v=="101-3 subd.B") event.value = "ValueB";
         else if (v=="101-3 subd.C") event.value = "ValueC";
         else event.value = " ";

  • How to get the sum in appropriate column without a red triangle appearing?

    Hello,
    In 'Numbers" - How do get columns to add (calculate) the sum in each decending column on an Expense Report.
    When I highlight the decending column the total appears on the far left of the screen.  When I drag the sum amount from there to the appropriate column a red triangle with an ! appears instead of the amount.
    Thanks for your immediate help.

    The red triangle is an Error triangle. Clicking it will display the error message and tell you what error has occurred. From your description, my assumption is that you dragged the SUM() function from the quick calculations at the lower left and dropped it intto a cell in the column being summed.
    If that's the case, this is likely the error message you would see:
    When you highlighted the 'decending column,' you likely selected all of the cells in that column, including the one into which you dropped the function.
    Instead, do one of the following. These assume the column you want to sum is column B.
    If you want the sum at the top of the column:
    Make sure the row you want the sum to appear in is a Header row.
    Enter this formula into any Header Row cell in column B:   =SUM(B)
    If you want the sum at the bottom of the column:
    Add a Footer row to the table. (Go Table (menu) > Footer Rows > 1).
    Enter this formula into the Footer Row cell in column B:   =SUM(B)
    SUM (and other functions) that expect a range of cells will interpret a cell reference entered using only the column letter (B) as meaning 'all of the non-header, non-footer cells in column B', and will exclude those cells in header or footer rows.
    Regards,
    Barry

  • I can't get the Sum of a Column

    I was hoping someone would be able to help me figure out what I'm doing wrong on a form that I'm unable to get a SUM of a column for?  I'm new to LiveCycle Designer and have poured over all that I can find on the internet to figure this out but it's been 10+ hours and I'm no closer now then when I started. Specifically, I added a table to a form that has a multiplication formula set up in each of the ROWs (item * cost = total kind of scenario). These formula's work and give me the the $ amount in the last column titled "total." The problem is I can't figure out how to get a sum of the totals for the "grandtotal" cell at the bottom? Each formula I've tried gives me a warning that "total[*] is unknown" so it makes me think I have my cell menu's set up incorrectly since it's not registering it the $ amount in my "total" cells?  This is work project and I'm at a stopping point until I can figure this out so any help is gratefully appreciated.  Donna
    Table/Row/Column Info:
    My table is: table 3
    My row is: cell1 (all are called cell1)
    My column is total1 (I've changed these to total 1, total2, total3, etc in my efforts to troubleshoot)
    FormCalc entries that I've tried:
    Sum(total[*])
    Sum(total[*]).amount[*])
    $ = Sum(total1.amount + total1.amount + total3.amount)
    Sum(table3.cell[*].total[*])

    HI,
    It appears you've phyically created 3 indivdual rows (correct me if I'm mistaken), so if that's the case...you can simply capature the GrandTotal by adding the fields using by their respective names. Thus, the GrandTotal script would be:  $ = Sum(total1+toal2+total3). Im not sure why you're using ".amount".
    [*] is used when you have repeating subforms. So, say you started out with a single row (Row1) with the following fields: Qty, UnitCost, Total... where Total (field in last column) had the follwoing script: $ = Qty * UnitCost
    If your form was "dynamic" and used an Add Row button, then you would only have to create one row and enable your user to "Add" additional rows, as needed.  As a result, you would need to use an array [*] to find all instances of Total on each row.
    In that case, your script for GrandTotal would look like this: $ = Sum(Page1.Items.Row1[*].Total). Note: Page1.Items is the absoulte location for Row1 on my form, so this would change for you.
    Going back to my previous comment, since your form doesn't appear to use an Add row button, you shoudl be able to add the fields names quite easily.
    Lastly, as an FYI,  you shouldn't need a [*] after total in......Sum(table3.cell[*].total[*])
    Let me know if this helps!
    Thanks
    Shaun

  • How to get the sum of  a column in a table layout region

    i have page table layout region and i have many rows in that ...i have a column say xyz now i want the sum of all xyz in all rows ...is that possible ..if it is how..????
    please help me out in this issues...so that i can proceed further with my work..im stuck otu here....if the solution r there in the devguide please tell me where it is ..i mean under which section...bcoz it 1400page document...

    If you are mentioning about table/advanced table region you can enable totalling in those regions. Please check the Table / Advanced Table section as appropriate in Chapter 4 of the dev guide.
    If it is not a table / advancedTable then you will have to programmatically total the column value and display it in the appropriate cell.

  • How to get the summed up total of the column?

    Hi BW gurus,
    i created a restricted keyfigure for amount,account#,0metype and for the corresponding 0metype and account# i am getting the amount for the fiscal period(12 months in column).
    i need to get the total for the amount for each fiscal period(columnwise total).
    If any more details needed plz reply me.
    Help is highly appreciated.
    Thanks in advance,
    Sam Mathew

    Hello Sam,
    You can try displaying the results row of 0metype or account#. Hope this helps.

  • Is it possible to get the sum of all true (checked) columns?

    I am totally new to numbers, and I have just a vague understanding of excel, so I be needing some help.
    I am a hairstylist and I am using my iPad for client tracking.  My spreadsheet has totals referring to amount of clients, service totals, retail totals, average service tickets, etc.  I also need to track my pre-booking.  An easy way for me to track my pre's is to have a true/false check box column.  Is there a way to add up all of the true checks?  I have other factors I need to track like amount of services so I would like to utilize the true/false check boxes.  I do not want to add the adjoining columns, just the true false columns.  To clarify, I want to add all of the true check boxes with a resulting sum, of only the true (checked) boxes.
    Hopefully I'm not being mega confusing....

    Yes it is
    Use the COUNTIF function

Maybe you are looking for

  • Why aren't recipients receiving the whole of my email?

    It has come to my attention that some recipients of emails are not receiving the entire message. On two recent occaisions I received replies asking for information I knew I'd already sent. Scrolling down showed that they'd only received a part of my

  • I am facing alot of weird problems on my lumia 620

    My phone started to lag so much wen I changed my SD card.wen I go to music and click a song the screen gets stuck and takes about 4 sec's to strt the song. And wen I save a photo from Bing,the phone makes 2 other copies of it.and the speakers suck th

  • Macbook Pro 2012 System Crash

    My 13'' Macbook 2012 is using Mavericks. On a number of occasions now I have been using my Mac and the system has crashed. As far as I can remember I have been using Safari at the time of the crash, and had a number of other applications running, but

  • I can't highlight FOI in a circle with mapviewer!

    Excuse me,I came with a question like this: At frist ,I added a basemap:linshi.demo_map; Then,I added a themebasefoi:linshi.cp_u_p; and then I'd like to draw a circle to highlight the foi in it. But when I had finished drawn the circle , an error app

  • Problem in LSMW IDOC - Test Scenario Loading Infotype0139

    Hi Experts, I am Currently working on LSMW IDOC method,The scenario is  InfoType 0139 - Loading applicant details (loading a flat file csv format from my desktop) In Step 1 : While saving after entering the details of Message type and Basic Type, get