Best Practices in development of Business Classes in OO ABAP

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Leo We present ourselves

    1 Favorite, 1 Group & 1 Event

    Best Practices in development of Business Classes in OO ABAP - Presentation Transcript

        • Leonardo De Araujo
        • Alexandre Giguere
      • Agenda
        • What are Business classes ?
        • Why do we need them ?
        • Development standards
        • Examples
        • How to use them
        • DEMO
        • Next Steps
      • What are business classes?
        • OO ABAP Classes that represent business objects (ex: Purchase order, Sales Order, Delivery, Material, etc);
        • Largely based on SAP content, but not restricted to it (you can have classes for your own objects);
      Best Practices in development of Business Classes in OO ABAP
      • Why do we need Business Classes?
      • Reduce TCO via standards, reusability, simpler coding and support;
        • Meaningful representation of SAP programs;
        • OO ABAP implementation;
        • MVC support. Business classes = Model;
      • Why do we need Business Classes? (cont.)
      • (Reasons why Object oriented approach achieves higher reliability)
      • Code abstraction makes it easier the communication between the functional and the technical team;
      • Reusability guarantees that the same logic is not coded in many places what could make it harder to maintain them in sync and potentially produce different results in different programs;
      • Encapsulation makes the solution more robust;
      • Why do we need Business Classes? (cont.)
      Classical Approach Business Requirement Development Objects Programs Tables Screens Example: Need a program to release a PO and create an inbound delivery for it. How to spec it? Where do I start the development?
      • Why do we need Business Classes? (cont.)
      Object Oriented Approach Business Requirement Development Objects Example: Need a program to release a PO and create an inbound delivery for it. CLASS ZCL_PURCHASE_ORDER Method RELEASE Method CREATE_DELIVERY
      • Development Standards
        • Naming convention;
        • Instantiation;
        • Buffering / performance optimization;
        • Inheritance;
        • Utility Classes;
        • Exception classes utilization;
        • Model Class;
        • Package Hierarchy;
      Best Practices in development of Business Classes in OO ABAP
      • Naming convention - General
        • Use English names
        • Use glossary terms
        • In compound names, use the underscore as separator
      • Naming convention - Attributes
        • Key Attribute – Instance Public (ONLY!); ex: Number(vbeln)
        • Attribute HEADER (if applicable) – Instance Private; ex: VBAK
        • Attribute ITEMS (if applicable) – Instance Private; ex: VBAP
        • Other options (SCHEDULE LINES, PARTNERS, etc…)
        • No need to prefix (ex: GS_HEADER)
        • For constants; use prefix CO_
      Best Practices in development of Business Classes in OO ABAP
      • Naming convention - Methods
        • Method names should begin with a verb;
        • Methods that return a boolean should begin by IS_
        • Event handler methods should begin with ON_
        • Method that verify of validate a state should begin by CHECK_
        • Events name should have the form noun_participle
        • Recommended methods parameters
          • IM_ for IMporting parameters
          • EX_ for EXporting parameters
          • CH_ for CHanging parameters
          • RE_ for REturning parameters
      • Naming convention – Methods (cont.)
        • Public
          • Method READ – Static Public;
          • Method DISPLAY – Instance Public;
          • Method GET_ <<attrib>> – Instance public;
          • Lifecycle methods CRUD (Create, Read, Update and Delete)
        • Protected / Private
          • Method READ_ <<attrib>> – Instance Private;
          • Method CONSTRUCTOR – Instance Private;
      • Instantiation
        • Instantiation as Private or Protected. NOT PUBLIC ;
        • Provide methods to instantiate your BC
          • Search
          • Read / Factory
        • Example:
        • PARAMETERS pa_vbeln TYPE vbeln_vl OBLIGATORY.
        • DATA lo_delivery TYPE REF TO zcl_outbound_delivery.
        • lo_delivery = zcl_outbound_delivery=>read( pa_vbeln ).
      • Buffering / performance optimization
        • Leveraging READ method to improve performance via buffering;
        • Attribute BUFFERED_OBJECTS (Public Static) of type table of the following structure:
          • KEY type <<TYPE OF THE KEY OF THE OBJECT>>
          • DATA type ref to <<CLASS ITSELF>>
        • READ method checks buffer before instantiation;
        • READ method updates buffer after instantiation;
      • Buffering / performance optimization (cont.)
        • Method READ.
        • Data: wa_buffered_obj type <<< >>>.
        • Read table BUFFERED_OBJECTS with key KEY = INPUT
        • into wa_buffered_obj <<binary search>>.
        • If sy-subrc eq 0.
        • Return = wa_buffered_obj-data.
        • Else.
        • Create object Return
        • exporting
        • key = INPUT.
        • wa_buffered_obj-key = Return-key.
        • wa_buffered_obj-data = Return.
        • Apppend wa_buffered_obj to buffered_obj.
        • Endif.
        • Endmethod READ.
        • ** PS. FREE_ALL( ) or optional parameter bypass_buffer
      • Inheritance
      ZCL_PURCHASEORDER
      • Attributes:
      • NUMBER
      • HEADER (EKKO)
      • ITEMS (EKPO)
      • INBOUND DELIVERIES
      • Methods:
      • CREATE
      • READ
      • FLAG_FOR_DELETION
      • SIMULATE_DISTRIBUTION
      • CREATE_DELIVERY
      ZCL_MMDOCUMENT
      • Attributes:
      • NUMBER
      • HEADER (EKKO)
      • ITEMS (EKPO)
      • Methods:
      • CREATE
      • READ
      • FLAG_FOR_DELETION
      ZCL_STO
      • Attributes:
      • NUMBER
      • HEADER (EKKO)
      • ITEMS (EKPO)
      • OUTBOUND DELIVERIES
      • Methods:
      • CREATE
      • READ
      • FLAG_FOR_DELETION
      • SIMULATE_DISTRIBUTION
      • CREATE_DELIVERY
      • Utility Classes (UC)
        • Main Advantages:
          • Implement OO
          • Build once and used everywhere
        • Examples:
          • ZCL_FTP (for File Transfer Protocol)
          • ZCL_APPLICATION_LOG (for Business Application Log)
          • ZCL_ADDRESS (for Business Address Repository)
          • ZCL_EMAIL (for Business Communication Service)
          • ZCL_BDC (for Batch Data Communication)
      • Class-Based Exceptions
      • Introduced as of BASIS release 6.10
      • Created using the Class Builder (SE24)
      • Derived from the predefined basic classes:
        • CX_STATIC_CHECK (recommended)
        • CX_DYNAMIC_CHECK REVIEW BY ALEX
        • CX_NO_CHECK REVIEW BY ALEX
      • Exception Text Management
        • Online Text Repository
        • Message Class (recommended)
      • Class-Based Exceptions (cont.)
      • Have your own EC linked to your BC (1:1 if applicable)
        • Example:
          • ZCL_OUTBOUND_DELIVERY (Business Class)
          • ZCX_OUTBOUND_DELIVERY (Exception Class)
      • Assign a Message Class to the EC (1:n)
        • Example:
          • Z_LE_SHP_DL (for Delivery Processing)
      • Class-Based Exceptions (cont.)
      • Attributes
        • Define KEY attributes of the business class
        • Flag public attributes as read-only
        • BAPIRET2_T (if applicable)
      • Methods
        • Log & display exception messages into the BAL
        • Display exception messages for RF screen limitations using SAP Console.
      • Model Class (MC)
      • Build your application logic over a general abstraction layer
      • Build your MC using:
        • Utility Class
        • Business Class
        • Persistent Class
        • Exception Class
      • Use the assistance class as your model for WD4A
      • Examples:
        • ZCL_DISTRIBUTION (for Distribution …)
        • ZCL_PICKING (for Picking …)
        • ZCL_PACKING (for Packing Station …)
      • Package Hierarchy
      • Examples
        • Business Classes in SAP ERP:
          • ZCL_SALES_ORDER
          • ZCL_PURCHASE_ORDER
          • ZCL_PURCHASE_REQUISITION
          • ZCL_CUSTOMER
          • ZCL_VENDOR
          • ZCL_MATERIAL
          • ZCL_HANDLING_UNIT
          • ZCL_STORAGE_UNIT
          • ZCL_TRANSFER_ORDER
          • ZCL_SHIPMENT
          • ZCL_MATERIAL_DOCUMENT
          • ZCL_INBOUND_DELIVERY
          • ZCL_OUTBOUND_DELIVERY
          • ZCL_ALLOCATION_TABLE
      • How to use them – Exemple 2 – Process flow
      • Report ZZZTEST123.
      • Parameters: p_order type vbeln.
      • Data: o_order type zcl_salesorder,
      • o_del type zcl_outbounddelivery.
      • ...
      • * Read instance of the sales order
      • o_order = zcl_salesorder=>read( p_order ).
      • * Create delivery, returning instance
      • o_del = o_order->deliver( ).
      • * Post GI for delivery
      • o_del->post_GI( ).
      • ...
      Method deliver. (class zcl_salesorder) ... r_del = zcl_outbounddelivery=>create( key ) ... Endmethod.
      • DEMO
      • Next Steps
        • Consolidation of community standard
        • Wizard for automation of class generation
      • For more information:
        • SAP-PRESS Releases
          • Next Generation ABAP Development
          • ABAP Objects: ABAP Programming in SAP NetWeaver
        • SAP TechEd 2008 Sessions
          • COMP275 – Modern Business Programming with ABAP Objects
          • COMP277 – ABAP Development: Update Your Skills to SAP NetWeaver 7.0
        • SAP Links
          • http://www.sdn.sap.com
          • http://help.sap.com

    + Leonardo De AraujoLeonardo De Araujo, 2 years ago

    custom

    1436 views, 1 favs, 0 embeds more stats

    Best Practices in development of Business Classes i more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1436
      • 1436 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 121
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories