How to extract cost centers and their number of appendant assets to internal table?

Hello,
my aim is to get an internal table with all my selected cost centers and the number of their appendant assets to pass this to a SmartForm.
The result would be something like:
cost center
number of assets
100000
65
100001
13
100002
105
100007
3
100008
57
What I did so far: I made up an SQL statement, which I tested in the transaction DBACOCKPIT (Performance -> Additional Functions -> SQL Command Editor), which works fine and gives me exactly what I need.
The SQL statement is (slightly simplified, and exemplarily only for costcenters 100000 and 100001):
select costcenter, count( assetnr ) as numberofassets from
     ( select anlz.kostlv as costcenter, anla.anln1 as assetnr, anla.deakt, anla.aktiv from anla
          join anlz on anla.mandt = anlz.mandt and anla.bukrs = anlz.bukrs and anla.anln1 = anlz.anln1
          where anlz.kostlv = '0000100000' or anlz.kostlv = '00000100001' )
group by costcenter
Now, I want this SQL statement to work in my ABAP code. To match the requirements of the ABAP Editor (SE80), I
- replaced all the point delimiters (.) by a tilde (~),
- removed all commas,
- added "into costcenter_assetcount" to store my result in an internal table.
So in my ABAP code the SQL looks like this (alias assetnr inb the first line is printed in red):
select costcenter count( assetnr ) as numberofassets from
   ( select anlz~kostlv as costcenter anla~anln1 as assetnr anla~deakt anla~aktiv from anla
       join anlz
         on anla~mandt = anlz~mandt
         and anla~bukrs = anlz~bukrs
         and anla~anln1 = anlz~anln1
       where anlz~kostlv = '0000100000' or anlz~kostlv = '00000100001' )
    into costcenter_assetcount
group by costcenter
Checking my code, ABAP Editor gives me a syntax error pointing to the SELECT of the subquery (it's in German, because this is my default language setting). After my first FROM, ABAP seems to expect a table name instead of a subquery.
Programm Z_FIAA_ASSETCOUNT        @0A\QFehler@
"SELECT" ist im ABAP-Dictionary nicht als Tabelle, Projektions- oder     
Datenbank-View deklariert.
Isn't it possible to use a SELECT subquery after my FROM in the ABAP Editor?
What would be the best practice to put the data in an internal table?
Looking forward to your comments!

Hi,
I think, You make it to complicated, try this:
select anlz~kostlv as costcenter count( distinct anla~anln1 ) as numberofassets
   from anla
        join anlz
          on anla~mandt = anlz~mandt
          and anla~bukrs = anlz~bukrs
          and anla~anln1 = anlz~anln1
        where anlz~kostlv = '0000100000' or anlz~kostlv = '00000100001'
   group by anlz~kostlv.
Jarek

Similar Messages

  • Can anybody tell me how to extract sales value and cost value for an materi

    dear all,
    Can anybody tell me how to extract sales value and cost value for an material sold .
    All the values of cost value and sale values are getting  stored in bseg-wrbtr field .
    How to identify them uniquely.
    Or there is another way to find the sale and cost values.
    Regards
    Mave

    Hi Mave!
    Normally there is no condition change, when something is sold.
    But sales price depends on sales conditions (not only price, but also surcharges, discounts, taxes - if customized).
    Nevertheless, after selling you have a invoice document, where correct values <i>should</i> be stored (see VBRP fields mentioned above). If here is a problem, then customizing of price determination is in question, not a programming of user-exits with MARD selection for costs (or some other tries to get a price).
    When you specify your requirements more in detail, you might get better answers - but currently only general hints are possible ('see in invioce / G/L accounts').
    Regards,
    Christian

  • Table for Cost Centers and Org Units

    Hi All,
    How to retrieve the list of Cost centers and the associated Organization Units?
    My HR user is in need of such list...
    Can anyone help me out....????
    Regards
    Pavan

    Hi
    I dont think you can associate a cost center with org unit, it is normally associated with position/person.
    You can check table PA0001 to get the cost center and org unit for a personnel number.
    Is this your requirement ?
    Thanks,
    Shrinivas

  • Cost Centers and distribution rules

    I need to allocate costs to profit centers and would like to have the costs be allocated first to the department cost center then distributed to product profit center by %.
    Example:  An invoice is first allocated to the sales department, then the distribution rule will allocate the cost between 4 product lines (33 % chemical A, 33 % chemical b, 17 % chemical c and 17 % chemical d).
    How would I setup the profit centers, cost centers and distribution rule to accomplish the above task.
    Thank you,
    Wayne

    Hi Fred,
    I assume you using 8.81?
    1. Administration - General Settings - Cost Accounting : Tick "Use Multidimensions" option
    2. Financial - Cost Accounting - Dimensions : Tick "Dimension 1" and "Dimension 2".
    Give proper description to each dimension, in your case maybe "Department" to Dimension 1 and "Product" to Dimension 2
    3. Financial - Cost Accounting - Cost Centers : Create your intended cost centre, "Sales" cost centre with dimension "Department", "Chemical A" to "Chemical D" with dimension "Product"
    4. Financial - Cost Accounting - Distribution Rules :
    As for your intention to allocate the invoice to Sales Department, since you want to allocate it 100% to Sales Department, you don't need to create a distribution rules, since B1 will automatically create a distribution rule with 100% allocation for each cost centre you created.
    As for your production cost allocation, create a distribution rule with your code "DR-P01" as an example, choose dimension "Product", set the Total with "100". In the detail section, choose each cost centre (Chemical A to D), enter respective value and click "Add" button.

  • Cost centers and profit centers mapping

    Hi Friends,
    I'm through with defining cost and profit centers. How do I map the cost centers and profit centers. I've gone ahead and assigned the cost elements to cost centers in OKB9, giving 2-Business area mandatory.
    I'm just done with defining the profit centers, but i dont have an idea how do I map the profit centers.
    pls suggest.
    regards
    Pallavi

    found it

  • Cost centers and budgets filtered by functional locations

    Hi All,
    I need report containing cost centers and budgets filtered by functional locations.
    Regards
    Hari

    Hi,
    Please find the logic below & try it at your system-
    Here cost center group is not possible (also i not checked it so do it on your own simultaneously i am trying the same).
    Use Table BSEG-> in bseg give the cost center-> with the help of cost center find the account number (field HKONT)-> take this GL account number & got to table COEP-> in this give the GL account number at field 'offsetting account' (field GKONT) & you will get the line item.
    Try it & let me know if you have any question.
    Thanks

  • Report of projects across cost centers and vice versa

    Hi friends,
    Do we have any standard report of Projects across Cost Centers and vice versa?
    In our case, it is statistical cost center postings and real project postings. How can we get a standard report of Projects across Cost centers ?
    thanks in advance,
    San

    Refer the thread
    Reports on Statistical WBS
    In the report CJI3- Actual Line Item Report, pull in the field Partner Object in this case it would be Cost Centre (where actuals are posted)
    Regards
    Sreenivas

  • Assignment of cost centers and profit centers

    Hi Friends,
    can anybody give me a series of steps of assignment of cost centers and profit centers, like I know there is a T.code 3KEH, but I really dont know the chronological (step by step) order of steps to be followed to assign the cost centers to profit centers, as profit centers cannot be directly posted to and as the postings.
    And above all when I see the info about 3KEH, it says we need to assign only balance sheet items there and not cost items.
    Basically I've not studied Profit center accounting Properly and so I'm facing this problme
    If there is any documentation on this can anyone pass this on to: kiransandhyaATyahooDOTcom
    regards
    sandhya

    Hi Sridhar,
    Thnx for replying. I've gone ahead and defined cost and profit centers and did what you have told me to. Now this is where I'm stranded. How do I map profit and cost centers so that the we get the right kind of reports.
    Basically, my question would be: say for eg: if we are defining Company, Co.Code, before completing with Global paramters, there are a series of steps that we need to complete, right.
    Like wise, I just wanted to have a series of mandatory steps that I need to follow where the cost centers and profit centers mapping is done, atleast if I have the steps with me then I can go ahead and check the logic as to why should I define a particular step.
    Like I mentioned I happened to see some information about 3KEI, so before going to 3KEI or 3KEH, are there any other steps that I need to follow.
    I need to get the cost center and profit center reports, so that is what I'm looking for, and what do i need to configure, before getting to that point?
    I dont have a great insight into PCA, and I was not a part of the controlling configuration, but because a person has left in between the project, I'm supposed to do this and that is the reason why I dont have much time in doing R&D, and thats the whole reason why I'm seeking inputs which would actually minimise my time of R&D, once I'm able to convince my people, then again I can sit back and try to improvise my self.
    regards
    sandhya

  • I have 2 Macs - an iMac that holds my entire iPhoto library and a Mac Book Pro that I use to hold a subset of the main library - how can I transfer photos and their metadata from the main library of the iMac to my Mac Book?

    I have 2 Macs - an iMac which holds my main iPhoto library and a Mac Book Pro which holds a subset of the library. How can I transfer photos and their metadata from the main library to the smaller 1 on the Mac Book Pro?

    Link the two Macs together and use iPhoto Library Manager
    Regards
    TD

  • I just got a new iphone 4 for att and my friend installed the sim card in it for me. the imessage function isnt connecting with the my cell number. a while back i had logged into my apple account on someone elses cell phone and their number keeps showing.

    i just got a new iphone 4 for att and my friend installed the sim card in it for me. the imessage function isnt connecting with the my cell number. a while back i had logged into my apple account on someone elses cell phone and their number keeps showing. when i try to just select my number to send and recieve imessages from it will not show up. i can send and recieve regular text but not pictures or imessage. i have tried logging off and restarting and nothing has worked.help please!!

    Did you remove your account information from the other person's iPhone?

  • Is it possible multiple line items debit & single line item credit and different cost centers and different profit centers in fbcj

    Hi all ,
    I have a requirement to Post Cash Journal Document using FBCJ tcode.
    Is it possible multiple line items debit & single line item credit and different cost centers and different profit centers
    for exp:
    pk   GL a/c   description       amount   cost center  profit center
    40  400101  telephone exp   500        1403            P 1000
    40  400101  telephone exp    100       1404            P 2000
    50  200100  cash in hand      600-                             
       This is My requirement  is it possible in fbcj
        Please suggest me.ASAP.
    Regards
       Naresh.

    Hi,
      This you can do it in two ways:
    1. Make three header under top level....one Product A, 2nd Product B ( as Billing element) and third as Common expense ( only cost). Now 1st & 2 nd WBS, you have to have sales order linking with individual lint item, for third you will accumulate all the common expense till the period end then make a reposting of the same in desired proportion to both products WBS hierarchy
    (This is if you want to have a track on the common expense as well.......like planning, budgeting & control)
    After this reposting, run RA for individual billing element and hence you will all the complement detailing and control over Revenue and expense with respect to Product A and Product B individually.
    2. If you don't want to maintain that kind of detailing the common expense and keep track of it through project, then have cost centers accordingly and make an assesment/ distribution with respect to expenses accumulated at those cost centers for the period to the respective WBS under each product. Then execute the period end processes for the project.
    Or
    You can try with have two more line items in the costing sheet as an overhead against common expenses with respect each product.
    I hope this should help you.
    Regards
    Avisek Bhardwaj

  • Link beteen cost centers and activities

    Hi
    We have 180 + cost centers and I want to have 100 + activities.. I want to link these cost centers & activities..Eventually what should happen is when processing transactions with a CO object (cost center, internal order, WBS) in AP posting, recurring entry, depreciation, PO ect the value should also hit the activities at the time it hitting the cost center
    I just want to know whether a link can be maintained in the cost center master data to link an activity..
    Thanks

    HI,
    the linkage of cost centers and activity types is done in cost center / act. type master data using the field "cost center category". if you set cost center category to "X" in the cost center, the cost center can only "use" act. types with cost center category "X" (or * which is a wildcard).
    In act. type master data you can key in up to 8 different CCtr categories, which allows you to limit activity type "test" to be used for cost center category X and Y and Z.
    The possible combinations can be seen in act.rate planning (kp26). Planning is only possible for the combination of cost center / act. type given by the linkage described above.
    Best regards, Christian

  • How do i switch information and phone number when they both say no service

    how do i switch information and phone number when they both say no service

    Please re-phrase the question. This doesn't make a lot of sense.

  • How assign 7 cost centers to one cost element.

    hi
    how assign 7 cost centers to one cost element.
    Ex: FUEL can use 10 departments.  how to assign this cost centers to one cost element.
    Thank you.
    Ashok kumar

    Hi Anil,
    At the time of posting fuel expenses you need to have 10 line items for each seperate cost center    or
    You can post to a one cost center inturn you can use Distribution or Assessment for re allocating to other cost centers.
    Regards,
    Murali

  • How do i uninstall applications and their packages without littering trashcan

    how do i uninstall applications and their packages without littering trashcan.
                                                                                                       *sincerly nube*

    OK. That wasn't clear at first. See the following:
    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, EasyFind, instead.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
        1. AppZapper 2.0.1
        2. AppDelete 3.2.6
        3. Automaton 1.50
        4. Hazel
        5. AppCleaner 2.1.0
        6. CleanApp
        7. iTrash 1.8.2
        8. Amnesia
        9. Uninstaller 1.15.1
      10. Spring Cleaning 11.0.1
    For more information visit The XLab FAQs and read the FAQ on removing software.

Maybe you are looking for