Download presentation
Presentation is loading. Please wait.
Published byDina Carson Modified over 9 years ago
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
Introduction R/3 Basis system overview R/3 Basis system R/3 user Presentation component ABAP Workbench R/3 user R/3 Application 1 R/3 Application N... 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 Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
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 Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
10
What is ABAP/4 program? ABAP/4 : Advance Business Application Programming Type of ABAP/4 program 1Executable program(Report/Interface) Can be started with transaction code/directly/background (via SE38 or SA38 - For example: RMCB0100 ) IINCLUDE program Can not run on its own, has been included in other program MModule pool Processing step of screens, can be executed via transaction code or Menu function (For example: SAPMV45A - Sale order processing) FFunction group Contain function modules (SE37) SSubroutine pool Externally-called subroutines
11
ABAP/4 overview Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
12
ABAP Dictionary Table View Data element Domain Structure Lock object F4 Search help SE11 - Data dictionary
13
ABAP/4 overview Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
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 Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
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 Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
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 the group 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 Often used transactions What is ABAP/4 program? ABAP dictionary Function Module Message Transaction code Authorization in ABAP object Topics:
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 Event in ABAP/4 program - Dialog module - Executable program (Selection screen, lists) ABAP statement and Keyword Topics:
26
Event in ABAP/4 program Event in Dialog Module 100 200 300 Transaction code has been requested from R/3 user Dialog screen chainModule pool PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb PBO Module. Module xxxx Module yyyy PAI Module Module aaaa Module bbbb PBO = Process Before Output PAI = Process After Input
27
Question??
28
Common Statement / Command Event in ABAP/4 program - Dialog module - Executable program (Selection screen, lists) ABAP statement and Keyword Topics:
29
ABAP statement and Keyword 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’. Statement The ABAP programming language consists of the following element types: STATEMENT, KEYWORD, COMMENT.
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
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 address OCCURS 0 Internal table
32
ABAP statement and Keyword(con’t) Modularization keywords Event define keywords INITIALIZATION Before selection screen is displayed AT SELECTION-SCREEN After input selection screen + selection screen is active START-OF-SELECTION After process selection screen GET when logical DB offer a line of database table END-OF-SELECTION After all selection has been done TOP-OF-PAGE Process when new page is started END-OF-PAGE Process when page is ended AT LINE-SELECTION When user select line in the list AT USER-COMMAND When 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 ABSAmount (absolute value) x von x SIGNSign of x; SIGN( x ) = 1 if x > 0 SIGN( x ) = 0 if x = 0 SIGN( x ) = -1 if x < 0 CEILSmallest integer value that is not less than x FLOORLargest integer value that is not greater than x TRUNCInterger part of x FRACDecimal part of x STRLEN String length
35
1.SELECT statements 2.SAP tables vs. Internal Tables 3.LOOP-ENDLOOP 4.WRITE statements 5.Comment in ABAP 6.Expressions and Operations in ABAP 7.Subroutines: FORMS, FUNCTION MODULE ABAP statement and Keyword(con’t)
36
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) ABAP statement and Keyword(con’t) SELECT statement
37
SELECT * FROM For selecting 1 or more records from a table: Additions... WHERE... ORDER BY PRIMARY KEY... ORDER BY... ABAP statement and Keyword(con’t) SELECT statement
38
For selecting individual columns from a table: SELECT... INTO (... ) FROM... For selecting a single record from a table: SELECT SINGLE * FROM WHERE. ( full key ) ABAP statement and Keyword(con’t) SELECT statement
39
SELECT DISTINCT... INTO (... ) FROM... For excluding duplicates: Aggregate expressions: SELECT AVG( ) COUNT( DISTINCT ) COUNT( * ) MAX( ) MIN( ) SUM( FROM... INTO (... ) ABAP statement and Keyword(con’t) SELECT statement
40
Two dimensional matrix describing relationship in database system Components: Table fields Foreign keys Technical Settings Indexes ABAP statement and Keyword(con’t) SAP Table
41
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 ABAP statement and Keyword(con’t) Internal Table
42
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. ABAP statement and Keyword(con’t) Internal Table Declaration
43
DATA: BEGIN OF IT_T001K OCCURS 0, BWKEY LIKE T001K-BWKEY, BUKRS LIKE T001K-BUKRS, END OF IT_T001K. WITH HEADER LINE ABAP statement and Keyword(con’t) Internal Table Declaration
44
Allows us to get contents of table and put it into internal table SELECT.. FROM INTO TABLE WHERE ABAP statement and Keyword(con’t) SAP --> Internal table
45
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 ABAP statement and Keyword(con’t) LOOP Command
46
DO TIMES. ENDDO. SY-INDEX Loop index statements ABAP statement and Keyword(con’t) DO Command
47
WHILE. ENDWHILE. WHILE COUNTER > 0.. SUBTRACT 1 FROM COUNTER. ENDWHILE. statements SY-INDEX Loop index ABAP statement and Keyword(con’t) WHILE Command
48
LOOP AT IT_T001K. WRITE: / IT_T001K-BWKEY. ENDLOOP. ABAP statement and Keyword(con’t) LOOP Command Example
49
The basic ABAP statement for displaying data on the screen WRITE ABAP statement and Keyword(con’t) WRITE Command
50
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 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 is treated as a quantity. ABAP statement and Keyword(con’t) WRITE Command
51
WRITE: / ‘Write’. WRITE: it_bseg-dmbtr CURRENCY it_bkpf-hwaer. WRITE: text-t01 LEFT-JUSTIFIED. ABAP statement and Keyword(con’t) WRITE Command Example
52
Written between statements of the ABAP program to explain its purpose to a reader / for internal documentation Helps to understand and change the program Flagged by special character: Asterisk (*) entire line to be a comment Double quotation mark (“) part of a line to be a comment Ignored by the system ABAP statement and Keyword(con’t) Comment
53
* Write Sales Order number to the screen Write: ‘Sales Order : ‘, 20 it_vbak-vbeln. “Sales Order Number ABAP statement and Keyword(con’t) Comment example
54
Relational Operator String Comparison Logical Expression If/Case/Check Statement Exit/Continue Statement ABAP statement and Keyword(con’t) Expression & Operation
55
DisplayMeaning EQ = Equal to NE<>>< Not equal to GT> Greater than GE>==> Greater than or equal to LT< Smaller than LE<==< Smaller than or equal to DATA: START TYPE D, SUM1 TYPE F, SUM2 TYPE P.. IF START IS INITIAL.... IF SUM1 GT SUM2.... IF SUM1 BETWEEN 0 AND 100.... BETWEEN f1 and f2 Interval IS INITIAL Initial value ABAP statement and Keyword(con’t) Relational Operator
56
CO contains only: f1 contains only characters from f2 ACCOUNT CO '0123456789' CA contains any: f1 contains at least one character from f2 CS contains string: f1 contains the string f2 'ABCDE' CS 'DE' CP contains pattern: f1 corresponds to the model f2 Model: *any string +any character #escape symbol 'ABXDE' CP '*B+D*' ABAP statement and Keyword(con’t) String Comparison
57
Logical Expression 1. AND 2. OR 3. NOT COUNTER GE 0 COUNTER GT 0 AND FLAG IS INITIAL ( FLAG1 NE SPACE OR FLAG2 NE SPACE ) AND COUNTER BETWEEN 0 AND 100 COUNTER EQ 0 AND NOT ( FLAG1 EQ SPACE AND FLAG2 EQ SPACE ) ABAP statement and Keyword(con’t)
58
IF Statement IF. ENDIF. IF. ELSE. ENDIF. IF. ELSEIF. ELSE. ENDIF. statements ABAP statement and Keyword(con’t)
59
Execute different statement blocks depending on the contents of particular data fields WHEN OTHERS: contents of does not equal to any of the contents CASE. WHEN. WHEN OTHERS. ENDCASE. statements ABAP statement and Keyword(con’t) CASE statement
60
Within Loop: to terminate loop pass conditionally CHECK. statements CHECK within a loop structure. CHECK outside loop structures. WHILE COUNTER GT 0. CHECK FLAG NE SPACE. ENDWHILE. statements 1 2 ABAP statement and Keyword(con’t) CHECK statement
61
Terminate loop entirely without any condition Terminate a subroutine without any condition DO... IF COUNTER GE 100. EXIT. ENDIF. ENDDO. statements EXIT within a loop structure. EXIT outside loop structure. EXIT. IF.... EXIT. ENDIF. statements 1 2 ABAP statement and Keyword(con’t)
62
Terminate loop pass immediately without any condition DO 100 TIMES. IF SY-INDEX GE 10 AND SY-INDEX LE 20. CONTINUE. ENDIF. ENDDO. statements CONTINUE. ABAP statement and Keyword(con’t)
63
Call calculate_tax Subroutine Calculate_tax PROGRAM RSDEMO01. PROGRAM RSDEMO02. PROGRAM RSDEMO03. Subroutine SUB1 Subroutine Calculate_tax PROGRAM RSDEMO04. Function module Calculate_tax ABAP/4 function library Function module........................ Call calculate_tax Avoid redundancy Modularization: easy to read easy to call ABAP statement and Keyword(con’t)
64
Define FORM [ ]. ENDFORM. Calling internally PERFORM [ ]. Calling external subroutine PERFORM (program name) [IF FOUND] ABAP statement and Keyword(con’t)
65
form f_check_file_exists using filename.............. endform. Parameters: p_path like rlgrap-filename............................... perform f_check_file_exists using p_path. ABAP statement and Keyword(con’t)
66
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.
67
Transportation of ABAP objects Type of ABAP object In Workbench organizer, there are several ABAP objects which are transportable Object In Transport request contain the following key PgmID: Program Id in request and task, normally there are 2 types for ABAP objects R3TR - name for R/3 Repository objects and Customizing objects LIMU - enables transport of R/3 Repository object components Obj:Object type (for example, DOMA, DTEL, FORM, PROG..) Object name: Name of the each object Funct.:Function D,K,M ObjStatus: LOCKED,ERR_IMP,OK_IMP and OK_GEN
68
Transportation of ABAP objects (con’t) Version management serves different purposes and user groups: - The developer can keep track of his or her work ("What have I changed?") - The developer can restore a previous version by reactivating it. - The system administrator can monitor work ("Which objects were changed and how were they changed in a specific time interval?") - It provides the basis for the auditor, who requires a complete history of changes. - It enables customers to adjust data with the help of the system after upgrading to a new Release.
69
Transportation of ABAP objects (con’t) ABAP object Version compare ABAP program Transaction code SE38, Under menu Utilities-->Version management Function module Transaction code SE37, Under menu Utilities-->Version management Data Dictionary Transaction code SE11, Under menu Utilities-->Version management Object Browser Transaction code SE80, Go to specific object and under menu utilities, Version management Workbench Organization Transaction code SE09, under menu Environment
70
Transportation of ABAP objects (con’t) ABAP object Version compare From Version management, you can 1. Display the object in other version 2. Compare the object in 2 versions 3. Retrieve the content of older version 4. Remote compare with another system 5. Display Transport Request
71
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.
72
Type of problem & How to investigate Type of problems ABAP Runtime Error Cause: Program error, system exception, database process error, etc. Using transaction code ST22 to analyze error. Unexpected message Update Terminate Cause: Update module can not be completed Program bug Cause: Written code is not correct
73
ABAP Runtime error - Analysis Error ID Date and time Double click to display detail
74
Unexpected message How to deal with unexpected message? 1. Go to Message long text if available. 2. Read through the section in the message help text, process where appropriate. Message help text component Diagnosis System response Procedure 3. Find the message location, the logic that drive the message appearance. Debugging Use “Where used list” function to find out the code where message is located (Not applicable for dynamic call)
75
Unexpected message (con’t) How to debug and locate the message in the program? 1. Debugging Set Debugger ON In Debugging screen, Set dynamic breakpoint on command “Message” Select debugging -> Continue (F8) When program reach MESSAGE command, cursor will be stopped Check the above logic before get into the current command, see the related data/value from debugging screen. 2. Using “Where used list” Function in message workbench SE91/SE80 When message is displayed, Double click on the status bar(if the message appear only in status bar, not popup) OR press F1 for popup message. Go to transaction code SE91/SE80 to find the location of the message call.
76
Update terminate Update terminate: Message/SAP internal mail will be sent to the transaction owner, either Error message Or ABAP runtime error (short dump) might be created. Analyzing the error Go to transaction code SM13 to analyze the update error. (Or Select Tools --> Administration --> Monitoring --> Update) Go to detail in update modules, You will get the following information: Where the error occurred: Program name, function module, line number and error text. (go to ABAP short dump Or Editor to locate the position) Why the error occurred:
77
Program bug Analyzing the error 1. Find out what went wrong. 2. Locate the position in the ABAP program How to find the right place? 1. Debugging 2. Use Call Hierarchy (SE48) 3. Use find function in ABAP editor
78
Simple Debugging How to: Switch on the debugger. Set and delete static and dynamic breakpoints. Set Watch points. Stop a program at specific key words or events or when a fields contents change. Continue processing after an interrupt. Display field contents during runtime. Display the contents of an internal table. Change field contents for testing purposes. Change the contents of an internal table. Display and use the debugger’s six different views.
79
Simple Debugging Start debugging: /h Start the debugger in Normal mode. Press enter to start. /hs Start the Debugger in System mode, for example, in order to debug the system program (program with type S) Appropriate menu options under system -> Utilities -> Debug ABAP Break-points Command. SE38 Start of programs in the debugging of transaction code SE38 SM50/SM51 via debugging menu SE80 - Object browser
80
Simple Debugging Set and delete static and dynamic breakpoints Static break-point Command BREAK-POINT. Or BREAK Dynamic break-point In ABAP Editor SE38 --> Utilities --> Breakpoints --> Display/Set In Debugging mode Place the cursor on the statement Choosing break-point -> Set/Delete At ABAP command At Event/Subroutine At Function module System exception
81
Simple Debugging Single step (F5) Execute (F6) Return (F7) Continue (F8) Field : Display content of fields up to 8 fields Table: Display content of internal table Watchpoints: Manage watchpoint during debug mode Calls : Display Call stack up to current statement (in sequence) Overview: structure of program, display event, sub routine, module and current statement SteppingDisplay mode
82
Simple Debugging Caution when debugging in Production system Since only a restricted number of dialog work processes can be switched to debugging mode, you should leave the debugger as soon as possible when you have finished working with it. Otherwise, the work process is not released for other users
83
Question ??
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.