| 1 | <h2>Comments</h2> |
| 2 | <pre><code> |
| 3 | * Line Comments |
| 4 | " End of line comment used as line comment. |
| 5 | value = 1. " End of line comment |
| 6 | |
| 7 | DATA: |
| 8 | "! ABAPDoc comment |
| 9 | value TYPE i. |
| 10 | </code></pre> |
| 11 | |
| 12 | <h2>Strings</h2> |
| 13 | |
| 14 | <pre><code> |
| 15 | my_string = 'Simple string'. |
| 16 | my_string = 'String with an escaped '' inside'. |
| 17 | my_string = |A string template: { nvalue } times|. |
| 18 | my_string = |A string template: { nvalue } times|. |
| 19 | my_string = |Characters \|, \{, and \} have to be escaped by \\ in literal text.|. |
| 20 | </code></pre> |
| 21 | |
| 22 | <h2>Numbers and Operators</h2> |
| 23 | |
| 24 | <pre><code> |
| 25 | value = 001 + 2 - 3 * 4 / 5 ** 6. |
| 26 | |
| 27 | IF value < 1 OR |
| 28 | value = 2 OR |
| 29 | value > 3 OR |
| 30 | value <> 4 OR |
| 31 | value <= 5 OR |
| 32 | value >= 6. |
| 33 | ENDIF. |
| 34 | |
| 35 | " Dynamic object assignment (with type cast check) |
| 36 | lo_interface ?= lo_class. |
| 37 | </code></pre> |
| 38 | |
| 39 | <h2>Structures and Classes</h2> |
| 40 | |
| 41 | <pre><code> |
| 42 | DATA: |
| 43 | BEGIN OF my_structure, |
| 44 | scomponent TYPE i, |
| 45 | END OF my_structure. |
| 46 | |
| 47 | CLASS lcl_my_class DEFINITION. |
| 48 | PUBLIC SECTION. |
| 49 | METHODS my_method |
| 50 | RETURNING |
| 51 | VALUE(ret_value) TYPE i. |
| 52 | ENDCLASS. |
| 53 | |
| 54 | CLASS lcl_my_class IMPLEMENTATION. |
| 55 | METHOD my_method. |
| 56 | ret_value = 1. |
| 57 | ENDMETHOD |
| 58 | ENDCLASS. |
| 59 | |
| 60 | DATA lo_instace TYPE REF TO lcl_my_class. |
| 61 | |
| 62 | CREATE OBJECT lo_instace. |
| 63 | |
| 64 | my_structure-component = lo_instace->my_method( ). |
| 65 | </code></pre> |