TDD - Abap

Hi Collegues,
I am new in Abap Development and I am trying to "port" some of my Agile Knowledges within this new world.
The Abap Unit framework implementation of xUnit is a good point to start.
A unit test is Unit if:
- there is no db connection
- it does no work with network
- etc.
I know, more depends by the way and intention of  unit test, but mock an object is really useful.
Is there a way to create mock object in Abap? Something like EasyMock.
Thanks for your replies.
Regards,
Mirco.

Hello Mirco,
as Sandra already told there is no automatic support for test doubles yet. All you can do is to write stubs, spies and mocks on your own.
BTW: As in ABAP you get the DB connection for free, the definition for a Unit Test does not apply in full extend. 
Best Regards
  Klaus

Similar Messages

  • Test Driven Development (TDD) in the ABAP world

    Hi All,
    It's been a long time since I've had any spare time to be active on the SCN forums so firstly hello to everyone.
    I've worked on a number of different SAP technologies over the years, starting with ABAP and moving into BSP, Portal API, Web Dynpro, Visual Composer, etc...  I'm currently working on a 7.01 Portal sat on top of an Oracle database and an old R/3 4.5b system.
    I'm also currently working on methodologies (trying to give something back to my colleagues here at AO) and have hit a bit of a blank around Test Driven Development when working in the ABAP stack.  I use JUnit to help me design, build and test Java based web services, ultimately used in WD, VC and via standalone Java applications.  I'm keen on increasing the adoption of TDD and other XP based practices but it needs to be viable in the ABAP world as well as the Java world.
    Here's my question - does anyone have any suggestions/experiences/guides or even just thoughts around using TDD with ABAP?
    I try to make all code I create service based so I rely on heavy use of componentisation, regardless of the language I am working with.  Obviously this is great with Java and ABAP Objects is also quite good, but sometimes we have to work with good old fashioned ABAP in the shape of programs, function groups and function modules.  I tend to treat a function group as a class and the function modules as the methods when designing and componentising.
    Applying the Java TDD approach, my rough idea is to use class/function groups to package my logic and then extend the class or group with an extra method/module that acts as the unit test routine.  I wonder if there is a better way though?
    It would be good to have a decent discussion in this area and capture everyone's thoughts as I'm sure I'm not the only person thinking along these lines.
    Thanks,
    Gareth.

    Hi Sandra,
    Thanks for that.  I wasn't sure if there'd be a proper SAP solution or not.
    Gareth.

  • TDD: Using Test-Data Containers(eCATT) in Unit-test

    Recently I learned about TDD, and learn how to write unit-test for some class. But When I write a report(with DB, post account doc) , I come across some problem.
    1. I  have some method just select some data form table , but I don't know how to write this unit-test? I know I can create a TDC though eCATT, but my method is select form table ,how do I finish this ?
    2. Also I have some method just handle data, such as check the data or move to another internal table, do I need to write unit-test for this kind method?
    Further more , I search the SCN many times , I didn't find a suitable program as TDD program (include SQL, input , output, data handle ). Is there anyone can share your example in TDD for us , thank you so much.
    Best Regards!

    Glad that you have interest in TDD. I write on ABAP unit at my site zevolving.com 
    TDD should not dependent on the data selection from the DB as the DB data could be changed and your test would fail without you being changing the logic.
    To avoid the dependency on the data, you need to prepare the dummy test data. You need to than also prepare the expected output from the dummy test data. Once you have the dummy test data, you can pass the data to the method (or subroutine or FM) and get the actual output. You compare the expected output with the actual output to verify it works as expected.
    For your example, you should modularize the program - method for GET_DATA, method for PREPARE_OUTPUT, method for GENERATE_OUTPUT. From these methods, you should be able to write unit test on PREPARE_OUTPUT.
    In your unit test, you need to declare local variables in your test class if you use the subroutine. if you use the class and methods, you can instantiate the object and you get all the variable access. Thats the reason it would be more easier and less confusing when using the objects with unit test.
    Fill up these tables. Say LT_VBRK, LT_VBFA, LT_VBAK. Make sure your subroutine PREPARE_OUTPUT has importing parameters. Pass these to them. Also, prepare the LT_OUTPUT_EXP with the expected results. Declare the table which would hold the actual values LT_OUTPUT_ACT and receive the results from the subroutine PREPARE_OUTPUT. Use the method  cl_aunit_assert=>assert_equals to check the values in the LT_OUTPUT_EXP and LT_OUTPUT_ACT.
    Regards,
    Naimesh Patel

  • ABAP UNIT - Test Driven Development

    Dear ABAPers,
    I hope some of you may have also ventured into this area of Test Driven Development.  I have just started looking into this new and exciting way of development.  My understanding after having gone through the available blogs and some reading material on TDD, is that, we have to religiously embrace Object Oriented programing to actually benefit from TDD methodology.  That raised a big question in my mind, how do we implement this technique when we are coding in the user exits like MV45AFZZ, which is mostly classical ABAP programming?
    Please help me understand the TDD a bit more than I currently do.
    Thanks much,
    SMA.
    <- removed by moderator ->
    Edited by: Neil Gardiner on Sep 29, 2010 10:38 AM

    As Dirk already mentioned TDD is writing test before writing productive code. This approach is not limited to OO practices or unit tests.
    E.g. writing an eCatt script in advance that passes as soon the scenario is working, adheres to TDD practices also..
    Vice versa if one practices unit testing and oo patterns it is no TDD if the tests are written after the productive code.
    Regards
      Klaus

  • Test Driven Development (TDD)

    Dear ABAPers,
    I hope some of you may have also ventured into this area of Test Driven Development. I have just started looking into this new and exciting way of development. My understanding after having gone through the available blogs and some reading material on TDD, is that, we have to religiously embrace Object Oriented programing to actually benefit from TDD methodology. That raised a big question in my mind, how do we implement this technique when we are coding in the user exits like MV45AFZZ, which is mostly classical ABAP programming?
    Please help me understand the TDD a bit more than I currently do.
    Thanks much,
    SMA.
    I tried placing this query in different forums on SDN and I am curiously awaiting for some ideas on this topic.
    (will reward any helpful replies/suggestions)

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1089283c-133d-2a10-f6b4-f3fd58265fb8
    http://www.webopedia.com/TERM/T/test_driven_development.html
    http://www.testdriven.com/modules/news/article.php?storyid=605
    http://blogs.ittoolbox.com/visualbasic/operating/archives/test-driven-development-life-and-beyond-4672
    http://www.testingreflections.com/taxonomy/page/or/53?from=56
    http://blogs.ittoolbox.com/visualbasic/operating/archives/test-driven-development-top-10-questions-5084
    Regards.

  • Issue in Creation of XML file from ABAP data

    Hi,
    I need to create a XML file, but am not facing some issues in creation of XML file, the in the required format.
    The required format is
    -<Header1 1st field= u201CValueu201D 2nd field= u201CValueu201D>
       - <Header2 1st field= u201CValueu201D 2nd field= u201CValueu201Du2026u2026. Upto 10 fields>
              <Header3 1st field= u201CValueu201D 2nd field= u201CValueu201Du2026u2026. Upto 6 fields/>
              <Header4  1st field= u201CValueu201D 2nd field= u201CValueu201Du2026u2026. Upto 4 fields/.>
               <Header5 1st field= u201CValueu201D 2nd field= u201CValueu201Du2026u2026. Upto 6 fields/>
          </Header2>
       </Header1>
    Iu2019m using the call transformation to convert ABAP data to XML file.
    So please anybody can help how to define XML structure in transaction XSLT_TOOL.
    And one more thing, here I need to put the condition to display the Header 3, Header 4, Header 5 values. If there is no record for a particular line item in header 3, 4 & 5, I donu2019t want to display full line items; this is only for Header 3, 4 & 5.
    Please help me in this to get it resolved.

    Hello,
    you can use CALL TRANSFORMATION id, which will create a exact "print" of the ABAP data into the XML.
    If you need to change the structure of XML, you can alter your ABAP structure to match the requirements.
    Of course you can create your own XSLT but that is not that easy to describe and nobody will do that for you around here. If you would like to start with XSLT, you´d better start the search.
    Regards Otto

  • Logical command in ABAP.....Urgent

    Hi,
      i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
      i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
    I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
    The logical command is ZCOPY and uses cmd /c copy
    Copies one or more files to another location.
    COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
         [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
      source       Specifies the file or files to be copied.
      /A           Indicates an ASCII text file.
      /B           Indicates a binary file.
      destination  Specifies the directory and/or filename for the new file(s).
      /V           Verifies that new files are written correctly.
      /N           Uses short filename, if available, when copying a file with a
                   non-8dot3 name.
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless COPY command is being executed from
    within a batch script.
    the problem now is i have no idea about how to use the logical command. can any one help me.
    Thank you,
    Ravi.

    If memory is not an issue, then there should be no reason why this should not work.
    report zrich_0001.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
    data: itab type table of string with header line.
    start-of-selection.
    * Read old file
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into itab.
          if sy-subrc <> 0.
            exit.
          endif.
          append itab.
        enddo.
      endif.
      close dataset d1.
    * Write to new file
      open dataset d2 for output in text mode.
      loop at itab.
        transfer itab to d2.
      endloop.
      close dataset d2.
    * Delete the old file
      delete dataset d1.
    Regards,
    Rich Heilman

  • Logical Database in Abap Objects

    Hi to All
    I want do it a program report using a Logical Database.
    Is this possible ??? But when I make a GET <node>, occurs the following error:
             "" Statement "ENDMETHOD" missing.  ""
    I'm doing the following:
    CLASS MONFIN IMPLEMENTATION.
           METHOD TRAER_DATOS.
                   GET VBRK.
           ENDMETHOD.
    ENDCLASS.
    Please, somebody tell me how I use the logical database in Abap Objects.
    Thank you very much
    Regards
    Dario R.

    Hi there
    Logical databases whilst of "some use" are not really part of OO.
    If you want to use a logical database in an abap OO program I would create a special class which just does the get data from your DB and pass this either at record or table level.
    Techniques such as GET XXXX LATE aren't really part of any OO type of application since at Object Instantiation time you should be able to access ALL the attributes of that object.
    As far as OO is concerned Logical databases are a throwback to "Dinosaur Technology".
    Since however modules such as SD and FI are still heavily reliant on relational structures (i.e linked tables etc)  then there is still some limited life in this stuff but for OO try and solve it by another method.
    If you really must use this stuff in OO then do it via a FMOD call and save the data in a table which your method will pass back to your application program.
    You can't issue a GET command directly in a method.
    Cheers
    Jimbo

  • LOGICAL DATABASE IN HR ABAP PRPGRAMMING

    Hi Friends,
    what is use of LOGICAL DATABASE IN HR ABAP PROGRAMMING
    AND END-OF-SELECTION EVENT IN HR PROGRAMMING PROGRAMMING???
    regards,
    vijay.

    hi
    HR Logical Databases
    In Human Resources (HR), the following logical databases can be used as a data source for HR InfoSets:
    PNP (PNPCE)
    PAP
    PCH
    By selecting a logical database, you determine the HR data that can be reported on using an InfoSet.
    Logical Database PCH
    This logical database generally enables you to report on all HR infotypes. However, you are advised not to use this logical database unless you want to report on Personnel Planning data.
    Logical Database PNP (or PNPCE)
    Use logical database PNP to report on HR master data. It is possible to use logical database PCH to access this data, but PNP meets such reporting requirements more quickly because it is best suited to the task of selecting persons.
    Logical database PNP enables you to access HR master data and infotypes from Personnel Planning. For example, you have the following options:
    Reporting on the costs, number of attendees booked, and instructor for a business event on which an employee is booked
    Reporting on working time and planned compensation for a position that an employee occupies
    Reporting on the validity and proficiency of a qualification that an employee fulfils
    From a technical perspective, this means you can use PNP to report on all of the infotypes that exist for objects (infotype 1000) that have a direct relationship (infotype 1001) with the Person object.
    The ability to access infotypes from Personnel Planning using logical database PNP is a special feature that you can only use in the context of SAP Query and Ad Hoc Query. You cannot use this functionality for ABAP reports you programmed yourself.
    You can also use logical database PNP to report on data from Personnel Time Management (infotypes 2000 to 2999) and Payroll (special payroll infotypes for the USA and customer infotypes; for more information, access Customizing for the Human Resources Information System and see Payroll Results).
    Logical Database PAP
    Logical database PAP enables you to access data from Recruitment.
    regards
    navjot
    reward if helpfull

  • FileName in ABAP XSLT Mapping

    Dear SDN,
    In an integration scenario we are using sender File Adapter and a  ABAP XSLT Mapping.
    Is there any way to get the source FileName from such mapping.  Im trying to use the adapter-specific message attributes, but it doesn't work, and I didn´t find an example, probably I and doing somthing wrong.
    regards,
    GP

    Thank you for your help,
    I just try to access the adapter-specific attibutes using:
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">
    <xsl:variable name="filename"  select="key:create('http://sap.com/xi/XI/System/File', 'Directory')" />
    </xsl:stylesheet>
    but the following error raised:
    <SAP:Stack>Error while calling mapping program YXSLT_TEST (type Abap-XSLT, kernel error ID CX_XSLT_RUNTIME_ERROR) Call of unknown function</SAP:Stack>
    have you had this situation?

  • ABAP-- diff between sy-sy-tabix and sy-index

    Hi Guru's,
    Pleae can anybody expalins me what is the difference between sy-tabix and sy-index(Loop Index) ?
    Because in one case i am Modifyimg the internal table inside the do loop by giving sy-index ((Index of Internal Tables)(MODIFY scarr_tab INDEX sy-index FROM scarr_wa TRANSPORTING currcode. )  in the syntax and in other case inside loop statement i am modifyng same record by giving sy-tabix MODIFY scarr_tab INDEX  sy-tabix FROM scarr_wa TRANSPORTING currcode.) in the syntax.
    in both cases its working fine but i am not getting which one i have to use  where to modify the internal table?
    regards
    SATYA

    Hi Henry,
    SY-INDEX is the value of the current iteration. It is applicable for the following programming constructs in ABAP -
    DO...ENDDO.
    WHILE...ENDWHILE.
    SY-TABIX (TABle IndeX) is applicable to internal tables. If you scroll down in the link which Eddie has given, you will find a more detailed explanation for sy-tabix and which statements affect its value.
    Regards,
    Anand Mandalika.

  • Comas(,) are not getting displayed in the output while using OO ABAP

    Hi All,
    I am using ABAP objects to display the ALV report in which there is a requirement to output Quantity fields. The Quantity fields are getting displayed without comas ','. Please help me in getting back the comas in the output.
    Eg:
    Below logic is used in my program.
    Class name: cl_salv_form_layout_grid
    Code:
      obj_footer->create_text(
            row    = v_row_cnt
            column = v_col_cnt
            text   = Quantity).
    Expected output:
    39,545.000
    Current Output:
    39545.000
    Thanks in advance for your help.
    Thanks & Regards,
    Siva.

    Hi,
    Please check if the images are in the server and in the /images alias path.
    thanks,
    Sharmila

  • NULL and Space value in ABAP

    Hi All,
           I like to know, is it NULL and Space value is same in ABAP, if it is not how to check null value.
    Thank you.
    Senthil

    everything is correct though some answers are not correct.
    A Database NULL value represents a field that has never been stored to database - this saving space, potentially.
    Usually all SAP tables are stored with all fields, empty fields are stored with their initial value.
    But: If a new table append is created and the newly-added fields do not have the 'initial value' marked in table definition, Oracle will just set NULL values for them.
    as mentioned: There is no NULL value to be stored in an ABAP field. The IS NULL comparison is valid only for WHERE clause in SELECT statement. WHERE field = space is different from WHERE field IS NULL. That's why you should check for both specially for appended table fields.
    If a record is selected (fulfilling another WHERE condition) into an internal table or work area, NULL values are convertted to their initial values anyway.
    Hope that sheds some light on the subject!
    regards,
    Clemens

  • Sale order before the regeneration of ABAP report: RSM13000

    Hi there,
    I am just wondering about something.
    After we installed support packages, users could not get any sales order without to get any error message and I we could only see  an error message via SM21 which says:
    Run-time error "LOAD_TYPEPOOL_VERSION_MISMATCH" occurred.
    So after we regenerated the ABAP report: RSM13000 after that everythings seems to be ok.
    Now the question is: When we try to find the order numbers which the users created  before the regeneration we find nothing.
    What about this numbers? Did they have not been created at all or what hapened? They customer is asking now.
    Thanks in advance
    Hanseatik

    I still do not know. We created them again

  • Report J_1IEWT_CERT getting cancelled, generating ABAP dump!

    A long running report J_1IEWT_CERT in background mode is getting cancelled after running for a while and generating the following dump :
    Error analysis
        When changing or deleting one or more lines of the internal table
        "\PROGRAM=J_1IEWT_CERT\DATA=PRINTTAB[]" or when inserting in the table
         "\PROGRAM=J_1IEWT_CERT\DATA=PRINTTAB[]", 0 was used as
        the line index. An index less than or equal to zero is not
        allowed.
        The error can occur when using the following options:
        1. "INDEX idx" for specifying the line number in the table
         "\PROGRAM=J_1IEWT_CERT\DATA=PRINTTAB[]"
           where you want to change, insert or delete.
        2. "FROM idx" for specifying the start index when deleting a line
           area from or inserting a line area into the table
         "\PROGRAM=J_1IEWT_CERT\DATA=PRINTTAB[]".
        3. "TO idx" for specifying the end index when deleting a line
           area from or inserting a line area into the table
         "\PROGRAM=J_1IEWT_CERT\DATA=PRINTTAB[]".
        At the time of the termination, the table contained 17008 lines.
    How to correct the error
        If the error occurred in your own ABAP program or in an SAP
        program you modified, try to remove the error.
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "TABLE_INVALID_INDEX" " "
        "J_1IEWT_CERT" or "J_1IEWT_CERT_F01"
        "FILTER_DATA"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
        3. If the problem occurs in a problem of your own or a modified SAP
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
    Tried searching for some SAP Notes to fix the issue, no success as of now, Please help me out...

    Have you checked these notes ?
    363107 Short dump occurs during TDS certificate printing.
      803806  Error while genrating TDS certificate 03.01.2005
      1066049  J1INCERT - Error while generating TDS certificate
    Regards,
    Subhash

Maybe you are looking for

  • Firefox crashes as soon as it loads

    process: I click the shortcut- short wait - firefox opens - and immediately crashes. It was working 2 days ago - it is not working now. I have downloaded v8 - no change

  • How to achive this in a single iview

    How can i create this iview/How to achive this. In Portal I created a Role and 2 different worksets under the role to publish BW Reports (Grouped according to the worksets) My requirment is when user Logins into his portal account and clicks the BW R

  • Error while using LabVIEW 8.2.1 Dll from Visual C++ 6.0

    I am getting an error while using a LabVIEW 8.2.1 dll from Visual C++ 6.0 application. This is what I am doing: 1) Created a dll using LabVIEW 8.2.1 (I used a tutorial from NI knowledge base: "Creating DLLs from 6.0i". It is a temperature conversion

  • How to add push button on UI?

    Hi, I would like to add a push button 'PROCESS' on one assignment block. When user selects the pushbutton I would like to execute some custom functionality. How do I achieve this? Regards, Akash

  • Ho to create Publications Reports using OBIEE 11g BI Publisher

    Hi All, I have a report, actually a publication to be printed on pdf. The content is basically lot of formatted text such as in any text book or manual such as table of contents, index, all type of graphs/charts , tabular information with numbers, fo