#1
|
|||
|
|||
ABAP/4 Development Workbench
FULL Material in Attachment with screen shots.
Tools of ABAP/4 workbench For programming
Last edited by Sumathi; 01-02-2009 at 08:36 PM. |
#2
|
|||
|
|||
Data dictionary objects:
·Tables A table is two dimensional data matrix. A table contains rows and columns. Rows contains data while column indicates fields. Table can contain 0 or multiple rows. ·Structures The object structure refers to the definition of object that does not have any contents. It is like table or view, but it never has entries i.e. it is only a structure. The basic difference between structure and table is that the structure does not exist at the underlying database system level. Structure exists as definition in the dictionary. ·Views A view is an imaginary table. It contains data, which are really stored in other tables. The contents for the view are dynamically generated when called from program. ·Data element They are definition of the properties and type for a table field. It is an intermediate object between the object type domain and the table field. A field in R/3 system is always associated with a data element, which at the same time is related to domain. ·Domains They are formal definition of the data types from a technical point of view. They set attributes such as data type, length, possible value range and so on. ·Lock objects These types of objects are used for looking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock object you can lock table-field or whole table. ·Matchcode objects are similar to table index, which gives list of possible values for either primary keys or non-primary keys. Tables in ABAP/4 dictionary Tables are the basic objects in R/3 application. There are almost 8000 tables in R/3 system. Following types of tables are available. Transparent tables Pool tables Cluster tables From user point of view, all tables are used to store data whatever be the type of table. There is no difference in the behavior or operation of these tables. All of them can be managed by using standard OPEN SQL. However from an administrator point of view transparent table do exists with the same structure both in dictionary as well as in the database.. While other two are not transparent in the sense that they are not manageable directly using database system tools. You cannot use native SQL on these tables. Pool or cluster tables are logical tables, which are arranged as records of transparent table. A table is made up of rows and columns. When the table is created, its columns are named; data type is supplied for each column. There can be only one data value in each column of each row in a table. Record or row or tuple as it called in different RDBMS is nothing but group of fields. While a column is a field of a table. A table is an indexed file. The main index is called as primary key, which can be a single field or combination of keys or fields. (A primary key can be defined as a field, which identifies a single unique record of the table) a table cannot have record with duplicate primary key. In any RDBMS, tables are related to each other. But to relate table to each other it is necessary that one of the tables contain some information of other table. Mostly tables are related to each other through primary keys. The primary key of one table, if it exists in other table then it is called foreign key. This type of database management system means that there is some redundancy of data. But it can minimize by using normalization procedures available. One of the most important function foreign key is to ensure data integrity. For example say you have EMP table, which has fields emp.no., emp.name, dept. code, salary and you have DEPT table which has dept.code and dept.desc. then in DEPT table dept.code is primary key while dept.code in EMP table is foreign key. If you enter dept.code for particular employee in EMP table the dept.code should exists in DEPT table, and if does not exists then will flash error. In this case DEPT is called check table while EMP foreign key table. Creation of table Steps to create a table ·Create a domain ·Create data element ·Create actual table Creating Domain Domain as already explained defines the technical properties of a field such as type and value range. A domain can be created from initial screen of data dictionary by clicking on create and clicking domain radio****on. Parameters to be passed are: (Data type) where you need to enter the data type available in SAP Field length: Field length is the number of valid position. Value table Name of the table to be entered. The fields referring to this domain may only assume values contained in the value table. Once the domain is created, save and activate it, so that it can be used for further objects (basic rule of dictionary) Creating Data Element The second step of table creation is to create data element. It assigns a certain meaning to the table fields, which are defined using that data element. A Data element always needs to be defined over a domain and field is always defined over a data element. This allows all fields with same technical properties to use the same data element. Parameters to be passed when creating a data element Short text. Mandatory field. Domain: A mandatory field. If the domain does not exist, SAP can take you directly to domain definition screen. Text element. You can enter description in short or long text for the field. This text is used when entering data for these fields. Save and activate. Creation of actual table. Parameters to be passed for creation of a table. Short description. Mandatory field. Delivery class. Table fields: Specify whether primary key. In this case it is mandatory to enter data element. Data class: Establishes the physical area of the database. Size category: Allows you to specify estimated space requirement for the table. Further down under buffering square box, the system allows specifying whether table is going to be buffered. When a table is buffered, it is loaded into the table buffer from the application server memory and it will remain there until you switch off or reboot system. If the table is to the buffered then you need to specify the type of buffering. Full is for entire table while partial is for only those records which are being accessed. Once the table is created, it has to be generated or activated to be able to be accessed by other objects like programs. General introduction to ABAP/4 SAP originally developed the programming language ABAP/4(advanced Business Application Programming for internal use to provide best working conditions for developers. SAP constantly improves the language to adapt to the increasing requirements of the business application. At present ABAP/4 is the only tool for developing application at SAP. SAP customers use ABAP/4for their own developments. The ABAP/4 Development Workbench contains all tools you need to create and maintain ABAP/4 programs. ABAP/4 programs are not compiled but generated. During generation, the system creates a so-called runtime object from the source code and the program attributes. When you start the program the system executes the runtime object. ABAP/4,a fourth generation language, contains all usual control structures and modularizing concepts for structured programming. The three parts of the ABAP/4language are: Structure and execution of ABAP/4 programs Basic language elements Programming reports Programming dialogs Structure and execution of APAP/4 programs are essentially different form entirely sequential programming languages such a s FORTRAN, PASCAL, or C, ABAP/4 instead shares certain similarities with modular, event –oriented programming languages such as Visual Basic or JAVA. The two most important statements concerning structure and execution are: An ABAP/4 program has a modular structure. For execution, you need a special runtime environment. This means, that ABAP/4 source texts always consist of a collection of program modules (one single module in the easiest case) or the sequential set of statements. The individual program modules consist of sequential statements. The set of statements of a program module is also called processing block. The runtime environment is responsible for calling the individual program modules one after the other. The runtime environment is the ABAP/4 processor, which can communicate with the list processor or the dialog processor, depending on the program type. Program flow within the individual processing blocks is sequential, as you know it from other sequential programming languages (for example, FORTRAN, PASCAL, and C). Within the processing blocks, you can use the general control statements for the program flow, such as IF, DO, WHILE. ABAP/4 does not contain GOTO statements. We mainly use programs that consist of single processing block only and, therefore, behave most likely like programs of other sequential programming languages. For programming applications, the entirely sequential concept is not sufficient. SAP distinguishes between two general types of application programs. Reports You use reports to databases and represent the results in list. Reports are collections of processing block that the system calls depending on events. Dialog programs Your use dialog programs to execute transitions, which usually read and change databases. Dialog programs are collection of processing blocks (so-called module pools) that are called by screen flow logic. The third part of the user’s Guide describe dialog programming in detail. Report can call dialog programs and vice versa. In it’s easiest an ABAP/4program contains one single sequential piece of coding and, thus, one single processing block. Characteristics of the ABAP/4 programming language: ·Declarative elements for declaring data of different type and structures. ·Operational elements for manipulating data. ·Control elements to control processing flow. ·ABAP/4 is multi-lingual. Text elements such as titles, headings, and text body are stored separately, independent of the program codes. This, you can change, translate, and maintain text elements without having to adapt the coding. ·ABAP/4 supports business-related data types and operations. You can execute calculation using special date and time fields. The system automatically executes all necessary type conversions. ·ABAP/4 provides a number of functions for processing character strings. ·ABAP/4 allows you to define and call subroutines. You can even call subroutines of other programs. There are different ways of how to pass parameters to a form the Subroutines. ·ABAP/4 contains a special type of subroutine, called function module. Function modules are stored and maintained in central library. They have clearly defined data interfaces to the calling program. You can test function modules in a standalone mode independent of the calling program. ·ABAP/4 contains an SQL subset called OPEN SQL. OPEN SQL allows you to read and change database tables independent of the underlying database system. ·ABAP/4 allows you to define and process internal tables that exist only for the execution period of the program. Internal tables most efficiently support the usage of database tables and allow you to implement complex data structures in a program. ·ABAP/4 allows you to store data not only on databases but also as sequential files on application and presentation server. Reports ·Reports are ABAP/4 programs. ·You use reports to evaluate data form database tables. The results of such an evaluation can be displayed on the screen or printed from. ·Reports are stand-alone programs. ·The user can execute reports directly via the program name, for example, by choosing System ® Utilities ® Reporting. ·Reports are controlled by events. ·A report program contains a collection of processing blocks for different events that are always triggered externally. In a report, you can react on events by programming the corresponding processing blocks or ignore the events by not writing the corresponding processing blocks or ignore the vents by not writing the corresponding processing blocks. A report itself never creates events. ·Reports can use logical databases or select statements defined by developer. ·For each application, SAP supplies logical databases. Or you can easily create logical databases yourself. ·Event control of a report corresponds to a certain scheme. When a report is executed, the ABAP/4 processor creates together with the logical database use (if any) a sequence of certain events for which you can program processing block. The chronology of the events is (more or less): Steps involved in creating a Report: 1.Processing the selection screen. After starting a report, the selection screen allows the user to enter limits or control values for further report processing. The report can contain several processing block for events during selection screen processing, for example, for checking the input values. 2.Reading the database After selection screen processing come the events for reading the database. Either the report reads data from relational databases it using the corresponding APAP/4 statements (OPEN SQL) or leaves this task to a logical database. In the latter case, the logical database creates a sequence of events to allow the report to copy the data. 3.Evaluating data and creating lists During or after the database the report creates the output list. During list creation, several events allow you to layout the output list (for example, layout the page header). 4.Outputting a list The last part of the processing sequence controlled by the ABAP/4 processor is the list output on the screen or printer. When displaying the list on the screen, the report user can trigger a number of other, interactive, events, for example, by clicking the mouse. By programming processing blocks for these events, you can change a normal report to a so-called interactive report. If a report does not contain event keywords, the entire coding of the report belongs to a single processing block, which is called by a standard event. This standard event is triggered directly after processing the selection screen. DIALOG PROGRAMS Characteristics of a Dialog Program: ·You use dialog programs to execute transactions. The users of dialog programs in dialog session are read and change database tables. Apart form the actual data processing (Open SQL), update and en-queue concepts are of great importance when programming dialogs. ·Dialog programs are not stand-alone. ·To execute dialog programs, they must be linked to at least one screen that itself is linked to a transaction code. The transaction code determines the initial screen with which the dialog session starts. ·Dialog programs are controlled by screen flow logic. ·The actual ABAP/4 dialog program is a so-called module pool. A module pool contains a collection of dialog modules that are called by the screen flow logic. ·To each module pool, at least one but usually several screens are allocated. Each screen has flow logic. The flow logic contains of BPO (Process Before Output) and PAI (Process After Input) blocks. This flow logic does not use the ABAP/4 programming language and the ABAP/4 Editor tool, but a special statement set and the Screen Painter tool, which you also use to layout screens. The flow logic mainly contains the chronologically ordered calls of the modules in the corresponding module pool. ·The Collection of PBO flow logic, screen and PAI flow logic is called “Dynamic Program” (Dynpro). A module pool must have at least one dynpro. Each screen of a dialog session thus is the visible part of a dynpro, to which also the flow logic belongs. The processing logic of a dialog session is stored in the corresponding module pool in the form of ABAP/4 modules. ·The ABAP/4 modules in the module pool are separated into PBO and PAI modules. The PBO or PAI blocks of the flow logic of each dynpro of a module pool can call each PBO or PAI module of this module pool. ·You can use ABAP/4 statements in the processing logic of the module pool to control the chronology of the different dynpros. After starting a dialog session via the transaction code, which is firmly connected to a dynpro of the module pool, the screen flow logic passes user entries to the processing logic in the ABAP/4 module pool. The processing logic processes the user entries (database accesses) and, if required, defines the appropriate subsequent screens. |
#3
|
|||
|
|||
Data Types and Data Objects
Data types and data objects are essential components of the ABAP/4 type concepts. Both can be declared and maintained by user. Unlike other programming languages in ABAP/4 you can create DATA TYPES independently. Data Types ·Are pure descriptions ·No memory is associated with data types. ·Describes the technical properties of data objects. Structure and definition classify data types. Can be of: 1.Elementary or structures 2.Predefined or use4r defined. Predefined User-defined ELEMENTARY C, D, F, I, N, P, T, X You can use directly Based upon elementary Data types Ex. TYPES: number type i. Cannot allocate memory to types. STRUCTURED Predefined types are TABLES User defined structured types are Field String and internal tables. Data Objects ·Data objects are units created during runtime. ·Data object cannot exist without data type. ·Occupies memory space. Kinds of Data Objects 1. INTERNAL DATA OBJECTS ·Literal A literal has a fixed value. Ex. WRITE ‘WORK HARD’. ·Variables DATA statement is used to create variables. Ex. DATA: NUM TYPE I. NUM is a variable declared by DATA statement. Any variable, which you use in program, need to be declared before you use it and can be done by DATA statement. Here variable is declared by referring to existing data type. Variable can also be declared by referring existing data object. Ex. We have already declared NUM by DATA statement. DATA : PRICE LIKE NUM. Here variable is declared by using LIKE parameter, which tells system that price has all the attributes of data object NUM i.e., PRICE is also of type I. The main difference between TYPE and LIKE parameter when defining or declaring the object is that TYPE is used to refer existing DATA TYPE (elementary or structured or user defined) while LIKE is used to declare data objects with reference to existing DATA OBJECTS. ·Constant Constant is a data object, which contains fixed value through out the program. Constant can be declared in program by using CONSTANT statement. Ex. CONSTANT: INT TYPE I VALUE 15. In program value of INT cannot be changed. If you give a statement like INT = 20. In this case system will give error. 2.EXTERNAL DATA OBJECTS Are defined in tables i.e., In ABAP/4 dictionary. You can access this data from table. TABLES: SFLIGHT. DATA: SEATS LIKE SFLIGHT-SEATSMAX. 3.SYSTEM-DEFINED OBJECTS SPACE & SYSTEM VARIABLES like sy-uname, sy-datum, sy-repid. 4.SPECIAL DATA OBJECTS PARAMETERS: are variables, which can accept value from user. SELECTIONS CRITERIA: are special internal tables to accept value range from user. Need for Data types: Consider the following example. DATA: fname(20), mname(20), Iname(20), add1(20), add2(20), add3(20) If you have DATA statement like above, and if you need to change the length of all the fields say from 20 to 25, then you need to change all the fields i.e., going through each and every statement. But consider the following case where TYPES has been used. TYPES: string(20) DATA: fname type string Mname type string Lname type string Add1 type string Add2 type string Add3 type string In this case if you need to change the length of all fields from 20 to 25. then just change the length of STRING and change will reflected for all the fields. If you define all the types in TYPE-POOL ie., global definition of all the types, you can use these types anywhere and in any program. Parameters Parameter statement is used to accept input from user. PARAMETER statement is used when you want user to enter data and depending upon what he enters you need to take action. The parameter statement declares the variable and also allows system to accept data into that variable. Syntax. Parameters : num type i. Here parameter statement declares the variable and creates the selection screen on which user enters the data i.e., in this case num is declared of type I and user can enter any number. Entered value is stored in the same variable and can be used in program. Data : m type I Parameters : num type I M = num + 5 Write : / ‘The number is m. You can define default values with parameter statement for example Parameter : num type I default 12. In this case when selection screen is displayed the default value is displayed. User can either use same value or overwrite the value. Parameter of type character and length one, can be displayed as checkboxes and radio ****ons. Parameter : C1 as checkbox C 2 as checkbox Parameter : R1 radio****on group g1 R2 radio****on group g1 When parameter is defined as radio****on, it needs to be attached to one group. Only one radio****on of one group can be clicked. Every parameter can be associated with language dependent text that is displayed on the selection screen. This can be done by using text elements. WRITE STATEMENT About WRITE statement The basic ABAP/4 statement for outputting data on the screen is WRITE. Syntax : This statement outputs the field By default, the list is displayed on the screen. The field PROGRAM ZDEMO WRITE : /’HELLO’ When you start this program, the system leaves the current screen i.e., your editor screen and branches to the output screen, which is also called as, list screen: The list screen has the same name as the title of the program specified in the program attributes. First line on the screen contains the list header. By default, the list header is the same as the title of the program. The current page number (1) appears on the right. The list header is followed by one line and then the output is displayed. Write : ‘HELLO’ Write : ‘WORK HARD’ On the screen, the output is normally left justified. But in above case, because we have used two WRITE statements, the output fields are displayed one after the other, each separated by one column (i.e., one blank). If there is not enough space for an output field on the current line, a new line is started. Almost all system-defined fields are right justified except FLOAT, INTEGER, and PACKED i.e., number field. The numeric data types F, P and I are right justified and padded with blanks on the left. If there is sufficient space, thousand separators are also output. If a type P field contains decimal places, the default output length is increased by one. With the data type D, the internal format of a date differs from its output format. When you use the WRITE statement for outputting data, the system automatically outputs dates of type D in the format specified in the users master record (e.g. DD/MM/YYYY or M/DD/YYYY). Formatting output You can position the output of a WRITE statement on the screen by making a format specification before the field name as follows : Syntax WRITE AT [/][ Where .the slash ‘/’ denotes a new line, For variables you need a mention the AT, for direct values it is not necessary. DATA : LEN TYPE I VALUE 10, POS TYPE I VALUE 11, TEXT (10) VALUE ‘1234567890’ WRITE AT POS (LEN) TEXT. This produces the following output on the screen : The text – 1234567890 – appears in the text. If the output length DATA : NUMBER TYPE I VALUE 1234567890, TEXT (10) VALUE ’abcdefghij’ WRITE : (5) NUMBER, /(5) TEXT. This produces the following output : 7890 adcde In the default setting, you cannot create empty lines with the WRITE statement. WRITE : ‘One’ / ‘ ‘, / ‘Two’ The output looks as follows : One Two The system suppresses lines that contain nothing but empty spaces. You can use various formatting options with the WRITE statement. Syntax WRITE ….. Formatting options for all data types Option Purpose LEFT-JUSTIFIED CENTERED RIGHT-JUSTIFIED UNDER NO-GAP USING EDIT MASK USING NO EDIT MASK NO-ZERO Output is left justified Output is centered Output is right justified. Output starts directly under the field The blank after the field Specifies a format template Deactivates a format template specified in the ABAP/4 Dictionary. Zeros, these are replaced by blanks. For type C and N fields, leading zeros are replaced automatically. Formatting options for numeric fields Option Purpose NO-SIGN DECIMALS EXPONENT ROUND CURRENCY UNIT The leading sign is not output. In type F fields, the exponent is defined in Type P fields are multiplied by 10**(-r) and then rounded. Format according to currency The number of decimal places is fixed according to the unit. specified in table T006 for type P fields. Horizontal lines You can generate horizontal lines on the output screen by using the following syntax : Syntax ULINE Will draw a horizontal line. ULINE (10) Will start drawing horizontal line from 10th column position. WRITE at 10(40) SY-ULINE This statement draws a horizontal line from 10th position. Vertical lines You generate vertical lines on the output screen by using the following syntax : Syntax WRITE [AT [/][ Blank lines You can generate blank lines on the screen by using the following syntax : Syntax SKIP [ Starting on the current line, this statement generates To position the output on a specific line on the screen use : Syntax SKIP TO LINE This statement allows you to move the output position upwards or downwards. Branches Like other higher programming languages, ABAP/4 provides standard keywords to control the flow of a program. Usually ABAP/4 programs get executed statement by statement. Many times you need to skip few statements depending upon certain conditions i.e. you change the flow of program. This can be done by : ·Branching (IF, CASE) ·Looping (DO, WHILE) However, unlike other languages where you have internal control, ABAP/4 has internal control and external control of the program flow. ·The internal control is steered by standard keywords as mentioned above. You define this in your program code. ·The external control is steered by events. Events are generated either from other ABAP/4 programs or from interactive user input (like, for example, using the mouse to click on the screen ). The system does not necessarily process the statements in the same sequence as they are listed in an ABAP/4 program. This makes ABAP/4 an event-driven programming language. The external control plays an important role mainly for report programs. Branching with IF statement The IF statement allows you to divert the program flow to a particular statement block, depending on a condition. This statement block consists of all the commands which occur between an IF statement and the next ELSEIF, ELSE, or ENDIF statement. Syntax IF ELSE ENDIF If the first condition is true, the system executes all the statements up to the end of the first statement block and then continues processing after the ENDIF statement. To introduce alternative conditions, you can use ELSEIF statements. If the first condition is false, the system processes the following ELSEIF statement in the same way as the IF statement, ELSE begins a statement block which is processed if none of the IF or ELSEIF conditions is true. The end of the last statement block must always be concluded by ENDIF. IF ELSEIF ELSEIF ELSE ENDIF ABAP/4 allows unlimited nesting of IF – ENDIF statement blocks, but they must terminate within the same processing block. In other words, an IF – ENDIF block cannot contain an event keyword. Branching with CASE statement To execute different statement blocks depending on the contents of particular data fields, you can either use IF statement or the CASE statement as follows : Syntax CASE WHEN WHEN WHEN ……… WHEN OTHERS ENDCASE. The system executes the statement block after the WHEN statement if the contents of The conditional branching using CASE is a shorter and simpler form of similar processing with IF. When you have many conditions IF becomes more complicated, in such cases CASE is used. LOOPING Looping with DO statement If you want to write your name say for 10 times, then you need to write WRITE statement for 10 times. When you want to process a statement more than once, you can write this statement within a lop with the DO statement as follows : Syntax DO 5 times Write :/ name ENDDO The system continues processing the statement block for 5 times the loop has been processed so in this case when the loop is over value of sy-index will be 5. In this case you know that, you want to perform WRITE statement for 5 times. But that is not the case always. Many times you need to terminate the loop depending upon certain conditions. This can be done by using EXIT or STOP statement. The important point to remember when you don’t you use TIMES option, is to avoid endless loops when working with the DO statement. If you do not use the TIMES option, include at least one EXIT, STOP statement so that system can leave the loop. Exit and stop takes you out of that loop. |
#4
|
||||||
|
||||||
Looping with WHILE loop If you want to process a statement block more than once as long as a condition is true, you can program a loop with the WHILE statement as follows : Syntax DATA : M TYPE I VALUE 0 WHILE M < 10 WRITE : / M M = M + 1. ENDWHILE The system continues processing the statement block introduced by WHILE and concluded by ENDWHILE statements as long as M is less than 10 or until the system finds an EXIT, STOP. The system field SY-INDEX contains the number of times the loop has been processed. You can nest WHILE loops any number of times and also combine them with other loops. Difference between DO loop and WHILE is that In WHILE, condition is checked first and if condition is true then loop is executed while in DO loop, the loop gets executed first if you don’t have TIMES option and then the condition is checked (if you have any) You can have nested DO and WHILE or DO and IF or IF and IF or any possible situation. String Operations ABAP/4 provides several keywords fro processing data objects of type C, also known as character strings. Shift command To shift the contents of a field, by one position or one character you can use the SHIFT statement. Using SHIFT allows you to shift field contents byte by byte or character by character. With the SHIFT statement, you can execute the following : String = ‘HELLO’ String1 = ‘ALL OF YOU’ String3 = ‘WORK HARD’ Shift String Shift string1 by 2 places Shift string2 right Shift string1 by 2 places circular The output will be ELLO – By default if nothing is specified then string is shifted by one position. L OF YOU – Here the string is shifted by 2 places. _WORK HARD – In this case the string is shifted to right by one place (with leading blanks) K HARDWOR – In this case the string is shifted to the left so that 3 characters on the left appear on the right. Replace command You use the REPLACE statement. Syntax REPLACE ABAP/4 searches the field Then, the statement replaces the first occurrence of the pattern REPLACE STR1 WITH STR2 INTO STRING Here whole string is searched for string1 and is replaced with str2. REPLACE ‘&’ WITH ‘M” Here the system searches string for & and replaces it with ‘M’ TRANSLATE command Syntax TRANSLATE TRANSLATE These statements convert all lower case letters in the field You can use TRANSLATE to substitute the characters in a string like replace. But the main difference between Translate and Replace is that Replace statement replaces only occurrence of particular character while Translate replaces all the occurrences of the character. When using substitution rules, use the following syntax: Syntax TRANSLATE OVERLAY command Syntax OVERLAY This statement overlays all positions in field SEARCH command Syntax SEARCH This statement searches the field STRLEN command To determine the length of a character string up to the last character other than SPACE, use the built-in function STRLEN as follows: Syntax N = STRLEN (STR) Here N is defined in DATA statement as type i. STRLEN processes any operand CONDENSE command To delete superfluous blanks in character fields, use the CONDENSE statement. Syntax CONDENSE This statement removes any leading blanks in the field CONCATENATE command To concatenate separate character strings into one, use the CONCATENATE statement : Syntax CONCATENATE This statement concatenates the character fields Trailing blanks are ignored during this operation. CONCATENATE STR ‘:’ STR2 INTO STRING Here str, str2 and ‘:’ is concatenated and result is stored in string. SPLIT command To split a character string into two or more smaller strings, use the SPLIT statement : Syntax SPLIT This statement searches the character field To place all fragments in difference target fields, you must specify enough target fields. Otherwise, the last target field is filled with the rest of the field Delimiters. SPLIT STRING AT ‘,’ INTO P1 P2 P3 P4 Here the string is split at ‘,’ and is put into strings p1, p2, p3, p4. ·In ABAP/4, you can specify offset values for elementary data objects in all statements, which process these data objects. To do so, specify the name of a data object in a statement as follows : Syntax The operation of the statement is performed for the part of the field If the length String = string l + 3(4) Assuming that string 1 = ‘abcdefgjk’ Here string will contain ‘defg’ OPEN SQL In the R/3 system, long-life data is stored in relational database tables. Structured Query Language (SQL) was created for accessing relational databases. SQL has two statement types : Data Definition Language (DDL) statements and Data Manipulation Language (DML) statements. TO include these SQL statements in an ABAP/4 program, use Native SQL to avoid incompatibilities between different database tables and also to make ABAP/4 programs independent of the database system in use, SAP has created a set of separate SQL statements called Open SQL. Open SQL contains a subset of standard SQL statements as well as some enhancements, which are specific to SAP. Using open SQL enables you to access any database tables available to the SAP system, regardless of the manufacturer be it oracle, Informix etc. The difference between Open SQL and Native SQL is as follows : A database interface translates SAP’s Open SQL statements into SQL commands specific to the database in use. Native SQL statements access the database directly. Open SQL keywords Keywords Used for SELECT : Reading Data from Database Tables INSERT : Adding Lines to Database Tables UPDATE : Changing Lines in Database Tables MODIFY Adding or Changing Lines DELETE : Deleting Lines from Database Tables When using open SQL statements in an ABAP/4 program, you must ensure the following: 1.The database system being addresses must be supported by SAP 2.The database tables being addressed must be defined in the ABAP/4 Dictionary. Select Statement The following system fields play an important role in Open SQL operations : SY-SUBRC As with other ABAP/4 statements, the return code value in the system field SY-SUBRC indicates after each Open SQL operation whether or not the operation was successful. If an operation is successful, SY-SUBRC = 0. If an operation is not successful SY-SUBRC <> 0. SY-DBCNT The value in the SY-DBCNT field indicates how many lines were affected by the operation or how many lines have already been processed. To read data from a database table, use the SELECT statement. Syntax SELECT This statement has several basic clauses. Each clause is described in the following table. SELECT The SELECT clause defines whether the result of the selection is a single line or a whole table, or few columns. FROM
|