Anda di halaman 1dari 45

ABAP General Concepts

India SAP CoE, Slide 1

Topics Covered
SAP Architecture R/3 Reports Function Modules Interfaces BDCs, LSMW Cross Applications BAPIs, RFCs, IDOCs

India SAP CoE, Slide 2

SAP R/3 Architecture

India SAP CoE, Slide 3

R/3 Architecture

India SAP CoE, Slide 4

R/3 Architecture

India SAP CoE, Slide 5

R/3 Architecture

India SAP CoE, Slide 6

Some Common Transactions


SE38 ABAP Editor SE37 ABAP Function Modules SE11 ABAP Dictionary SE93 Transactions SE80 Object Navigator LSMW Legacy System Migration Workbench SHDB Transaction Recorder SM35 Session Overview

India SAP CoE, Slide 7

Reports

India SAP CoE, Slide 8

Reports
Reports are Programs that read data from the database, processes the data and displays the data to the required format. Reports are uses in day to day business environment. For eg
Displaying the purchase orders vendor wise Displaying the balance of vendors to be paid till a particular date

Enhance the efficiency & transparency of Business Processes Sound Decision making with the control of master data and accurate reporting Relevant Documents immediately available for in case of drill down reports Multiple angles of Data representing and Forecasting Values

India SAP CoE, Slide 9

Reports: Classification
Classical Interactive

India SAP CoE, Slide 10

Process Flow: Classical Report

India SAP CoE, Slide 11

Process Flow: Interactive Report


event keyword
event begin event end processing block internal control event keyword processing block internal control external control

external control

...
India SAP CoE, Slide 12

Events
ABAP/4 report programs are event driven programs The different events in a report Program are:
Initialization.
Initialization of all the values. You can fill your selection screen with some values at runtime.

At Selection-Screen.
Validation & Checks of inputted values happen here

Start-of-Selection.
Here the program starts selecting values from tables.

End-of-selection.
After all the data has been selected this event writes the data to the screen.

Interactive Events.
Used for interactive reporting. It is used to create a detailed list from a basic list.

India SAP CoE, Slide 13

Data Declaration
Data statement Like and Type Keywords

India SAP CoE, Slide 14

Internal Tables
Standard Sorted Hashed

Key Access Access Time For n Entries

Table Scan

Binary Srch

Hash Function

Increases Linearly (O(n))

Increases Logarithmically Remains Constant (O(log(n)) (O(1))

Access Using

Predominantly Index

Predominantly Key

Key Only

Uniqueness

NON-UNIQUE

UNIQUE| NON-UNIQUE

UNIQUE

India SAP CoE, Slide 15

Internal Tables
Operations without header line
INSERT <wa> INTO TABLE <itab>. COLLECT <wa> INTO <itab>. READ TABLE <itab> ... INTO <wa>. MODIFY TABLE <itab> FROM <wa>. MODIFY <itab> FROM <wa>WHERE

Cont..

Operations with header line


INSERT TABLE ITAB COLLECT <itab>. READ TABLE <itab> MODIFY TABLE <itab> MODIFY <itab> WHERE DELETE TABLE <itab>.

DELETE TABLE <itab> FROM <wa>.

India SAP CoE, Slide 16

Common Statements
Write Loop.. Endloop If Else Endif Case When Endcase Select

India SAP CoE, Slide 17

Interactive Reporting
The following are the different events associated with Interactive Reporting

Event Keyword
At Line-Selection At User-Command At PFn Where n is between 0 to 99 Top-of-Page during Line Selection

Event
Event is triggered by either the user double clicking a particular line or using F2 to select it Event triggered by user pressing a function key Event triggered on press of a function key. Event called during list processing when a detailed list is called

India SAP CoE, Slide 18

Interactive Reporting
Hotspot

Cont..

If one drags the mouse over the data displayed in the report using the FORMAT statement then the cursor changes to a Hand with an Outstretched Index finger 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>.

Get Cursor Command


Like Hide this is also used for getting the values after selection of a row. Syntax: Get Cursor field cur_name value cur_value. cur_name and cur_value are variables.

CALL TRANSACTION '<TRAN>' AND SKIP FIRST SCREEN.


Call a SAP transaction from ABAP Code.

India SAP CoE, Slide 19

Modularization
Subroutines
Subroutines are procedures that you can define in any ABAP program and also call from any program.

Function modules
Function modules are procedures that are defined in function groups and can be called from any ABAP program.

Include
If you want to use the same sequence of statements in several programs, you can code them once in an include program.

India SAP CoE, Slide 20

Subroutines
Defining Subroutines
FORM <subr> [USING ... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ] [CHANGING... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ]. ... ENDFORM.

The Parameter Interface


Parameters Passed by Reference list these parameters after USING without the VALUE addition Parameters Passed by Value list these parameters after USING with the VALUE addition Passing by Value and Result If you want to return a changed output parameter from a subroutine to the calling program only after the subroutine has run successfully, use CHANGING for the <pass> option of the FORM and PERFORM

India SAP CoE, Slide 21

Subroutines
Calling Subroutines
PERFORM... [USING ... <pi>... ] [CHANGING... <pi>... ].

Cont..

Static Variable
If you want to keep the value of a local data object after exiting the subroutine, you must use the STATICS statement to declare it instead of the DATA statement. With STATICS you declare a data object that is globally defined, but only locally visible from the subroutine in which it is defined. STATICS f_text TYPE f_word VALUE 'INIT'.

India SAP CoE, Slide 22

Function modules
Calling Function Modules
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....en = rn [ERROR_MESSAGE = r E] [OTHERS = ro]].

Creating Function Modules (SE37)


Attributes Parameter Interface Tables Exceptions Source Code

India SAP CoE, Slide 23

Debugger
Fields Table

Cont..

The scrollable field display contains the contents of up to eight fields. The contents of the three most important system fields are always displayed. This is the default display mode in the Debugger. See also Processing Fields Displays the contents of an internal table. This mode allows you to display and edit the entries in an internal table. See also Processing Internal Tables A scrollable display containing up to 30 breakpoints. Next to each breakpoint is a counter. You can also delete breakpoints in this display. See also Managing Dynamic Breakpoints You can set a watchpoint for a field so that the program is interrupted whenever the value of that field changes. This display mode contains a list of Watchpoints, the fields and programs to which they are assigned, the current values of the fields, and the conditions upon which the watchpoint is activated. See also Setting Watchpoints This mode displays the current sequence of events, and the sequence of calls up to the current breakpoint. The last active call is displayed at the top of the list; previous calls are listed in reverse chronological order. When an event (for example, START-OF-SELECTION) concludes, it is deleted from the display. This mode displays the structure of the program. It lists its events, subroutines, and modules, and shows which sections belong to which events. It also displays the section currently being processed. This mode displays the current Debugger settings. You can change the settings by selecting or deselecting various options. For further information, refer to Settings and Warnings

Breakpoints

Watchpoints

Calls

Overview

Settings

India SAP CoE, Slide 24

Hands On
An output report is required which takes sales document no (VBAPVBELN) as input, selects the fields VBELN POSNR & NTGEW and displays a report as shown :

India SAP CoE, Slide 25

Hands On: Steps


Declare Internal table Create Selection Screen Select data from VBAP and store in Internal table Loop at the internal table and display the data.

India SAP CoE, Slide 26

Additional Info
Use the below link for complete details on ABAP.
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d 1829f0000e829fbfe/frameset.htm

India SAP CoE, Slide 27

Data Upload
BDC LSMW

India SAP CoE, Slide 28

Purpose
BDC stand for BATCH DATA COMMUNICATION Through this concept we transfer the data into SAP R/3 System Legacy System R/3 System

Data

BATCH INPUT

India SAP CoE, Slide 29

Reading data from application server or presentation server


Presentation server

WS_UPLOAD

ABAP/4 PROGRAM

Application server

Internal table

Read Dataset

India SAP CoE, Slide 30

Reading data from application server or presentation server


Presentation server

WS_UPLOAD

ABAP/4 PROGRAM

Application server

Internal table

Read Dataset

India SAP CoE, Slide 31

Batch Input Methods


METHOD #1 CALL TRANSACTION USING STATEMENT

METHOD #2 METHOD #3

BATCH INPUT SESSION


DIRECT INPUT

India SAP CoE, Slide 32

Process flow of Batch Input Session


Opens the Session

Process BDC table for each record

Close the Session


India SAP CoE, Slide 33

Function Modules

Processing Batch Input sessions


When you create a batch input session, it remains in the batch input queue until it is explicitly started. Session processing can be started in two ways:

An on-line user can start the session using the batch input menu options. (To access the batch input options, choose System

Services Batch Input.)

SM35

You can submit the background job RSBDCSUB to start a session in background processing. If several sessions have the same name, RSBDCSUB starts them all.

India SAP CoE, Slide 34

Direct Input
To enhance the batch input procedure, the system offers the direct input technique, especially for transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but stores the data directly. It does not process screens. To enter the data into the corresponding database tables directly, the system calls a number of function modules that execute any necessary checks. In case of errors, the direct input technique provides a restart mechanism. However, to be able to activate the restart mechanism, direct input programs must be executed in the background only. To maintain and start these programs, use program RBMVSHOW or Transaction BMV0. It is better to use BDC method unless data volume is very high, as validations are very critical to data upload in SAP. Examples for direct input programs are:

India SAP CoE, Slide 35

Transaction Recorder (SHDB)


Before you work with the Batch Input methods, you should know the purpose of the tool Transaction Recorder. Use: You can use the transaction recorder to record a series of transactions and their screens. Features: You can use the recording to create Data transfer programs that use batch input or CALL TRANSACTION Batch input sessions Test data Function modules. Note: It doesnt record F1, F4 and Scrollbar movements
India SAP CoE, Slide 36

Scheduling a Background Job


Transaction SM36 Job Scheduling

Start date
General data Job name Job class

Steps

<job name> A Scheduled <target system for processing>

Status
Target host

India SAP CoE, Slide 37

LSMW
How LSMW works ?
Legacy data on PC

Structure relations

Read data

Read data
Legacy data on application server

Field mapping

Convert data Batch Input processing Converte d data Direct Input processing IDoc inbound processing

Conversion rules

India SAP CoE, Slide 38

IDoc Record Types


Control Record
IDoc-ID Sender-ID Receiver-ID IDoc type and logical message External structure IDoc-ID Sequence/Hierarchy Segment Format definition for
header data item data

Data Record

Status Record

IDoc-ID Status information

India SAP CoE, Slide 39

What is EDI & ALE ?


ALE Application Link Enabling Used mostly for SAP to SAP communication. Used in Distributed servers system. E.g. Say a Company has a central server at its head office and local servers at its branches. ALE is used to keep all the servers synchronized. Does not need EDI subsystem for communication. ALE is an SAP terminology. ALE is integrated with SAP product. EDI Electronic Data Interchange Used Mostly for communication between any 2 systems on different networks. E.g. Communication by a company with its Suppliers and Customers. Needs a EDI subsystem for communication EDI is a technology in itself. It has its own set of standards. SAP supports EDI through IDOCs.

India SAP CoE, Slide 40

Example of Document Exchange interface:


Customer RFQ Quotation Purchasing Purchase Order Order Acknowledgement Purchase Order Change Sales Vendor

Receiving

Shipping Notice

Shipping

Invoice Accounts Payment Details Customer Bank Vendor Bank Accounts

India SAP CoE, Slide 41

Intermediate Documents

(IDOCs)

What is an IDoc ? An IDoc is simply a data container that is used to exchange information between any two processes that can understand the syntax and semantics of the data.
India SAP CoE, Slide 42

IDoc Record Types


Control Record
IDoc-ID Sender-ID Receiver-ID IDoc type and logical message External structure IDoc-ID Sequence/Hierarchy Segment Format definition for
header data item data

Data Record

Status Record

IDoc-ID Status information

India SAP CoE, Slide 43

Agenda Hands On
Create A Database table. Create a report to upload data to the table. Attach a transaction to the report. Create a recording for the above transaction. Generate program for the recording. Write BDC program. Write LSMW.
India SAP CoE, Slide 44

Thank You!

India SAP CoE, Slide 45

Anda mungkin juga menyukai