1.71k likes | 1.98k Views
Report Layout. Report Heading. Report Title. Column Heading. Report Body. Standard Page Heading. Standard Page Heading. Execute. Report Statement : Standard Heading. REPORT < Report Name > [ NO STANDARD PAGE HEADING ]. REPORT ztest1 NO STANDARD PAGE HEADING. No Standard Page Heading.
E N D
Report Layout Report Heading Report Title Column Heading Report Body
Standard Page Heading Standard Page Heading Execute
Report Statement : Standard Heading REPORT <Report Name> [NO STANDARD PAGE HEADING]. REPORT ztest1 NO STANDARD PAGE HEADING.
No Standard Page Heading Execute
WRITE …Column Number… WRITE: 10 ‘Hello’, 50 ‘World’.
Report Statement : Line Size REPORT <Report Name> [LINE-SIZE no. of columns]. REPORT ztest LINE-SIZE 255 . sy-linsz
Exercise Column : 50 Column : 170
WRITE Statement • * Write data • WRITE ‘Hello World’. • WRITE: ‘OK’ , ‘Test data’. • WRITE:/15(10) ‘ABCDEFGHIJKLMNOPQ’. • WRITE /20 ‘Test data’.
Breaking to a New Line * Write data WRITE: / ‘First Line’, ‘Data 1’, / ‘Second Line’,‘Data 2’, /(20) ‘Third Line’,‘Data 3’, /35 ‘Fourth Line’,‘Data 4’. sy-colno
Exercise Column : 50 Line : 1 Column : 170 Line : 2
Creating Lists ABAP statement that create list WRITE ULINE SKIP The complete report list will appears automatically at the end of the processing block
List Buffer Local Memory • Dialog WP User Context TaskHandler Memory Space ABAP Processor Dynpro Processor List Buffer WRITE,SKIP,ULINE DB Interface
Inserting Blank Lines(SKIP) • *Skip Statement • SKIP. • WRITE: ‘Hello World’, sy-linno. • SKIP. • WRITE: ‘Test 1’. • SKIP 5. • WRITE: ‘Test 2’. • SKIP TO LINE 20. • WRITE ‘This is line 20’.
NEW-LINE • WRITE ‘Hello World’. • NEW-LINE. • WRITE ‘OK’. = • WRITE ‘Hello World’. • WRITE / ‘OK’.
Exercise Column : 50 Line : 5 Column : 170 Line : 7
Inserting Horizontal Lines(ULINE) • * Uline • WRITE: ‘Hello World’. • ULINE /1(20). • WRITE: /(20) sy-uline. • WRITE: / sy-vline, 20 sy-vline. • ULINE /(20). • WRITE: / ‘This is an underline’. • ULINE.
Frame • ULINE: /1(45). • WRITE: /1 sy-vline, 'Column #1', • 15 sy-vline, 'Column #2', • 30 sy-vline, 'Column #3', • 45 sy-vline. • ULINE /(45).
Exercise I sy-uzeit sy-datum 20 55 80 80
FORMAT Statement FORMAT [COLOR <color>]. [COLOR OFF].
FORMAT Statement • FORMAT COLOR 1. • WRITE: / ‘Hello World’, ‘Test’ COLOR 7. • FORMAT COLOR OFF.
FORMAT COLOR FORMAT COLOR col_heading. “color 1 FORMAT COLOR col_normal. “color 2 FORMAT COLOR col_total. “color 3 FORMAT COLOR col_key. “color 4 FORMAT COLOR col_positive. “color 5 FORMAT COLOR col_negative. “color 6 FORMAT COLOR col_group. “color 7 FORMAT COLOR col_background. “color 0
Text Symbol • Text Element • Text Symbols • Text Symbol Text REPORT ztest. WRITE: text-001, text-002. 001 Text 1 002 Text 2
Text Symbol WRITE: / text-001. WRITE: / text-001. WRITE: / text-001. WRITE: / text-001. WRITE: / text-001.
CONSTANTS • * Constant variable • CONSTANTS ctext TYPE string VALUE ‘Hello World’. • WRITE / ctext. • WRITE / ctext. • WRITE / ctext. • WRITE / ctext. • WRITE / ctext.
Options of the WRITE Statement * Write Syntax WRITE var [NO-ZERO] [NO-SIGN] [NO-GROUPING] [NO-GAP] [DECIMALS no of decimals]
Suppressing Zero With Blanks (NO-ZERO) • * No Zero • DATA: number(10) TYPE N VALUE 23. • WRITE: number, number NO-ZERO.
Suppressing Number(+ / -) Sign • * No Sign • DATA: v_integer TYPE i VALUE -1. • WRITE: v_integer, v_integer NO-SIGN.
NO-GROUPING • * No grouping • DATA: v_integer TYPE i VALUE 120000. • WRITE: v_integer, v_integer NO-GROUPING.
NO-GAP • * No gap • WRITE: ‘Hello’ NO-GAP, ‘World’.
DECIMALS • * Decimals • DATA: v_pack TYPE P DECIMALS 4 VALUE ‘1234.5678’. • WRITE: v_pack, v_pack DECIMALS 2.
Formatting Options * Format options of WRITE statement * LEFT-JUSTIFIED for Numeric data * RIGHT-JUSTIFIED for Character data * CENTERED DATA tmp1(20) VALUE ‘test’. WRITE: tmp1 CENTERED. tmp1 test
STRLEN Built-in Function • DATA: tmp(20) VALUE ‘Test String’, • count TYPE i. • count = strlen( tmp ). • WRITE count.
Include Program You can create a program with program type include program in the program attribute Include program do not have to have an introductory statement During the syntax check and during program generation by the ABAP compiler, the INCLUDE statement is replaced by the source text of the defined include program • REPORT ztest1. • INCLUDE zinclude1. • … Include Program : ZINCLUDE1 DATA tmp(10). DATA tmp1 TYPE i. DATA tmp2 TYPE p. DATA tmp3. • REPORT ztest2. • INCLUDE zinclude1. • …
Flow Control in ABAP • Branching ==> IF, CASE. • Looping ==> DO, WHILE.
IF Statement • IF <Condition>. • <Statement Block> • ELSEIF <Condition>. • <Statement Block> • ELSEIF <Condition>. • <Statement Block> • ELSE. • <Statement Block> • ENDIF.
IF Statement • IF sy-mandt = ‘100’. • WRITE: / ‘This is Production Client’. • ELSEIF sy-mandt = ‘800’ or sy-mandt = ‘805’. • WRITE: / ‘This is Training Client’. • WRITE / sy-mandt. • ELSE. • WRITE: / ‘This is Test Client’. • ENDIF.
CASE Statement • CASE <field>. • WHEN <value1>. • <Statement Block> • WHEN <value2>. • <Statement Block> • ... • WHEN OTHERS. • <Statement Block> • ENDCASE.
CASE Statement CASE sy-mandt. WHEN ‘100’. WRITE: / ‘This is Production Client’. WHEN ‘800’ or ‘805’. WRITE: / ‘This is Training Client’. WRITE / sy-mandt. WHEN OTHERS. WRITE: / ‘This is Test Client’. ENDCASE.
DO Statement • DO. • WRITE sy-index. • IF sy-index = 3. • EXIT. • ENDIF. • WRITE: sy-index. • ENDDO. Loop Counter
DO Statement • DO 10 TIMES. • WRITE / sy-index. • ENDDO. Loop Counter
WHILE Statement • DATA: count TYPE i value 1. • WHILE count <> 4. • WRITE: sy-index. • count = count + 1. • ENDWHILE. Loop Counter WHILE sy-index <> 4. WRITE: sy-index. ENDWHILE.
Logical Expressions • >,GT • <,LT • >=, =>, GE • <=, =<, LE • =, EQ • <>, ><, NE • BETWEEN <value1> AND <value2> • IS INITIAL
Arithmetic Operators • + , - , * , / , ** • DIV • MOD • Example : • 9 / 2 = 4.5 • 9 DIV 2 = 4.0 • 9 MOD 2 = 1 • 2 ** 4 = 16
ABAP : Data Retrieval • Open SQL (SELECT)