Source Code: Few simple examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | REPORT CHAP0102. * Copying the content of one data object to another DATA: SOURCE(10) TYPE C, TARGET LIKE SOURCE. MOVE SOURCE TO TARGET. * Displaying the contents of fields WRITE 'ABAP/4 is easy.'. NEW-LINE. WRITE 'This text is displayed on a new line.'. WRITE / 'After the symbol /, text also appears on a new line.'. * Standard control structures (conditions and loops) IF SOURCE = TARGET. WRITE / 'Fields source and target have the same content'. ELSE. WRITE / 'Fields source and target do not have the same content'. ENDIF. DO 3 TIMES. WRITE / SY-INDEX. ENDDO. * Local subroutine of a single program DATA: A1 TYPE I, A2 TYPE I. PERFORM CALC USING A1 CHANGING A2. WRITE / A2. FORM CALC USING F1 LIKE A1 CHANGING F2 LIKE A2. F2 = F1 + ( F2 * 17 ). ENDFORM. * Event for drill-down facilities (reacts when a user selects a line) AT LINE-SELECTION. WRITE 'This is displayed after double-clicking a line'. |
If you like this post, you may as well like these too:
- ABAP Programs: Simple examples of field conversion REPORT ZSOURCE0702. * Converting to numbers during computationsDATA: NUMBER_1(4) VALUE ‘1771′, NUMBER_2(3), RESULT TYPE I. NUMBER_2 = ‘005′.RESULT = NUMBER_1 + NUMBER_2.WRITE / RESULT. NUMBER_2 = ‘ 5′.RESULT = NUMBER_1...
- Source Code: Designing a report REPORT ZSOURCE0104. * Declaration of a work area for a Dictionary tableTABLES CUSTOMERS. * Internal table used as snapshot of the database tableDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER...
- ABAP Source Code: Character types REPORT ZSOURCE0403. * Type c is the default type when no type is specified.* Initial value is space, if it is not specified explicitly.DATA: NAME(25) TYPE C, CITY(25), FLAG, SINGLE_CHARACTER...
- ABAP Source Code: Types, data, constants REPORT ZSOURCE0402.* Type flag defines an abstract typeTYPES FLAG TYPE C. * Field address_flag will allocate space in main memory at runtimeDATA ADDRESS_FLAG TYPE FLAG VALUE ‘X’.* Constants are defined...
- ABAP Source Code: Three approaches to define data objects REPORT ZSOURCE0401.* 1. Elementary typesDATA: CUSTOMER_NAME_1(25) TYPE C, VENDOR_NAME_1(25) TYPE C. * 2. Reference to an existing fieldDATA: CUSTOMER_NAME_2(25) TYPE C, VENDOR_NAME_2 LIKE CUSTOMER_NAME_2. * 3. Reference to a non-elementary...
















Leave a Reply