1. Trang chủ
  2. » Công Nghệ Thông Tin

Sams teach yourself ABAP 4 in 21 days sep 1998 ISBN 0672312174

917 90 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 917
Dung lượng 2,61 MB

Nội dung

Sams Teach Yourself ABAP/4đ in 21 Days Copyright â 1999 by Sams All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photo-copying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Neither is any liability assumed for damages resulting from the use of the information contained herein HTML conversion by : LEVEL X L.L.C., Warren, New Jersey, 800-422-3475 e-mail : compudoc@compudocinc.com â Copyright, Macmillan Computer Publishing All rights reserved Sams Teach Yourself ABAP/4đ in 21 Days Chapter Chapter Chapter Chapter Chapter Chapter Chapter Introduction Week 1 at a Glance The Development Environment Your First ABAP/4 Program The Data Dictionary, Part 1 The Data Dictionary, Part 2 The Data Dictionary, Part 3 The Data Dictionary, Part 4 Defining Data in ABAP/4, Part 1 Week 1 in Review Week 2 at a Glance Chapter Defining Data in ABAP/4, Part 2 Chapter Assignments, Conversions, and Calculations Chapter Common Control Statements 10 Chapter Internal Tables 11 Chapter Advanced Internal Tables, Part 1 12 Chapter Advanced Internal Tables, Part 2 13 Chapter The write Statement 14 Week 2 in Review Week 3 at a Glance Chapter Formatting Techniques, Part 1 15 Chapter Formatting Techniques, Part 2 16 Chapter Modularization: Events and Subroutines 17 Chapter Modularization: Passing Parameters to Subroutines 18 Chapter Modularization: Function Modules, Part 1 19 Chapter Modularization: Function Modules, Part 2 20 Chapter Selection Screens 21 Week 3 in Review Appendix A Appendix B â Copyright, Sams Publishing All rights reserved Sams Teach Yourself ABAP/4đ in 21 Days Introduction Conventions Used in This Book About the Authors Tell Us What You Think! Introduction Having taught the ABAP/4 certification course to hundreds of beginners and experienced developers at both at SAP and at other institutions, I know the kind of problems and questions you will have when learning this powerful language By incorporating all the best techniques that I have encountered into this book, I hope to impart that same learning experience to you as well To that end, this book is chock full of detailed diagrams, full-screen snapshots, working sample programs, narrated screencams, and step-by-step procedures All the sample programs are also supplied on the CD-ROM so that you can upload and run them on your own system In addition, the utilities that I supply to all of my classes are included on the CD-ROM, plus some new ones that I have written specifically for the buyers of this book ABAP/4, for all of its simplicity on the surface, is a complex language underneath Because of that, the beginner is often bewildered by its behavior By understanding how it works below the surface, you will be able to master this language By understanding the hows and whys, you will gain an understanding few have in this exciting field This book will guide you through the intricacies of the ABAP/4 language and environment one step at a time After you complete each chapter, you will be presented with exercises to reinforce your learning Working solutions are provided for all exercises on the CD-ROM As experienced programmers know, and beginners soon find out, creating ABAP/4 programs often means creating more than just a program It frequently involves the creation of development objects to support it Procedures for creating these objects are all explained in exquisite detail using a list of numbered steps Each step contains the title of the screens you encounter and the expected responses to each command All procedures are accompanied by a screencam showing you exactly how it is done Now, not only can you learn by watching me, but you can fast forward and rewind me as well The sheer volume of information needed to master ABAP is a daunting task for most, but I have taken the most vital information that you need and separated it into 21 manageable bites With the knowledge you gain using this book, you will be able to branch out to complex ABAP/4 tasks with a solid understanding as your foundation As you go through the material, if you have problems or questions please visit the Internet site http://www.abap4.net There I will post answers to frequently asked questions, and problems you may encounter that have not been covered If you find an error in this book, or suspect there may be an error, you can find and post errata there I hope you will find using this book as enjoyable as I have found writing it Cheers Here's to your ABAP/4 in 21 days! Conventions Used in This Book Text that you type and text that you see onscreen appear in monospace type It will look like this to mimic the way the text looks on your screen Variables and placeholders (words that stand for what you will actually type) appear in italic monospace Each chapter ends with questions pertaining to that day's subject matter, with answers from the author Most chapters also include an exercise section and a quiz designed to reinforce the day's concepts (The answers appear in Appendix B.) NOTE A note presents interesting information related to the discussion TIP A tip offers advice or shows you an easier way of doing something CAUTION A caution alerts you to a possible problem and gives you advice on how to avoid it DO These Do/Don't sidebars give you tips for what to do and what not to do with ABAP/4 DON'T Many of the procedures in this book are demonstrated using screencams Screencams are like movies; they show a series of screens, including keystrokes and mouse movements, with a descriptive voice-over New terms are introduced using the New Term icon The Syntax icon alerts you to the proper syntax usage for the code The Input icon highlights the code to be input The Output icon highlights the output produced by running the code The Analysis icon designates the author's line-by-line analysis loop at it write: / sy-tabix, it-land1, it-regio endloop free it Day 13 Quiz Answer Numeric fields (types i p and f) are filled with zeros The rest of the fields to the right of the control level are filled with asterisks Exercise 1 Answer report ztz1301 data: begin of it occurs 3, f1(2) type n, f2 type i, f3(2) type c, f4 type p, end of it it-f1 = '40' it-f3 = 'DD' it-f2 = it-f4 = 4 append it it-f1 = '20' it-f3 = 'BB' it-f2 = it-f4 = 2 append it sort it by f1 do 5 times it-f1 = sy-index * 10 it-f3 = 'XX' it-f2 = it-f4 = sy-index read table it with key f1 = it-f1 binary search comparing f2 f3 f4 transporting no fields if sy-subrc = 2 modify it index sy-tabix elseif sy-subrc 0 insert it index sy-tabix endif enddo loop at it write: / it-f1, it-f2, it-f3, it-f4 endloop Exercise 2 Answer Here is an efficient way to fix the problem: report ztz1302 tables: ztxlfa1 data: begin of it occurs 10, lifnr like ztxlfa1-lifnr, land1 like ztxlfa1-land1, end of it select lifnr land1 from ztxlfa1 into table it loop at it write: / it-lifnr, it-land1 endloop Day 14 Quiz Answers You must sign off and sign back on again to the R/3 system before changes to user defaults take effect An edit mask beginning with a V, when applied to a numeric field (types i, p, and f), causes the sign field to be displayed at the beginning If applied to a character field, a V is actually output The no-sign addition, when used with variables of type i, p, or f, suppresses the sign character's output In other words, negative numbers will not have a sign and appear as if they were positive Exercise 1 Answer report ztz1401 write: / ' + + + + 4', / 'First', 40 'December', /16 'January', /30 'First' Day 15 Quiz Answers The three graphical additions are symbols, icon, and line The program should have an include statement, include , for each of the graphical additions in order to utilize it For example: include for symbols, include for icons, include for lines The two additions used with the report statement are line size and line count The variables used for the additions must be numeric because they control the size of the page Exercise 1 Answer report ztz1501 include write: /4 sym_filled_square as symbol, 'square', /4 sym_filled_diamond as symbol, 'diamond', /4 sym_filled_circle as symbol, 'circle', /4 sym_glasses as symbol, 'glasses', /4 sym_pencil as symbol, 'pencil', /4 sym_phone as symbol, 'phone', /4 sym_note as symbol, 'note', /4 sym_folder as symbol, 'folder' Figure B.5: Day 16 Quiz Answers The statement back can be used to return to the current output position Use the skip sy-linct instead of new-page when you want to set a new page and you want a footer at the bottom of that current page Exercise 1 Answer Line 3 begins a do loop The first time through, the write statement on line 6 triggers the top-of-page event The value of sy-linno always contains the current list line number At this point, it is set to the line following the standard page headings Line 13 assigns this value to variable n Control returns to line 6 and A is written out On each successive pass through the loop, line 8 increments the value of n, and line 9 sets the current output line This results in the output being written on successive lines, beginning at the line following the standard headings Line 4 begins a nested do loop Each time through, line 5 sets the current output position equal to the current loop iteration The current output position is set to 1 the first time through The second time through it's set to 2, and so on This causes line 6 to write the letter A four times, in columns 1-4 Day 17 Quiz Answers No Don't use stop in the following events: initialization, at selectionscreen output, top-of-page, and end-of-page Technically, it can work with top-of-page and end-of-page if you refrain from issuing write statements within end-of-selection afterward To be precise, a variable is only known within a program after the point at which it is defined For example, if you define a variable on line 10, you would be able to access it on lines 11 and later, but not on lines 1-9 In the case of a local definition, you can access the global version of the variable at any point before the local definition Exercise 1 Answer REPORT ZTZ1701 NO STANDARD PAGE HEADING TABLES ZTXLFA1 PARAMETERS P_LAND1 LIKE ZTXLFA1-LAND1 INITIALIZATION P_LAND1 = 'US' START-OF-SELECTION PERFORM CREATE_REPORT FORM CREATE_REPORT SELECT * FROM ZTXLFA1 WHERE LAND1 = P_LAND1 PERFORM WRITE_REC ENDSELECT ENDFORM FORM WRITE_REC WRITE: / ZTXLFA1-LIFNR, ZTXLFA1-NAME1, ZTXLFA1-LAND1 ENDFORM TOP-OF-PAGE FORMAT COLOR COL_HEADING WRITE: / 'Vendors with Country Code', P_LAND1 ULINE Day 18 Quiz Answers Parameter names that appear on the form statement are called formal parameters This term is easy to remember because formal starts with form For example, in the statement form s1 using p1 changing p2 p3, the parameters p1, p2, and p3 are called formal parameters Passing a variable of the wrong data type or length to a typed parameter causes a syntax error New memory is not allocated for the value A pointer to the original memory location is passed instead All references to the parameter are references to the original memory location Changes to the variable within the subroutine update the original memory location immediately The additions using f1 and changing f1 both pass f1 by reference-they are identical in function The reason they both exist is that, used properly, they can document whether the subroutine will change a parameter or not Exercise 1 Answer The following output is generated: Top of page, flag = S ctr = 1 -in Start-Of-Selection p1 = The initialization section is not executed because no selection criteria is present in the program The Start-Of-Selection event is executed When the program gets to the first write statement, control in the program is passed along to the Top-of-page event When the Top-of-page event is complete, control is passed back to the Start-Of-Selection event Day 19 Quiz Answer True You never need to specify a value for an import parameter that has a proposal True You never need to code parameters that are exported from the function module Exercise 1 Answer When the program executes the internal table is filled and the function module is called A pop-up window with the contents of the internal table will appear Depending on what entry was chosen by the user, it will then print out using the write statement Day 20 Quiz Answers The data definitions of both of the parameters must be identical Use the menu path Function Module->Release->Cancel Release The program will be aborted and a short dump that has the runtime error RAISE_EXCEPTION will result They should not be used within function modules Instead, the raise statement should be used because it enables the caller to set the value of sysubrc on return Exercise 1 Answer function z_tz_div *" -3 *"*"Local interface: *" IMPORTING *" VALUE(P1) TYPE I DEFAULT 1 *" VALUE(P2) TYPE I *" EXPORTING *" VALUE(P3) TYPE P *" EXCEPTIONS 10 *" ZERO_DIVIDE 11 *" -12 if p2 = 0 13 raise zero_divide 14 endif 15 p3 = p1 / p2 16 endfunction Day 21 Quiz Answers The two flavors of the matchcode assembled are physically and logically Physically, the data is stored in a separate table Logically, the data is managed by database view, which is the same as the transparent storage Yes, changes to the characteristics of a domain linked to data elements will also change, because data elements in a domain inherit all properties of a domain that are referenced The primary rule for establishing a foreign key relationship is to define and link a relationship between multiple tables Exercise 1 Answer report ztz2101 tables: mara, t001w * Selection parameters for BOMs selection-screen begin of line selection-screen comment (33) text-bom parameters: bom like mara-matnr, spras like t002-spras selection-screen end of line selection-screen skip 1 Select-options: matnr for mara-matnr, werks for t001w-werks Figure B.6: © Copyright, Sams Publishing All rights reserved ... Selection Screens 21 Week 3 in Review Appendix A Appendix B â Copyright, Sams Publishing All rights reserved Sams Teach Yourself ABAP/ 4 in 21 Days Introduction Conventions Used in This Book About the Authors... Executive Editor Programming Mail: Macmillan Computer Publishing 201 West 103rd Street Indianapolis, IN 46 290 USA â Copyright, Macmillan Computer Publishing All rights reserved Sams Teach Yourself ABAP/ 4 in 21 Days. .. The Data Dictionary, Part 3 The Data Dictionary, Part 4 Defining Data in ABAP/ 4, Part 1 Week 1 in Review Week 2 at a Glance Chapter Defining Data in ABAP/ 4, Part 2 Chapter Assignments, Conversions, and Calculations

Ngày đăng: 19/04/2019, 10:41