Get total quantity and amount value from mseg

Hello everyone, i am a newbie abaper, i am trying to do a report of some movements, i made the most difficult part but
i have problems to get the total of quantity and amount because there are not negatives values in
menge, i know that i must use the bwart to know if + or - to the quantity but there is a more efficient way
to do than, thanks:
Edited by: javico40 on Nov 16, 2011 2:26 PM

I solved it using bwart
LOOP AT it_matinitial INTO  wa_matinitial.
     IF materialCodeAct EQ ''.
       materialCodeAct = wa_matinitial-matnr.
       if wa_matinitial-bwart = '561'.
         GIN = totalInitial + wa_matinitial-menge.
         totalInitial = GIN.
         AIN = totalAmountInitial + wa_matinitial-dmbtr.
         totalAmountInitial = AIN.
       elseif wa_matinitial-bwart = '562'.
         GIN = totalInitial - wa_matinitial-menge.
         totalInitial = GIN.
         AIN = totalAmountInitial - wa_matinitial-dmbtr.
         totalAmountInitial = AIN.
       endif.
     ELSEIF materialCodeAct EQ wa_matinitial-matnr.
       if wa_matinitial-bwart = '561'.
         GIN = totalInitial + wa_matinitial-menge.
         totalInitial = GIN.
         AIN = totalAmountInitial + wa_matinitial-dmbtr.
         totalAmountInitial = AIN.
       elseif wa_matinitial-bwart = '562'.
         GIN = totalInitial - wa_matinitial-menge.
         totalInitial = GIN.
         AIN = totalAmountInitial - wa_matinitial-dmbtr.
         totalAmountInitial = AIN.
       endif.
     ELSEIF  materialCodeAct NE wa_matinitial-matnr.
       wa_matinitial_aux-matnr = materialCodeAct.
       wa_matinitial_aux-menge = totalInitial.
       wa_matinitial_aux-dmbtr = totalAmountInitial.
       INSERT wa_matinitial_aux INTO TABLE it_matinitial_aux.
       GIN = 0.
       totalInitial = 0.
       materialCodeAct = wa_matinitial-matnr.
       if wa_matinitial-bwart = '561'.
         GIN = totalInitial + wa_matinitial-menge.
         totalInitial = GIN.
          AIN = totalAmountInitial + wa_matinitial-dmbtr.
          totalAmountInitial = AIN.
       elseif wa_matinitial-bwart = '562'.
         GIN = totalInitial - wa_matinitial-menge.
         totalInitial = GIN.
         AIN = totalAmountInitial - wa_matinitial-dmbtr.
         totalAmountInitial = AIN.
       endif.
     ENDIF.
   ENDLOOP.

Similar Messages

  • Sql query to bind data from grid and print total count and amount total when date changes

    SELECT SLHD.VOUCH_CODE,SLHD.VOUCH_DATE,SLHD.VOUCH_NUM,SUM(SLTXN.CALC_NET_AMT) AS AMT,ACT.ACT_NAME,SUM(SLTXN.TOT_QTY) AS QTY
    FROM SL_HEAD20132014 AS SLHD,ACCOUNTS AS ACT,SL_TXN20132014 AS SLTXN
    WHERE SLHD.ACT_CODE=ACT.ACT_CODE AND SLTXN.VOUCH_CODE=SLHD.VOUCH_CODE
    GROUP BY SLHD.VOUCH_CODE,SLHD.VOUCH_DATE,SLHD.VOUCH_NUM,ACT.ACT_NAME
    ORDER BY SLHD.VOUCH_DATE 
    i want to print total quatity and total sale in grid when data changes
    like
    date amount quantity
    01/02/2013 1200 1
    01/02/2013  200 1
    01/02/2013  1400 2 // date changes here 
    02/03/2013 100 1 
    02/03/2013 50 4
    02/03/2013 150 5 // date changes and so on

    this query only print all the data from table i want total quantity and total amount of daily sale in same grid when ever date changes
    You may add the date filter to Visakh's query:
    SELECT SLHD.VOUCH_DATE,SUM(SLTXN.CALC_NET_AMT) AS AMT,SUM(SLTXN.TOT_QTY) AS QTY
    FROM SL_HEAD20132014 AS SLHD,ACCOUNTS AS ACT,SL_TXN20132014 AS SLTXN
    WHERE SLHD.ACT_CODE=ACT.ACT_CODE AND SLTXN.VOUCH_CODE=SLHD.VOUCH_CODEand SLHD.VOUCH_DATE = @yourdate --passed from the front end application
    GROUP BY SLHD.VOUCH_DATE
    WITH CUBE
    ORDER BY SLHD.VOUCH_DATE
    Having said, each time when you select the date, you query the table would be expensive method. May be you can filter the date within your dataset already populated if you have entire data in the dataset.

  • How to display total "items" and "amount " in header.jsp in CRM ISA B2B

    Hi,
    I am modifying “header.jsp” in standard CRM ISA B2B application.  Here we have summary of total number of items and total amount but it is coming in to button and for that below code is there in “header.jsp” and it display it as button text.
    if (!ui.homActivated) { %>
    !!" alt="" border="0" height="16" width="20">
    </td>
    <td class="vertical-align-middle" name="miniBasket" value="<isa:translate key="b2b.header.minibasket.default"/>" >
            <form name="basketForm" action="javascript:show_basket();">
         <input class="green" name="miniBasket" type="button" value="<isa:translate key="b2b.header.minibasket.default"/>"/>   
        </form>
    </td>   
    <% } else { %>
    <!-- HOM scenario - minibasket displays collective order -->
    <td  class="vertical-align-middle" align="right">
    !!" alt="" border="0" height="16" width="20">
    </td>
    <td  class="vertical-align-middle" name="miniBasket" value="<isa:translate key="b2b.header.collorder.default"/>">
    <form name="basketForm" action="javascript:show_collective_order();">
        <input class="green" name="miniBasket" type="button" value="<isa:translate key="b2b.header.collorder.default"/>"/>   
    </form>
    </td>
    <% } %>
    Now I want to display total number of items and total amount separately in two different <td> element.
    How I can get total number of items and total amount in “header.jsp” I tried below code but did not get any success.
    Insert below line in “header.jsp” with respective page import statement for class or let me know which class I have to import.
    <%
         HeaderSalesDocument  hdr =
                (HeaderSalesDocument) request.getAttribute(MaintainBasketBaseAction.RK_HEADER);
        ItemList items =
                (ItemList) request.getAttribute(MaintainBasketBaseAction.RK_ITEMS);
    %>
    And then I use
    <td><%= hdr.getNetValue() %></td>
    <td><%= items.size() %></td>
    But it is not printing any thing and header page not display at all.
    Pl. tell me how to get total amount and number of items in header area. Which class or object I have to use here.
    I really appreciated any help from any one.
    Thanks and regards.
    Ashish Patel.

    Hi, I tried another logic. I took value from  Standard button, in which B2B application display total items and amount and I hide this field, to another text element.
    Now I Am breaking that value in words and stored them in array  and then trying to display that array with particular number which contains total item and amount through Java Script on Focus.
    But problem here is, It is not getting updated automatically I have to click on new text files to trigger Onfocus event. How I can achieve effect like as soon as Standard button changes it's value which is now hidden filed my new text box should update automatically.
    Thanks.
    Ashish

  • Miro line item quantity and amount after miro

    Dear Forum,
    I have got the help about this subject and quite clear. Thanks for all have helped.
    Now I need to confirm 1 more part.
    Assuming in PO there are 2 scenarios where gr based iv is ticked and also not ticked, after both GR and miro done (complete the process from PO until book vendor invoice in miro), I purposely do another miro invoice type referring to these 2 PO.
    I just wonder why the item line still enabled with quantity and amount fields empty? I thought the line item should be totally grey out?
    Need advice.
    Thanks
    Rgds

    Dear Srina,
    As Std SAP practice system will populate the line item with enable mode even though MIRO fully done for said line item. But any how message will prompt if you enter amount & qty again in empty field & wanted to post the said line item as stated below;
    "Check if invoice already entered under accounting doc. no. XXXXXXXXX  2010". Probably you may refer to abapers to have user exit to control this field.
    Please view the below link for better understanding.
    Exits and Badi in Logistic Invoice Verification
    Calculate tax in MIRO
    rgds,
    nanthakumar

  • Difference in Quantity and amount between PO and invoice

    Dear Experts,
      In my implementation, the customer puts water in the finished material BOM and wants to issue it to the production. So we made a fake PO with the required quantity and received its quantity in the inventory. The problem faces us when the monthly water invoice comes from the water company and we want to invoice in "MIRO" with reference to the purchase order. Always the quantity and amount in the incoming invoice are different from the ones in the purchase order. Please, Advise.
    Thanks,
    Magdy.

    Hi all ;
    I think that you procure water which is used your BOM. You get invoices periodically but there is inconsistency between PO and Invoice quantity and amount.
    You can benefit from M8 system messages , i created a document M8 messages for incoming invoices with tolerances that might be helpful.
    If it is used in BOM, i do not think so relation pipeline material process...
    Regards.
    M.Ozgur Unal

  • How to get total numbers and total price in query reports

    Hi,
    how to get total numbers and total price in query reports.for example:
    particular item is issued 3 times a week...I need total quantity of item issued
    my query...
    SELECT T0.[DocNum], T1.[ItemCode], T1.[Quantity], T1.[Price] FROM OIGE T0  INNER JOIN IGE1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[ItemCode]  Like '%%[%1]%%'  and  T1.[U_WOType]='[%0]'

    Hi,
    Try this:
    SELECT T1.[ItemCode], SUM (T1.[Quantity]) as [Total Quantity], SUM (T1.[Quantity] * T1.[Price]) as [Total Price] FROM OIGE T0  INNER JOIN IGE1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[ItemCode]  Like '%%[%1]%%'  and  T1.[U_WOType]='[%0]'
    Group By T1.[ItemCode]
    Beni.

  • To get line item and confirmation details from CRM_ORDER_READ

    Hi,
    Please can anybody let me know which the field from which i can get line item details and material for the service order given?
    I am using CRM_ORDER_READ to retrieve the values. In that i am exporting 4 fields - et_orderadm_h,  et_orderadm_i, et_product_i, et_doc_flow. So from where to get line items and material id from these fields?
    I will be very thankful if i get the answer of this question.

    Hi,
    The attribute NUMBER_INT of ET_ORDERADM_I contains the Item Number.
    Hope this helps!
    Regards,
    Rohit

  • [ASK] Get One Row of Property Value From Dimension in Script Logic

    Hello, i need help about how to get one row of property value from dimension in script logic.
    Let say there is CATEGORY dimension and the members are like this :
    ID                                                  YEAR   Status
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    PLAN_2012                                  2012        A
    PLAN_2012_V1                           2012        I
    ACTUAL_2012                             2012        I
    FORECAST_2012                         2012        I
    FORECAST_2012_V1                  2012        A
    If i scope CATEGORY like this :
    *XDIM_MEMBERSET CATEGORY = [CATEGORY].PROPERTIES("YEAR") = "2011"
    Then i will get member scope like this :
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    Question :
    In script logic, how can i read the second record of scope and move it to variable ?
    Ex. : I read second record, so i can get the data of second record (PLAN_2011_V1, 2011, A).
    Is there any function to read all record that had been scope ? So i can read all those 5 records.
    Is there any substring or offset function in script logic ? How to use it ?
    Thank you.

    Hi,
    Firstly, when we scope the logic, it doesnt fetch the entire record from the member sheet. It just fetches the ID.
    Secondly, we dont have the feasibility to read only the second ID and skip the others. However, one alternative is that you use the SELECT statement to store all the IDs in a variable, and then use a FOR loop. But this will loop through all the 5 IDs, as per your example. If you want to skip all the IDs except one, you should maintain some property, so that all the IDs are neglected which doesnt have a particular property value.
    Hope you got the idea.

  • How SAP calculate the outstanding PO quantity and amount.

    how SAP calculate the outstanding PO quantity and amount.

    Hi Arun Raj,
    APO does not calculate the open qty.
    Only the open qty of the PO is ciffed to APO from R/3.
    Regards,
    Ashok

  • Recording measured voltage and current values from LCR 4284A

    Hello,
    I want to use the labview VI to record the measured voltage and current values from LCR 4284A. These are shown as Vm and Im on the instrument screen. Is it possible to record these values using a VI?
    I have looked through the drivers that are available through the "Instrument driver network" (Link) for 4284A but none of the VIs give any option to monitor Vm and Im. If you know how this can be done then I would really appreciate a reply.
    Thanks
    Mansoor

    I haven't used the instrument but there are functions to enable/read voltage level and current level monitors. Are those different than what you are asking for? What does the manual say about Vm and Im and programatically getting them? If you can find the command in the manual, you can just open the VI Tree and do a text search for the command.

  • Get total quantity

    I need to find the total quantity of each fruit eg apple=120
    FRUITNAME QUANTITY FRUITID
    apple 20 1
    orange 30 2
    pineapple 50 3
    apple 40 1
    lemon 15 4
    orange 40 2
    apple 60 1
    i used the sql stmt
    select *
    from (select fruitname,
    sum(decode(fruitid,1,quantity)) Apple,
    sum(decode(fruitid,2,quantity)) Orange,
    sum(quantity) Total
    from fruitinput
    group by fruitname)
    order by 1;
    I am not getting the expected output. please refer to http://www.orafaq.com/wiki/SQL_FAQ. below example works fine.
    SELECT *
    FROM (SELECT job,
    sum(decode(deptno,10,sal)) DEPT10,
    sum(decode(deptno,20,sal)) DEPT20,
    sum(decode(deptno,30,sal)) DEPT30,
    sum(decode(deptno,40,sal)) DEPT40,
    sum(sal) TOTAL
    FROM emp
    GROUP BY job)
    ORDER BY 1;
    Kindly let me know the correct sql stmt to be executed to get total quantity of each fruit in table

    Kindly let me know the correct sql stmt to be executed to get total quantity of each
    fruit in table Kindly let us know what you are looking for.
    SQL> select fruitname, sum(quantity) from fruitinput group by fruitname;
    FRUITNAME                      SUM(QUANTITY)
    pineapple                                 50
    lemon                                     15
    apple                                    120
    orange                                    70
    SQL>
    SQL> select fruitname, sum(quantity) from fruitinput where fruitid = 1 group by fruitname;
    FRUITNAME                      SUM(QUANTITY)
    apple                                    120
    SQL>The query you mentioned also works fine:
    SQL> select *
      2  from (select fruitname,
      3  sum(decode(fruitid,1,quantity)) Apple,
      4  sum(decode(fruitid,2,quantity)) Orange,
      5  sum(quantity) Total
      6  from fruitinput
      7  group by fruitname)
      8  order by 1;
    FRUITNAME                           APPLE     ORANGE      TOTAL
    apple                                 120                   120
    lemon                                                        15
    orange                                            70         70
    pineapple                                                    50
    SQL>
    I am not getting the expected output.What is the expected output

  • How do I use Migration Assistant to get my Mail and Keychain settings from

    How do I use Migration Assistant to get my Mail and Keychain settings from my Power Mac G5 2.3Ghz? I just purchased a new 2.5 MacBook Pro which will be delivered tomorrow, and I want to to know how to transfer Mail and Keychain?
    Thank You in advance for your reading and replying.
    Kindest Regards,
    Sebastian

    Rather than using Migration Assistant, which can cause trouble with the PPC to Intel change, simply boot the G5 in FireWire target disk mode and manually transfer the following:
    /Home/Library/Keychains (copy the whole folder)
    /Home/Library/Mail (copy the whole folder)
    /Home/Library/Preferences/com.apple.mail.plist
    You might want to look over Kappy's helpful guide for migrating, which covers the full process for a manual migration (including the above files).
    Hope this helps...

  • How do you get your tunes and voice recordings from your iPod Touch into iTunes on a new computer if you don't have Mobile Me?

    How do you get your tunes and voice recordings from your iPod Touch into iTunes on a new computer if you don't have Mobile Me?
    iTunes on tmy new computer shows none of my data and I fear if I sync my iPod with the computer all will be deleted on the iPod.
    I still have everything in iTunes on the old computer.

    Just move your iTunes library to you new computer.  You can transfer iTunes purchases to you new computer from your iPod by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT1848Make sure you also move the backup.  You an find where the the backup is located here:
    iPhone and iPod touch: About backups
    You can move other items by:
    Best iPod to PC
    After you move you stuff to the new computer, restore the iPod from backup.

  • How can i remove a key and its value from properties file

    hi all,
    i want remove a particular key and associated value from the
    properties file. is their any standard way of doing?
    thanks inadvance
    daya

    hi,
    thanks
    i am able to remove the key,
    one more question how can avoid storing date and time
    in properties file.
    thanks
    daya

  • Is there any function module to get vc characteristics and its value using material number?

    Hi Experts,
    I am using BAPI_CLASS_GET_CHARACTERISTICS, BAPI_OBJCL_GETCLASSES to get characteristics description and its values.
    Is there any other Function module to pull this values using material number?
    Thanks in Advance.
    Ramkumar

    Have you tried this BAPI_OBJCL_GETDETAIL
    Import parameters
    MATNR value in the OBJECTKEY
    MARA in OBJECTTABLE
    Class name in CLASSNUM
    '001' in CLASSTYPE
    You will get the Class Characteristics data into these tables:
    ALLOCVALUESNUM
    ALLOCVALUESCHAR
    Jogeswara Rao K

Maybe you are looking for