SAP P/L query editing

Hi experts,
i have a query below that brings out my account code and name and balance based on the account type(I,E).
i want someone to help me modify the query so that when the account type is I the balance will be calculated as (credit-debit) and when the account type is E it should be debit-credit for balance.
experts urgent help is required.
Please assist me.
Regards
Justice
SELECT T0.[FormatCode] as "Account Code", T0.[AcctName] as "Account Name", SUM(T1.[Credit]-T1.[Debit]) Balance ,
T4.OcrName as "Segment", T5.DimDesc,
T3.Name as "Period",T3.Category as "Year"
FROM OACT T0 INNER JOIN JDT1 T1 ON T0.AcctCode = T1.Account
INNER JOIN OJDT T2 ON T1.TransId = T2.TransId
inner join OFPR T3 on T1.FinncPriod=T3.AbsEntry
left join OOCR T4 on T1.ProfitCode=T4.OcrCode
left join ODIM T5 on T4.DimCode=T5.DimCode
WHERE T0.[ActType] in ('I','E')
and DateDiff(YY,T2.[RefDate],GetDate()) = 0
AND T1.[Debit] != T1.[Credit] GROUP BY T0.[FormatCode],
T0.[AcctName], T4.OcrName, T3.Category, T3.Name,T5.DimDesc
Having SUM(T1.[Debit]-T1.[Credit]) != 0 ORDER BY T0.[FormatCode]

Hi Justice Doku...
You can Achieve this in many ways like using case statement , using Union all function
Try This using Case
SELECT T0.[FormatCode] as "Account Code", T0.[AcctName] as "Account Name",
case when T0.ActType = 'I' then sum(T1.[Credit]-T1.[Debit]) end as Income,
case when T0.ActType = 'E' then sum(T1.[Debit]-T1.[Credit]) end as Expense,
T4.OcrName as "Segment", T5.DimDesc,
T3.Name as "Period",T3.Category as "Year"
FROM OACT T0 INNER JOIN JDT1 T1 ON T0.AcctCode = T1.Account
INNER JOIN OJDT T2 ON T1.TransId = T2.TransId
inner join OFPR T3 on T1.FinncPriod=T3.AbsEntry
left join OOCR T4 on T1.ProfitCode=T4.OcrCode
left join ODIM T5 on T4.DimCode=T5.DimCode
WHERE  T0.ActType IN ('I','E') and
DateDiff(YY,T2.[RefDate],GetDate()) = 0
AND T1.[Debit] != T1.[Credit] GROUP BY T0.[FormatCode],T0.ActType ,
T0.[AcctName], T4.OcrName, T3.Category, T3.Name,T5.DimDesc
Having SUM(T1.[Debit]-T1.[Credit]) != 0 ORDER BY T0.[FormatCode]
Using Union all
SELECT T0.[FormatCode] as "Account Code", T0.[AcctName] as "Account Name",
  sum(T1.[Credit] - T1.[Debit])   as Sales,
o as Exp,
T4.OcrName as "Segment", T5.DimDesc,
T3.Name as "Period",T3.Category as "Year"
FROM OACT T0 INNER JOIN JDT1 T1 ON T0.AcctCode = T1.Account
INNER JOIN OJDT T2 ON T1.TransId = T2.TransId
inner join OFPR T3 on T1.FinncPriod=T3.AbsEntry
left join OOCR T4 on T1.ProfitCode=T4.OcrCode
left join ODIM T5 on T4.DimCode=T5.DimCode
WHERE  T0.ActType IN ('I') and
DateDiff(YY,T2.[RefDate],GetDate()) = 0
AND T1.[Debit] != T1.[Credit] GROUP BY T0.[FormatCode],T0.ActType ,
T0.[AcctName], T4.OcrName, T3.Category, T3.Name,T5.DimDesc
Having SUM(T1.[Debit]-T1.[Credit]) != 0 ORDER BY T0.[FormatCode]
union all
SELECT T0.[FormatCode] as "Account Code", T0.[AcctName] as "Account Name",
0 as Sales,
case when T0.ActType = 'E' then sum(T1.[Debit]-T1.[Credit]) end as Exp,
T4.OcrName as "Segment", T5.DimDesc,
T3.Name as "Period",T3.Category as "Year"
FROM OACT T0 INNER JOIN JDT1 T1 ON T0.AcctCode = T1.Account
INNER JOIN OJDT T2 ON T1.TransId = T2.TransId
inner join OFPR T3 on T1.FinncPriod=T3.AbsEntry
left join OOCR T4 on T1.ProfitCode=T4.OcrCode
left join ODIM T5 on T4.DimCode=T5.DimCode
WHERE  T0.ActType IN ('E') and
DateDiff(YY,T2.[RefDate],GetDate()) = 0
AND T1.[Debit] != T1.[Credit] GROUP BY T0.[FormatCode],T0.ActType ,
T0.[AcctName], T4.OcrName, T3.Category, T3.Name,T5.DimDesc
Having SUM(T1.[Debit]-T1.[Credit]) != 0 ORDER BY T0.[FormatCode]
Hope Helpful
Regards
Kennedy

Similar Messages

  • SAP NW Java Slim Edition Installation Error

    HI All,
    While i'm installing SAP NW Java Slim Edition
    I'm getting below error(ERR-24936,ERR_DBNORUN: Database instance is not running).
    Could someone help me to fix this issue.
    Thanks,
    Chandra,
    ERROR 2006-08-19 00:06:53
    CJS-00030  Assertion failed: in function sapdb_check_schema(dbhost, dbname, db_sch)
    {    var r_v = false;    var sdbInst = new sdbInstance();    sdbInst.dbName = dbname;   
    sdbInst.dbHost = dbhost;    var sql_statement = "SELECT USERNAME FROM DOMAIN.USERS";   
    var r_arr = sdb_sql_query(sql_statement, sdbInst);    ASSERT(arguments.callee,
    r_arr != undefined, "ERROR EXECUTING DBMCLI COMMAND!");    if (r_arr[0] == "false")
    {        var err_msg = "ERROR EXECUTING SQL QUERY: ";     
      for (var i_cnt = 1; i_cnt < r_arr.length; i_cnt++) {            err_msg = err_msg + r_arr[i_cnt];        } 
          ASSERT(arguments.callee, false, err_msg);    } else {      
    var cmp_s = new RegExp("'" + db_sch.toUpperCase() + "'");     
      for (var i_cnt = 0; i_cnt < r_arr.length; i_cnt++)
    {            if (cmp_s.test(r_arr[i_cnt])) {                r_v = true;            }        }    }    return r_v;}
    ERROR EXECUTING SQL QUERY: Error! Connection failed to node Chandu for database
    J2E: ERR_USRFAIL: user authorization failed
    ERROR 2006-08-19 00:24:55
    CJS-00030  Assertion failed: in function sapdb_check_schema(dbhost, dbname, db_sch)
    {    var r_v = false;    var sdbInst = new sdbInstance();    sdbInst.dbName = dbname;   
    sdbInst.dbHost = dbhost;    var sql_statement = "SELECT USERNAME FROM DOMAIN.USERS";  
    var r_arr = sdb_sql_query(sql_statement, sdbInst);   
    ASSERT(arguments.callee, r_arr != undefined, "ERROR EXECUTING DBMCLI COMMAND!");   
    if (r_arr[0] == "false") {        var err_msg = "ERROR EXECUTING SQL QUERY: ";    
       for (var i_cnt = 1; i_cnt < r_arr.length; i_cnt++) {            err_msg = err_msg + r_arr[i_cnt];        }
           ASSERT(arguments.callee, false, err_msg);    } else
    {        var cmp_s = new RegExp("'" + db_sch.toUpperCase() + "'");       
    for (var i_cnt = 0; i_cnt < r_arr.length; i_cnt++) {            if (cmp_s.test(r_arr[i_cnt]))
    {                r_v = true;            }        }    }    return r_v;}
    ERROR EXECUTING SQL QUERY:
    ERR-24936,ERR_DBNORUN: Database instance is not running

    Hi Chandra,
    Did you install SAPDB?. Seems like the DB is not installed or is offline, <b>ERROR EXECUTING DBMCLI COMMAND</b> seems like DBMCLI commands are not been recognized.. Did you when through all th pre-installation checks?
    Regards
    Juan
    Please reward with points if helpful

  • Difference between sap query and sap ad hoc query

    Hello Experts-
    Is there any difference between sap query and sap ad hoc query. If yes, I will appreciate if you can provide some input.
    Thanks,

    Hi,
    SAP Query
    Purpose
    The SAP Query application is used to create reports not already contained in the default. It has been designed for users with little or no knowledge of the SAP programming language ABAP.
    SAP Query offers users a broad range of ways to define reports and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    The SAP Query comprises five components: Queries, InfoSet Query, InfoSets, User Groups and Translation/Query.
    Classic reporting- the creation of lists, statistics and ranked lists- are covered by the InfoSet Query and Queries components. Other components’ range of functions cover the maintenance of InfoSets, the administration of user groups and also the translation of texts created in the SAP Query.
    All data required by a user for a report can be read from various tables.
    To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. In the WYSIWYG mode, you can edit the lists using Drag & Drop and various toolbars.
    AD Hoc Query
    Definition
    A Web item that enables you to create and change queries in a Web application on an ad-hoc basis.
    Use
    You can use the  Ad-hoc Query Designer Web item in the Web Application Designer to structure Web applications in which you create or change queries. The Web item is as a tool for designing ad-hoc queries in a Web environment.
    In particular it enables you to:
    ·        Create queries by assigning characteristics from an InfoProvider to rows, columns, filters, and free characteristics, and including key figures from the InfoProvider in the key figure structure of the query.
    ·        Restrict or filter key figures and characteristics
    ·        Use predefined key figure structures and restricted or calculated key figures in the query
    ·        Set or change query properties and key figure/characteristic properties in the query
    ·        Create or change conditions and exceptions
    When compared with the BEx Query Designer, the Ad-hoc Query Designer Web item has the following restrictions when creating or changing queries:
    ·        You cannot integrate variables into the query directly.
    However, you can use variables in reusable structures, or restricted or calculate key figures, which are used in the Ad-hoc Query Designer
    ·        The query can contain only one structure. This structure has to be the key figure structure and be in the rows or columns of the query.
    -        You cannot use key figures or key figure structures in the filter.
    -        You cannot define exception cells, since this requires two structures.
    You cannot create the following objects using the Ad-hoc Query Designer Web item:
    -         Reusable structures
    -         Reusable restricted key figures
    -         Reusable calculated key figures
    -        Local calculated key figures
    You can create local, restricted key figures using the Ad-hoc Query Designer Web item.
    You can edit existing queries in the Ad-hoc Query Designer Web item, if the queries adhere to the restrictions laid out above The Ad-hoc Query Designer checks these requirements when loading a query. If the query is too complex, the query can be loaded into the Ad-hoc Query Designer but you cannot change it there. You then receive the appropriate message. You can still check and execute the query.
    "Ad Hoc" is a Latin phrase which means "for this purpose" and in today's parlance generally means "on the fly," or "spontaneously."
    An ad hoc query is a query that is run at the spur of the moment, and generally is never saved to run again. These queries are run using a SQL statement created by a tool or an administrator. So therefore, such a query is one that might suit a situation which is only there for the moment and later on will become irrelevant.
    As queries become more complex, it can be difficult to write them correctly ad-hoc. To help with this, one can instead write the knowledge needed for queries as business rules in English, and then use a system called "Internet Business Logic" to automatically generate and run the SQL queries. One can then get explanations of the results, in English, at the business level.
    Check these links....
    http://help.sap.com/saphelp_nw04/helpdata/en/1f/03223c5f00612be10000000a11402f/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/80bf2f79-021d-2a10-5082-dadc79aaa92c
    http://www50.sap.com/businessmaps/27FEEF3A12444F89A8524CCACAF4F5BF.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/15/00a042b443c56ae10000000a155106/content.htm
    Reward points if useful....
    Regards
    AK

  • How can we remove the commas from the Formula value in SAP BW BEx query

    Hi All,
    How can we remove the commas from the Formula value in SAP BW BEx query
    We are using the formula replacing with characteristic.The characteristic value needs to be display as number with out commas.
    Regards
    Venkat.

    Do you want to remove the commas when you run the query on Bex Web or in RSRT?
    Regards

  • Initial password for SAP* in SAP NetWeaver 2004s ABAP Edition

    Hello,
    I have just installed the SAP NetWeaver 2004s ABAP Edition on my PC and I want to setup some new clients to simulate an ALE model.
    Does anyone know the initial password for SAP* ?
    I have already tried PASS and pass because I know it is case -sensitive now but it did not work.
    Thanks a lot.
    Wim Van den Wyngaert

    Hi,
    initial SAP* password is 06071992 
    DDIC is 19920706

  • Designer support for Subquery against SAP BW Bex Query

    BusinessObjects designer has an option in the paramaters window to turn on "Allow Sub-Queries" in a universe that has been created using a olap source.  SAP BW BEX Query to be specific.  Once turned on, you can build a query and the subquery button and functionality is actually enabled and allows you to build it.  When running the query I get an error message "A filter contains a wrong value. You cannot run this query". 
    Now, I am pretty sure this functionality is not supported on a BW or OLAP source but, I can not find anything definitive from SAP stating that it is not supoorted.  So I want to make sure that this is not one of those situations where everyone just says "It's not supported" but really just doesn't know.  Does anyone have the official word or link to an SAP statement that this functionality is officially not supported.

    What I would say is, it won't support. The reason could be, as its not support any structure view in universe designer, that means we cannot create any derived tables where we could use sql query.
    I believe the same applies  here too. Even if you look at LOV defintions in universe, it won't show any query.
    So the same applies to reports.
    Hope this helps.
    Regards
    Gowtham

  • Connecting Crystal Reports to SAP BW BEx query

    Post Author: mfrank
    CA Forum: Data Connectivity and SQL
    We have used Crystal Enterprise 8.5 to connect to an SAP BW BEx query in the past, however we are having some difficulties.  Rather than trying to upgrade our old CE system, I've been told that we should be able to connect Crystal Reports (2008?) directly to the BW BEx query.  I've been trying to accomplish this, but can't seem to find any drivers that will allow the connectivity.  When I try to set up a connection using OLAP, the only two options listed are Hyperion and Microsoft OLAP.  I have an old version of Brio Query (now Hyperion, now Oracle) that does show up with a driver for BW, but this doesn't show up in my Crystal options.
    Can someone give me some advice as to how to connect Crystal Reports to SAP BW?  I realize there are licensing issues with running live data without using Crystal Enterprise (or later BO products), but I'm just looking to print a report to a PDF.
    Thanks

    Post Author: A Kumar
    CA Forum: Data Connectivity and SQL
    Hi mfrank,
    I am also facing a similar kind of a problem. Did you get any solution to your problem. If yes, kindly let me know.
    Thanks
    A kumar

  • Query editing in Management Studio

    I've accidentally done something to my install of Management Studio that is making query editing very difficult.  I must have used a weird key combination to enable some feature that is now opening an Intellisense like window with suggested keywords
    or column names.  I've tried every option I can find to disable this and even tried all the <ctrl> key combinations from A-Z to try to turn this off.  Can anyone tell me how to have the editor revert to the "default" behavior as installed?
    I've received several replies about disabling Intellisense or changing the Intellisense options and I've already done this to no effect.  I've also not installed any 3rd party tools.  I was editing queries when the problem began and I think I had
    hit a <ctrl> or <alt> key combination key that started this problem.
    I took a screen shot but when I hit the <ctrl> key, the options fade out but hopefully it can still be seen.

    I've accidentally done something to my install of Management Studio that is making query editing very difficult.  I must have used a weird key combination to enable some feature that is now opening an Intellisense like window with suggested keywords
    or column names.  I've tried every option I can find to disable this and even tried all the <ctrl> key combinations from A-Z to try to turn this off.  Can anyone tell me how to have the editor revert to the "default" behavior as installed?
    My guess is that you have installed any third party SQL-Server plug in and which is active. Click on Tools and check if it shows any add-on is there. You need to uninstall it from Control Panel then.
    Cheers,
    Vaibhav Chaudhari
    MCP, MCTS, MCSA (SQL Server 2012)

  • How to work with sap bw bex query structure

    Dear Friends,
    How can we use SAP BW bex query structure in crystal reports.
    Thanks with regards.
    Malik

    i have two structure in my query.
    and structure is comming in my Crystal report.
    i have 10 memebers in that structure and i make display off for some of members .
    but in crystal all of members are comming either its property is hidden or not.
    any help higly appricated.
    Regards
    Malik

  • Voting Thread for the SAP NetWeaver ABAP Developer Edition for Windows 7

    Hi Everyone,
    as Mario Herger suggested in the discussion to his Blog [New Community Developer License is available|/people/mario.herger/blog/2010/01/20/new-community-developer-license-is-available] I start the topic requesting a SAP NetWeaver ABAP Developer Edition for Windows 7.
    Best regards
    Gregor

    Currently, ABAP Developer Edition can be installed on Windows XP Mode for Windows 7 (Pro,Business,Ultimate).
    Here some usefull links:
    [http://www.microsoft.com/windows/virtual-pc/download.aspx]
    [http://news.cnet.com/8301-13860_3-20000693-56.html?tag=newsEditorsPicksArea.0]
    [http://blogs.zdnet.com/microsoft/?p=5607&tag=mncol;txt]

  • Voting Thread for the SAP NetWeaver ABAP Developer Edition for VMWare

    Hi Everyone,
    as Mario Herger suggested in the discussion to his Blog [New Community Developer License is available|/people/mario.herger/blog/2010/01/20/new-community-developer-license-is-available] I start the topic requesting a SAP NetWeaver ABAP Developer Edition for VMWare.
    Best regards
    Gregor

    Hi everyone,
    please check out the Wiki Page: [Testdrive on Linux|http://wiki.sdn.sap.com/wiki/x/XgJ8C] where you find the section "Netweaver 7.02 (projected)". So let's hope that this version will be released soon as the RampUp is already running.
    Best regards
    Gregor

  • Voting Thread for the SAP NetWeaver ABAP Developer Edition for Linux

    Hi Everyone,
    as Mario Herger suggested in the discussion to his Blog [New Community Developer License is available|/people/mario.herger/blog/2010/01/20/new-community-developer-license-is-available] I start the topic requesting a SAP NetWeaver ABAP Developer Edition for Linux.
    Best regards
    Gregor

    I think having a pre-packaged VMWare machine running on Windows or Linux would be great as it would help a lot of the non-Basis consultants get a system up and running. Perhaps even offer it as an AMI package on AWS so that hardware is not an issue.
    I'd also like to see the traditional installation packages offered as many technical consultants use the build as a process to look at installation issue and post installation configuration.
    I think both the pre-built and build it from scratch approaches have an audience here on SDN and I'd like to see both being offered.
    In fact I'm just looking at the new license options one of which come with the DVD's which is ideal but at a price!
    Thanks,
    George M-A

  • SAP Netwiever Slim Java Edition

    Dear community i am new to SAP, couple of questions.
    1. I am downloading the SAP Netwiever Slim Java Edition, i have 4.6C SAP IDES already install do this netwiever work top on it or it is a complete separate flavour and do not require any prior installation of SAP.
    2. Does SAP WEB AS will installed with SAP Netwiever Slim Java Edition installation or do i require it separatly?
    3. Why Netwiever Developer Studio not available with SAP Netwiever Slim Java Edition how can i start learning development with it.
    i know all the question i asked are very basic but i need some clearification cause i am very new to it.
    Kind regards and thanks in advance.

    > One thing: the os lenagauge is not english... Could
    > be that a problem?
    I'm not sure, but I don't think so. I have installed the Slim Edition on WinXP/Service Pack<b> 2</b>/German.
    Also the j2sdk 1.4.2_08

  • SAP BW Query Vs SAP BW MDX Query

    Dear Gurus,
    Can someone please tell me the difference and advantages of connecting Crystal Reports2008 to  "SAP BW Query" & "SAP BW MDX Query"while .
    My main concern being SAP BI resource is , we don't create SAP MDX queries in BW.
    Regards,
    -Neha

    Hi Ingo ,
    So the Crystal report  datasource will be SAP BEx queries when we select the connection SAP BW MDX Queries .
    My question is do we have to write MDX statements somewhere in SAP BW  or the system will automatically generate when we select the SAP BW MDX Queries ?
    Regards,
    -Neha

  • Installation Guide for SAP BusinessObjects BI, Edge Edition Free Trial

    I'm new at this place, but familiar with SAP BO from projects and usage.
    Anyway, was downloading the SAP BusinessObjects BI, Edge Edition Free Trial on global.sap.com, and then reading the pdf file Master Guide.
    It tells you to follow the Installation Guide. Found a link to that on help.sap.comyet SAP customer cannot download and installing this free trial without first create an account in at service.sap.com. I contacted the scn support, and they advised me to use this place for try to find out.
    My question now is, whether a not-yet SAP customer can find this Installation Guide for the free trial somewhere else?

    Isn't it rather: https://help.sap.com/bopip41
    In any case, my concerning was rather related to how to accesing such information without any need for have any account. But I personally solved it by register, as we're a SAP partner and having a partner id. But for those tht not have any partner or customer id, then may not so easy to access these files.

Maybe you are looking for

  • 'open doc' javascript based on the name of original pdf, e.g. pdf a5.pdf has button to open b5.pdf because script is able to know its '5'

    I hope this makes sense. I have two sets of pdfs containing 100+ individual pages (totalling 200 pages in one folder) Set/series 1: a1,a2,a3 -----> a100 Set/series 2: b1,b2,b3------> b100 I would like to create a button on each page that will open a

  • Inbound IDOC Mass processing - No status message

    Hi Friends, I am updating a database table using inbound IDOC. But in batch job when XI passes multiple IDOCS, for some IDOCs there is no status message even though i coded for status message. If i rerun IDOC in BD87 then it work fine. please help. r

  • Ipod USB in car

    USB connection in the car gives message, device without function, when I plug new ipod touch in. The car is a VW passat. Is there a setting I need to find?

  • Camera raw 7 slow zoom in/out ,but fast process 2003 or 2010

    Hi i did notice that zoom in or out in camera raw is slow , even in middle pc , i'm not talking about hi end pc but i did find it's amazing fast if use process 2003 or 2010 may i use like default the 2003 or 2010 ? how can i do it? thanks cheers

  • Change JWS policy

    Hello, I have a java class that reads a file for a simulation. It is working fine on Netbeans editor. Now, I need to distribuite it. So, I created a jar file, a jnlp file for web start. Everything is working fine, but when I click on the "open file"