Class Pool are K programs type that represented with the keyword CLASS-POOL.
P/4, the earlier ABAP version, as well as applications using ABAP Objects.
Executable Programs (ABAP Reports): are I programs type that represented with the keyword REPORT INCLUDE Program:- are I programs type that represented with the keyword INCLUDE Module Pool/Dialogue programs: are type M programs represented with the keyword PROGRAM. Sub-Routine Pool: are S programs type that represented with the keyword PROGRAM. Interface Pool: are J programs type that represented with the keyword INTERFACE-POOL. Class Pool: are K programs type that represented with the keyword CLASS-POOL. Function Group: are F programs type that represented with the keyword FUNCTION-POOL. Type group: are represented with the keyword TYPE-POOL.
DATA Variable_Name Type Variable_Type
Example:
DATA employee_number Type I.
The following is a list of Data Types supported by ABAP
Data Type | Initial field length | Valid field length | Initial value | Meaning |
---|---|---|---|---|
Numeric types | ||||
I | 4 | 4 | 0 | Integer (whole number) |
F | 8 | 8 | 0 | Floating point number |
P | 8 | 1 - 16 | 0 | Packed number |
Character types | ||||
C | 1 | 1 - 65535 | ' ... ' | Text field(alphanumeric characters) |
D | 8 | 8 | '00000000' | Date field(Format: YYYYMMDD) |
N | 1 | 1 - 65535 | '0 ... 0' | Numeric text field(numeric characters) |
T | 6 | 6 | '000000' | Time field(format: HHMMSS) |
Hexadecimal type | ||||
X | 1 | 1 - 65535 | X'0 ... 0' | Hexadecimal field |
a=16. move 16 to a. write a to b.
compute a = a*100.
if [not] exp [ and / or [not] exp ]. ........ [elseif exp. .......] [else. .......] Endif.
Case variable. when value1. ......... when value2. ......... [ when others. .........] Endcase. Do.
While <logical expression>. ..... ..... Endwhile.
Do <n> times. ..... ..... Enddo.
Data Dictionary is a system independent interface to the database (virtual database ) . Its main function is to support the creation and management of data definitions (or "metadata").
Objects in the ABAP Dictionary resided on 3 levels : Tables and structures Tables . Represent the Database Tables where data actually resides. . Tables can be defined independently of the database in the ABAP Dictionary. . The fields of the table are defined with their (database-independent) SAP ABAP data types and lengths. Structures . Are record declarations that do NOT correspond to a Database Table. Just like user-defined data type. Defined like a table and can then be addressed from ABAP programs. Structures contain data only during the runtime of a program. Data elements . Describes the role played by a field in a technical context . Fields of same semantic meaning can refer to the same data element Contains the field information Domains . Describes the technical characteristics of a table field Specifies a value range . . it describes allowed data values for the fields . Fields referring to the same domain (via the data elements assigned to them) are changed when a change is made to the domain Ensures consistency
.In the ABAP Dictionary, aggregated objects are objects which come from several different transparent tables.
. Are same as database views. . Views are used to summarize data which is distributed among several tables . The data of a view is not actually physically stored. . The data of a view is instead derived from one or more other tables , It is tailored to the needs of a specific application
. Search help is a tool to help you search for data records in the system . An efficient and user-friendly search assists users where the key of a record is unknown
. Simultaneous accessing of the same data record by two users is synchronized by a lock mechanism.
. Locks are set and released by calling certain function modules.
. These function modules are generated automatically from the definition of so-called lock objects in the ABAP/4 Dictionary.
Function modules :
Enqueue_
SE11 | Data Dictionary Initial Screen (SE12 Display only) |
SE13 | ABAP Dictionary : Technical Settings |
SE14 | Database Utility |
SE15 | Repository Information System |
SE16 | Data Browser |
SE17 | General table Display |
SE55 | Table View Maintenance |
SM30 | Table Maintenance |
Is a place to put a sequence of ABAP statements. Then, instead of placing all of the statements in your main program, you just call the module.
If you want to reuse the same set of statements more than once in a program, you can include them in a macro. . You can only use a macro within the program in which it is defined, . It can only be called in lines of the program following the definition. . Macros can be useful for long calculations or complex WRITE statements.
DEFINEMacros can use Parameters &N where N = 1,2,3... Example:'Macro Statements END-OF-DEFINITION
DATA: number1 TYPE I VALUE 1. DEFINE increment. ADD 1 to &1. WRITE &1. END-OF-DEFINITION. Increment number1. WRITE number1.
. Include Programs are solely for modularizing source code, and have no parameter interface. . they allow use of the same source code in different programs.
Include < include program Name >. Include programs cannot call themselves. . Include programs must contain complete statements. . Example:
INCLUDE ZILX0004. WRITE: / 'User', SY-UNAME,/ 'Date', SY-DATUM. ================================ PROGRAM ZRPM0001. INCLUDE ZILX0004.
. Subroutines are procedures defined and used in program. . If you want a function to be reusable throughout the system, use a function module.
FORM < Subroutine > [< pass >]. < Statement block >. ENDFORM.
. Internal subroutine defined in same program being called. . they Can access all the data objects declared in the main ABAP/4 program.
. External subroutine defined outside the program being called. . they Need to use the < pass > option or declare data objects in common parts of memory.
PERFORM < subroutine > [< pass >]which: < subroutine > = Name of the subroutine < pass > = Parameters being passed . Data declared in main program is automatically available.
PERFORM < subroutine >(< Program>) [< pass>]. PERFORM < subroutine> (< Program>) [< pass>] [IF FOUND]. PERFORM (< subroutine>) IN PROGRAM (< Program>) [< pass>] [IF FOUND]. PERFORM < index> OF < subroutine1> < subroutine2> < subroutine3> [< pass>].
. Nested calls are allowed in subroutines (i.e. PERFORM within a FORM ... ENDFORM ). . Recursive calls are also possible. . To define local data, use the DATA statement after FORM . . To define global data used within a subroutine, use the LOCAL statement after FORM . . The values are saved when you enter the subroutine and then released at the end (from the stack) . Each time you enter the subroutine, the data is recreated (with an initial value) and released at the end (from the stack).
Function Modules are general purpose ABAP routines that anyone can use. . Infact , there are a large number of standard function Modules available. . Function Modules are organized into Function Groups: . A Function module always belongs to a Function Group. Syntax
FUNCTION < function module> < Statements> ENDFUNCTION
To call a function module, use the CALL FUNCTION statement:
CALL FUNCTION < module > [EXPORTING f1 = a 1.... f n = a n] [IMPORTING f1 = a 1.... f n = a n] [CHANGING f1 = a 1.... f n = a n] [TABLES f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E] [OTHERS = ro]].
. Function groups are containers for function modules.
. There are a large number of standard Function Groups.
. All of the function modules in a function group can access the global data of the group.
. Like executable programs (type 1) and module pools (type M),
Function groups can contain screens, selection screens, and lists.
Points to Note
- Function Groups cannot be executed.
- The name of a function group can be up to 26 characters long.
- When you create a function group or function module, the main program and include programs are generated automatically.
- Function groups encapsulate data.
How to create a Function Group
- Goto Transaction SE80.
- Select Program in the DropDown.
- Write the name of the Function Group That you want to create.
Generally User made Function groups start with "Z". e.g. -
In ABAP, there are 2 types of SQL : OPEN SQL Open SQL allows to access the database tables declared in the ABAP dictionary regardless of the database platform that the system is using. NATIVE SQL Native SQL allows to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by ABAP dictionary, and therefore integrate data that is not part of the R/3 system.
. Open SQL thus provides a uniform syntax and semantics for all of the database systems supported by SAP. . Open SQL statements can only work with database tables that have been been created in the ABAP dictionary.
TABLES SBOOK. DATA C TYPE CURSOR, WA LIKE SBOOK. OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228' ORDER BY PRIMARY KEY. DO. FETCH NEXT CURSOR C INTO WA. IF SY-SUBRC <> 0. CLOSE CURSOR C. EXIT. ENDIF. WRITE: / WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE, WA-SMOKER, WA-LUGGWEIGHT, WA-WUNIT, WA-INVOICE. ENDDO.
All Open SQL statements fill the following two system fields with return codes :
SY-SUBRC
After every Open SQL statement,
the system field SY-SUBRC contains the value 0 if the operation was successful, a value other than 0 if not.
SY-DBCNT
After an Open SQL statement, the system field SY-DBCNT contains the number of database lines processed.
As already mentioned, Native SQL allows you to use database-specific SQL statements in an ABAP program. To use Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement. Syntax
EXEC SQL [PERFORMING < form>]. < Native SQL statement> ENDEXEC.. There is no period after Native SQL statements. . Comments: using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. . Casee sensivity:You need to know whether table and field names are case-sensitive in your chosen database. . host variables :In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). . You can use elementary structures as host variables. . Exceptionally, structures in an INTO clause are treated as though all of their fields were listed inpidually. . As in Open SQL, after the ENDEXEC statement,SY-DBCNT contains the number of lines processed. . In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement.
To improve the performance of the SQL and in turn of the ABAP program, one should take care of the following rules :
Internal tables are used to obtain data from a fixed structure for dynamic use in ABAP. Each line in the internal table has the same field structure. The main use for internal tables is for storing and formatting data from a database table within a program.
Work areas are single rows of data. They should have the same format as any of the internal tables. It is used to process the data in an internal table one line at a time.
There are 2 types of internal tables.
There are many ways to create an Internal Table : 1.By Using the Type Statement
Let us now create a Internal table itab using the TYPE statement. syntax :
Types : begin of line, column1 type I, column2 type I, end of line.
Example:
TYPES : begin of line, empno type I, empname(20) type c , end of line.
The TYPES statement creates a structure line as defined. To actually create an Internal Table itab use the following command-
Data itab type line occurs 10.
You can create an internal table by referring to an existing table.
The existing table could be a standard SAP table, a Z table or another internal table.
Syntax :
Data <f> <type> [with header line].
Example-
DATA itab TYPE line OCCURS 10 with header line.Here an internal table itab is created of the type line with a header line. Please note "with header line" is optional 3.By referring to existing Structure
Syntax-
Data <f> LIKE <struct> occurs n [with header line].
Example-
DATA itab LIKE sline OCCURS 10.
Here a table itab is created having a structure same as that of sline
4.By creating a new Structure
Let us now create an internal table with a structure of our own.
Here the table is created with an Header line, by default.
Syntax -
Data : Begin of <f> occurs <n>, <component declaration>, ................................., End of <f>.
Example -
Data : Begin of itab occurs 10, column1 type I, column2(4) type C, column3 like mara-ernam, End of itab.
Internal table itab is created
Now that we have successfully created some internal tables, let us see how do we populate them with some records. There are various methods available to populate tables 1.Append Data line by line
The first method available is the use of the APPEND statement. Using the APPEND statement we can either add one line from another work area to the internal table or we can add one initial line to the internal table.. Syntax :
APPEND [<wa> TO / INITIAL LINE TO] <itable>.Here work area <wa> or the Initial Line is appended to the internal table <itable>. The system variable SY-TABIX contains the index of the appended line. Example:
Data: Begin of itab occurs 10, col1 type C, col2 type I, end of itab. Append initial line to itab.
COLLECT is another form of statement used for populating the internal tables.
Generally COLLECT is used while inserting lines into an internal table with unique standard key.
Syntax-
COLLECT [<wa> INTO] <itable>.Incase of tables with Header line, INTO option is omitted. Suppose there is already an entry having a key same as the one you are trying to append, then a new line is not added to the table, but the numeric fields of both the entries are added and only one entry corresponding to the key is present. Value of SY-TABIX is changed to the row of the original entry. Else COLLECT acts similar to APPEND and SY-TABIX contains the index of the processed line. 3.Using INSERT statement
INSERT statement adds a line/work area to the internal table. You can specify the position at which the new line is to be added by using the INDEX clause with the INSERT statement. Syntax
INSERT [<wa> INTO / INITIAL LINE INTO] <itable> [index <idx>].Here, the work area <wa> or INITIAL LINE is inserted into internal table <itable> at index <idx>.
The contents of one internal table can be copied to another by using the APPEND LINES or INSERT LINES statement.
A more simpler way is to usetany of the following syntax's.
MOVE <itab1> To <itab2>. OR <itab1> = <itab2>.These copy the contents of ITAB1 to ITAB2. Incase of internal tables with header line we have to use [] inorder to distinguish from work area. So, to copy contents of internal tables with header line the syntax becomes,
itab1[] = itab2[].
1. Using Loop -Endloop
One of the ways of accessing or reading the internal table is by using LOOP-ENDLOOP.
Syntax
LOOP AT <itable> [INTO <wa>] ................................... ENDLOOP.Here when you say LOOP AT ITABLE, then the internal table ITABLE is read line by line. You can access the values of the columns for that line during any part of the LOOP-ENDLOOP structure. The value of the SY-SUBRC is set to 0, even if only one record is read. 2. Using READ The other method of reading the internal table is by using the READ statement.
READ TABLE <itable> [INTO <wa>] INDEX <idx>.This statement reads the current line or line as specified by index <idx>. The value of SY-TABIX is the index of the line read. If an entry with the specified index is found, then SY-SUBRC is set to 0. If the specified index is less than 0, then run-time error occurs. If the specified index exceeds table size then SY-SUBRC is set to 4.
There are many ways for deleting lines from an internal table.
1.Deleting lines in a loop.
This is the simplest way for deleting lines.
Sytax
DELETE <ITABLE>.This statement works only within a loop. It deletes the current line. You can delete the lines in a loop conditionally by adding the WHERE clause. 2.Deleting lines using the index. This is used to delete a line from internal table at any know index. Syntax :
DELETE <ITABLE> INDEX <IDX>.The line with the index <IDX> is deleted. The index of the following line is decremented by 1.
. Table controls and step loops are objects for screen table display that you add to a screen in the Screen Painter. . From a programming standpoint, table controls and step loops are almost exactly the same. . Table controls are simply improved step loops that display data with the look and feel associated with tables in desktop applications. . With table controls, the user can:
Step loops table rows can span more than one line on the screen. A row of a table control, on the other hand, must always be contained in a single line (although scrolling is possible). In general, many of the features provided by the table control are handled locally by your system's SAPgui frontend, so you do not need to program them yourself. The only notable exception to this is vertical scrolling .
Example (Transaction TZ60) Syntax To handle table controls in ABAP programs, you must declare a control in the declaration part of the program for each table control using the following statement:CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>
where <ctrl> is the name of the table control on a screen in the ABAP program. The control allows the ABAP program to read the attributes of the table control and to influence the control .Here, <scr> is the screen number where the initial values of the table are loaded. Cursor Position for a table control can be set in following ways: At PBO you can set the cursor on a specific field of a specific row of a table control.
SET CURSOR FIELD <f> LINE <lin> [OFFSET <off>]
Using the optional addition OFFSET, you can enter the offset of the cursor in
the field as described under Setting the Cursor Position.
At PAI you can read the current cursor position.
GET CURSOR FIELD <f> LINE <lin> ...
In addition to the information given under Finding Out the Cursor Position, field <lin> contains information on which row of the table control the cursor is currently on. You can also use
GET CURSOR LINE <lin>.
to determine the row of the table control. SY-SUBRC allows you to check if the
cursor is placed in a row of a table control.
For getting the corresponding line of the internal table :
GET CURSOR line <lin>. ind = <table_control>-top_line + <lin> - 1. Read table <itab> index ind.
The system variable stepl - contains the current table line index in a loop ... endloop. Loopc - contains number of lines visible in the table To create a table control 1.Add a table control element to your screen 2.Give a name to the table control. In the ABAP program declare a structure with the same ( CONTROLS <tcl> type TABLEVIEW USING SCREEN <scrn >) 3.To create fields go to the Dict./Program fields function.
If you want a selection column , check the appropriate check box in the attributes and give it a name. Create the field in the ABAP program. In the PBO you should have the statement
LOOP at <itab> USING CONTROL <cntrl_name>. ENDLOOP.
In the PAI you should have.
LOOP at <itab>. ENDLOOP.
It is within the loops that data transfer happens between the screen and the internal table.
When you populate the internal table use DESCRIBE TABLE <itab> LINES <cntrl_name>-lines,
to store the total number of lines in the control.
The FIELD statement can be used to control when the data transfer happens
To change the attributes of inpidual cells temporarily change the SCREEN table in the PBO.
You can change the attributes of the structure created by the CONTROLS statement
<cntrl>-fixed_cols etc are the attributes of the control <cntrl>-cols-index etc are the attributes of the columns. <cntrl>-cols-screen-invisible etc are the screen attributes of each column.
SAP-ABAP supports two types of Programs : - Report Programs & Dialog Programs. Report Programs are used when large amounts of data needs to be displayed Purpose/Use of Report Programs
Report <report name> no standard page heading line-size <size> line-count <n(n1)> message-id <message class>.
"Selection screen" is the screen where one specifies the input values for which the program should run. The selection screen is normally generated from the :
Selection-screen begin of screen <screen #> selection-screen begin of block <#> with frame title <text> ......... ......... selection-screen end of block <#> selection-screen end of screen <screen #>Parameters Parameters help one to do dynamic selection. They can accommodate only one value for one cycle of execution of the program. Syntax Defining parameters as a data type
Parameters p_id(30) type c.Defining parameters like a table field:
Parameter p_id like <table name>-<field name>.Parameters can be Checkboxes as well as Radiobuttons:
Parameters p_id as checkbox.Parameters p_id1 radiobutton group <group name>. Parameters p_id2 radiobutton group <group name>.Parameters can be listbox.
Parameter p_id like <table name>-<field name> as listboxSelect Options A Select-Option is used to input a range of values or a set of values to a program Syntax
select-options s_vbeln for vbak-vbeln.
select-options s_vbeln for vbak-vbeln no intervals no-extension
ABAP report programs are event driven programs.
The different events in a report Program are:
Load-of-program
ABAP allows the reports to be formatted as the user wants it to be. For example, "Alternate Lines" must appear in different colors and the "Totals" line should appear in Yellow. Syntax
Format Color n Format Color n Intensified On
n
may correspond to various numbers
Please note that there are other additions along with format as well
FORMAT COLOR OFF INTENSIFIED OFF INVERSE OFF HOTSPOT OFF INPUT OFF
Some commands used for interactive programming
Hotspot
If one drags the mouse over the data displayed in the report the cursor changes to a Hand with
an Outstretched Index finger. An hotspot can be achieved using the FORMAT statement.
Syntax: Format Hotspot On (Off).
Hide
This command helps you to store the field names based on which one will be doing further processing to
get a detailed list. It is written directly after the WRITE statement for a field.
When a row is selected the values get automatically filled in the variables for further use.
Syntax: Hide <field-name>.
Advantages of a logical database over normal Select queries.
Note: Due to the complexities involved, logical databases are not used in most of the cases
SAP-ABAP supports two types of programs - Report Program and Dialog Program. If your ABAP program demands user input , Dialog programming is used. A user dialog is any form of interaction between the user and the program and could be any of the following
Dialog program is also used when we need to navigate back and forth between screens Dialog programs are created with type as 'M' - Module Pool. They cannot be executed independently and must be attached to at least one transaction code in which you specify an initial screen.
Report Program:
A report is a program that typically reads and analyzes data in database tables without
changing the database.
Dialog Program:
A dialog program allows you to work interactively with
the system and to change the contents of the database tables. Each dialog program has a certain sequence
of screens that are processed by the system one after the other.
Unlike report which generally entails the creation of one autonomous program which can be executed independently of other objects, dialog program development entails development of multiple objects none of which can be executed on it's own. Instead all objects are linked hierarchically to the main program and and are executed in a sequence dictated by the Dialog Main Program. The components of a dialog program are: Transaction code
To use a subscreen, you must follow three simple steps
You can include a subscreen screen using the CALL SUBSCREEN statement in the flow logic of the main screen.
To include a subscreen screen in the subscreen area of the main screen and call its PBO flow logic,
use the following statement in the PBO event of the main screen:
PROCESS BEFORE OUTPUT. CALL SUBSCREEN <area> INCLUDING [<prog>] <dynp>.
This statement assigns the subscreen screen with number <dynp> to the subscreen area called <area>.
You can also specify the program in which the subscreen screen is defined (optional).
If you do not specify the program explicitly, the system looks for the subscreen screen in the same ABAP program
as the main program. If it does not find a corresponding subscreen screen, a runtime error occurs.
The PBO flow logic of the subscreen screen is also included at the same point.
This can call PBO modules of the ABAP program in which the subscreen screen is defined.
At the end of the subscreen PBO, the global fields from the program are passed to any identically-named screen fields
in the subscreen screen. The PBO flow logic of the subscreen screen can itself include further subscreens.
The name <area> of the subscreen area must be entered directly without inverted commas.
You can specify the names <prog> and <dynp> either as literals or variables.
If you use variables, you must declare and fill identically-named variables in the ABAP program.
The screen number <dynp> must be 4 characters long. If you do not assign a subscreen screen to an area,
it remains empty.
To call the PAI flow logic of the subscreen screen,
use the following statement in the PAI flow logic of the main screen:
PROCESS AFTER INPUT. CALL SUBSCREEN <area>.
This statement includes the PAI flow logic of the subscreen screen
included in the subscreen area <area> in the PBO event.
This can call PAI modules of the ABAP program in which the
subscreen screen is defined. Data is transported between
identically-named fields in the subscreen screen and the ABAP
program either when the PAI event is triggered, or at the
corresponding FIELD statements in the PAI flow logic of the
subscreen screen.
Points to Remember
PROCESS ON HELP-REQUEST FIELD <f> [MODULE <mod>] WITH <num>
HELP_OBJECT_SHOW_FOR_FIELD
PROCESS ON VALUE-REQUEST FIELD field name MODULE module name
MODULE VALUE_CARRIER INPUT. CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST' EXPORTING TABNAME = 'DEMOF4HELP' FIELDNAME = 'CARRIER1' DYNPPROG = PROGNAME DYNPNR = DYNNUM DYNPROFIELD= 'CARRIER'. ENDMODULE.F4IF_INT_TABLE_VALUE_REQUEST
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTINGThat's all to POH and POV. Leave your comments in case of any doubts.RETFIELD = 'CONNID' DYNPPROG = PROGNAME DYNPNR = DYNNUM DYNPROFIELD = 'CONNECTION' VALUE_ORG = 'S' TABLES VALUE_TAB = VALUES_TAB.
The common desired features of any report are "column alignment", sorting, filtering, subtotals, totals etc. To implement these from scratch , a lot of coding effort is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV). Each of these reports provide function modules which help in producing desired output without much effort.
SAP script is the SAP System's own text-processing system. It is used to print preformatted text in pre-formatted forms.
. An editor for entering and editing the lines of a text . Styles and layout sets for print layout. These are created independent of the inpidual texts using the corresponding maintenance transactions and are allocated to the texts later . The composer is a central output module. The SAP script composer is invisible to the outside . A programming interface that allows you to include SAP script components into your own application programs and to control the output of layout sets from within the programs . Several database tables for storing texts, styles and layout sets
To output documents using the programming interface, R/3 application programs need so-called layout sets (a kind of form). In SAP script a layout set describes the layout of the inpidual print pages and uses text elements to supply definable output blocks, which a print program can call. A layout set can be defined as a page design for a document Layout set on its own doesn't contain any data. The selection of data for the document is done through the print program. The print program selects the data from database table and feeds it to the layout set. When the print program is executed the document is printed on the screen, printer. Usually a SAPScript Layout consists of following components
Header Data: Header data is used for information and control of SAP printing. The header data comprises of 2 parts - Device Independent - Stores information like Start page , Default paragraph ,Language Attributes etc. And Device Dependent stores information like Page format ,Orientation Lines per inch etc Paragraph and Character Formats: Paragraphs are formatted using various attributes. For instance Standard paragraph attributes specify Left or Right margin, Alignment ,Line spacing etc. Font attributes specify Font family ,Font size etc. Character formats allow to format entire blocks of text within a paragraph Windows and Text Elements: Windows are inpidual text areas (header address, date, footer) in a page . It helps combine the information contained in a document into certain groups and make each group appear on the printed page in an inpidual area. You can define text elements (window texts) for each window. The print program accesses text elements by name, formats them and prints them in the respective window. The paragraph and the character formats used must be defined in the form. Pages: They are inpidual pages of a document and must have a unique name. You will often find different layouts for inpidual pages: The first page of an invoice differs from the subsequent pages, on which you need not repeat general information, such as address or customer data. Page Windows: While defining windows and pages, you do not yet determine the position and spacing of the texts to be output. A page window defines the rectangular output area in the output medium by specifying the left upper edge of the output area and its width and height
The purpose of "control commands" is to allow control of the output formatting. These commands are not interpreted by the SAP script editor, but are passed through to the SAP script Composer for processing. This includes, for example, line and page formatting, the formatting of text according to the paragraph and character formats specified. Syntax
Enter /: in the paragraph format
NEW-PAGE - Explicit page break PROTECT .........ENDPROTECT - To print complete paragraph in one page. INCLUDE - To include the content of another text into current text PERFORM - To call a subroutine of any ABAP program
The execution of script is done through an ABAP program, which is referred as Print Program. Each print program should have an ENTRY form , which will be called from customization. For a standard configuration we can see the form name (script name), print program name and output type in the table TNAPR. The print program uses the Form control functions to call the script. The print program call either all or some of the form control functions to execute the script OPEN_FORM (Mandatory) Opens the layout set output CLOSE_FORM (Mandatory) Ends the layout set output START_FORM (Optional) Starts a new layout set WRITE_FORM (Mandatory) Calls a layout set element END_FORM (Optional) Ends the current layout set
The output type can specify, a printed form that you need for internal use or a form that you want to send to a customer or vendor . The output type can also be an internal electronic mail message that you want to send to staff in another department. For example "Print out" can be classified as one output type of a billing document, i.e. when this output type is executed the billing document is printed. Similarly "Fax" can be an output type, i.e. when this output type is executed a fax of the billing document is sent All the output types for any document (e.g. billing document) will be stored in the table NAST. Output types are executed through the program RSNAST00 . Example : Output type in a billing document- Go to VF03 Enter billing document number and press enter again Chose Output under the menu Goto -> Header Here Z101 is an output type of a print output
Standard Texts for your report can be created using transaction SO10 Graphics and printer macros are uploaded with report RSTXLDMC into inpidual standard text documents or through transaction SE78. Graphics are uploaded in "Baseline TIFF 6.0" format (.tif files on PC) SAP Script & Standard text elements can exported or imported between two systems using RSTXSCRP program Copying Scripts Across clients: SAP Script is a client dependent object.Unlike programs, changes done to SAP script in one client will not be reflected in other clients. For copying script from one client to another, go to SE71 and use "Copy from Client" option available under Utilities menu or import the transport request, in which the script is saved, from the original client using the transaction SCC1 . Important Points to Note SAP script does not maintain any versions. So when modifying the SAP script , ensure that the changes are well documented in script. This applies to the standard texts too. The output of the form will differ when viewed on the screen and on the printer. So always test the output of the script on the printer.
SAP Smart Forms is used to create and maintain forms for mass printing in SAP Systems. As output medium SAP Smart Forms support a printer, a fax, e-mail, or the Internet (by using the generated XML output). SAP introduced SmartForms in 1998 to overcome the limitations in SAP Scripts. SmartForms are easier to develop, maintain and transport than SAP Script.
Multiple page formats are possible in SmartForms which is not the case in SAPScripts It is possible to have a SmartForm without a main window. Routines can be written in SmartForms tool. SmartForms generates a function module when activated. Labels cannot be created in SmartForms.
They help adapting forms without any programming knowledge due to entirely graphical user interface When activating the smart form the system automatically generates the function module and at the runtime . To make any changes we have to use the Drag & Drop, Cut & Paste. These actions do not include writing of coding lines or using a script language. We can insert static and dynamic tables. These include the line feeds in the inpidual table cells, triggering events for table headings and subtotals and sorting data before output. The smart forms allow the user to include graphics, which can be displayed as a part of the form or as background graphics. During printout the user can suppress the background graphic as and when necessary. Web Publishing is possible using the generated XML output
. Maintenance window shows attributes of the elements . Form printer window shows the layout of the page
Whenever we create smart forms, SAP creates/generates a function module.Unlike SAPscripts , SAP FORMS allow you to change language. In the navigation window you will find Global Data Declarations: The Data defined here can be used throughout the smartform for coding purposes. Form Interface : Here all the data which will be passed to the smartform from the Print program is defined. Right-Clicking on the Pages will allow creation of New Page, Window, Graphic or Address. Printing will take place on the basis of 'next page' field. But processing will happen as per the sequence in navigation window! For background picture and graphics you can pick up either black and white or color bitmap images and are stored in the form of standard texts. You may take a detour from the smartform screen and open Form Graphics screen. Transaction code: Se78 Setting in the Graphics in Smart Form Window-1.Main 2.Secondary
Important Points to Note. You cannot have more than 1 main window in a page. You can have multiple secondary windows .Whatever you print in secondary window...it has to be static. (If u have 20 lines in a PO and there is page constraint the lines get carried forward to next page in the main window. i.e. In a predecessor and successor type of content, they will be printed in sequence in main window. This is not allowed in Secondary windows.
Inside the main window we can add text as introduction to customize the form output. The Output options on each window determine the Line size, Width, Colors and background to be put. Smartforms gives the option of giving the address number which is maintained in the central address management. The address will be directly taken from ADRC table and will be populated in the form. The two different editors are available in Smartforms viz. Normal Editor and the Graphics Editor. This setting can be changed using the Configure editor in Utilities. In Table painter, you can draw the format as per client requirement (e.g. Heading, Sub Heading, Item, Sub Total, Grand Total etc.) You can use the table layout to determine:. The number of lines and cells . The height of each line . The width of each cell . The alignment of the table in the window
The Table shows the different line types which will be used in the table. The Line types define the size of each cell and the number of cells in each line.. Header data containing the default values of a Smart Style . Paragraph formats including indents and spacing, font attributes, tabs, and outline and numbering . Character formats including effects (superscript, subscript), barcode and font attributes . Colors and underlines for a paragraph or character format
You can use the transaction 'smartforms' / 'smartstyles' to create a smart style.
Customer exits are "hooks" provided by SAP within many standard programs, screens and menus on which customers may "hang" custom functionality to meet business requirements.
1. Function Module Exits
It allows customer to add code via a function module at a specific location in an SAP application program
Syntax: CALL CUSTOMER-FUNCTION '004'2. Screen Exits
: It allows customer to add fields to a screen in an SAP program via a subscreen. The subscreen is called within the standard screen's flow logic.
Format: CALL CUSTOMER-SUBSCREEN CUSTSCR23. Menu exits
It allows customer to add items to a pulldown menu in a standard SAP program. These items may be used to call add-on programs or custom screens.
Format: +CUS ( additional item in GUI status )
In transaction CAT2 - Time Sheet Entry, HR wishes to include an interactive acknowledgment that knowingly submitting incorrect data is grounds for dismissal.
Example of a Menu ExitIn transaction SE38 - ABAP Editor, the development team wishes to include a menu link to transaction SE80 - Object Navigator for ease of use. Befor: After:
Example of a Function Module ExitThe company wants the bank details of the Vendors in the Vendor creation to be mandatory event . So it must flash a error message that 'Please Enter the bank details' Before: After:
In transaction SMOD and look into the details Or in transaction SE81 you can use the appropriate application area
To create a customer exit you first need to create a project in transaction CMOD What is User Exits and Customer Exits in SAP ABAB Later you assign the Customer Exit to your project.
User Exit serve the same purpose as Customer Exits but they are available only for the SD module. The exit is implemented as a call to a Function Module. The code is written by the developer. Well know User Exit in SD is MV45AFZZ
USEREXIT_FIELD_MODIFICATION - To modify screen attributes USEREXIT_SAVE_DOCUMENT - To perform operations when user hits Save USEREXIT_SAVE_DOCUMENT_PREPARE USEREXIT_MOVE_FIELD_TO_VBAK - When user header changes are moved to header work area. USEREXIT_MOVE_FIELD_TO_VBAP - When user item changes are moved to SAP item work area
BADI stands for Business Add Ins Just like Customer Exits , BADI help hook custom enhancements to SAP functionality. Example of a BADI: In transaction CAT2 - Time Sheet Entry, HR wishes to include an interactive acknowledgment that knowingly submitting incorrect data is grounds for dismissal. This can be achieved using BADI
. BADI's are Object Oriented . They can be implemented multiple times . It does not require SAP Software Change Registration . No effect on release upgraded on the functioning of BADI's
This involved three steps Step 1 Creating BADI Definition : Transaction SE18 Step 2 Define BADI interface: Transaction SE19 Step 3 Define a class implements the interface : During implementation creation, a class for implementing the enhancement's interface is also created
The ABAP Query application is used to create reports not already present in SAP system. It has been designed for users with little or no knowledge of the ABAP programming. ABAP Query offers users a broad range of ways to define reports and create different types of reports such as basic lists, statistics, and ranked lists. The ABAP Query comprises four components:
1.Queries 2.InfoSets 3.User Groups 4.Translation of Query
The Queries component is used by end users to maintain queries. One can create queries,change queries and execute queries. Transaction SQ01
InfoSets are special views of data sources. An InfoSet describes which fields of a data source can be reported on in queries. An InfoSet can be assigned to several roles or user groups. Advantages- By creating InfoSets and assigning them to roles or user groups, the system administrator determines the range of reports that the inpidual application departments or end-users are able to generate using the SAP Query. End-users are able to work only with those InfoSets that are relevant to their particular area, as designated by the role or user group that they are assigned to.
The User Groups component is used to maintain user groups (from a security standpoint). Users working in the same application are assigned to the same user group. It does not matter who actually defined a query in a user group. Every user assigned to the user group is able to execute the query. Users in a user group need to have the necessary authorizations before they are able to change or redefine a query. Every user in a system can be assigned to several user groups.
A lot of texts are generated when defining queries, InfoSets, and user groups. These texts are displayed in the language that we chose when we log on to the SAP system. We can compare the text/languages using this component.
Data can be processed and presented in 3 ways:-
BASIC LIST - Presents data in the order defined by the functional area ( supports sorting and summation ). STATISTIC - Shows the statistical figures calculated from the basic data. RANKED LIST - A ranked list is a specialization of a statistic. E.x. Top ten customers of a travel agency.
A query can have one basic list , upto nine statistics and upto nine ranked lists.Step 1. Goto SQ01. Give a name to the query and click on the Create button Step 2. Give the description of the query in the next screen. Specify the output length and select the processing option from the Further Processing Options box. The data can be displayed in various formats such as table, download to a file, and display in Word etc. Step 3. Click on the next screen, select the field group to be used. Step 4. Click on the next screen, select the fields you want displayed Step 5. On the next screen, select the selection fields and then chose one of the output types ( basic, statistics, ranked ). In each of the lists, you can select various options. ( eg. Sort order of fields, change output length, column color,totals,page header, page footer etc.). Step 6. After providing all the above options you can save the query and execute it .
Batch input is typically used to transfer data from non-R/3 systems to R/3 systems or to transfer data between R/3 systems. It is a data transfer technique that allows you to transfer datasets automatically to screens belonging to transactions, and thus to an SAP system. Batch input is controlled by a batch input session. Batch input session Groups a series of transaction calls together with input data and user actions . A batch input session can be used to execute a dialog transaction in batch input, where some or all the screens are processed by the session. Batch input sessions are stored in the database as database tables and can be used within a program as internal tables when accessing transactions. Points to note
. BDI works by carrying out normal SAP transactions just as a user would but it execute the transaction automatically. All the screen validations and business logic validation will be done while using Batch Data Input. . It is suitable for entering large amount of data. . No manual interaction is required
SAP provide two basic methods for transferring legacy data in to the R/3 System.
1.Classical Batch Input method. 2.Call Transaction Method.
Classical Batch Input method In this method an ABAP/4 program reads the external data to the SAP System and stores in a batch input session. After creating the session, you can run the session to execute the SAP transaction in it. This method uses the function modules BDC_ OPEN, BDC_INSERT and BDC_CLOSE Batch Input Session can be process in 3 ways 1.In the foreground 2.In the background 3.During processing, with error display You should process batch input sessions in the foreground or using the error display if you want to test the data transfer. If you want to execute the data transfer or test its performance, you should process the sessions in the background. Points to note about Classical Batch Input method . Asynchronous processing . Transfer data for multiple transactions. . Synchronous database update. . A batch input process log is generated for each session. . Session cannot be generated in parallel. Call Transaction MethodIn this method ABAP/4 program uses CALL TRANSACTION USING statement to run an SAP transaction. Entire batch input process takes place online in the program Points to Note:
. Faster processing of data . Synchronous processing . Transfer data for a single transaction. . No batch input processing log is generated.
You will typically observe the following sequence of steps to develop Batch Input for your organization
1. Analysis of the legacy data. Determine how the data to be transferred is to be mapped in to the SAP Structure. Also take note of necessary data type or data length conversions. 2. Generate SAP data structures for using in export programs. 3. Export the data in to a sequential file. Note that character format is required by predefined SAP batch input programs. 4. If the SAP supplied BDC programs are not used, code your own batch input program. Choose an appropriate batch input method according to the situation. 5. Process the data and add it to the SAP System. 6. Analyze the process log. For the CALL TRANSACTION method, where no proper log is created, use the messages collected by your program. 7. From the results of the process analysis, correct and reprocess the erroneous data.
You may observe the following process to write your BDC program
1.Analyze the transaction(s) to process batch input data. 2.Decide on the batch input method to use. 3.Read data from a sequential file 4.Perform data conversion or error checking. 5.Storing the data in the batch input structure,BDCDATA. 6.Generate a batch input session for classical batch input,or process the data directly with CALL TRANSACTION USING statement.
Batch Input Data StructureDeclaration of batch input data structure
DATA : BEGIN OF < bdc table> OCCURS. INCLUDE STRUCTURE BDCDATA. DATA:END OF .
Field name | Type | Length | Description |
---|---|---|---|
PROGRAM | CHAR | 8 | Module pool |
DYNPRO | NUMC | 4 | Dynpro number |
DYNBEGIN | CHAR | 1 | Starting a dynpro |
FNAM | CHAR | 35 | Field name |
FVAL | CHAR | 80 | Field value |
. While populating the BDC Data make sure that you take into consideration the user settings. This is specially relevant for filling fields which involves numbers ( Like quantity, amount ). It is the user setting which decides on what is the grouping character for numbers E.g.: A number fifty thousand can be written as 50,000.00 or 50.000,00 based on the user setting. . Condense the FVAL field for amount and quantity fields so that they are left aligned. . Note that all the fields that you are populating through BDC should be treated as character type fields while populating the BDC Data table. . In some screens when you are populating values in a table control using BDC you have to note how many number of rows are present on a default size of the screen and code for as many rows. If you have to populate more rows then you have to code for "Page down" functionality as you would do when you are populating the table control manually. . Number of lines that would appear in the above scenario will differ based on the screen size that the user uses. So always code for standard screen size and make your BDC work always in standard screen size irrespective of what the user keeps his screen size as.
1. Open the batch input session session using function module BDC_OPEN_GROUP. 2. For each transaction in the session: . Fill the BDCDATA with values for all screens and fields processed in the transaction. . Transfer the transaction to the session with BDC_INSERT. 3. Close the batch input session with BDC_CLOSE_GROUP
Batch input recorder (System > Services > Batch input > Recorder) records transactions which are manually entered and creates a batch input session which can be executed later using SM35.
. Begin the batch input recorder by selecting the Recording pushbutton from the batch input initial screen. . The recording name is a user defined name and can match the batch input session name which can be created from the recording. . Enter a SAP transaction and begin posting the transaction. . After you have completed posting a SAP transaction you either choose Get Transaction and Save to end the recording or Next Transaction and post another transaction. . Once you have saved the recording you can create a batch input session from the recording and/or generate a batch input program from the recording. . The batch input session you created can now be analyzed just like any other batch input session. . The program which is generated by the function of the batch input recorder is a powerful tool for the data interface programmer. It provides a solid base which can then be altered according to customer requirements.
EDI, stands for Electronic Data Interchange, is the electronic exchange of structured business data between different applications. EDI Architecture consists of
1. EDI-enabled applications :They support the automatic processing of business transactions. 2. The IDoc interface: This was designed as an open interface. The IDoc interface consists of IDoc types and function modules that form the interface to the application. 3. The EDI subsystem: This converts the IDoc types into EDI message types and vice versa. This component of the EDI architecture is not supplied by SAP.
Advantages of EDI process. Reduced data Entry Errors . Reduced Processing cycle time . Availability of data electronic form . Reduced Paper Work . Reduced Cost . Reduced Inventories and Better Planning . Standard Means of Communicating . Better Business Processes . Competitive Advantage
ALE supports the distribution of the business functions and process across loosely coupled SAP R/3 systems (different versions of SAP R/3). Connections from R/2 and non SAP systems is also supported. ALE supports- Distribution of applications between different releases of R/3 Systems Continued data exchange after a release upgrade without requiring special maintenance Customer-specific extensions. Communication interfaces that allow connections to non-SAP systems. Coupling of R/3 and R/2 Systems.
ALE is used to support distributed yet integrated processes across several SAP systems whereas EDI is used for the exchange of business documents between the systems of business partners (could be non-SAP systems) ALE is SAP's technology for supporting a distributed environment whereas EDI is a process used for exchange of business documents which now have been given a standard format Both ALE and EDI require data exchange. An Idoc is a data container which is used for data exchange by both EDI and ALE processes.
IDOC is simply a data container used to exchange information between any two processes that can understand the syntax and semantics of the data. In simple words , an idoc is like a data file with a specified format which is exchanged between 2 systems which know how to interpret that data. IDOC stands for " Intermediate Document" When we execute an outbound ALE or EDI Process, an IDOC is created.In an inbound ALE or EDI process, an IDOC serves as input to create an application document.In the SAP System, IDOCs are stored in database. Every IDOC has an unique number(within a client). IDOCs are based on EDI standards, ANSI ASC X12 and EDIFACT. In case of any conflict in data size, it adopts one with greater length. IDOCs are independent of the direction of data exchange e.g. ORDERS01 : Purchasing module : Inbound and Outbound. IDOCs can be viewed in a text editor. Data is stored in character format instead of binary format. IDOCs are independent of the sending and receiving systems.(SAP-to-SAP as well as Non-SAP)
. IDOCs are independent of the sending and receiving systems.(SAP-to-SAP as well as Non-SAP) . IDOCs are based on EDI standards, ANSI ASC X12 and EDIFACT. In a case of any conflict in data size, it adopts one with greater length. . IDOCs are independent of the direction of data exchange e.g. ORDERS01: Purchasing module: Inbound and Outbound . IDOCs can be viewed in a text editor. Data is stored in character format instead of binary format.
More Info..Business Application Programming Interface(BAPI) are standardized programming interfaces (methods) enabling external applications to access business processes and data in the R/3 System. They provide stable and standardized methods to achieve seamless integration between the R/3 System and external applications, legacy systems and add-ons. BAPIs are defined in the BOR(Business object repository) as methods of SAP business object types that carry out specific business functions.They are implemented as RFC-enabled function modules and are created in the Function Builder of the ABAP Workbench. Some BAPIs and methods provide basic functions and can be used for most SAP Business Objects.These are called STANDARDIZED BAPI's. List of Standardized BAPIs: BAPIs for Reading Data - GetList() , GetDetail() , GetStatus() , ExistenceCheck() BAPIs for Creating or Changing Data- Create() ,Change(),Delete() and Undelete() , BAPIs for Mass Processing -ChangeMultiple(), CreateMultiple(), DeleteMultiple(). More Info
What is RFC? RFC is a mechanism that allows business applications to communicate and exchange information (in pre-defined formats) with other systems. RFC stands for 'Remote Function Call' RFC consists of two interfaces: A calling interface for ABAP Programs A calling interface for Non-SAP programs. Any ABAP program can call a remote function using the CALL FUNCTION...DESTINATION statement. The DESTINATION parameter tells the SAP System that the called function runs in a system other than the callers. More Info..