Tuesday 6 May, 2008

SAP BI - Meta data tables

Below are some of the tables that contain info about BI reporting related queries, IOs, etc.

RSRREPDIR Number of queries available in BW system
RSZELTDIR Directory of the reporting component elements
RSZELTTXT Texts of reporting component elements
RSZELTXREF Directory of query element references
RSRREPDIR Directory of all reports (Query GENUNIID)
RSZCOMPDIR Directory of reporting components

Sunday 4 May, 2008

SAP Terminologies

ABAP/4 – Advanced Business Application Programming. SAP R/3 programming language.

ABAP Dictionary – central information base for developers, containing application-specific data.

ABAP Workbench – a set of tools for tailoring R/3 applications to individual requirements and for extending applications. It includes quality assurance and optimization tools. ABAP applications can be ported to a wide range of different platforms. It can also be used to develop software independent of SAP standard software.

Accelerated HR - a focused and customized configuration of SAP HR designed for a quick, cost effective implementation. By concentrating on the most essential aspects of SAP HR, Accelerated HR meets the immediate needs of most companies, including Human Resources Administration, Payroll, and Benefits Administration functionality.

Accelerated SAP – ASAP – methodology and tools to ease implementation of R/3.

ALE – Application Link Enabling – allows cooperative processing within a network of loosely coupled application systems (non-SAP, R/2 and R/3). ALE is based on an exchange of messages controlled by business processes and performed using consistent data; applications are integrated using asynchronous communications mechanisms.

APO - Advanced Planner & Optimizer. This is a key component of SAP’s New Dimension products. It is a complete suite of supply chain planner applications that enhance the flow of information and provide decision support through forecasting, planning and optimization.

ASAP – Accelerated SAP. A methodology focusing on system implementation.

BAPI – Business Application Programming Interface – methods providing direct communication between applications from different suppliers (e.g. COM or CORBA). BAPIs link SAP business objects and represent open business management interfaces.

Basis System – software that enables distribution of resources and system components. Basis software provides the runtime environment for the R/3 System applications and ensures that the applications are optimally embedded in the system environment.

BFA - Business Framework Architecture – independent business management components, integration technology, and open interfaces, combining to create a flexible, standards-oriented environment in which the R/3 System and software from external providers can cooperate in a dynamic way. Business Framework Architecture consists of: business components (e.g. HR), business objects (e.g. employees) and BAPIs.

BOM - Bill of Material

BOR – Business Object Repository – administers and maintains business objects (e.g. BAPIs).

Business Components - configurable software modules that collaborate via standard interfaces. The SAP Logistics module is an example of a Business Component.

Business Engineer - The Business Engineer lets you install and customize R/3 quickly and smoothly, at minimum cost and with maximum reliability. Fully integrated into the R/3 System, the Business Engineer supports you in analyzing, designing and configuring your business processes. It accesses the R/3 Reference Model and it includes: Process Models, Business Process Scenarios, Procedure Model, Implementation Guide.

Business Explorer – SAP Business Information Warehouse front end.

Business Explorer Analyzer – Micorsoft Excel front end to Business Explorer.

Business Information Warehouse – (SAP BW) provides decision-support functionality extending the mySAP.com Internet business strategy. It is a data warehouse including R/3 data and external data.

Business Navigator - provides a graphical view of business processes. It is part of the R/3 Basis and is used to access the R/3 Reference Model. Business Navigator also provides direct access to other parts of the SAP R/3 System such as Customizing, the Data Model, and business application transactions.

Business Objects - An SAP Business Object such as a "customer order," a "vendor," or an "employee," is used in SAP’s business processes.

Business Scenario – offers the specific knowledge, functions, and services that one or more users may need to succeed in a business task. mySAP.com provides a host of e­business solutions, including purchasing, collaborative planning, employee self service, direct customer servicing, and inter­business knowledge management. Business Scenarios will provide access to all R/3 and SAP New Dimension functionality. At present, several SAP Web­enabled Business Scenarios are being developed. In addition, role­based business scenarios soon will be available to help you leverage SAP applications and other data sources in ways that support all major roles in your enterprise. Business Scenarios will be delivered to customers on a role­by­role basis, so that customers can choose SAP functionality for the jobs they need. It is important to note that a Business Scenario can contain many roles, and these roles may differ from company to company. For example, a business­to­business Internet selling scenario might have a purchaser role, a seller role, and an approver role. The buyer would get only the purchaser role (unless he were also engaged in selling), and the seller would only get the seller role. Scenarios are role­based because users typically participate in business solutions as a member of a team, performing one specifically defined role. (In some cases a Business Scenario could have only one participant and therefore only one role.)

BW – Business Warehouse. The Business Warehouse provides management reporting, including non-SAP data sources into reports. This independent data warehouse solution summarizes data from R/3 applications and external sources to provide executive information for supporting decision making and planning. Reports cover a wide range of information requirements, automated data staging, and standard R/3 business process models.

CCMSComputing Center Management System – allows continuous monitoring of the R/3 System at the operating system, network, database, and application level.

CRM – Customer Relationship Management.

Digital Signatures – required to sign documents.

EDI – Electronic Data Interchange.

EPC – Event Driven Process Chain (a Reference Model view).

Enterprise Data Model – is the result of configuring R/3 to meet the needs of the enterprise.

GSS-API – Generic Security Services API – used as part of SAP SNC.

HAHTsite – from HAHT Software Inc, an SAP partner, a platform for extending R/3 to the Web, inlcuding an application server and an integrated development environment.

IDES - Internet (formerly International) Demonstration and Education System; a database with model companies used for training in R/3.

IDES TS – IDES Training System.

IDOC – Intermediate Document for exchange of information between systems. An IDOC is the data container for an exchange between SAP Systems or between SAP systems and external systems.

Organizational Architect – tool that allows the user to build the structure of their distributed applications.

IMG – Implementation Guide -a detailed, on-line methodology designed to assist in the configuration of the SAP R/3 System

INSM – Integrated Network and System Management – for large users, and optionally allows SNMP-MIB for integration of the R/3 System.

ITS – Internet Transaction Server (also known as the SAP Web Basis).

Knowledge Warehouse – (previously the InfoDB) provides a network of information resources for transferring knowledge and enhancing employee performance. The Knowledge Warehouse provides unstructured information, the Business Information Warehouse provides structured data.

LUW - Business transactions are processed as Logical Units of Work.

MAPI - MAPI is an acronym for Messaging Application Programming Interface. It is a standardized set of C functions placed into a code library known as a Dynamic Link Library (DLL). The functions were originally designed by Microsoft, but they have received support of many third party vendors. Having a standard library of messaging functions allows Windows application developers to take advantage of the Windows messaging subsystem, supported by default with Microsoft Mail or Microsoft Exchange. By writing to the generic MAPI interface, any Windows application can become "mail-enabled". Since MAPI standardizes the way messages are handled by mail-enabled applications, each such application does not have to include vendor-specific code for each target messaging system. The MAPI library is also available to Visual Basic application writers through a Basic-to-C translation layer.

MPS - Master Production Schedule

mySAP.com - an open collaborative business environment of personalized solutions on demand. It is a comprehensive basket of offerings that includes Internet­enabled applications, such as the Web­enabled core components of SAP R/3 , new enterprise and collaborative business scenarios, the personalized Workplace as enterprise portal, the Marketplace as a global e­business hub, and services like application hosting. mySAP.com goes a lot further than any one product or system. It is a real­time, collaborative, business solution environment. mySAP.com integrates seamlessly with existing R/3 functions, users of mySAP.com need not have R/3 installed, and R/3 can be used without mySAP.com. In essence if you have R/3 installed, then mySAP.com would sit on top of your applications. From Release 4.6 on, R/3 will be a mySAP.com component. mySAP.com can interoperate with R/3 from Release 3.1 on. Earlier R/3 releases can be connected on a project basis. Key elements of mySAP.com ­ the mySAP.com Workplace, collaborative Commerce Business Scenarios, the mySAP.com Marketplace, and Web­Based Application hosting, among others ­ will become available for customers in the third quarter of 1999. Industry­specific components will be provided on a continuous schedule over the following months till the end of first quarter of 2000. Other individual components of mySAP.com will follow their own availability and release cycles.

mySAP.com Marketplace - can be a confusing concept to new audiences because it is actually two things. It is the infrastructure that supports many of our collaborative Business Scenarios, allowing many buyers and sellers to come together to exchange goods, services, and information. It is also the name we currently are using to describe the Web portal that SAP hosts at www.mySAP.com. In 1999, the Marketplace features 20 communities of interest, 16 of which are focused on specific industries and 4 of which focus on topics that cross industry boundaries. More communities are being added all the time. Anyone can access and use the Marketplace via www.mySAP.com. Buyers as well as sellers can leverage the Marketplace without the need for any SAP software. If, however, the buyer does use the SAP procurement solution, the transaction between the buy and the sell sides takes place as a one­step transaction. That is, all necessary updates of the participating administrative systems are executed simultaneously, avoiding delays and error­prone manual steps between the Web front­ends and the back­end systems. mySAP supports transactions not only within the enterprise but also across enterprises. In addition, the mySAP.com Marketplace allows customers to leverage their existing ERP investments, whether those involve SAP or not.

mySAP.com Workplace – the personal, corporate portal by which business scenario customers access their personal business solutions environment. It is a customizable, Web­enabled doorway into R/3, offering additional functions and services beyond the core R/3 functions. In addition, it provides integration with other ERP solutions and non­ERP information sources including financial market data, news tickers, and industry­specific content. mySAP.com provides users with the ability to customize their desktop interfaces in ways that address their specific needs.

NC – Network Computers – Java-based SAPGUI allows NCs to be used as R/3 clients.

New Dimensions – see SAP New Dimention

OLTP – On-Line Transaction Processing

OSS – Online Service System.

PCT – Private Communication Technology security package from Microsoft.

PKCS#7 – industry standard format for signed or encrypted documents.

QMIS - Quality Management Information System.

R/2 System – for mainframe systems, providing integrated handling of all business routines in accounting, logistics, and human resources management.

R/3 Basis System (middleware) - The central SAP R/3 Basis System guarantees all application modules are integrated and platform-independent, since the SAP R/3 System is a modular, standard software system supporting all of a company’s business transactions. It includes: Client/server architecture, Application architecture, and System communication .

R/3 Information Database - SAP’s central information repository for the administration of all types of information.

R/3 Procedure Model - . a procedural guide for structuring an SAP implementation, to guide you through the different project phases step by step (from project generation to going live) in configuring R/3. A wide range of tried-and-true, graphically portrayed business scenarios and processes are stored in the R/3 Reference Model. From this wealth of experience you choose the best possible processes for your company.

R/3 Reference Model - a graphical description of best practice business processes – a tool that is provided to support configuration activities; it contains the knowledge base of the standard business functions available in R/3.

R/3 System – for client/server architectures, distributed applications among multiple computer levels, providing integrated handling of all business routines in accounting, logistics, and human resources management. R/3 is a multilayer Internet architecture with an open three-tier approach: presentation, application, and database layers.

R/3 Technology Infrastructure – middleware within the the R/3 System that enables application programs, the operating system, and the communications network to work together smoothly. It hides details of the technical implementation from users.

R/3-MIB – includes interfaces for controlling and monitoring applications and for alarm handling.

RAID – Redundant had disk capacity – supported by SAP.

SAP - Systems, Applications and Products in Data Processing

SAP Automation API – used in developing business processes that are independent of specific applications (– user interfaces, different GUIs, browsers?? etc.)

SAP Business Workflow – links information with active control of business processes; offers a MAPI compatible interface (e.g. for mail front-ends MS Outlook, Lotus CC:Mail, MS Exchange).

SAP BW - Business Information Warehouse.

SAP Internet Business Framework – provides a proven, open application server infrastructure for effectively and efficiently managing workflow. The Internet Business Framework supports the XML standard and provides a basis for context­rich Internet communication that can cross company firewalls. The Internet Business Framework allows customers to integrate SAP R/3 Releases 3.1H and higher. The Internet Business Framework uncouples the integration technology from the development language and runtime. This means that the software module that calls a certain service need not be written in the same language as the software module that provides the service. Rather, the software providing the service can be implemented in virtually any language (COM+ and EJB­compatible languages or ABAP Objects). SAP is already exploiting this flexibility. For example, SAP business solutions are implemented in Microsoft Excel, Sun Java, Microsoft C++ and Visual Basic, UNIX C++, and ABAP Objects all tied together via the Internet Business Framework.

SAP New Dimension – A suite of products beyond R/3. THis includes: Customer Relationship Management, Advanced Planner and Optimizer (supply chain management), Strategic Enterprise Management, Business to Business Procurement, Business Information Warehouse, Knowledge Management.

SAP R/3Enterprise Business Software.

SAPGUI – provides for organization-defined and user-defined menus, frequently used transactions in a personal directory.

SAPnet – Web Frontend/R3 Frontend – SAP’s online information and communication service (requires a password).

SAPoffice – provides an integrated communication service in R/3. Supports e-mail standard X.400 and MAPI interface. Templates in SAPoffice are used for general project documentation

SAPscript – R/3 integrated word processing tool.

SEM – Strategic Enterprise Management.

Session Manager – allows user customization for frequent transactions, manage parallel sessions in the same or different R/3 systems.

SET – Secure Electronic Transactions standard for Internet applications; integrated into R/3. SET is based on PCT from Microsoft and SSL from Netscape. These packages handle client authentication, server authentication, confidentiality, connection reliability and secure payment.

SNC – Secure Network Communications interface – R/3 can be integrated with any network security product that itself supports the GSS-API (e.g. Kerberos from MIT, SecuDE from GMD).

SNMP-MIB – Simple Network Mangement Protocol – Management Information Base) - for integration of the R/3 System.

SOP – Sales and Operations Planning.

SSF – Secure Store & Forward – allows R/3 data and documents to be encrypted and signed with digital signatures.

SSL – Secure Socket Layer security package from Netscape.

Supply Chain Cockpit – part of SAP Advanced Planner & Optimizer.

UPS – Uninterruptible Power Supply.

valueSAP – an SAP AG service to review and improve their customer’s ERP solutions and mix of productrs.

Web Reporting – allows reports and report hierarchies to be displayed as HTML documents in a Web browser.

WFMC – Workflow Management Coalition – workflow standards, between applications.

Workbench Organizer – records and documents all ABAP work, coordinates program changes.

Workflow (WF) – a module that links the integrated SAP R/3 application modules by managing the sequence of work activities and the invocation of appropriate human and/or IT resources with the various activity steps.

Workflow Client Application API - allows client programs from external suppliers to be integrated into the workflow.

Workflow Wizards – used to produce an executable workflow definition quickly and safely.

X.509 – industry standard for asymmetric encryption.

References

http://www.ryerson.ca/~ppille/sap/Resources/SAPterminology.htm

Writing a Virtual Characteristic or Key figure

Writing a Virtual characteristic is one which i really struggled to get on - more because of lack of material than the complexity itself.

Here, i have documented my approach to write one - hope it is a good reference for some one planning to write one.

CAUTION: Virtual char and KFs seriously impact the performance of the query; therefore use them with discretion.
---------------------------------------

Need for virtual char & KFs:

To do calculation/manipulation of char or KFs at query run-time

Walk-through:

We’ll go through the virtual char & KFs using this example.

‘Calc Date’ is an IO that holds the below logic

If Current Date > Revised Promise Date Then

Calc Date = ‘PD’

Else

Calc Date = Revised Promise Date

We shall see how this is implemented using virtual characteristics.

Step 1: Creation of dummy IO

Create a ‘dummy’ info object (without any mapping) that would be the holder for Calc Date

I created IO - ZCRPDTCLC.

Step 2: Associating IO to data target

Add this info object to the data target that would be used for reporting.

I added ZCRPDTCLC under DSO ZPP_DS06 and again to ZPU_M03 MP.

The next steps would involve writing the code for calculating Calc Date.

The code is written in 3 modules.

ZXRSRTOP - Global declaration of variables is done here

ZXRSRU02 - Mode of access for each of the IOs used in the exit is defined here.

ZXRSRZZZ - Association of the global variable to the actual IO is done here.

The exit logic is also written here.

Step 3: Global declaration of variables

Go to ZXRSRTOP module in ABAP editor (tcode se38)

In the ‘Include for Virtual Char’ block (it could be in other blocks also, code written here to make it more organized), declare global variables for Calc Date and Revised Promise Date (these are the objects that will be used in the calculation)

The global variables declared should be in the format –

g_pos__

Data type should be number.

Eg:

Data:

g_pos_ZPP_DS06_ZCRPDTCLC TYPE I,

g_pos_ZPP_DS06_ZCRPDT TYPE I.

Step 4: Defining mode of access for the IO.

Go to ZXRSRU02 module in ABAP editor (tcode se38)

There will be a single CASE block for structure i_s-rkb1d

Eg:

CASE i_s_rkb1d-infocube.

ENDCASE

This structure ‘i_s_rkb1d’ has all details regarding the query like query tech name, data target, etc.

Thereby, i_s_rkb1d-infocube will contain the data target for each query.

CASE i_s_rkb1d-infocube.

WHEN 'ZPP_DS06'.

* Fields to read

g_t_chanm-mode = rrke_c_mode-read.

g_t_chanm = 'ZCRPDT'.

APPEND g_t_chanm to e_t_chanm.

* Fields to write

g_t_chanm-mode = rrke_c_mode-no_selection.

g_t_chanm-chanm = 'ZCRPDTCLC'.

APPEND g_t_chanm to e_t_chanm.

ENDCASE.

We check the info cube attribute for the corresponding data target related to our query.

‘rrke_c_mode’ is the structure that defines the mode of access for each IO (read mode, write mode).

‘g_t_chanm’ is the structure that will hold the name of characteristics that will be used

‘g_t_kyfnm’ is the structure that will hold the name of key figures that will be used

In our example, we use only characteristics and hence only ‘g_t_kyfnm’ structure.

The rest of the code should be self-explanatory.

For each new object, you assign its tech name to ‘g_t_chanm_chanm’ object and append it to ‘e_t_chanm’ which is the output structure.

Similarly for key figures, ‘e_t_kyfnm’ is the output structure.However for key figures, there is no structure to set the mode of access (mode of access – read/write by default).

Another example to drive the point home:

* Characteristics and Units

g_t_chanm-mode = rrke_c_mode-read.

g_t_chanm-chanm = '0MATERIAL'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = '0PLANT'. append g_t_chanm to e_t_chanm.

g_t_chanm-mode = rrke_c_mode-no_selection.

g_t_chanm-chanm = 'PR_ID1'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'PR_ID2'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'PR_YEAR1'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'PR_YEAR2'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'PR_CURR1'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'PR_CURR2'. append g_t_chanm to e_t_chanm.

* Key Figures

append '0QUANT_B' to e_t_kyfnm.

append 'AMOUNT1' to e_t_kyfnm.

append 'AMOUNT2' to e_t_kyfnm.

For ‘g_t_kyfnm’ we need not set any mode.

Step 5: Writing the logic for virtual char/KF

Go to ZXRSRZZZ module in ABAP editor (tcode se38)

Here, create a new form for the data target being used.

Form name should be begin with ‘USER_’ followed by the data target’s name.

C_S_DATE is the structure that would hold the data in the query.

To access the IOs in the code, we have to create field symbols that act as aliases.

Then the global variables created are associated to these aliases using the ASSIGN statement.

The rest of the code involves the implementation logic as in the snippet below.

FORM USER_ZPP_DS06 USING I_S_RKB1D TYPE RSR_S_RKB1D

CHANGING C_S_DATE TYPE ANY.

DATA: L_DATE TYPE SCAL-DATE.

DATA: L_WEEK TYPE SCAL-WEEK.

CONSTANTS: PAST_DUE(2) TYPE C VALUE 'PD'.

FIELD-SYMBOLS: , .

ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDT OF STRUCTURE C_S_DATE TO .

ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDTCLC OF STRUCTURE C_S_DATE TO .

L_DATE = SY-DATUM. "Today's Date

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

DATE = L_DATE

IMPORTING

WEEK = L_WEEK.

IF L_WEEK GT . "If Current Week is greater than Revised Promise Date, Calc_Date holds "PD"

= PAST_DUE.

ELSE. "Calc_Date holds Revised Promise Date

= .

ENDIF.

ENDFORM.


Overall Program Flow for Calc Date

ZXRSRTOP

Data:

g_pos_ZPP_DS06_ZCRPDTCLC TYPE I,

g_pos_ZPP_DS06_ZCRPDT TYPE I.

ZXRSRU02

CASE i_s_rkb1d-infocube.

WHEN 'ZPP_DS06'.

* Fields to read

g_t_chanm-mode = rrke_c_mode-read.

g_t_chanm = 'ZCRPDT'.

APPEND g_t_chanm to e_t_chanm.

* Fields to write

g_t_chanm-mode = rrke_c_mode-no_selection.

g_t_chanm-chanm = 'ZCRPDTCLC'.

APPEND g_t_chanm to e_t_chanm.

ENDCASE.

ZXRSRZZZ

FORM USER_ZPP_DS06 USING I_S_RKB1D TYPE RSR_S_RKB1D

CHANGING C_S_DATE TYPE ANY.

DATA: L_DATE TYPE SCAL-DATE.

DATA: L_WEEK TYPE SCAL-WEEK.

CONSTANTS: PAST_DUE(2) TYPE C VALUE 'PD'.

FIELD-SYMBOLS: , .

ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDT OF STRUCTURE C_S_DATE TO .

ASSIGN COMPONENT g_pos_ZPP_DS06_ZCRPDTCLC OF STRUCTURE C_S_DATE TO .

L_DATE = SY-DATUM. "Today's Date

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

DATE = L_DATE

IMPORTING

WEEK = L_WEEK.

IF L_WEEK GT . "If Current Week is greater than Revised Promise Date, Calc_Date holds "PD"

= PAST_DUE.

ELSE. "Calc_Date holds Revised Promise Date

= .

ENDIF.

ENDFORM.



ABAP Basics

SAP R/3 - ABAP - BASICS

SAP originally developed the ABAP/4 (Advanced Business Application Programming) language for internal use. It is being constantly improved and modified to meet the needs of the business world. Today, ABAP/4 is the sole tool used by SAP to develop all of its applications. Now ABAP/4 is just called "ABAP", by SAP. The ABAP/4 Development Workbench (DW) contains all the tools needed to create and maintain ABAP programs. ABAP is a fourth generation language which supports structured programming. Some of its basic features include the following:

    ABAP/4 contains

    - declarative elements for declaring data of various types

    - operational elements for data manipulation

    - control elements for controlling the program flow

    - event elements for reacting external events

    ABAP/4 supports several languages. Text elements (e.g. titles, headers, and other text) are stored separately from the program code. You can change translate and maintain these at any time without changing the program code.

    ABAP/4 supports business data types and operations. You can perform calculations with special date and time fields.

    ABAP/4 contains a subset of SQL called Open SQL which will enable the user to read and access database tables regardless of the database system (Oracle, DB/2, etc.).

    ABAP/4 allows the user to define and process internal tables which exist only as long as the program is running. Internal tables make it easier to work with database tables.

    ABAP/4 allows you to define and call subroutines. You can also call the subroutines of other programs. Parameters can be passed to and from subroutines in various ways.

    ABAP/4 contains a special kind of subroutine known as a function module. You create and maintain function modules in a central library. They can be tested in a stand-alone mode independently of the calling program.

    There are two main types of ABAP/4 programs

- Report Programs
Report programs are used to analyze data from database tables. In reporting you use ABAP/4 Open SQL to read data from the R/3 database. A report consists of a selection screen, on which you define the data set you wish to display, and a list, which displays the data itself. Typically, reports merely read data from the database. However, it is also possible to make changes in the database using a report. Report programs are based on logical databases which are special ABAP/4 programs which provide access to all databases. List in SAP is called a report.
- Dialog Programs
Dialog programs are organized as module pools which contain dialog modules. Each "dynpro" (a Dynamic program which consists of a screen and its flow logic) is based on exactly one ABAP/4 dialog program. In dialog programming you use the Screen Painter to create screens and program the sequence in which they appear. You write a ABAP program (ABAP/4 module pool) for your screens. Dialog program is a SAP transaction.

Creating an ABAP Program

Creating a simple ABAP Program involves the following basic steps:
    Naming the program

    Specifying the program attributes

    Writing the program code

    Testing the program

The procedures described here apply to reports and short training programs. To create dialog programs (module pools for a new transaction, you can proceed in a different way than for a report program). There are two menu paths to create a new program.
Tools -> ABAP/4 Workbench; Choose ABAP/4 Editor; Enter a name for the program you want to create in the program field; Choose Create; ABAP/4 Program attribute screen appears.

Tools -> ABAP/4 Workbench; Choose Object Browser; Choose Program under Object List; Choose Program Objects under Single Object list; Enter the name of program and click Display. If the program does not already exist, you are asked whether you want to create it - yes

Some rules and conventions for naming a program
    Use at least one, but not more than eight, characters

    Do not use the following characters:

    - period .

    - comma ,

    - space

    - parentheses ( )

    - single or double quotation marks ' "

    - equal sign =

    - asterisk *

    - percentage % and underscore _

    Report programs (for outputting data analyses in list format): Yaxxxxxx or Zaxxxxxx. Replace a with the classification letter of the application area (f for finance, s for sales, etc.). Replace x with any valid character. SAP report programs follow a similar naming convention: Raxxxxxx.

    Any other ABAP/4 programs (training programs or programs for transactions); SAPMYxxx or SAPMZxxx. Replace x with any valid character. Standard SAP programs follow a similar naming convention: SAPMaxxx, where a represents an application area.

Program attributes

When you have assigned a name to the program and chosen Create on the ABAP/4 editor: the Program Attributes screen appears - To enter the program attributes:
    Enter the title for the program in the field Title. Choose a title which describes the function of the program. The system automatically incorporates the title in the text elements. If you want to change the title later you can change it: Choose Text Elements or Attributes on the ABAP/4 Editor: Initial Screen, Choose Change.

    Complete the two mandatory fields Type and Application

- For a report program enter 1 and for module pool enter M in the Type. You can look at possible values in the list box.

- Enter the classification letter for your application in the Application field i.e. F for financial accounting

If you are creating a report (type = 1) Choose, Enter. The system automatically inserts input fields for report specific attributes:
    Type

    Apart from type 1 and type M, there is a type I for include programs. An include program is an independent program which contains program code, that can be used by different programs. In addition, include programs serve to modularize program source codes into logically related parts. Each of these parts is stored in a different include program. Include programs improve readability of source code and facilitate maintenance.

    Development Class

    The development class is important for transporting between systems. When performing a transport, you can combine workbench objects (different programs, tables, transactions, etc.) assigned to one development class together. If you are working in a team, you may have to assign your program to an existing development class or create a new one. Programs assigned to development calass $TMP are private objects and can not be transported to other systems. You can, however change the development class to which a program is assigned by choosing Program -> Reassign on the ABAP/4 Editor, Initial Screen.

    Logical database from application (report programs only)

    These attributes determine which logical database the report uses to retrieve data and to which application the logical database belongs. Database names within an application must be unique. However, the entire system may contain several databases with the same name. It is therefore important to specify an application. If your program reads data directly instead of using a logical database, you should specify an application as usual but leave the logical database field blank.

    Selection Screen Version (report programs only)

    If you do not specify a selection screen version, the system automatically creates a selection screen based on the logical database selection criteria. If you want to use your own selection screen, enter a number in this field. The number must be smaller than 1000.

    Editor lock

    If you set this attribute, other users cannot modify, rename, or delete your program. Only you can release the lock.

    Fixed point arithmetic

    If you set this attribute the system rounds type P fields according to the number of decimal places.

After entering the program attributes save the attributes by choosing Save. Maintain Object Catalog Entry window appears. Enter the development class $TMP or choose Local Object. Save the development class by choosing Save. You will be now in the Program Attributes Screen.

Leave the screen by choosing back. If you want to branch to the ABAP/4 editor directly,

choose Goto -> Source code.

Writing the Program

You write your ABAP/4 program in the ABAP/4 editor. Choose Source Code in the ABAP/4 Program Attributes Screen, or Select Source Code and Choose Change on the ABAP/4 Editor - Initial Screen.

The ABAP/4 Editor: Edit Program screen appears. The editor can run in three different modes: "Command Mode", "PC Mode with line numbering", and "PC Mode without line numbering". You can switch between editor modes by choosing Settings -> Editor Mode. The system automatically enters the first ABAP/4 statement, e.g. REPORT or PROGRAM . For report name/ program name the system uses the name you entered on the ABAP/4 Editor: Initial Screen.

Enter the program code. Check the Syntax by choosing Check. The system then scans the program code for any syntax errors and incompatibilities. In an error, is detected, a message appears to report this and, if possible proposes a solution or correction. The cursor is placed in the appropriate position. Then save the code by choosing Save. The source text is stored in the program library. You can also change the source code of the program by Choosing Change from ABAP/4 editor. You can again check for syntax errors after making changes and then save the source code. If the development class is $TMP the changed version is saved immediately. If it is not $TMP you see a window where you can specify a correction number.

Testing the Program

Test the program to check whether the code works correctly. Choose Program -> Execute on the ABAP/4 Editor: Edit Program screen. If you are creating an ABAP/4 program module (dialog programs), you must create a transaction code before running the program. For testing purposes, you can run a program that is not part of a module pool without saving it first. The editor keeps a temporary version containing the changes. However, you must return to the editor after the test is over to ensure that all changes are saved.

Assigning Transaction Codes to Report Programs

You can assign transaction codes to standalone programs of type 1 and handle these programs like transactions afterwards. Choose Development -> Further tools -> Transactions at the ABAP/4 DW screen.
Fill in a name for the transaction and choose Create on Maintain Transaction screen.
Select Report Transaction on the following dialog window. Fill in required entries Transaction Text and Program on the Crate Report Transaction screen. Save the transaction code in a development class.

ABAP/4 Program Syntax

Syntax Elements
Statements - must end with a period. First word should be a key word.
PROGRAM SAPMTEST.

WRITE 'FIRST PROGRAM'.

Keywords
Declarative Keywords
Define data types or declare the data objects which the program can access. Ex: TYPES, DATA, TABLES They are processed independently of their position in the program.
Event Keywords
Define processing blocks in a program. Processing blocks are groups of statements which are processed as soon as a particular event occurs. Ex: AT SELECTION SCREEN, START-OF-SELECTION, AT USER-COMMAND
Control Keywords
Control the flow of a program according to certain conditions. Ex: IF, WHILE, CASE
Operational Keywords
The process the data (defined by declarative keywords) when certain events (triggered by event keywords) and conditions (defined by control keywords) occur. Ex: WRITE, MOVE, ADD
Comments
Comments are text elements which you can write between the statements of the ABAP program to explain the purpose to a reader. Comments are flagged by special characters which cause the system to ignore them. Comment should be used to document the program. Example:
**********************************************

* PROGRAM SAPMTZTST

* Created by Dr. Prattipati, 11/22/1998

* Last Change by Dr. Grambo 11/23/1998

* Purpose Demonstration

***********************************************

PROGRAM SAPMTZTST

***********************************************

* Declaration Part

***********************************************

DATA.....

All lines beginning with an asterisk (*) are comments and are ignored by the system.

Syntax Structure

An ABAP program is a sequence of different statements which have a particular structure. Comments can be inserted between statements. Sequences of separate, but similar, statements can be combined into chain statements. There are no format restrictions. Statements can be entered in free format. This means that you can indent statements, write several statements on one line, or extend one statement over several lines.Words within a statement must be separated with at least one space. You can insert comment lines anywhere in a program. If you want to entire line to be a comment enter an asterisk (*) at the beginning of the line. If you want part of a line to be a comment, enter a double quotation mark (") before the comment. Some examples of valid Syntax Structures:
***********************************************
REPORT SAPMZTST.

TABLES SPFLT.

GET SPLFI.

WRITE SPFLI-CITYFROM.

WRITE SPFLI-CITYTO.

WRITE SPFLI-CITYTO UNDER SPFLI-CITYFROM.
*************************************************

PROGRAM SAPMZTST.

WRITE 'THIS IS A STATEMENT'.

Could also be written as

PROGRAM SAPMZTST. WRITE 'THIS IS A STATEMENT'.

**************************************************

Statement sequence

WRITE SPFLI-CITYFROM.

WRITE SPFLI-CITYTO.

WRITE SPFLI-AIRPTO.

Chain statement

WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.

You could also write these statements as

WRITE: SPFLI-CITIYFROM,

SPFLI-CITYTO,

SPFLI-AIRPTO.

**************************************************

Statement sequence;

SUM = SUM + 1.

SUM = SUM +2.

SUM = SUM + 3.

SUM = SUM + 4.

Can be written as a chain statement

SUM = SUM +:1,2,3,4.

****************************************************

Concepts of Data Types & Objects

Data types in ABAP are classified by structure and definition. Data types are either:
    elementary (non-structured) or structured

    Pre-defined or user-defined

Elementary Data Types - Pre-defined
C -- Text, character (alpha numeric characters default size = 1)

D -- Date format (yyyymmdd)

F -- Floating point number - accuracy range upto 15 decimals

I -- Integer (whole numbers - fractions are rounded not truncated)

N -- Numeric text (Telephone numbers, IDs, Account numbers, etc.)

P -- Packed Number - allows digits after the decimal point - "Fixed Point arithmetic" - rounds to the nearest decimal point specified. Used for such values as distances, weights, amounts of money, etc.

T -- Time format (HHMMSS)

X -- Hexadecimal

Numeric pre-defined data types: I,P, and F

Elementary Data Types - User defined
User defined elementary data types are based on pre-defined elementary data types. To define your own elementary data types, you use the TYPES statement. Examples are given later.

Structured data types

In general, structured data types in ABAP programs are user defined. There are two kinds of structured data types:
    Field Strings: A consecutive collection of other data types. A data object with a field string data type occupies a continuous area in the memory. The components of the field strings can themselves field strings or internal tables. The field strings are defined with TYPES statement or with the DATA statement

    Internal tables: An internal table consists of several lines of the same type. Unlike field strings, which extend only horizontally, internal tables also extend vertically. You define internal tables with OCCURS parameter of the TYPES or DATA statements.

Data Objects

In ABAP/4 you can work with several kinds of data objects, such as:
Internal data objects: They are created for use in one particular program. They have no validity outside this program. Internal data objects are literals (text literals, and number literals), variables and constants. Text literals are sequences of alphanumeric characters enclosed in single quotation marks ex: 'Antony Smith'. Example of number literals: '-8473.67'.

Variables: A variable is used to store and reference data under a certain name and in a certain format. Variables can differ in name, type, length, and structure. You declare variables in your program with the DATA statement.

Constants: A constant is a data object containing a value which you fix at initialization. Their values can not be changed during the execution of the program. You declare constants with the CONSTANTS statement. Use constants if you need specific value frequently in your program. In this case do not use literals.

External Data Objects: External data objects exist independently of programs. You can not work with them directly, but you can copy them to internal data objects and write them back when you have finished. External data objects can be used globally throughout the system environment. External data objects are stored in tables defined in ABAP/4 dictionary. To access this data from within a program, you declare the tables in the program with the TABLES statement.

System Defined Data Objects: Some data objects are defined automatically by the system and do not need to be declared. System-defined data objects include: SPACE (constant of type C) and SYSTEM FIELDS. All system fields have names with the format SY-. Some examples of system fields are: SY-SUBRC (return code value '0' if an operation is successful) SY-UNAME (log on name of the user), SY-DATUM (current date), SY-UZEIT (current time), SY-TCODE (current transaction), etc.

Special Data Objects: ABAP/4 also includes some data objects with special features - namely: PARAMETERS, and SELECTION CRITERIA.

Declaring Data - Examples

Pre-Defined Elementary Data Types and Objects
PROGRAM SAPMZTST.

DATA TEXT1 (14) TYPE C.

DATA TEXT2 LIKE TEXT1.

DATA NUMBER TYPE I.

TEXT1 = 'The Number'.

NUMBER = 100.

TEXT2 = 'is an integer.'.

WRITE: TEXT1, NUMBER, TEXT2.

OUTPUT: The Number 100 is an integer.

In this example the data objects TEXT1, TEXT2, and NUMBER are declared with data statement. The data type of each is specified with the TYPE or the LIKE parameter of the DATA statement. The data types used here (C,I) are pre-defined in the system. The values are assigned to the data objects, contents of which are displayed.

**********************************************************************

User Defined-Elementary Data Types and Objects

PROGRAM SAPMZTST.

TYPES MYTEXT (10) TYPE C.

TYPES MYAMOUNT TYPE P DECIMALS 2.

DATA TEXT TYPE MYTEXT.

DATA AMOUNT TYPE MYAMOUNT.

TEXT = '4 /3 = '.

AMOUNT = 4/3.

WRITE : TEXT, AMOUNT.

Output: 4 /3 = 1.33

Here user-defined data types MYTEXT and MYAMOUNT are defined with the TYPES statement with reference to elementary data types that are pre-defined in the system. Then the data objects TEXT and AMOUNT are declared with DATA statement. Their data types are determined to be MYTEXT, and MYAMOUNT.

*******************************************************************

Example of field Strings (Structured)
PROGRAM SAPMZTST.

TYPES: BEGIN OF NAME,

TITLE (5) TYPE C,

FIRST_NAME (10) TYPE C,

LAST_NAME (10) TYPE C,

END OF NAME.

TYPES: BEGIN OF MYLIST,

CLIENT TYPE NAME,

NUMBER TYPE I,

END OF MYLIST.

DATA LIST TYPE MYLIST.

LIST-CLIENT-TITLE = 'Lord'.

LIST-CLIENT-FIRST_NAME = 'Howard'.

LIST-CLIENT-LAST_NAME = 'Mac Duff'.

LIST-NUMBER = 1.

WRITE LIST-CLIENT-TITLE.

WRITE LIST-CLIENT-FIRST_NAME.

WRITE LIST-CLIENT-LAST_NAME.

WRITE / 'Number'.

WRITE LIST-NUMBER.

Output: Lord Howard Mac Duff

Number 1

In this example, the structured data types NAME and MYLIST are defined with the TYPES statement. The field string, NAME contains three components, TITLE, FIRST_NAME, and LAST_NAME, which have pre-defined elementary data type C. The field string MYLIST contains two components, namely CLIENT and NUMBER, CLIENT it self is already structured because it is given data type NAME. A structured data object LIST is declared with data type MYLIST. Values are assigned to the components and their contents are then displayed.

******************************************************************

Example of Internal Tables
PROGRAM SAPMZTST.

TYPES: BEGIN OF MYSTRING,

NUMBER TYPE I,

NAME TYPE C,

END OF MYSTRING.

TYPES MYTAB TYPE MYSTRING OCCURS 5.

DATA STRING TYPE MYSTRING.

DATA ITAB TYPE MYTAB.

STRING-NUMBER = 1. STRING-NAME = 'John'.

APPEND STRING TO ITAB.

STRING-NUMBER = 2. STRING-NAME = 'Paul'.

APPEND STRING TO ITAB.

STRING-NUMBER = 3. STRING-NAME = 'Ringo'.

APPEND STRING TO ITAB.

STRING-NUMBER = 4. STRING-NAME = 'George'.

APPEND STRING TO ITAB.

LOOP AT ITAB INTO STRING.

WRITE: / STRING-NUMBER, STRING-NAME.

ENDLOOP.

Output

1 John

2 Paul

3 Ringo

4 George

First a data type MYSTRING is defined as a field string. Then, based on field string MYSTRING, a data type MYTAB is defined as an internal table with the OCCURS parameter of the TYPES statement. The data objects STRING and ITAB are declared with data types MYSTRING and MYTAB. The fields of the internal table ITAB are then filled line by line. By using the field string STRING, the contents of ITAB are displayed on the screen.

__________________________________________________________________________________________________________________________

Compilation - Arun KK