ABAP for modern dev

object oriented
of 2
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
  SAP NetWeaver AS ABAP Release 731, ©Copyright 2011 SAP AG. All rights reserved.  ABAP Keyword Documentation  !   ABAP Programming Guidelines  !   ABAP-Specific Rules  !   Modern ABAP Background  ABAP is a living programming language that is continually being developed. Since its introduction some 30years ago, new ABAP programs have been developed continually, with work to advance the ABAP languageongoing at the same time. Developments to the ABAP language are either extensions of the existing languageattributes to implement new functionality, or the replacement of existing functionality with more advancedconcepts. The replacement of existing language elements with new ones usually makes the existing languageelements superfluous or obsolete. The most prominent example of a development of the ABAP language is stillthe implementation of ABAP Objects.With regard to the ABAP language, SAP has committed itself to a policy of strict downward compatibility. Thismeans that an ABAP program written for release 3.0, for example, can be executed on an AS ABAP in release7.0 or higher - provided that you are using a non-Unicode system. On the other hand, this also means: An experienced developer will have had little impetus to break with old habits and engage in newconcepts. The only exception is the changeover to Unicode systems, where ABAP programs have to beconverted into Unicode programs with slightly changed syntax rules. ABAP beginners get confused by the multitude of options available for the same task. Where there isdoubt, older programs are used as templates, and the obsolete concepts are frequently still used insteadof the new ones.To remedy these problems, you can use the following simple rule. Rule Do Not Use Obsolete Language Elements Do not use obsolete language elements for new developments. We also recommend an incrementalchangeover to new concepts as they become available. Details Newer language elements are always the better language elements. Obsolete language elements are onlyprovided for downward compatibility reasons. A statement or statement addition is declared as obsolete onlywhen a more powerful alternative exists or when the language element is identified as being prone to errors (inthe sense that it invites insecure and non-robust programming). For this reason, secure and robustprogramming is not possible if obsolete language elements are used, which makes the use of such obsoletelanguage elements out of the question for new developments.If ABAP Objects is used, the majority of the obsolete statements and additions are already prohibitedsyntactically. For this reason among others, we strongly recommend using ABAP Objects. Outside of ABAPObjects, that is, in cases that are still allowed, you must make sure that no obsolete language elements areused. Obsolete Language Elements provides an overview of the obsolete statements and statement additions. Bad Example The following source code shows the solution of a task using obsolete language elements. A procedure issupposed to replace all occurrences of substring  in a text  with a new character string new  if the substring isnot at the end of a word. FORM bad_example USING substring TYPE csequence new TYPE csequence ABAP Keyword Documentation of 2 06/10/2014 18:10   CHANGING text TYPE csequence. DATA: pattern TYPE string, subrc TYPE sy-subrc. CONCATENATE '*' substring INTO pattern. SEARCH text FOR pattern. IF sy-subrc <> 0. CLEAR subrc. WHILE subrc = 0. REPLACE substring WITH new INTO text. subrc = sy-subrc. ENDWHILE. ENDIF.ENDFORM. In the above source code, aside from the modularization with FORM - ENDFORM  , the statement SEARCH  andthe used variant of REPLACE  are obsolete. Furthermore, a character string operator && is available as areplacement for CONCATENATE . Good Example The following source code executes the same task as above; however, it uses the latest available languageelements.  METHOD good_example. FIND REGEX substring && `\b` IN text. IF sy-subrc <> 0. REPLACE ALL OCCURRENCES OF substring IN text WITH new. ENDIF.ENDMETHOD. The subroutine is replaced with a method. By using FIND  in connection with a regular expression, which iscomposed using the character string operator &&, you no longer require any help variables. The  WHILE  loop isreplaced with REPLACE ALL OCCURRENCES , which means it is unnecessary to use another help variable, andthe control flow is moved to the ABAP runtime environment. The latter increases the execution speed and helpsto limit the maximum nesting depth. Note In connection with the above rule, the question on the coexistence of old and new concepts within a programunit arises. There is only one area in which this is clearly syntactically defined, that is, the use of the classicaland the class-based exception concept in processing blocks. Otherwise, obsolete language elements can bedirectly next to new language elements in a program part. In this context, we recommend keeping the use withina context as consistent as possible, that is, do not use different statements, such as FIND  and SEARCH , inparallel for the same purpose.However, this does not mean that in enhancements to existing procedures you should continue to use obsoletelanguage elements to keep consistency, just because they already exist. Rather, you should seize theopportunity to switch the entire procedure to the corresponding new language elements. By using module teststo cover the procedures to be changed, you can ensure that there will be no unpleasant surprises during thechangeover. ABAP Keyword Documentation of 2 06/10/2014 18:10
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks