1 / 83

Simple ABAP/4 for trouble shooting

Simple ABAP/4 for trouble shooting. May 25th, 2004. Objectives:. Understand and get an idea on what ABAP/4 programming does, and what is the component in ABAP workbench Get to know common statement, understand the ABAP program logic roughly.

elam
Download Presentation

Simple ABAP/4 for trouble shooting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simple ABAP/4 for trouble shooting May 25th, 2004

  2. Objectives: • Understand and get an idea on what ABAP/4 programming does, and what is the component in ABAP workbench • Get to know common statement, understand the ABAP program logic roughly. • Able to do the basic investigation when facing the problem.

  3. Content • Introduction R/3 Basis system overview • ABAP/4 overview • Component, Program, ABAP dictionary, Function Module , Message/Transaction code, etc. • Common Statement / Command • - Main event in ABAP program • - General ABAP command • Transportation for ABAP objects • Type of problem and how to investigate • Program bug, ABAP runtime error, Update terminate, Unexpected error message.

  4. R/3 Application 1 R/3 Application N ... Introduction R/3 Basis system overview R/3 user R/3 user R/3 user Presentation component ABAP Workbench R/3 Basis system Kernel & Basis services Database Management System Database

  5. Content • Introduction R/3 Basis system overview • ABAP/4 overview • Component, Program, ABAP dictionary, Function Module , Message/Transaction code, etc. • Common Statement / Command • - Main event in ABAP program • - General ABAP command • Transportation for ABAP objects • Type of problem and how to investigate • Program bug, ABAP runtime error, Update terminate, Unexpected error message.

  6. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  7. Often used transactions • SE80 - Repository Browser: Used to display and edit hierarchical lists of development objects. • SE11 - Dictionary : Used to define and save data definitions You can also store documentation, help information, data relationships, and other information. You also use the Dictionary to generate database objects like tables and indexes. • The Dictionary is a central storage area for system-wide data definitions. Because definitions are stored centrally, they are available for use anywhere in any program throughout the system • SE38 - ABAP editor : Create/edit/Display program code • SE37 - Function Builder : define and store function modules, use the library to write new modules and look up information on existing modules

  8. Often used transactions (con’t) • SE51 - Screen Painter : Used to design the screens in an application's graphical user interface. • SE41 - Menu Painter : Used to design the menus that appear in your interface • SE16 - Data browser : Display data in Transparent table or Database view • SM30 - Table maintenance : Maintain data

  9. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  10. What is ABAP/4 program? ABAP/4 : Advance Business Application Programming Type of ABAP/4 program 1 Executable program(Report/Interface) Can be started with transaction code/directly/background (via SE38 or SA38 - For example: RMCB0100 ) I INCLUDE program Can not run on its own, has been included in other program M Module pool Processing step of screens, can be executed via transaction code or Menu function (For example: SAPMV45A - Sale order processing) F Function group Contain function modules (SE37) S Subroutine pool Externally-called subroutines

  11. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  12. F4 ABAP Dictionary SE11 - Data dictionary View Table Structure Data element ABAP Dictionary Domain Lock object Search help

  13. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  14. Function module Function Module - ABAP/4 program: Include program - Special external subroutines (include) stored in a central library - Different from normal ABAP routine is the clearly defined interface for passing data to and from the function module. The calling program and the called function module have separate work areas - Located in Function group (main program start with SAPLxxxx) - Can be tested separately in SE37 - Statement in ABAP to call function module are: - CALL FUNCTION ‘xxxxx’

  15. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  16. Message There are several different types of message: W - Warning (Correction possible) E - Error (Correction required) S - Success (message on next screen) I - Information (press Enter to continue) A - Abend (Transaction terminated) X - Exit (Terminated with short dump) Note : Transaction code for message maintenance is SE91, Table store the message text is T100, language dependent. ABAP key word - MESSAGE

  17. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  18. Transaction code Transaction code is: Sequence of alphanumeric characters forming a code for business task. Transaction type: Dialog transaction - Flow by sequence of screens (for example FB03) Report transaction - Start program with type 1(for example MCBA) Variant transaction - (client specific) start another transaction with variant (for example UPAR) Area menu - Menu which contain thegroup of frequently-used transactions (for example S001) Parameter transaction - pre-assign values in the initial screen and suppress the screen when transaction is executed (for example OB22) Note : All transactions are stored in table TSTC, Maintain via SE93

  19. ABAP/4 overview Topics: • Often used transactions • What is ABAP/4 program? • ABAP dictionary • Function Module • Message • Transaction code • Authorization in ABAP object

  20. Authorization in ABAP object • Program authorization • Transaction code • Table maintenance/Data browser

  21. Program authorization group • Authorization group is field of the authorization objects S_DEVELOP (program development and program execution) and S_PROGRAM (program maintenance). • This field contains the name of a program group that allows users to • execute programs • schedule jobs for background processing • maintain programs • maintain variants • When creating a program, you can specify an authorization group as one of the program attributes. This allows you to group together programs for the purposes of authorization checking.

  22. Transaction authorization group Authorization object in transaction code will be checked whenever the transaction is started. The following object will be checked S_TCODE(Authorization check for transaction start ) The authorization checks defined by the developer with transaction SE93 (transaction maintenance) or in the ABAP/4 source code continue to be performed. Field to be checked is TCD: Transaction code

  23. Table maintenance/Data browser Authorizations for displaying or maintaining tables. The object only controls access using the standard table maintenance tool (SM31), enhanced table maintenance (SM30) or the Data Browser (SE16), including access in Customizing. Object S_TABU_DIS -Table Maintenance (via standard tools such as SM31) will be checked for the following fields: Authorization group for DD objects: Authorization for tables by authorization class according to table TDDAT. (Using SM31 to display the authorization group table) Activity: Allowed operations. Possible values are: - 02: Create, change or delete (Maintain) table entries - 03: Display table entries only

  24. Content • Introduction R/3 Basis system overview • ABAP/4 overview • Component, Program, ABAP dictionary, Function Module , Message/Transaction code, etc. • Common Statement / Command • - Main event in ABAP program • - General ABAP command • Transportation for ABAP objects • Type of problem and how to investigate • Program bug, ABAP runtime error, Update terminate, Unexpected error message.

  25. Common Statement / Command Topics: • Event in ABAP/4 program • - Dialog module • - Executable program (Selection screen, lists) • ABAP statement and Keyword

  26. Event in ABAP/4 program Event in Dialog Module PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb 100 PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb Transaction code has been requested from R/3 user 200 PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb 300 Dialog screen chain Module pool PBO = Process Before Output PAI = Process After Input

  27. Question??

  28. Common Statement / Command Topics: • Event in ABAP/4 program • - Dialog module • - Executable program (Selection screen, lists) • ABAP statement and Keyword

  29. ABAP statement and Keyword Statement The ABAP programming language consists of the following element types: STATEMENT, KEYWORD, COMMENT. An ABAP program consists of individual ABAP statements. Each statement begins with a keyword and ends with a period. There might be comment in the same line as a statement For example: PROGRAM ZTEST. WRITE ‘Hello world’. In this case program ZTEST will generate the list consist of line ‘Hello world’.

  30. ABAP statement and Keyword(con’t) • Keywords • Declarative keywords : define data types or declare the data objects • Modularization keywords : define processing blocks in an ABAP program • Event keyword :The respective processing blocks are processed as soon as a particular event occurs • Define keyword: define processing blocks that are processed as soon as they are called by an explicit statement in an ABAP program or in a screen flow logic • Control keywords: control the flow of an ABAP program according to certain conditions • Calling keywords: call processing blocks (defined by modularization keywords) in the same or other ABAP programs or branch completely to other ABAP programs • Expression and Operation keywords: Process the data

  31. address OCCURS 0 Internal table ABAP statement and Keyword(con’t) Declarative keywords TYPES create user-defined elementary data types and structured data types Example TYPES:surname(20) TYPE C. DATA define local/global variable for structure/internal table/memory block Example DATA: BEGIN OF address, address_number(10) TYPE C, street(30), country LIKE T001-LAND1, END OF address. TABLES create a data object called a table work area refer to ABAP dictionary(tables, structure,view) Example TABLES: KNA1, KNB1. CONSTANTS declare it as a fixed value variable Example CONSTANTS: name(10) VALUE ‘Exxon Mobil’ structure

  32. ABAP statement and Keyword(con’t) Modularization keywords Event define keywords INITIALIZATIONBefore selection screen is displayed AT SELECTION-SCREENAfter input selection screen + selection screen is active START-OF-SELECTIONAfter process selection screen GET <table> when logical DB offer a line of database table END-OF-SELECTIONAfter all selection has been done TOP-OF-PAGEProcess when new page is started END-OF-PAGE Process when page is ended AT LINE-SELECTIONWhen user select line in the list AT USER-COMMANDWhen user press function key/enter command in command field

  33. ABAP statement and Keyword(con’t) Modularization keywords (con’t) Process define key word for statement block FORM...ENDFORMDefine subroutine FUNCTION...ENDFUNCTION Define Function module MODULE...ENDMODULE After process selection screen

  34. ABAP statement and Keyword(con’t) Built in function Arithmetic & string function ABS Amount (absolute value) x von x SIGN Sign of x; SIGN( x ) = 1 if x > 0 SIGN( x ) = 0 if x = 0 SIGN( x ) = -1 if x < 0 CEIL Smallest integer value that is not less than x FLOOR Largest integer value that is not greater than x TRUNC Interger part of x FRAC Decimal part of x STRLEN String length

  35. ABAP statement and Keyword(con’t) • SELECT statements • SAP tables vs. Internal Tables • LOOP-ENDLOOP • WRITE statements • Comment in ABAP • Expressions and Operations in ABAP • Subroutines: FORMS, FUNCTION MODULE

  36. ABAP statement and Keyword(con’t) SELECT statement • to read table entries (records) from a table (database) • the return code is stored in system field SY-SUBRC • 0: if one or more table entries were retrieved • 4: if no table entries were retrieved (table is empty/ no data match the criteria)

  37. For selecting 1 or more records from a table: SELECT * FROM <dbtab> Additions . . . WHERE <condition> . . . ORDER BY PRIMARY KEY . . . ORDER BY <f1> <f2> . . . <fn> ABAP statement and Keyword(con’t) SELECT statement

  38. SELECT <f1> . . . <fn> INTO (<h1> . . . <hn>) FROM <dbtab> . . . • For selecting a single record from a table: SELECT SINGLE * FROM <dtab> WHERE <condition>. ( full key ) ABAP statement and Keyword(con’t) SELECT statement • For selecting individual columns from a table:

  39. ABAP statement and Keyword(con’t) SELECT statement • For excluding duplicates: SELECT DISTINCT <f1> <f2> . . . <fn> INTO (<g1> <g2> . . . <gn>) FROM <dbtab> . . . • Aggregate expressions: SELECT AVG( <f1> ) COUNT( DISTINCT <f1> ) COUNT( * ) MAX( <f1> ) MIN( <f1> ) SUM( <f1> FROM <dbtab> . . . INTO (<g1> . . . <gn>)

  40. ABAP statement and Keyword(con’t) SAP Table • Two dimensional matrix describing relationship in database system • Components: • Table fields • Foreign keys • Technical Settings • Indexes

  41. ABAP statement and Keyword(con’t) Internal Table • One way to process large quantities of data in ABAP • Internal table is a dynamic sequential dataset in which all records have the same structure and a key • The data is taken from a fixed structure, stored line by line in the memory

  42. ABAP statement and Keyword(con’t) Internal Table Declaration <No header line> TYPES: BEGIN OF T_T001K, BWKEY LIKE T001K-BWKEY, BUKRS LIKE T001K-BUKRS, END OF T_T001K. DATA: IT_T001K TYPE T_T001K OCCURS 0.

  43. ABAP statement and Keyword(con’t) Internal Table Declaration <With header line> DATA: BEGIN OF IT_T001K OCCURS 0, BWKEY LIKE T001K-BWKEY, BUKRS LIKE T001K-BUKRS, END OF IT_T001K. • WITH HEADER LINE

  44. ABAP statement and Keyword(con’t) SAP --> Internal table Allows us to get contents of table and put it into internal table SELECT <field1> <field2>.. <fieldn> FROM <table> INTO TABLE <internal table> WHERE <condition>

  45. ABAP statement and Keyword(con’t) LOOP Command • To perform looping operation in the flow logic • Four kinds of loops in ABAP: • Unconditional loops using the DO statement • Conditional loops using the WHILE statement • Loops through internal tables and extract datasets using the LOOP statement • Loops through datasets from database tables using SELECT statement

  46. SY-INDEX ABAP statement and Keyword(con’t) DO Command DO <n> TIMES. ENDDO. statements Loop index

  47. SY-INDEX ABAP statement and Keyword(con’t) WHILE Command WHILE <logical expression>. ENDWHILE. statements Loop index WHILE COUNTER > 0. . . . SUBTRACT 1 FROM COUNTER. ENDWHILE.

  48. ABAP statement and Keyword(con’t) LOOP Command Example LOOP AT IT_T001K. WRITE: / IT_T001K-BWKEY. ENDLOOP.

  49. ABAP statement and Keyword(con’t) WRITE Command The basic ABAP statement for displaying data on the screen WRITE <f> <AT position(length)> <option> <AS CHECKBOX> <AS SYMBOL> <AS ICON> <AS LINE>

  50. ABAP statement and Keyword(con’t) WRITE Command • <OPTION> behind the WRITE statement is for formatting options • E.g. : ..NO-ZERO, NO-SIGN, No GROUPING, DD/MM/YY, • LEFT-JUSTIFIED, CENTERED, RIGHT-JUSTIFIED • The most commonly used options: • CURRENCY w to treat the content of field <f> as a currency amount with w as a currency key • DECIMALS d to determine number of decimals to be displayed • UNIT u to format the value according to the unit specified in the field u. The content of field <f> is treated as a quantity.

More Related