Two Questions on ABAP UNIT

I'm familiar with the technical concept of ABAP Unit testing, using both local or global classes, running sets of Unit Tests using the Code Inspector. However, I'm struggling with two issues:
a) Technical issue: how can I test a Protected or Private method of a class using ABAP Unit testing? It works if the class to be tested has granted friendship to the unit test class, but is that the way to do this?
b) conceptual issue on the types of Unit Tests to define: the Unit Test is based on comparing actual results with expected results. But how can I predict a result on a development environment that is constantly changing?
Thanx in advance
Ben Meijs

Hi!
For having plan vs actual report, first of all you need to define CO versions through ORKE for your operating concern. You also needs to define plan version through KE14. Also you need to assign COPA reciever plan version for integrated planning.
     All your SD condition types need to be assigned to value fields. Also to flow actual values of production orders, CO Orders - it is required to assign PA transfer structure to settlement profile. Settlement profile must allow profitlability segments as settlement recievers and it must be stored in settlement profile. The assignment ensures that variances also flows to COPA. Key figure should also be defined for when assessment is caried out from cost center accounting to COPA. Also your value fields are also to be assigned to Cost component structure in COPA.
       After doing above necessary activity, you may plan for your form of report through KE34. Lines, form and header are specified by means of characteristics or value fields.
Hope it helps a lot!
Please revert back for any query.
Thanks & Regards,
Taral Patel

Similar Messages

  • Hi Experts, questions about abap unit test(abap oo)?

    Hi Experts,
    I am learning abap unit test, could you please tell me some info about how I can test the performance of some specific code in my program? can abap unit test do this kind of job? and could you please tell me what I can do using abap unit test? and some classic examples are appreciated, thanks in advance!
    Kind regards
    Dawson

    Hi
    Below documents will give you more information,
    http://help.sap.com/saphelp_nw04/helpdata/en/a2/8a1b602e858645b8aac1559b638ea4/content.htm
    ABAP Testing and Troubleshooting [original link is broken]
    http://bi.offis.de/publicProject/g16cglafhqva.htm
    regards
    Nagaraju

  • Questions about ABAP Unit (Integrate in class / encapsulate DB access)

    Hi,
    i have allready done some Unit Tests. Till this post i have created a report and put my test class definition / implementation there. The report is just a wrapper for testing. The functionallity is impelemented in classes.
    My first Question is how to integrate the test code in my class. In all examples they put the code beneath the class implementation. How do i get there? In se80 i can only see the public definition.
    The other question is about testing methods, which contains database access. How can i encapsulate the db access for tests. I read abput implementing a seperate class, which handles all db related actions.
    Bye Richard.

    Hello Richard,
    it is recommended to keep the domain code and the test code within the same program. Depending on the release in use a Class-Pool (program) offers an implementation include (for any local class) or possibly also a dedicaded test class include.
    Put the definition and the implementation of your unit test into one of this includes.
    In case your code under test has hard to test dependencies you need to break them. After the hard to test dependency (such as repository access) is separated it can be replaced by use of test doubles (see also http://www.xunitpatterns.com).
    Propably the following approach is the easiest one:
    - put any db access into a separate method
    - create a local subclass as test double that overwrites exactely the db access methods with test friendly code
    - run your unit test logic against this local test double
    The say "cleaner" way is to:
    - separate the db access to a dedicated repository service class (with instance methods of course).
    - create a test double of this repository class
    - use the technique "dependency injection" and run your test
    Best Regards
      Klaus

  • ABAP Unit question

    Hello,
    I am new to ABAP unit, and not really sure on how I can execute one ABAP unit test script.
    Let's say I have the below code (extracted from SAPBC401_PRJD_ABAP_UNIT program in SAP ECC 6.0 system (SP9).
    **& Report  SAPBC401_PRJD_ABAP_UNIT
    REPORT  sapbc401_prjd_abap_unit.
    CLASS myclass DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA text TYPE string.
        CLASS-METHODS set_text_to_x.
    ENDCLASS.
    CLASS myclass IMPLEMENTATION.
      METHOD set_text_to_x.
        text = 'U'.
      ENDMETHOD.
    ENDCLASS.
    * Test classes
    CLASS mytest DEFINITION FOR TESTING.
      PRIVATE SECTION.
        METHODS mytestmethod FOR TESTING.
    ENDCLASS.
    CLASS mytest IMPLEMENTATION.
      METHOD mytestmethod.
        myclass=>set_text_to_x( ).
        cl_aunit_assert=>assert_equals( act = myclass=>text
                                        exp = 'X' ).
      ENDMETHOD.
    ENDCLASS.
    The simple question is, how I can execute the
    mytestmethod
    from
    mytest
    class?
    If I just execute the above code using F8, I believe nothing is executed right?
    I tried to append the below code, but it is also only executing the method in that particular class (not in the test case class).
    start-of-selection.
    myclass=>set_text_to_x( ).
    Please help me to start...
    Thanks in advanced.
    rgs,
    hiroshi

    Dear Klaus,
    Thanks very much! The link is very useful.
    I implemented the below class for test, and now I got the idea how to continue!
    class ZCL_WALLET definition
      public
      final
      create public .
    *"* public components of class ZCL_WALLET
    *"* do not include other source files here!!!
    public section.
      data LIQUIDITY type I .
      methods CHECK_LIQUIDITY .
      methods GET_LIQUIDITY
        returning
          value(RE_LIQUIDITY) type STRING .
      methods PUT_IN
        importing
          !EUROS type I .
    REPORT  Z_MAIN_ABAPUNIT.
    class lcl_Wallet_Test definition for testing. "#AU Risk_Level Harmless
      private section.
        methods check_Liquidity for testing.
    endclass.
    class lcl_Wallet_Test implementation.
    method check_Liquidity.
      data:
        my_Wallet type ref to zcl_Wallet,
        liquidity type i.
      create object my_Wallet.
      liquidity = my_Wallet->get_Liquidity( ).
      cl_Aunit_Assert=>assert_Equals(
        act = liquidity
        exp = 1 "purposely put 1 to show error
        msg = 'New wallet assumed empty' ).
      my_Wallet->put_In( euros = 12 ).
      cl_Aunit_Assert=>assert_Equals(
        act = my_Wallet->liquidity
        exp = 12
        msg = 'As many euros as put in before' ).
    endmethod.
    endclass.

  • I have two questions. Are unlocked iPhone 5 available in apple stores in US? Can i use a factory unlocked iPhone 5 (GSM) anywhere outside united states?

    I have two questions. Are unlocked iphone 5 now available in Appple Stores in US? Can i use a factory unlocked iphone 5 (GSM) anywhere outside the United States?

    The Apple (Republic of Ireland) online store has the unlocked Iphones 4, 4S and 5 for sale. They are dear but worth it. I ordered the unlocked I phone 5 last week. That said, retail Apple Stores do and will not carry the Iphone line instore. They do however sell some accessories for all Iphones but thats as far as the Irish retail stores go.
    Its obvious to me that the Apple sales strategy for the US is different to the Irish one, so your retail stores may carry the unlocked versions at some point in the future.
    Sorry I could not be of more help..

  • Abap Unit Tets Question

    Hi,
    I want to do a unit test for Fm ,but the FM input have some value that always changing and other
    Are stay the same ,and the FM output change accordingly , i can build a unit test for this kind of FM,
    Or it's worthless ?
    Regards
    Ricardo Arona

    Hi Naimesh,
    But your FM involves some kind of processing i.e. collecting table, modifying data in to internal table, filling up final table etc than you should write ABAP Unit only on that Subroutine.
    Yea , my FM get always different key.
    the WORKITEM_ID is unique and always changing.
    like :
    Import
    WORKITEM_ID                  -                           005104574
    DECISION_KEY          -                                   0001
    USER_ID                         -                                    C0267195
    OPERATION_ID                        -                             EXEC
    so the export data is always changing accordingly .
    What u suggest for this kind of issue?
    Regards

  • Two questions about Risk Management 2.0

    hi experts,
    Please find below two questions about Risk Management:
    -In SPRO, Risk Management>Create top node: after completing information and executing I have this error:
    Error in the ABAP Application Program
    The current ABAP program "/ORM/ORM_CREATE_TOP_NODES" had to be terminated
    because it has
    come across a statement that unfortunately cannot be executed.
    The following syntax error occurred in program "/ORM/SAPLORM_API_SERVICES " in
    include "/ORM/LORM_API_SERVICESU10 " in
    line 97:
    "Bei PERFORM bzw. CALL FUNCTION "GET_ORGUNIT_THRESHOLDS" ist der Aktual"
    "parameter "I_ORGUNIT_ID" zum Formalparameter "IV_ORGUNIT_ID" inkompati"
    "bel."
    The include has been created and last changed by:
    Created by: "SAP "
    Last changed by: "SAP "
    Error in the ABAP Application Program
    The current ABAP program "/ORM/ORM_CREATE_TOP_NODES" had to be terminated
    because it has
    come across a statement that unfortunately cannot be executed.
    Do you know where it could come from?
    -On the Portal>Risk Management
    when I click in a link under the risk management menu(activities and risks, risk report, document risk,...) i alway have an internal server error:
    While processing the current request, an exception occured which could not be handled by the application or the framework.
    If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator. To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    Do we have to set up some customizing points before accessing these links?
    Thank you !
    Regards,
    Julien

    Hi Julien ,
    I have the same error what u described as :-
    -On the Portal>Risk Management
    when I click in a link under the risk management menu(activities and risks, risk report, document risk,...) i alway have an internal server error:
    While processing the current request, an exception occured which could not be handled by the application or the framework.
    If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator. To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    Do we have to set up some customizing points before accessing these links?    "
    Are you able to solve this. Please let me know how to resolve this???
    Thanks
    Regards,
    Atul

  • ABAP Unit Test Problem

    Here we go again on questions regarding ABAPUnit.  We are trying to use Abap unit within a Class object.  All the examples we have seen have to do with Classes and Methods within a Report program. 
    What we have created:
    Class: ZCL_MAIN
    Type: General Class
    Method:  test_abapunit
    Class: ZCL_MAIN_TEST
    Class type: Abap Unit
    Sub Class of ZCL_MAIN
    Method: Test_abapunit_test 
    We try and run the Abap Unit Test from the Test Class and it says it is complete but does not execute our code.  I know we are doing something wrong but are stumped as to what it is.
    Glenn

    Hi Glenn,
    although Uwe and Klaus actually provided for the relevant information we too faced some difficulties at first understanding 'where' you actually put the test classes. So here are the mechanics:
    Open SE80 or SE24 and implement your class ZCL_MAIN.
    While this class is opened, choose <i>Goto->Class-local types->Local Class Definitions/Types</i> from the menu. An editor for local classes is opened on the right.
    Type in your class definition ZCL_MAIN_TEST like this:
    CLASS lcl_main_test DEFINITION FOR TESTING.
      "#AU Risk_Level Harmless
      PRIVATE SECTION.
        CONSTANTS: some_initial_test_value TYPE i VALUE 5.
        DATA: main_class TYPE REF TO zcl_main.
        METHODS setup     FOR TESTING.
        METHODS teardown  FOR TESTING.
        METHODS check_get_my_int FOR TESTING.
        METHODS check_.. FOR TESTING.
    ENDCLASS.
    This is btw a 'normal' local class, no subclass of cl_abap_unit.. whatsoever.
    Go back (menu <i>Goto->Class Definition</i>).
    Choose <i>Goto->Class-local types->local class implementations</i> from the menu.
    Type in your class implementation for ZCL_MAIN_TEST, i.e. implement especially the setup()-method for the test fixture and the various test-methods.
    Compile/activate your class ZCL_MAIN.
    Run the test by choosing <i>Test->Unit Test</i> from the context menu of the class ZCL_MAIN.
    Hope this helps, regards,
    Sebastian

  • Transport of ABAP Unit Test Classes between systems.

    Hi guys
    I have a bit of a dilemma on hands here pertaining to the transport of ABAP Unit test classes. Generally when you create a transport containing classes the transport manager will automatically include all "programs" related to the class like the local type definitions, local implementations and with ABAP Unit the local test classes.
    <b>The question that I have is how would one go about excluding the ABAP Unit test classes in transports to production systems and pre-WAS 6.40 systems that do not support ABAP Unit? Does the transport system automatically manage this for you?</b> Any help ideas regarding this would be greatly appreciated.
    Kind regards
    Ettienne Hugo

    Hello Ettienne
    I have a very similar problem that I have to maintain objects for release 6.20 and 6.40. Since I appreciate ABAP Unit Tests as being very helpful I do not want to miss them even in such a situation.
    My approach is as following:
    - If possible, I try to separate the local classes from the tested object, for example:
    - Report or function group
         - contains an include like <z_include_ft01>
                - Within <i><z_include_ft01></i> I have a single stament <i><z_include_au01></i>
    The actual ABAP Unit Tests are coded in <z_include_au01>. Now if I need to ship the development to a release < 6.40 the only thing I need to do is to comment the single INCLUDE statement in <z_include_ft01>. This manual step cannot be ommitted (however, it would be simple task to define an eCATT doing this). In addition, include <z_include_au01> should not be in the transport request for the development (if it happened the import error would not affect the function of the development because it is no longer linked together).
    Advantage of this approach:
    - I clearly see that my development contains ABAP Unit Tests (use naming conventions for the includes) and
    - I can ship - with little effort - the development to SAP releases not supporting ABAP Unit Testing yet
    Regards
      Uwe

  • When i try to download an app and i have entered my password i am asked to add some security questions. I can add two questions and an alternative e-mail address, however it will not let me select the third security question.

    when i try to download an app and i have entered my password i am asked to add three security questions. I can add two questions and an alternative e-mail address, however it will not let me select the third security question.

    Thanks Liam. After the second ap download it asked me three security questions on iTunes and on my MAC it allowed me to set up these with no error on the third question. iPAD 3 now downloads apps fine.
    Apple really need to sort out this issue or provide guidance on this. Two days of the unit not really being fit for purpose - what use is an IPAD without the ability to download aps.
    Also NO Response from Apple via online tech support and it's now been nearly 24 hours - I was told by telephone support I would get a response within 24 hours or less, as also stated in the email response too!??
    It would be good to get a formal response from Apple on this rather than radio silence.

  • ABAP unit: test classes part of prod. code

    Hi all,
    I've read <a href="https://weblogs.sdn.sap.com/pub/u/266">Thomas Weiss</a>'s weblog: <a href="/people/thomas.weiss/blog/2004/12/17/a-spotlight-on-abap-unit-part-1 Spotlight on ABAP Unit Part 1</a>.
    I posted a question there, but apparently Thomas can't answer at the moment, and since I'm impatient for getting someone's opinion, I reckon we can discuss that topic here  :^)
    As explained in the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1be1003-0701-0010-3795-f87160de6483">NetWeaver Developer’s Guide Using ABAP</a>, the test classes are part of the program under test (PUT):
    <i>In ABAP Unit, test classes are part of the production code of the TU. This avoids problems arising from the test code being separate from the production code:
    - Programs and tests must be kept synchronized.
    - You have to ensure that the test and program code are transported together.
    - External test code only enables black box tests with an outside perspective of the tested program.
    Since the test code is part of the production code, it is easy to keep the unit tests and the
    production code up to date if the latter is changed.
    Although the test code and the production code are transported through the system landscape, ABAP unit tests do not increase the load on the production system. By default, the test code is not compiled in the production system. Therefore, the test code can never be executed in the production system.</i>
    On the other hand, this idea is quite different from what suggested by other unit testing frameworks.
    For instance, the documentation of <a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test::Unit - Ruby Unit Testing Framework</a> reads:
    <i>It‘s handy to collect a bunch of related tests, each test represented by a method, into a common test class that knows how to run them.
    The tests will be in a separate class from the code they‘re testing for a couple of reasons. First of all, it allows your code to stay uncluttered with test code, making it easier to maintain. Second, it allows the tests to be stripped out for deployment, since they‘re really there for you, the developer, and your users don‘t need them. Third, and most importantly, it allows you to set up a common test fixture for your tests to run against.</i>
    Regarding the advantages outlined by NetWeaver Developer’s Guide:
    - Programs and tests might be kept synchronized even if they don't belong to the same unit of code.
    - Moreover, you could assure that the test and program code are transported together by saving them in the same package.
    - And quite frankly, I don't have a thourough understanding of the reason why external tests only allow <i>black box tests with an outside perspective</i>.
    What are your opinions on this?
    Regards, Davide

    Hi,
    when I started unit testing with JUnit I was quite surprised that SAP groups the tests with the production code. But now I actually really like it. It has a few advantages:
    - Good tests serve as an excellent documentation so why not bundling them together.
    - If you want to look at the tests they are easy to find.
    - I write all my class tests as local classes. I found out that it really helps me to focus on writing tests only for the class under test. Sometimes it is quite easy to forget the "unit" and write integration tests again.
    Regarding your question:
    >And quite frankly, I don't have a thourough understanding of the reason why external tests only allow black box tests with an outside perspective.
    Usually I would not use the term black box testing in this context. Maybe you mean that it is easy to access private attributes, methods when you group class and testclass together?
    Normally black box testing means that you cannot look at the implementation of the code under test. So your tests are based on the specifications or if there is not one, on your common sense.
    cheers
    Thomas

  • Code Inspector & ABAP UNIT Testclasses

    Hallo all,
    I am currently trying to implement automated checks using the code inspector. I especially want to see if all our developers use our naming conventions. Also, we use ABAP Unit tests. Unfortunately, the generated test classes are not compliant with our name conventions (And also these Test classes are not interesting to be checked).
    Now, I receive many warnings, mostly from the Unit test implementations.
    Now: Is there a way to exclude these local test classes from my object set?
    Thanks for you help!
    Best regards,
    Martin Imme

    Other language NUnit test frameworks similar to ABAP Unit (AUnit) commonly have project extensions for storing test results. These are useful for the unit level regression (did a new change break any existing functions). History of test results, help narrow down the nature of a current failure by answering the question of 'When did this break?' or when did it last pass? In systems dependent upon outside components the history can provide a pattern for occasional failures due to factors outside the system under test.
    I see that ABAP unit test results can be added into the Code Inspector under the Check Variant.
    1. Is it common or recomended to use the Code Inspector (SCI) to store AUnit test results?
    2. Is it common or recomended to use Code Inspector Object variants to collect individual AUnit tests for a regresssion style 'TestSuite'?
    3. What reporting or tools exists for Code Inspector history?
    4. Is Application Logging the better spot for AUnit results history?
    (also posted on the wiki.. apologies - I'm new to the forum and wiki)
    Will Loew-Blosser

  • ABAP Unit for Function Module(Function Group)

    Hi, Gurus:
    Can we use ABAP Unit to test Function Module(Function Group).
    If can, give me a simple example. how to create methods. Thanks.
    Regards,

    I'm a little unclear about your question, Yunfa.
    Do you want to single-test a SE37 function-module? This can be easily done, just hit the F8 button, and it takes you to a single-test environment.
    Do you want to test an FM using an ABAP-program? This too is easy to do. To code the FM-call, there's a button called Pattern, in the standard SE38 screen, where you can put in your FM name, and it inserts the relevant code in your program.
    Note that if you're testing BAPIs using the single-test environment, the actual document posting will not happen, because that requires a BAPI_COMMIT_WORK call. So, the way to test BAPIs which post documents would be to write an SE38 program, which also calls the commit-bapi.
    Hope this answers your question!

  • Two questions before purchase ...

    I'm close to purchasing the 1.83ghz macbook from amazon (100 rebate) and have two questions:
    1) Does it look like Apple has solved the discoloration problem? I've been looking through the posts here and I see alot of people talking about how their June-July purchased macbooks have this problem so is it too soon for the August ones to have this problem or does it look like Apple has fixed the defect?
    2) This is not macbook specific. In Office 2003 (Windows based) you can have the "Speaker Notes" box open during a full screen slide show so you can add notes to the lecture while in slide show mode; does the mac version of office 2004 have this feature?
    Thanks for any help.
    -Chris

    I'm close to purchasing the 1.83ghz macbook from
    amazon (100 rebate) and have two questions:
    1) Does it look like Apple has solved the
    discoloration problem? I've been looking through the
    posts here and I see alot of people talking about how
    their June-July purchased macbooks have this problem
    so is it too soon for the August ones to have this
    problem or does it look like Apple has fixed the
    defect?
    I would advise ordering one direct from Apple to get the latest build. I'm sure some units out in retail channels have bad logic boards in them yet. Also, you will be waiting 4 MONTHS for that rebate from Amazon.
    -Bmer
    Mac Owners Support Group
    Join Us @ MacOSG.com
    ITMS: MacOSG Podcast
     An Apple User Group 

  • What is expected from a two year experience ABAPer

    Hi guys,
    After working in ABAP for one year... what will be the expected experience from a two years experience ABAPer?
    I have three years of experience in .NET and one year experience in ABAP.
    I have finished my training a year ago in ABAP.
    Any suggestion?
    William Wilstroth

    Hello William,
    This is a rather difficult question, due to it's highly subjective nature. What an employer wants is something that cannot really be predicted.
    some of them might want very strong skills in SAP Script and SMARTFORMS, while they really may not care if you have not worked on BDC. Some may want very good knowledge about the BADI and User-Exits concepts, while they don't mind if you are not familiar with LSMW, for instance.
    If you're looking for a job, then please read the job requirements carefully. That is the best source for the kind of information you're seeking.
    Regards,
    Anand Mandalika.

Maybe you are looking for

  • Iphoto won't switch to my apple ID? due for an update but cannot update. help???

    I had recently purchased my Imac OSx from a family friend and did a complete update to the Mavricks software. I changed all the accounts to my own apple ID but cannot change iPhotos domain account to my apple ID. it shows another email and does not g

  • I cannot uninstall program (I need the space) - suggestions?

    When I run the windows uninstall program nothing happens - the uninstall program does not run

  • How do I turn a photo to Portrait?

    Hello, I've been using iWeb to create my new site. Everything has been going well, except when I create a photo page, my photos are inserted in "Landscape" even though in iPhoto I had already turned the photo to "Portrait". Can anyone assist in how I

  • Foreign character set issue

    Hi This might sound a bit silly, but stay with me. There's a database that decidedly supports UTF 8. I checked using this query select * from nls_database_parameters where parameter like '%CHARACTERSET' And got this result NLS_CHARACTERSET     UTF8 N

  • Best setting for mpeg streamclip conversion of mpeg2 to mov

    Through this forum I learned about mpeg streamclip. Thanks so much! Now I am able to convert an mpeg to a mov and keep the audio and quality, etc. Now my problem is that I am building a site, refering to the movies externally so they play in quicktim