How to calculate no.of records for a specific company Code and Transaction

Hi All,
Could you please help me how to calculate or count no.of records, in a table which are having a specific Company Code and Transaction Code and populate  in an output table displaying that these many records are present for this company code and Transaction code.
The table is having the data like this:
LOB   TRAN CODE    COUNT
X1                             1   
X1                              2   
X1                              3   
X1                              4   
F1   NB                      5   
F1   NB                     6   
F1   NB                     7   
F1   NB                    8   
F1   NB                    9   
F1   NB                    10  
F1   NB                    11  
F1   NB                    12  
F1   NB                     13  
F1   NB                     14  
F1   NB                     15  
F1   NB                     16  
F1   NB                     17  
F1   NB                     18
F1   NB                    19  
F1   NB                    20  
F1   NB                   21  
F1   NB                   22  
F1   NB                   23  
F1                          24  
F1                         25  
F1                         26  
F1                         27  
    In the above table there are totally 27 records,where as the no.of records with F1 as company code and NB as transaction code are 18..so i have to display like F1 NB and 18 as one record as output.
Thanks and Regards,
Johny

You can go for Control Breaks for your requirement.
First sort the internal table by company code and transaction. Declare a counter variable.
Now loop the internal table and increment the counter variable. within the loop use AT END OF tcode.......ENDAT. Within the control break append the counter variable as well as the company code and tcode to some other ITAB and clear the counter.
This will give you the total number of records for a combination of co code and tcodes.
This will be a good reference for your requirement. What I am doing here is, for each Vendor i am calculating total number of deliveries and amounts for that vendor. For every new vendor i am writing the ouput on to a list and clearing the counter variables.
  LOOP AT t_vend_prod_grp INTO fs_vend_prod_grp.
    w_total_delv = w_total_delv + 1.
    w_total_amt = w_total_amt + fs_vend_prod_grp-dmbtr.
    AT NEW matkl.
      w_mat_grp = fs_vend_prod_grp-matkl.
* To display the material group and the header texts for the data
* grouped by material group and vendor.
      SKIP 1.
      WRITE:  text-mtk  COLOR COL_HEADING
                              INTENSIFIED,
            / w_mat_grp COLOR COL_NORMAL
                              INTENSIFIED OFF.
      SKIP 1.
      FORMAT COLOR COL_HEADING ON INTENSIFIED.
      ULINE  1(54).
      WRITE:/ sy-vline,
            2 text-ven,
           12 sy-vline,
              text-dlv,
           26 sy-vline,
           38 text-amt,
              sy-vline,
           46 text-cur,
           54 sy-vline.
      ULINE /1(54).
      FORMAT COLOR COL_HEADING OFF INTENSIFIED.
    ENDAT.                             " AT NEW MATKL
    AT END OF lifnr.
* To display the actual data for the grouping based on Material group
* and Vendor.
      FORMAT COLOR COL_NORMAL ON INTENSIFIED OFF.
      WRITE: / sy-vline,
             2 fs_vend_prod_grp-lifnr COLOR COL_KEY,
            12 sy-vline,
               w_total_delv,
            26 sy-vline,
               w_total_amt CURRENCY text-usd,
               sy-vline,
            46 text-usd,
            54 sy-vline.
      FORMAT COLOR COL_NORMAL OFF INTENSIFIED OFF.
      CLEAR: w_total_amt,
             w_total_delv.
    ENDAT.                             " AT END OF LIFNR
  ENDLOOP.                             " LOOP AT T_VEND_PROD_GRP

Similar Messages

  • How to identify all the information for a given company code?

    Hi,
    Our company provides data migration services for SAP and other ERP applications. Our customers provide us the specifications for extractions and conversions. We use one or more 3rd party tools to extract data from legacy systems into text/Excel files. Customers use LSMW to load generated files.
    We just got an unusual request. This customer wants to get ALL the data from SAP for a given company code and dump into Excel. They would do some manual editing on the data and load it into a new SAP client.
    In the past, customers would be more specific in their requirements. For example, they will mention Materials, Customers, Inventory, etc. In this case, the customer simply wants ALL the data for a given company code.
    Q1. Is everything in SAP related to company code, either directly or indirectly? For example, can materials be filtered by company code?
    Q2. The tools that we use let us extract data from SAP using SQL-like queries. How do I identify ALL the tables that I would need for a given company code?
    My feeling is the customer themselves are not clear on what they really want. Perhaps they are expecting us to guide them.
    I would appreciate any thoughts that you may have.
    If there is a more appropriate forum for this question, please let me know.
    Thank you in advance for your help.
    Regards,
    Peter

    hi
    t001w is the master table for plants, u can see all plants in this table.
    regads:
    rajesh.k

  • Calculate the database size for a particular company code in SAP

    Hi Experts,
    We have 30 company codes in our FI production system. So to plan another new company code to be deployed into the system, we need to know exact data capacity (database) of the previous company code that we already deployed. Kindly let me know whether it possible to calculate the database size occupied for a particular company code in a SAP system.

    >
    Kalyan Kumar Bandlamudi wrote:
    > Hi Experts,
    >
    > We have 30 company codes in our FI production system. So to plan another new company code to be deployed into the system, we need to know exact data capacity (database) of the previous company code that we already deployed. Kindly let me know whether it possible to calculate the database size occupied for a particular company code in a SAP system.
    Its not possible to calculate data size based on company code.
    By creating company code It will not occupy much space. Depends on your posting documents for particular company codes.
    Thanks
    Siva

  • How to process AT END OF command for company code and transaction number.

    Hi,
      I  have report with selection screen with company code and key date.  Based ON key date given I should calculate Accrued interest for all transaction with in each company code.
        When I run report with one company code it works fine. But when I run with multiple company codes the amounts are messed up.
    I am getting all company codes with transaction details in to ITAB1 like this below, and PERFORM get_processdata. has my calculation for interest rate.
      SORT itab1 BY company_code  transaction.
      LOOP AT itab1 INTO wa_tab1.
        itab2 = wa_tab1.
        APPEND itab2.
        AT END OF transaction.
           PERFORM get_processdata.
        ENDAT.
      ENDLOOP.
    Thank you.

    Hello,
    You need to use AT New event to clear your total variables.
    AT New - this will go for first time also but we want to clear variables from second time. it requires flag to stop going it first time
    Pseudo code:
    clear: flag.
    Loop at itab1 to itab2.
    At New.
    if flag eq c_x.
    clear: <total variables>, intenal tables.
    move c_x to flag.
    endif.
    tab2 = wa_tab1.
    APPEND itab2.
    AT END OF transaction.
    PERFORM get_processdata.
    ENDAT.
    ENDLOOP.

  • How to restrict the user id to a specific company code?

    Hi,
    I want to restrict a user id to access a specific company code only for both customizing and application data creation. This means that the user id can do customizing and create application data for that company code only and not for any other company codes.
    how can i do this?

    Hello Raja,
    You requirement of restricting users for application data can solved by adding the company code in the organization level button and the user will be restricted to mainatin application (transaction) data for the org element for which he is authorized for, if the transaction has objects which check company code.
    Customizing data authorization can be very tricky, as most of the customizing transactions are for maintaining customizing tables will not necessarily have an authorization check for org elements. In this case you may to manually insert a object called S_TABU_LIN alongwith S_TABU_DIS it will perform the job of restricting authorizations.
    In cases where the end user is accessing tables directly with SE16 S_TABU_DIS is the object that is check and maintained in PFCG.But,Such a restriction cannot be made with S_TABU_DIS alone. Fortunately SAP provides us with another authorization object S_TABU_LIN (Authorization for Organizational Unit), which can be used in conjunction with S_TABU_DIS to enforce such a restriction.
    This authorization object works only with Maintenance Views and Customizing tables. Also note that an Organization Criterion is a prerequisite for implementing the same
    A detailed step by step procedure to be followed is given below:
    1. The first step in implementation of line authorization is defining an Organization Criterion. For this we need to access the u201CSAP Reference IMGu201D customization page from SPRO transaction.
    2. From the IMG display screen select SAP Web Application Server -> System Administration -> Users and Authorizations -> Line Oriented Authorizations. Select the execute ( ) button for the u201CDefine Organization Criteriau201D.
    3. The resulting table display show all available Org Criteria values existing in the system. For our purposes we will create a new Org Criteria to suit our needs. Select the tab u201CNew Entriesu201D as shown below.
    4. Give an appropriate name starting with Y or Z for the new value. Note that a name starting with another letter will not be accepted by the SAP system. Click on u2018Saveu2019 button to save the newly created Org Criteria. This opens a new window asking for a Workbench Transport Request. This would be required so as to transport the new Line authorization restrictions further to the test and production systems.
    5. Now select the new Org Criterion u201CY_TESTu201D and double-click the u201CAttributesu201D tab as below to define the various Org Attributes.
    6. Provide the new Attribute name and Description for the same. Also fill the Authorization field value from the provided dropdown (1st Org Criterion Attribute u2026. 8th Org Criterion Attribute). The search help field is an optional field which can be filled if a search criterion exists or has been created earlier for the specific purpose. This field enables the u201CF4u201D when filling entries in the authorization object
    7. We already have a search help (C_T001) available, which provides as an F4 help the list of all available Company Codes in the system.
    Note that we can create up to 8 Org Attributes as per our requirements (by selecting u201CNew Entriesu201D tab), each corresponding to a column in the target table.
    8. Selecting the attributes link again will show us a list of all defined attributes and the authorization Field it will appear in. Now that we have defined the Attribute Field that we require, we need to associate each attribute to the corresponding Table Field in the target table.
    Select one of the attributes as below and double-click on the u201CTable Fieldsu201D button to define the field associations.
    9. Select the u201CNew Entriesu201D tab to create a new table field association.
    10. The View/table field must be filled with the target table which we need to control.
    11. The u201CField Nameu201D will require the field name of the target table which be linked with the specific Org Attribute. Performing an F4 on this field will display the list of all possible fields available in the View/table provided earlier. Here we will select the field name BUKRS (Company Code). Save the entries in the same workbench request created earlier.
    12. The next step would be to activate this new Org Criterion so that SAP now checks the authorization for S_TABU_LIN for every user
    13. In the u2018IMG displayu2019 go to SAP Web Application Server -> System Administration -> Users and Authorizations -> Line Oriented Authorizations. Select execute ( ) button for the u201CActivate Organization Criteriau201D.
    14. From the resulting customization screen tick the check-box for the Org Criterion that we have created. On saving the settings the system then asks for a Customizing Transport Request for further transport into test and development systems.
    15. Any user without this authorization will not be allowed in to the SM30 display/change screen for this table.
    16. In the role for which the S_TABU_DIS provides maintenance access for the table , we will now also need to maintain the object S_TABU_LIN.
    17. On selecting change button besides any authorization field you will need to select the Organization criterion which needs to be maintained here. Note that only one Org Criterion can be maintained in one instance of S_TABU_LIN object.

  • TAX code is not working for a specific company code

    Hi Friends,
    One tax code is giving error messa ge that it is not maintained in tax procedure, when iam using the same code for another company code it is working fine.
    Please help me, points are assured.
    Thanks.
    Srini

    Hi Srini,
    The tax codes are defined at the country level.  Please check whether the company codes belong to the same country.  If not ensure that the tax code is maintained in the tax procedures of the respective countries.
    You can check the assignment of the tax procedure to a country in the TCode OBBG.
    please reward points if helpful.
    Regards,
    Sreekanth....

  • Delete authorization for specific Company Code

    All,
    For a specific transactions, our users may only run the transaction for a specific company code. Transaction is TPM55A
    What authorization object do I need to add to my role, so the users have only authorization for let's say Company code range 1000 - 1050.
    Many thanx for help
    kr,
    Stef

    Hi Stef,
    Please try to add this authorisation object manually F_BKPF_BUK- Authorisation object for company code.
    In the filed BUKRS you can maintain the company code as you required for the users.
    I hope this may help you in resolving the issue.
    Thanks
    Karthick

  • Calculate database size for a particular company code

    Hi Experts,
    We have 30 company codes in our FI production system. So to plan another new company code to be deployed into the system, we need to know exact capacity (database) of the previous company code that we already deployed. Kindly let me know whether it possible to calculate the database size for a particular company code in a ERP system.

    >
    Kalyan Kumar Bandlamudi wrote:
    > Hi Experts,
    >
    > We have 30 company codes in our FI production system. So to plan another new company code to be deployed into the system, we need to know exact data capacity (database) of the previous company code that we already deployed. Kindly let me know whether it possible to calculate the database size occupied for a particular company code in a SAP system.
    Its not possible to calculate data size based on company code.
    By creating company code It will not occupy much space. Depends on your posting documents for particular company codes.
    Thanks
    Siva

  • Automatic creation of Company Code and Sales Area Data for Customer Master

    Hi,
    We have a organisation structure setup with multiple company codes and sales areas.
    A customer will be created using VD01 via the Sales Order VA01. Because the customers are created using VD01 we need to automatically extend the customer for the various company codes and sales areas. The data on these views will be populated using reference customers.
    Any recommendations on the best approach (technically) to auto extend the customer master would be appreciated.
    I'm reluctant to use BDC's because of performance. We are in a Retail environment.
    Thanks in advance
    Craig

    The sample code has been taken from the SAP notes - in which have the affected as outlined in the example.
    The codes does not do what my requirements are, which is to identify the next available number in isolation of the BP type.

  • Delete G/L Accounts for one company code when transaction data exists

    SAP transaction OBR1 can be used to reset transaction data.
    If you execute this transaction for a specific company code, the FI transaction data of that company is deleted. Because of the procedure to keep FI and CO in line, also the CO data has te be deleted.
    But you can not reset CO transaction data for one company code. You have to reset CO transaction data for a whole controlling area.
    If you can not delete the FI and CO transaction data for a specific G/L account in one company code, you can not delete that G/L account.
    There exists another solution for the deletion of FI and CO transaction data for one company code, and thus for the deletion of G/L accounts?
    Thank you very much for your feedback.
    Edited by: E. Deleu on Mar 3, 2008 3:42 PM

    Helllo,
    I believe the account group information is what you get when loading hierarchies. Please look into the hierarchy extractor 0GL_ACCOUNT_T011_HIER.
    Regards,
    Christoffer

  • How to calculate number of rows for perticular characterstic in SAP BI Bex

    Hi experts,
    Please let me know how to calculate  ' number of rows  ' for perticular characterstic in Bex query. 
    Thanks & Regards,
    Babu..

    Hello,
    You can try this
    Create a CKF and assign the vale 1 to it. Open the query and select Character where you want to display ' number of rows ', go to properties windows, select 'display', in the results row drop down box, select  'always display'.
    Thanks.
    With regards,
    Anand Kumar

  • How to calculate work in process for maintenance order

    how to calculate work in process for maintenance order i.e raw materials not used

    Hi,
    Generally, when u create PR from maintenance order, account assignment category should be F. Cost of services first settles on the order when u create service entry sheet. Further it got settled onto settlement receiver given in order.
    If you want to change the category from F to K for maintenance orders then follow the IMG menu path as given below.
    Plant Maintenance and Customer Service > Maintenance and Service Processing > Maintenance and Service Orders  >
    General Data > Define Account Assignment Cat. and Document Type for Purchase Requisitions

  • How to maintain a condition record for a output type ?

    Hi All
    How to maintain a condition record for a output type ?

    Hi,
    Goto NACE and there is a button for maintiaining the Condition Reocrds.

  • How to Use the same iview for both KM End User and the KM Administrator

    Hi friends,
    *This is my scenario :* How to Use the same iview for both KM End User and the KM Administrator but with different Context
    Menu Options.
    i followed these steps but im getting same context menu for both KM End User and the KM Administrator .
    Assign the role Content Administrator to the user km_admin. This is needed so that km_admin can change
    the presentation settings for the KM Folder u201EReports_kmFolder‟.
    Now, login with user km_admin. Navigate to the Km Folder reports_kmFolder through Content Administration
    -> Km Content. Click on Details link of the folder reports_kmFolder.
    Go To Settings -> Presentation. Click on the tab u201ESettings for You‟-> Click on button u201ESelect Profile‟.
    Select the radio button corresponding to u201Elayout Set‟, and choose u201EConsumerExplorer‟ from the dropdown.
    Click u201EOK‟.
    Select both the check boxes corresponding to Items Affected as shown above, and click u201ESave‟
    Now, remove the u201ESuper Administrator‟ role from the user km_admin and login with this user.
    How rto resolve this????
    Regards,
    Prasad.

    Hello Prasad,
    Most likely the user km_admin still has system principal roles assigned, even though you removed the Super Admin role, you should check that this user doesn't have any other admin roles, otherwise it will be considered a System Principal user and will therefore still have access to all content. For more information see http://help.sap.com/saphelp_nw70/helpdata/en/19/56f28fbd4e11d5993b00508b6b8b11/frameset.htm
    Try creating a new user with just read access to the content and you should see that it will not be able to make any changes etc.
    Regards,
    Lorcan.

  • How can I find my password for iTunes?  Forgot it and can't see how to restore or change

    How can I find my password for iTunes?  Forgot it and can't see how to restore or change it.  It is not the same as the apple id password - or so my iPhone iTunes says - Help

    I don't want to reset my apple ID password. I know it's right. It doesn't work on Itunes to restore my phone. All the passwords I know are not working. I want to know why.

Maybe you are looking for

  • Sap Conatiner Concept

    hello all, I was Trying to open a web application inside SAP and a PDF inside the sap Screen but in both the case it is opening in new respective window. I tried to open it through the Container concept but was not able to open it. I am able to creat

  • Error of "Configure the Role of the Integration Service"

    Hi Guru: When i run the Template Installer,I got the following error in the step 19:"Configure the Role of the Integration Service" =================================================== Element 'SXMB_SET_ROLE_TO_IS':ONLY_ONE_CENTRAL_XMB Element 'SAPDEM

  • I have Evernote web clipper. It does not appear on Firefox menu. What to do?

    Evernote web clipper is properly installed. The version is exactly for Firefox. The icon does not appear as promised on a toolbar, so I can not webclip my Mozilla pages. Regards, Andris Ozols

  • Office 365-Outlook

    I am jumping on the band wagon with the outlook problem. It seems to work OK on my Windows 8 laptop, but my windows 7 it is a piece of crap. Since that is the main computer I use I will not be using outlook or renewing my 365 subscription when it exp

  • Acer c720 touchpad not being recognized

    I have installed Arch on an Acer c720 Chromebook. I followed the wiki all the way through and ran the script that installs the proper kernel patches to get the touchpad working. The issue I have is the touchpad isn't even being recognized. I can't pa