Need code for calculation of amount field(DMBTR)of BSEG table conditionally

Hi all,
I am selecting data for fields belnr(A/c doc.), dmbtr(Amount), hkont(G/L acc) from  bseg cluster table giving the particular value for hkont in the selection screen.now there are some records fetched out of which there are few records in which same A/c no.(belnr) .So my requirement is to collect those same belnr records and do following calculation:
1. suppose for some record of same belnr , if all the value for field SHKZG is 'H' then summing up the values of field DMBTR.
2. suppose for some record of same belnr , if few value for the field SHKZG is 'H'  and few are 'S' then the                                  (summation the values of field DMBTR for all 'H' in field SHKZG  -summation the values of field DMBTR for all 'S') and both the case the single record will fetched with belnr, sum(DMBTR) according to the condition, and hkont. Please provide me the reqd. code for the above problem.Thanks in advance.
regards
Anand.

Hi Anand,
We can do like this.
This will take into account 'S', 'H' (debit/credit indicator) and BELNR wise sum.
1. Create new internal table, STAB with only two fields. (with header line)
    BELNR    "<------- refer below statement
    HKONT    "<------ Whatever unique combination of field(s) you want, you can put here 1,2, 
    DMBTR    "<----
Numeric field
If you want only HKONT wise SUM, then remove BELNR
2. Now write this code.
Loop at Itab.
Clear STAB.
IF ITAB-SHKZG = 'H'.
STAB-DMBTR = ITAB-DMBTR.
else.
STAB-DMBTR =  - ITAB-DMBTR. "<----- Negative Sign
endif.
STAB-BELNR = ITAB-BELNR.
STAB-HKONT = ITAB-HKONT.
COLLECT STAB. "<------ Important.
Endloop
Note:
Based upon the alphanumeric fields combination (BELNR and HKONT), the sum will be done.
Similar to group by in a select query
regards,
amit m.
Edited by: Amit Mittal on Jan 22, 2010 2:14 PM

Similar Messages

  • Need code for sales order create report using bapi's

    need code for sales order create report using bapi's

    Hi,
    Go through below link
    http://www.saptechies.com/bapi_salesorder_createfromdat2/
    <b>Reward points if it helps,</b>
    Satish

  • Need code for restarting my system

    hello every body i need code for restarting system
    this code does not work
    try {
    Runtime.getRuntime().exec("shutdown -s -t01") // stop
    }catch(...
    or
    try {
    Runtime.getRuntime().exec("shutdown -r -t01") // reboot
    }catch(...
    or
    try {
    Runtime.getRuntime().exec("shutdown -l -t01") // logout
    }catch(...

    write a jni function that calls this method : ExitWindowsEx()
    check the documentation

  • Need code for Sales order creation in oops using xi as integration server

    Need code for Sales order creation in oops using xi as integration server.

    hi rocky,
              could you pls give a bit explanation on what you are expecting.
    regards,
    Pavan

  • Need code for ITC502

    I need code for gpib to ITC 502.
    Need to set temperature and threshold,
    thankx

    The instruction manual for this instrument is available from Oxford
    Instruments at no charge- they sent me a copy by email as a PDF file. I
    don't have it to hand at the moment so can't dig out the relevant info but
    it would be worth having the full manual, I think. There's a bit more to a
    decent driver than simply setting the temperature, and I'm not sure what you
    mean by "threshold".
    "mdeleon" wrote in message
    news:[email protected]..
    > I need code for gpib to ITC 502.
    > Need to set temperature and threshold,
    > thankx

  • Need code for padding (spacing) 5 navigation links in my #topnavbar internal style

    need code for padding (spacing) 5 navigation links in my #topnavbar internal style

    I'm new at this and the below code is regarding the navigation bar and links
    I started using a template to create the first html page and made copies of it to create the other four.
    All the links work but I wanted to space them apart further.
    They look basically like this horizontally: Home About Us Photo Gallery Services Contact Us
    #topnavbar {
    text-align:center;
    #topnavbar a:link a:visited{
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 100%;
    font-weight: bold;
    color: #039;
    text-decoration: none;
    margin: 0 25px:
    #topnavbar a:hover a:active {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 100%;
    font-weight: bold;
    color: #039;
    text-decoration: none;
          <div id="topnavbar">
          <nav>
          <p><a href="index.html">Home</a>  
             <a href="aboutus.html">About Us</a>  
             <a href="photogallery.html">Photo Gallery</a>
             <a href="services.html">Services</a>
             <a href="contactus.html">Contact Us</a></p>  
          </nav>
           </div>

  • Urgently Need Code for Copy & Paste from Html Table in JSP to Excel file

    I am creating a html table in JSP file .
    I need code for 'Cut,Copy,Paste' functions ie. if someone wants to copy data from my table to excel file or from excel file to html table he shud be able to do that.
    Can someone give me code for 'Cut,Copy and Paste' i.e. some javascript functions which can do cut, copy and paste which i can put in my jsp file
    Thanks
    Message was edited by:
    javatechguru2007

    package com.chinmayananda
    public class Tetris{
    // complete here
    code]
    public abstract class AbstractTetris {
       public abstract void start();
       public abstract void stop();
    }nearly done

  • I'm new to jsf VWP..i need code for searching

    Hi,
    i need code for search...
    just populate records from database using jsf VWP5.5.1
    how to bind in table.
    we enter name r value in textbox click button related records display to table.how write code in button.
    pls help me....

    Don't crosspost. Please proceed here: http://forum.java.sun.com/thread.jspa?threadID=5211369

  • How to update Tr code FB02   and update the field reference key1 (bseg-xref

    Can any body
    help me how to update   Tr code   fb02
    and  update the field  reference  key1 (bseg-xref1)  with the interest amount
    calculated.
    Below i have  written My  program  flow logic
    The program should read the open items i.e debit items in the customer account,
    Based on the  invoice date and customer payment terms  calculate the due date and then the  interest should be  calculated on that item based on the due date.
    Use the  transaction  fb02  and update the field  reference  key 1 (BSEG-xref1)
    with the interest amount calculated
    Only  consider  customers whose  interest indicator  knb1-vzskz = 'vk'.
    Interest is to be  calculated for every  30  days
    at the rate of  1% .please see example below.
    Document date is 01.01.2007
    for amount  1000SGD   payment  term  7  days
    It becomes  due  on  08.01.2007
    until  06.02.2007 you should not  consider  for calculation of interest
    SGD  on   7.02.2007 run you can consider this  item for interest calculation

    Hi Robert,
    Thanks for answering.
    I am looking at Ref 2 should flow automatically to clearing document from the accounitng document for billing.
    Ex: Billing document is created and accounted. Ref 2 is AB
    Now when receipt is accounted for this biling document this AB should flow automatically to Ref 2 field.
    Thanks
    NNS.

  • I need to add check whether 21 fields of a internal table are empty or not.

    Hello,
    I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
    I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.

    Hi,
    After the select quiery.
    If not itab is initial.
    Message 'Table is not empty'    type 'I'.
    Endif.
    Regards,
    Jagadish.

  • Need Code for FM for extracting the fields in view!

    Hi,
    can any one here pls give me the sample code for the function module, extracting all the fields in view ?
    Thanks,
    Ravi

    No No,
    I need to append two more fields other than the fields existing in View.and for that i need to create FM as per the requirement. they do not want view in the data source definition any more.
    now i want a sample code for Building the FM code
    Hope i am clear this time
    Thanks,
    Ravi

  • Code for calculating variance between plan and actual in Co module

    Hi Abbapers,
    I have to develop a  2 fresh report : One for calculating the variance for the Plan/Actual in controlling and second for sales variance for the month Jan to Dec .
    I need your help as I have to complete this reports in this week . Its Bit urgent.
    Can you please help me with the sample code or any of the similar report which you might have created as I am bit new in ABAP. Please reply asap.
    Thanks in advance!
    Best Regards.

    Hi Deepak,
    For Finished Goods materials  if you assigned Price control  V (Moving Average) it is irrelevant  to run the Standard Cost Estimation.
    My earlier client we don't have variance because of the Moving Average Price for Finished Goods.
    Please check, It is really required Variance??  If it is required check whether variance key is automatically assigned to Process order or not. (Control Tab)
    Ravi Polampalli

  • Need code for this Small validation on when-validate-item

    Hi All,
    I have a text item(date datatype) in forms 4.5 I need to do a small validation want to write on when-validate-item. When I enter a date in that text item (Ex 10-JUN-2005) it has to check
    1) It Cannot be "blank"
    2) It cannot be "Not older than today"
    can you please put me code for this small validation. I am new to Forms.
    Thanks in Advance,
    Reddy

    I always put code in the when-validate-RECORD trigger to ensure fields are entered, rather than setting the property. That way, the user can enter other fields within the record, and then gets a message that the field is required only when leaving the record.
    ...of course, if the date item is the only field in the block, then the when-validate triggers will not run unless the user at least types a space in the date. In that case, you need to check in the key-commit trigger.

  • BADI used for updation of Amount fields for transaction CL24N

    Hi All,
    Badi's used for the transaction CL24N . Since need to update amount field ZPO_AMOUNT , ZPO_AMOUNT_GBP in the trsaction for a particular Realease strategy
    Thanks,
    Narasimha.

    Hi,
      There are 4 User-Exits and 2 Badis present for that transaction. Check whether it is useful.
    Enhancement/ Business Add-in            Description
    Enhancement
    CLCLRS01                                Additional Fields on the Result Screen
    CLCLRS02                                Fill the Additional Fields on the Result Screen
    CLFM0003                                Call Up After Check of Assigned Characteristic Values
    CLMMD001                                Selection of Objects for Mass Processing
    Business Add-in
    CACL_CHARACTER_INPUT                    Value Assgmt Screen: Set Ready-For-Input Status for Chars
    CACL_VALUE_CHANGE                       Change/Check User Input Before Syntax Check
    Hope this will help.
    Regards,
    Swarna Munukoti.

  • Need code for dialog program

    Hi All,
    My requirement is to create a selection screen with
    1. browse field - selection for the  files to be uploaded
    2. Checkbox - Test run the transaction without parking the entries
    3. Two push button Execute and Cancel
      Execute - to lunch the program
      Cancel - cancel the program and return to menu
    Please provive the code and procedure to create screen. i am new for dialog program.
    Thanks,
    Madhu

    Rather than waiting for someone here to write the code for you, you'd be better off looking at the examples in SAP as already mentioned and reading the SAP help at[http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba66935c111d1829f0000e829fbfe/frameset.htm]

Maybe you are looking for