State-of-the-Art ABAP in SAP NetWeaver 7.0 EhP2
Transcription
State-of-the-Art ABAP in SAP NetWeaver 7.0 EhP2
Orange County Convention Center Orlando, Florida | May 15-18, 2011 State-of-the-Art ABAP in SAP NetWeaver 7.0 EhP2 Director Product Management Wolfgang Weiss ] [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 2 [ State-of-the-Art ABAP in SAP NetWeaver 7.0 EhP2 New ABAP Features Support Efficient Business Programming: Secondary Keys for internal tables, Resumable Exceptions, new data type for exact calculation of large numbers and much more… Increase Developer Productivity: comprehensive string processing, strong support for efficient and resource optimizing memory usage and more… Offer New Dimension of Testing and Troubleshooting: powerful and efficient Debugging, Runtime Analysis and Memory Inspection of multi-layered web-based applications, automated debugging via Debugger Scripting, and more… Improve Enhancement Programming: Full fledged support for multi level enhancements Real Experience. Real Advantage. 3 [ ABAP 7.02 - Information at Your Fingertips Read ABAP 7.02 Blogs and watch Live Demos on ABAP 7.02 SDN http://www.sdn.sap.com/irj/sdn/abap?rid=/webcontent/u uid/1009fbb7-fd08-2d10-0182-852b6fa05f08 Download ABAP 7.02 Trial Version on SDN at ABAP 7.02 Trial http://www.sdn.sap.com/irj/sdn/abap?rid=/library/u uid/80db43c2-9ee5-2d10-de8e-8547de363868 Use ABAP Keyword Documentation on ABAP 7.02 Docu Real Experience. Real Advantage. SAP Help Portal (see „Release specific changes“): http://help.sap.com/abapdocu_702/en/index.htm [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 5 [ Secondary Indexes for Internal Tables Before SAP NetWeaver 7.02: Only Access by Primary Key time Only one (primary) key for an internal table ... UNIQUE | NON-UNIQUE KEY ... Optimizing the key SORTED and HASHED speeds up only one access path Access STANDARD can be very slow for large internal tables size O(n) Real Experience. Real Advantage. O(log n) O(1) As of SAP NetWeaver 7.02: Additional Secondary Keys Up to 15 secondary keys for an internal table ... SORTED UNIQUE | SORTED NON-UNIQUE KEY | HASHED UNIQUE ... When accessing the data (LOOP, READ, …) you should write which secondary key should be used Secondary indices with UNIQUE are updated when the table is changed. Lazy update for NON-UNIQUE keys Use UNIQUE not so often! Every secondary index needs memory and needs to be updated Use it only for tables that are often read and seldom changed. [ Secondary Indexes for Internal Tables: Example DATA spfli_tab TYPE SORTED TABLE OF spfli WITH NON-UNIQUE KEY cityfrom cityto WITH UNIQUE HASHED KEY dbtab_key COMPONENTS carrid connid. primary key „non-unique sorted“ secondary index „unique hashed“ FIELD-SYMBOLS <spfli> TYPE spfli. SELECT * FROM spfli INTO TABLE spfli_tab. LOOP AT spfli_tab ... USING KEY dbtab_key. ... ENDLOOP. READ TABLE spfli_tab WITH TABLE KEY dbtab_key COMPONENTS carrid = 'LH' connid = '0400' ASSIGNING <spfli>. Real Experience. Real Advantage. Check for duplicates in secondary index loop ordered by secondary index fast access by secondary index [ Resumable Exceptions Before SAP NetWeaver 7.02: Propagation of exceptions destroys context When propagating the exception the context (“call stack”) , that raised the exception, is deleted. Handling the exception cannot work in the original context It is not possible to handle the mistake and then to go on with program execution at the position where the exception was raised. For example you cannot use exceptions to only write a record of errors Real Experience. Real Advantage. As of SAP NetWeaver 7.02: Resumption Possible If the CATCH statement has the addition BEFORE UNWIND the context of the exception can be accessed The context will be deleted after the catch block is processed The CATCH block can resume the exception at the position where it was raised (RESUME), if: the context is not deleted (BEFORE UNWIND) and the exception is raised with the addition RESUMABLE is declared in the interface of the method/function module as RAISING RESUMABLE [ Numeric Data Types Before SAP NetWeaver 7.02: Numeric Types p and f Type p (“packed number”) calculates exactly, but has a limited range Type f (“floating point number”) has a large range, but calculates in a binary mode, and this way sometimes wrong: decimal rounding and moving of decimal place can cause errors Results of calculations may depend on database and platform DATA float TYPE f. float = 805 / 1000. As of SAP NetWeaver 7.02: New Data Type decfloat New types decfloat (“decimal floating point number”) calculates as exact a p on a larger range than f Decfloat16: 8 bytes, 16 digits exponent -383 to +384 (range 1E-383 through 9.999999999999999E+384 ) 16 bytes, 34 digits, exponent -6143 to +6144 (range 1E-6143 through Decfloat34: 9.999999999999999999999999999999999E+6144) Based on standard IEEE-754r DATA decfloat TYPE decfloat16. decfloat = 805 / 1000. 8.05E-01 8.0500000000000005E-01 Real Experience. Real Advantage. [ Numeric Data Types – How to Use Them Whole Numbers If domain is sufficient, use type I If domain of I not sufficient, use type p If domain of p not sufficient, use decfloat. Numbers with a fixed number of decimal places If range is sufficient, use data type p If range is not sufficient, use decfloat Numbers with a variable number of decimal places Use decfloat16 or decfloat34 (decfloat16 needs less memory, but is not faster) What about the Future of f ? No longer recommended for business calculationsIf you still want to use type f: TRY. The new key word EXACT COMPUTE EXACT result = 3 * ( 1 / forces an exception if rounding CATCH cx_sy_conversion_rounding ... ... leads to incorrect results ENDTRY. Real Experience. Real Advantage. 3 ). [ … and still more ABAP Language Features Dynamic Where Clause for internal tables Can avoid the expensive dynamic creation of programs Syntax for where clause as in OpenSQL DATA cond_syntax TYPE string. cond_syntax = `col1 ... AND col2 ... `. LOOP AT itab ... WHERE (cond_syntax). Analog für MODIFY und DELETE Boxed Components Storage of structures on the heap – like the storage of strings and internal tables Memory is allocated when needed Low memory consumption for initial values Access to boxed components as usual But: Boxed components are deep data objects TYPES: BEGIN OF s1, comp1 TYPE I, comp2 TYPE syst BOXED, END OF s1. TRY. RETRY-Statement for exceptions Restarts the Try block during the handling of exception Real Experience. Real Advantage. obj->lock( ). CATCH cx_already_locked. WAIT UP TO 1 SECONDS. RETRY. ENDTRY. [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 12 [ Expressions Before SAP NetWeaver 7.02: Expression with COMPUTE Arithmetic and binary expressions only allowed in COMPUTE statement Logical expressions only allowed in control statements (IF, WHILE, …) Embedded functions and functional methods as operands are only allowed in a limited number of cases Code gets more complex and unreadable by using auxiliary variables Real Experience. Real Advantage. As of SAP NetWeaver 7.02: Expressions as Operands In general, expressions can be used as operands Arithmetic, binary, and string expressions Many new embedded functions (in particular string functions) Chained method calls are now possible Code is getting leaner and more elegant by using “in-place” expressions [ Expressions: Improvements at One Glance v1 v2 v3 IF = a + b. = c - d. = meth( v2 ). v1 > v3. ... IF a + b > meth( c – d ). ... len = strlen( txt ) - 1. DO len TIMES. ... DO strlen( txt ) – 1 TIMES. ... idx = lines( itab ). READ TABLE itab INDEX idx ... READ TABLE itab INDEX lines( itab ) ... regex = oref->get_regex( ... ). FIND REGEX regex IN txt. FIND REGEX oref->get_regex( ... ) IN txt. CONCATENATE txt1 txt2 INTO txt. CONDENSE txt. txt = condense( txt1 && txt2 ). DATA oref TYPE REF TO c1. oref = c2=>m2( ). oref->m1( ). c2=>m2( )->m1( ). Real Experience. Real Advantage. [ String Processing Before SAP NetWeaver 7.02: String Processing painful Some basic statements FIND SUBSTRING|REGEX, REPLACE SUBSTRING|REGEX, CONCATENATE, SPLIT, ... Logical operators CS, NS, CA, NA, CP, NP Few embedded functions strlen(...), charlen(...), ... Access to substring by offset and length ... text+off(len) ... String processing was possible, but meant a lot of work Real Experience. Real Advantage. As of SAP NetWeaver 7.02: Expressions as Operands New string expressions: concenation (Operator &&) string templates (text and formatting) New embedded string functions distance, condense, concat_lines_of, escape, find, find_end, find_any_of, find_any_not_of, insert, repeat, replace, reverse, segment, shift_left, shift_right, substring, substring_after substring_from, substring_before, substring_to, to_upper, to_lower, to_mixed, from_mixed, translate New predicate functions for strings contains, contains_any_of, contains_any_not_of String processing is now far easier [ String Processing: Example "amount: -116.00 USD“ Real Experience. Real Advantage. [ Code Completion in ABAP Editor Complete Code Completion proposes what to type in and inserts the text proposed if wanted Press CRT + SPACE Key words: Methods etc. from the global Repository: Real Experience. Real Advantage. [ Code Completion in ABAP Editor Press SHIFT and RETURN to insert all parameters. Real Experience. Real Advantage. [ … and still more ABAP Workbench Features Class Builder Change between form based and code based view © SAP Real 2007 / Experience. Page 19 Real Advantage. [ … and still more ABAP Workbench Features Classification Tool Problem: More and more metadata Define your own meta data for any repository object Sort the objects by your own classification Tools to define the categories, to assign the attributes to objects and to define a classification Use Classification Reports: Query of classification for objects Statistic assessment of the occurrence of properties Search for objects by your self-defined meta data Real Experience. Real Advantage. © SAP 2007 / [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 21 [ More Options to Analyze ABAP Programs Coverage Analyzer 7.02 Code coverage on statement level (before: module level) Code Coverage for branches .. Visualization in Edit-Control Integration with ABAP Unit Statement-Coverage of tests for favorites in ABAP unit directly accessible ABAP Unit 7.02 New ABAP Unit Browser integrated in Object Navigator Overview of unit test and the option to define favorites Running of many tests at once Coverage Analyzer results integrated with the ABAP Unit result display. Program and Block Level Coverage. Access currently from the Favorites in the ABAP Unit Browser. This will enable developers to check whether their unit test really covers all intended functionality. Real Experience. Real Advantage. © SAP 2007 / [ Code Coverage in ABAP Unit Test: Example © SAP Real 2007 / Experience. Page 23 Real Advantage. [ Automated Debugging – Debugger Scripting Before SAP NetWeaver 7.02: No automated debugging The debugger runs in a session of its own and controls the debuggee by using an API doDebugStep(SingleStep) setBreakpoint() setWatchpoint() getValue(‘SY-SUBRC’) getStack() ... The debugger is controlled only by the debugger UI Real Experience. Real Advantage. As of SAP NetWeaver 7.02: Debugger Scripting You can additionally control the debugger by using a script normal ABAP syntax API of the debugger engine available as methods of a script Standalone transaction SAS for script analysis Many use cases: Write debugging information in a trace file Conditional BPs and WPs depending on previous program state Analysis and display of complicated data structures Interactive scripts for typical error situations (dump analysis, consistency check,…) [ Request Based Debugging Before SAP NetWeaver 7.02: User Based Debugging User breakpoints for all external requests (HTTP, RFC) User breakpoint is server-dependent User breakpoints don’t work in many cases because of: Load Balancing: “On which server to set a breakpoint?” Generic user: “For which user to set a breakpoint?” Real Experience. Real Advantage. As of SAP NetWeaver 7.02: Request Based Debugging User breakpoint is now server-independent (active on all servers of the system) Request based Debugging: via Terminal ID Terminal ID represents Windows logon session and is sent with every request Debugger stops only If Terminal ID of the request matches the Terminal ID of the user breakpoint How to send Terminal ID: For HTTP requests: SAP HTTP PlugIn for Internet Explorer: CSS Note 1435190 For GUI requests: SAP GUI:OK-Code: ”/htid” [ Software Layer Aware Debugging – Motivation Business applications(ABAP) dfdfdf My code … Some other stuff Application framework layer I Application framework layer II Debugging is a nightmare! My code is hidden under all the other stuff ! Web Dynpro for ABAP System services (ABAP, system program) ( update, printing, controls …) Kernel (C/C++) (ABAP / Dynp core functionality) System stuff – irrelevant for ABAP application developer Real Experience. Real Advantage. [ Software Layer Aware Debugging Restrict the Code to be debugged in a Debugging Session Determine which code should be shown in a debugger by defining a particular layer In particular important if you want to debug your code in a large framework like Web Dynpro ABAP Code that does not belong to the relevant layer is not shown in the debugger Definition of Layers New transaction SLAD Define selections sets by arbitrary criteria Packages, Programs, Classes, Function Modules all objects implementing a particular interface Use logical operators to combine sets to layers Layers are transport objects After activation of layers in Debugger Profile: Debugger will only stop only in visible layers New button “Next object set” to jump from layer to layer Real Experience. Real Advantage. © SAP 2007 / [ SAT – New ABAP Runtime Analysis Tool Before SAP NetWeaver 7.02: Transaction SE30 SE30 is used for performance and trace analysis of any ABAP application Local trace storage -> only traces on current server are visible UI is not “state-of-the art” anymore Limited analysis functionality (Call Hierarchy and Hitlist Tools) Missing trace comparison etc… Real Experience. Real Advantage. As of SAP NetWeaver 7.02: New transaction SAT Central trace storage on the database Modern multi-tool user interface (as in new ABAP debugger) New tools for different trace aspects: Profile Tool for runtime consumption of components, packages, programs and even debugger layers. Processing Blocks tool to get aggregated view (as a tree) on the call sequence Call Stack tool for each item of the call hierarchy DB tables tool identifies time-consuming database statements Easy navigation between tools Memory and performance analysis, trace comparison and more… [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 29 [ Nested Enhancements Nested Enhancements Create explicit enhancement points and sections in enhancement implementations Use implicit enhancement points at the beginning and end of every enhancement implementation Use Cases Add IS-specific code to the code of an enhancement package of SAP ERP Customers can add enhancements into IS specific code Customers or partners can enhance Add-ons of lower layer that are realized in enhancements © SAP Real 2007 / Experience. Page 30 Real Advantage. [ Agenda Overview Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Summary and Outlook Real Experience. Real Advantage. 31 [ Summary New ABAP features in SAP NetWeaver 7.0 EhP2 increase developer productivity, enable an even more efficient business programming, lead into a new dimension of testing and troubleshooting and complete enhancement programming Topic Efficient Business Programming Developer Productivity Testing and Troubleshooting Enhancement Programming Goal Make Business programming in ABAP even more efficient Make development in ABAP easier Prevent and find errors and performance leaks Full fledged support for multi level enhancements Real Experience. Real Advantage. Details and Benefits Secondary keys for internal tables: better performance for searches in large internal tables Decfloat: new data type for exact calculation on large numbers Resumable exceptions: More flexible handling of exceptions Boxed components: Save memory by more flexible handling of data in the memory New BGRFC: optimized transactional and queued call of functions in other systems New Features of Shared Objects: Strong handling of memory shortages, data objects in shared memory, etc. Improved functionality for database access, time format (new 12 hour format), xml processing, etc. Code Completion: Full fledged, state-of-the-art code completion Two Way Editing for Global Classes: Change between form- and code based editor for global classes Enhanced Expression Enabling Pragmas: Avoid warnings from check tools New Functions for String processing: check and manipulate strings in state-of-the-art way Classification Tool: Create, manage, and analyze new classification metadata for different kinds of development objects Layer Aware Debugging: Efficient Debugging for multi-layered applications Debugger Scripting: Use ABAP as a script language to change the program flow, set breakpoints dynamically or write traces SAT: more efficient runtime analysis, in particular enabled for multi-layered applications New Features for ABAP Unit Testing: Test Class Generator and Integration of Coverage Analyzer. Improvements of Coverage Analyzer: More detailed results by coverage results on statement level More efficient memory analysis in debugger and Memory Inspector (dominator trees) Nested enhancements for source code plug-ins in the Enhancements: Add enhancements as part of other enhancements. [ ABAP Outlook – Empower Classic and New SAP Products ABAP has a strong position in SAP Product Strategy Default technology for transactional and analytical business applications ON-DEVICE Mobile access to ABAP based business apps ON-DEMAND SAP Business ByDesign SAP Sales On-Demand etc. ON-PREMISE SAP Business Suite and Industry Solutions SAP Business All-In-One In-Memory Computing Engine Real Experience. Real Advantage. LEVERAGING IN-MEMORY COMPUTING TECHNOLOGY 33 [ ] Thank you for participating. Please remember to complete and return your evaluation form following this session. For ongoing education in this area of focus, visit www.asug.com. SESSION CODE: 712 Real Experience. Real Advantage.