Difference between 2 sub-totals in SAP query
Hello Experts,
Is there any possibility to find out the difference between 2 sub-totals and display it at the bottom of the ALV output( like total) in SAP Query using SQ01.
For example: see below example(Request you to paste the below in an excel sheet for more readability).
PRZ 25.05.2011 A 007 008 01 15 10 EA 0,00 INR 0,00 INR 2,00 INR 0,00 INR
PRZ 27.05.2011 A 007 008 01 00 1 PC 10,00 INR 0,00 INR 0,20 INR 0,10 INR
PRZ 27.05.2011 A 007 008 01 00 1 PC 10,00 INR 0,00 INR 0,20 INR 0,10 INR
Sub-total 10 EA 20,00 INR 0,00 INR 2,40 INR 20 INR
2 PC
DRP 26.05.2011 WDB2020261X744924 1 PC 60,00 INR 50,00 INR 30,00 INR 0,00 INR
DRP 31.05.2011 WDB2020261X744924 1 PC 60,00 INR 50,00 INR 30,00 INR 0,00 INR
Sub-total 2 PC 120,00 INR 100,00 INR 60,00 INR 0,00 INR
Grand totals 10 EA 140,00 INR 100,00 INR 62,40 INR 20 INR
4 PC
In the same way as Grand total, Is there any possibility to find out the difference between the 2 sub-totals and display at the bottom after the Grand Totals row.
Please let me know if there is any possibility for the same.
Just to update on my question.
In the sub-totals line you can see that there is 20,00 INR value which is summation of the above fields present in individual line numbers above. And the same way for the rest of the fields as well.
After calculating the sub-totals in this manned, I need to find out the difference between the subtotals and display it at the bottom of the output.
Please let me know if this is possible.
Similar Messages
-
Trying to find the difference between two sub-totals (sales - credits)
Hi Everyone,
I have the following code which essentially lists the total sales for an items on the first row, and the total credits for the same item on the second row.
SELECT T0.ItemCode, SUM(T0.LineTotal) as 'Total Sales'
FROM INV1 T0
WHERE T0.ItemCode = 'ACR2401010'
GROUP BY T0.ItemCode
UNION ALL
SELECT T1.ItemCode, SUM(T1.LineTotal) as 'Total Sales'
FROM RIN1 T1
WHERE T1.ItemCode = 'ACR2401010'
GROUP BY T1.ItemCode
The results of the query are shown below (with some alterations for confidentiality).
What I would like to do is write a code block that subtracts the total credits from the total sales, leaving me with only one row of data for the ItemCode.
If anybody can help with writing the code to achieve this it will be greatly appreciated.
Kind Regards,
DavoHi, Please take a look and tweak accordingly. You may pay attention to nulls and manipulate accordingly. Best of luck!
--Option 1
SELECT t2.ItemCode,( SUM(T2.TotalSales)-SUM(TotalCredits)) AS 'Total'
FROM
SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales',SUM(0) as 'TotalCredits'
FROM INV1 as T0
WHERE T0.ItemCode = 'ACR2401010'
GROUP BY T0.ItemCode
UNION ALL
SELECT T1.ItemCode, SUM(0) as 'TotalSales', SUM(T1.LineTotal) as 'TotalCredits',
FROM RIN1 as T1
WHERE T1.ItemCode = 'ACR2401010'
GROUP BY T1.ItemCode
) AS t2
GROUP BY t2.ItemCode
--Option 2
SELECT t2.ItemCode, ( SUM(T2.TotalSales)-SUM(TotalCredits)) AS 'Total'
FROM
SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales',SUM(0) as 'TotalCredits'
FROM INV1 as T0
--WHERE T0.ItemCode = 'ACR2401010'
GROUP BY T0.ItemCode
UNION ALL
SELECT T1.ItemCode, SUM(0) as 'TotalSales', SUM(T1.LineTotal) as 'TotalCredits',
FROM RIN1 as T1
--WHERE T1.ItemCode = 'ACR2401010'
GROUP BY T1.ItemCode
) AS t2
WHERE t2.ItemCode = 'ACR2401010'
GROUP BY t2.ItemCode
--Option 3
SELECT t2.ItemCode, ( SUM(T2.TotalSales)-SUM(TotalCredits) ) AS 'Total'
FROM
SELECT T0.ItemCode, T0.LineTotal as 'TotalSales', 0 as 'TotalCredits'
FROM INV1 as T0
UNION ALL
SELECT T1.ItemCode, 0 as 'TotalSales', T1.LineTotal as 'TotalCredits',
FROM RIN1 as T1
) AS t2
WHERE t2.ItemCode = 'ACR2401010'
GROUP BY t2.ItemCode
--Assuming credit part is optional..also assuming each table should return only one row else results would inflate...option 4
SELECT t0.ItemCode, ( SUM(T0.TotalSales)-SUM(T1.TotalSales)) AS 'Total'
FROM
INV1 as t0
left outer join
RIN1 as t1
ON t0.ItemCode = t1.ItemCode
WHERE t0.ItemCode = 'ACR2401010'
GROUP BY t0.ItemCode
--option 4 with grouping to ensure single row from each table
SELECT t0.ItemCode, ( isnull(T0.TotalSales,0)-isnull(T1.TotalSales,0)) AS 'Total'
FROM
SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales'
FROM INV1 as T0
--WHERE T0.ItemCode = 'ACR2401010'
GROUP BY T0.ItemCode
)as t0
LEFT OUTER JOIN
( SELECT T1.ItemCode, SUM(T1.LineTotal) as 'TotalCredits',
FROM RIN1 as T1
--WHERE T1.ItemCode = 'ACR2401010'
GROUP BY T1.ItemCode
) as t1
ON t0.ItemCode = t1.ItemCode
WHERE t0.ItemCode = 'ACR2401010'
--Option 5 with grouping to ensure single row from each table.
--Also assuming that sales or credits can be optional
SELECT
ISNULL(t0.ItemCode,t0.ItemCode) AS ItemCode,
( isnull(T0.TotalSales,0)-isnull(T1.TotalSales,0)) AS 'Total'
FROM
SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales'
FROM INV1 as T0
--WHERE T0.ItemCode = 'ACR2401010'
GROUP BY T0.ItemCode
)as t0
FULL OUTER JOIN
( SELECT T1.ItemCode, SUM(T1.LineTotal) as 'TotalCredits',
FROM RIN1 as T1
--WHERE T1.ItemCode = 'ACR2401010'
GROUP BY T1.ItemCode
) as t1
ON t0.ItemCode = t1.ItemCode
WHERE (t0.ItemCode = 'ACR2401010' OR t1.ItemCode = 'ACR2401010') -
There is a difference between the document total and its components
Hi!
I have an error message "There is a difference between the document total and its components" when I want to create an InventoryGenEntry
the problem arises from time to time and my customer must do the document two or three times before it is created.
I have seen in this forum and in notes that this is probably being caused by a Rounding.
I am using 2 digits for amounts, 4 digits for prices, 6 digits for rates and 3 digits for quantities.
For information my customer use SAP 2005 and the patch level 46.
This problem happened only in InventoryGenEntry. how can I modifiy parameters to resolve this problem?
thank you for your help.
Best Regards
SéverineHi Séverine,
Do you find any additional code added to SBO_SP_Transaction stored procedure. A similar issue with stock transfer fixed in later patch. Please test in latest patch.
Regards,
Vijay kumar
SAP Business One Forums Team -
Difference between the document total and its components in inventory transfer
Hi Everyone!
When I make Inventory Transfer, SAP notice error "There is difference between the document total and its components.".Everyone that knows this problem, Pls help to find way to solve it.
Thanks & Best regards
Ngoc LoanHi,
Please refer to the thread.
There is a difference between the document total and its components
Hope Helps!
Regards, -
*what is the difference between web flow engine and sap business workflow?*
Hi,
Can any please guide me by telling what is the difference between web flow engine and sap business workflow?>
Arghadip Kar wrote:
> Check this link
>
> http://www.workflowing.com/id35.htm#1__what_is_the_difference_between
... which is exactly where the FAQ item came from! -
Calculate sub totals in SAP Script
Hi Friends, In Sapscript, I want to print as follows. Please help.
Empno Name Dept. Salary
A1 AAAA DP01 1000.00
A2 BBBB DP01 1500.00
2500.00
A3 CCCC DP02 2000.00
A4 DDDD DP02 2200.00
4200.00Hi
To calculate totals and sub totals in sap scripts you have to use subroutines.
Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine
/: DEFINE &TOT_PRICE&
/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM
Then write the variable where ever you want it to be printed (mostly it will be in footer window)
Then create subroutine pool program and you have to write the code.
FORM F_GET_PRICE tables int_cond structure itcsy
outt_cond structure itcsy. data : value type kbert.
statics value1 type kbert.
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
PLZ REWARD POINTS -
This is regarding totals and sub totals in sap-scripts
Hi to all...............
1...How to print totals and subtotals in sap-scripts? where we have to code the logic.what sort of logic is needed to print the same?
regards,
swaminath.Hi
HI,
To calculate totals and sub totals in sap scripts you have to use subroutines.
Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine
/: DEFINE &TOT_PRICE&
/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM
Then write the variable where ever you want it to be printed (mostly it will be in footer window)
Then create subroutine pool program and you have to write the code.
FORM F_GET_PRICE tables int_cond structure itcsy
outt_cond structure itcsy. data : value type kbert.
statics value1 type kbert.
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
To know more, have a look at this thread ..
Re: SAP Script: Display Total calculated on page 2 in page 1
<b>Reward if usefull</b> -
What's the difference between WorkflowTask and WorkflowJob in SAP MDM API?
Hi Support,
Could you tell me the differences between WorkflowTask and WorkflowJob in SAP MDM API? And which can represent a workflow in Workflows tab in MDM Date Manager.
Thanks & Regards,
SongHi Songxu,
Workflow Task: It is the task(workflow steps like Process, Approver etc) assigned to different user during Workflow. User's use the workflow tabs in Data Manager to view and process workflow tasks. see page 91/654 of Data Manager Guide.
http://help.sap.com/saphelp_nwmdm71/helpdata/en/4b/72b8aaa42301bae10000000a42189b/MDMDataManager71.pdf
Workflow Job: Each workflow is invoked as a job that can consist of multiple records that move through the steps of a workflow (how many records are involved into your Workflow) as a group while simultaneously maintaining record-level granularity. Once the job has been launched, it moves automatically from step-to-step and from user-to-user, showing up in the inbound task queue in each useru2019s Workflows tab for disposition and processing.
Regards,
Mandeep Saini -
Difference between "Physical Read Total IO Requests Per Sec" and "Physical Read IO Requests Per Sec"
What is the difference between "Physical Read Total IO Requests Per Sec" and "Physical Read IO Requests Per Sec" metrics in dba_hist_sysmetric_summary?
From docs (Reference, Statistics Descriptions) :
physical read IO requests : Number of read requests for application activity (mainly buffer cache and direct load operation) which read one or more database blocks per request. This is a subset of "physical read total IO requests" statistic.
physical read total IO requests : Number of read requests which read one or more database blocks for all instance activity including application, backup and recovery, and other utilities. -
Difference between ECC 5.0 and SAP 4.7
Hi,
Can anyone please explain the difference between ECC 5.0 and SAP 4.7 from ABAP point of view? What is the full form of ECC?
Best wishes,
AtanuHi,
Check these
Technical difference between 4.7 and ECC 5.0
difference between sapr/3 4.7 and sapr/3 ecc 5.0
Differences b/n 4.6c,4.7 and ECC 5.0
Regards
vijay -
Difference between open text ECM and SAP DMS?
Hello All,
What is the difference between open text ECM and SAP DMS functionality ??
Why we use SAP open text extended ECM ?
please help me to know about additional feature provided by open text ECM apart from SAP DMS??Hi,
normally openText is not a part of SAP Document Management but I hope that the following links could be useful for you:
Extended ECM version 10 documentation can be ac
cessed from following locations:
Extended ECM for SAP Solutions 10.0 Support Package 2:
https://knowledge.opentext.com/knowledge/cs.dll/Open/34046660
or
https://knowledge.opentext.com/knowledge/piroot/_doclists/extsap-basic.e
es100002.xml
Older versions of xECM documentation are available from following links:
Extended ECM for SAP Solutions 10.0.0:
https://knowledge.opentext.com/knowledge/cs.dll/Open/19614094
or
https://knowledge.opentext.com/knowledge/piroot/_doclists/extsap-basic.e
es100000.xml
Extended ECM for SAP Solutions 10.0 Support Package 1:
https://knowledge.opentext.com/knowledge/cs.dll/Open/25691512
or
https://knowledge.opentext.com/knowledge/piroot/_doclists/extsap-basic.e
es100001.xml
Please ensure you have access to documentation links.
Best regards,
Christoph -
Difference between R/3, mySAP ERP, SAP ERP 2004..
Hi guys,
I'd like to know, what's the difference between R/3, mySAP ERP, SAP ERP 2004 (or other terms). Sometimes I see R/3, sometimes ERP... I'm a little bit confused.
Thanx for answers!
PeterHi,
SAP R/3 is package which is available in different versions 3.1i,4.6c,4.7. mySAP ERP 2004 i.e. ECC 5.0 and mySAP ERP 2005 i.e. ECC 6.0 are advanced versions of SAP R/3.
Please refer one more link.
http://solutionbrowser.erp.sap.fmpmedia.com/
Here you will be able to know difference in functionality for different modules.
Regards
Tushar A.Vhora -
Difference between Tech-Ed and Normal SAP Certification
Hi,
Is there any difference between SAP TechEd certification and other Normal certification (Other than Tech-Ed, conducted by SAP) ?
I am planning to give C_TBIT51_70, which is not in TechED
(TBIT40,TBIT50 and TBIT51).
Is there any experts who cleared this exam, please provide your inputs.
Thank you.
ShyleshHi Shyl,
The most important differences are:
1) The evaluation criteria and pass percentage !!
2) Certification fee
1) In teched, you will not be given any partial credit but the pass percentage is less than that of the exams which you take in other months.
For me the normal certfication pass percentage was 70 % for which the same in teched was 57% BUT REMEMBER NO PARTIAL CREDIT IN TECHED.
but the normal monthly exams would be granted partial marks for each question but percentage is 70.
2) The certification fee in teched also differs in the case. its less than that of direct certification.
BUT MY SUGGESTION IS GO FOR TECHED SINCE YOU LL HAVE GOOD EXPOSURE ON THE TECHNLOGY YOU DO. NEVER MISS IT!!
Hope it helps!!
Thanks!
Preethi. -
Differences between AIX and Windows for SAP
Dear All,
I have a problem regarding SAP Software.We want to change our company software .First we order SAP On Windows with Oracle10g But Now We want SAP on AIX with Oracle10g.
SAP delivered us software on Windows platform.
Please Suggest me for this as what are the differences between the above two platforms and what are the differences between the above 2 platforms.
Regards,
Pankaj Kalsayanhi Pankaj,
well, this is a very general question. perhaps you could specify a little more.
in general i would see no difference regarding the end user sitting in front of his pc using sapgui.
as far as i know all server side sap software is available for aix and windows (and many more).
for administration on the other hand there is of course lots of difference. AIX is a UNIX operating system running on special hardware with power processors. it offers quit extensive virtualisation abilities using so called LPARs and supports real big number of CPUs and large RAM. Windows is a completly differnet operating system running mostly on x86/amd64 hardware.
therefore you should also consider what know-how is available in your system administration.
not shure if that is partly answering your question ...
btw. if you are going forward with AIX you should perhaps consider switching oracle with db2. so you have a consistent IBM based landscape. also to me, sap and db2 seem to "like" each other more than sap and oracle
regards,
martin -
SolMon 3.2, Difference between SolMon report and Service .sap report?
Hi Guys,
last week i found one strange thing, there are differences between the reports of our local SoMon server report and report from service.sap (service message).
why there will be difference like this, Please help me in this regards.
Regards
SriniSoftware Components for SAP Solution Manager 4.0 as of April 2007.
SAP_BASIS 700 Basis Component
SAP_ABA 700 Cross-Application Component
PI_BASIS 2005_1_700 PI_BASIS 2005_1_700
ST-PI 2005_1_700 SAP Solution Tools Plug-In
SAP_BW 700 SAP NetWeaver BI 7.0
SAP_AP 700 SAP Application Platform
BBPCRM 500 BBPCRM
CPRXRPM 400 SAP xRPM/cProjects/cFolders 4.00 (ABAP)
ST 400 SAP Solution Manager Tool
ST-A/PI 01I_CRM500 Application Servicetools for CRM 500
ST-ICO 150_700 SAP Solution Manager Implementation Content
ST-SER 700_2006_2 SAP Solution Manager Service Tools
ST (Solution Manager Infrastructure, tx solution_manager, SOLAR01)
ST-A/PI (Download modules to get data for service sessions, monitoring)
ST-ICO (Implementation Content - Business Process Repository)
ST-SER (Service Sessions as EarlyWatch Alert, SAP GoingLive Check, Setup System Monitoring, Central System Administration, Setup Business Process Monitoring, Service Level Reporting, ....)
See also SAP Notes:
- 707705 (www.service.sap.com/sap/support/notes/706705) for an explanation on Components for Messages (with lots of key words).
- 394616 (www.service.sap.com/sap/support/notes/394616) Release strategy for SAP Solution Manager
Best regards
Ruediger
Maybe you are looking for
-
How to change layout in List of Sales Orders (VA05)
Hello, Does anybody knows how I can save layout changes or create new layout in transaction VA05 (List of Sales Orders)? Thanks for advance
-
DISTINCT in the query -- RBO vs CBO
Hi all, We are in a process of migrating our applications from RBO to CBO as we moved to 10g and recently I observed a simple query with DISTINCT clause showing different results in CBO. Here is my order of creating a table in 10g environment, create
-
Inbound IDOC error 51 Application Document not posted
Inbound IDOC error 51: Item: 002 Goods/Service number not entered So application document not posted. Please help me out
-
Help installing Flash Player 9
I follow the recomendations on the flash player support but I can install it. I only have Safari. Any advice? Thank you in advance.
-
Modifier Keys suddenly not working with Numberpads
I favor the use of a numberpad and as such i have been using a third party USB Numberpad. I also have a Apple wired keyboard that comes with the number pad. All these while, the modifier keys (shift, alt, ctrl) works with the numberpad and the numbe