ABAP4 Dialog Programming Basics

download ABAP4 Dialog Programming Basics

of 64

Transcript of ABAP4 Dialog Programming Basics

  • 8/3/2019 ABAP4 Dialog Programming Basics

    1/64

    ABAP/4 Dialog programming Basics

  • 8/3/2019 ABAP4 Dialog Programming Basics

    2/64

    Contents Introduction to ABAP

    ABAP/4 Development Architecture

    Why Dialog programming

    Differences between report & Dialog programming

    Structure of a Dialog program with example transaction.

    Main components in Dialog programming. Screen painter in ABAP/4.

    Menu painter in ABAP/4.

    Interaction between screen painter and ABAP/4 modules.

    How communication is maintained in ABAP/4 modules.

    How to create simple dialog program with screen shots.

    Testing the transaction.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    3/64

    Introduction to ABAP

  • 8/3/2019 ABAP4 Dialog Programming Basics

    4/64

    ABAP/4 Features

    ABAP/4 is a programming language developed by SAP for theinteractive development of application programs. ABAP/4 is a fourth-generation programming language that is thebackbone of the R/3 System. The language is event-driven with user actions and systemevents controlling the execution of the applications.

    You can use the ABAP/4 programming language to create entirelynew client/server applications, as well as extend existing R/3modules, which is the most common use of the ABAP/4language.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    5/64

    The Development Workbench provides access to SAPs development tools.

    R/3Repository

    Function

    Modules

    MenuPainter

    ScreenPainter

    ReportingABAP/4Editor

    ABAP/4Dictionary

    Data

    Modeller

    ABAP/4 Development Workbench Architecture

  • 8/3/2019 ABAP4 Dialog Programming Basics

    6/64

    All programs are stored in the R/3 Repository.

    A program is simply an object.

    All definitions are kept in the data dictionary.

    e.g. variable descriptions and parameters of fields.

    Double-clicking will navigate you to wherever the object isstored.

    Remote call functions let you access other systems.

    ABAP/4 Development Workbench Architecture (cont)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    7/64

    1.Reports

    A report program in ABAP/4 is a program which reads and analyzes datafrom database tables without modifying the database.

    2. Dialog programming

    In dialog programming you use the Screen Painter to create screens andprogram the sequence in which they appear. You write an ABAP/4program (ABAP/4 module pool) for your screens. This is a collection ofdialog modules which are called by the flow logic of your screens. Youuse dialog programs for both reading and changing database tables.

    ABAP/4 Programming Types

  • 8/3/2019 ABAP4 Dialog Programming Basics

    8/64

    Report Vs Dialog Program

  • 8/3/2019 ABAP4 Dialog Programming Basics

    9/64

    Reports and dialog programming

  • 8/3/2019 ABAP4 Dialog Programming Basics

    10/64

    Why Dialog programming A dialog program must offer:

    a user-friendly user interface

    format and consistency checks for the data entered by the user

    easy correction of input errors

    access to data by storing it in the database.

    ABAP/4 offers a variety of tools and language elements to meetthe requirements for creating and running dialog programs

  • 8/3/2019 ABAP4 Dialog Programming Basics

    11/64

    Structure of a Dialog Program A dialog program consists of the following basic components:

    Screens (dynpros) Each dialog in an SAP system is controlled by dynpros. A dynpro

    (Dynamic Program) consists of a screen and its flow logic and controlsexactly one dialog step. The flow logic determines which processingtakes place before displaying the screen (PBO-Process Before Output)and after receiving the entries the user made on the screen (PAI-Process

    After Input).ABAP/4 module pool Each dynpro refers to exactly one ABAP/4 dialog program. Such a

    dialog program is also called a module pool, since it consists ofinteractive modules. The flow logic of a dynpro contains calls ofmodules from the corresponding module pool. Interactive modules

    called at the PBO event are used to prepare the screen template inaccordance to the context, for example by setting field contents or bysuppressing fields from the display that are not needed. Interactivemodules called at the PAI event are used to check the user input and totrigger appropriate dialog steps, such as the update task.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    12/64

    Structure of a Dialog Program (Flow)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    13/64

    Sample Transaction

  • 8/3/2019 ABAP4 Dialog Programming Basics

    14/64

    Transaction ExplanationThis transaction consists of one dynpro only. The user enters the

    ID of an airline company and a flight number to request flightinformation. When the user chooses Display, the system retrievesthe requested data from the database and displays it.

    SAP Transaction Screens An R/3 transaction is a series of business-related, logically

    consistent dialog steps. The transaction uses a program thatconducts a dialog with the user. In a typical dialog, the systemdisplays a screen on which the user can enter or requestinformation. As a reaction on the the user input or request, the

    program executes the appropriate actions: it branches to thenext screen, displays an output, or changes the database.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    15/64

    Transaction Flow

  • 8/3/2019 ABAP4 Dialog Programming Basics

    16/64

    Main Components of a Dialog Program

    You use the Screen Painter and the Menu Painter to create anddesign screen templates and screen programs.

    You define the processing logic in an ABAP/4 program (modulepool).

    Data structures are defined in the ABAP/4 Dictionary. You canaccess these structures from the ABAP/4 program and whendefining screen fields.

    The dialog processor controls the flow of your dialog program.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    17/64

    Main Components of a Dialog Program Overview

  • 8/3/2019 ABAP4 Dialog Programming Basics

    18/64

    Dynpro

    . Each screen contains fields used to display or requestinformation. Fields can be text strings, input or output fields,radio buttons, checkboxes, or pushbuttons.

    An SAP dynpro consists of several components: Flow logic: Calls of the ABAP/4 modules for a screen. Screen layout: Positions of the texts, fields, pushbuttons, and

    so on for a screen.

    Screen attributes: Number of the screen, number of thesubsequent screen, and others.

    Field attributes: Definition of the attributes of the individualfields on a screen.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    19/64

    DYNPRO PARTSParts of dynpro (screen) will be like this.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    20/64

    Screen painter In ABAP/4To create a screen, take the following steps:

    Define the basic features of a screen (screen attributes) Design the screen layout (in the full screen editor)

    Define the field attributes (field list)

    Write the screen flow logic

    The most important ABAP/4 program components are found in thefollowing objects:

    Global data or Dictionary structures in the TOP include program(data declarations)

    PBO (Process Before Output) module PAI (Process After Input) module

    Subroutines (if required)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    21/64

    Screen painter-ABAP/4 (cont)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    22/64

    ABAP/4 Module PoolIn the Object Browser, the module pool code belongs to one of the

    following categories:

    Global fields: data declarations that can be used by all modulesin the module pool

    PBO modules: modules that are called before displaying thescreen

    PAI modules: modules that are called in response to the userinput

    Subroutines: subroutines that can be called from any positionwithin the module pool .

  • 8/3/2019 ABAP4 Dialog Programming Basics

    23/64

    ABAP/4 Module Pool (cont)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    24/64

    Interactions between Screens and ABAP/4 Modules

    In its most simple form, a transaction is a collection of screensand ABAP/4 routines, controlled and executed by a dialogprocessor. The dialog processor processes screen after screen,thereby triggering the appropriate ABAP/4 processing for eachscreen.

    For each screen, the system executes the flow logic that containsthe corresponding ABAP/4 processing. The control passes fromscreen flow logic to ABAP/4 code and back.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    25/64

    Interactions between Screens and ABAP/4 Modules (cont)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    26/64

    ommunication: ScreenABAP/4 Module pool

  • 8/3/2019 ABAP4 Dialog Programming Basics

    27/64

    Overview: Creating a Dialog Program In the following, we are going to create a dialog program which

    displays a planned flight connection. On the first screen, the usercan enter values for the key fields of the planned flightconnection. On the second screen, the system displays thecontents of the corresponding entry in table SPFLI.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    28/64

    Creating a ProgramExplanationYou create your program (ABAP/4 module pool) in the ABAP/4

    Development Workbench. Customer dialog programs must be called SAPMZxxx or SAPMYxxx.

    The TOP include program contains only the PROGRAM statement at first,but will later also contain all data declarations and TABLES statements(global data).

    If you are working with includes, the system proposes names for them

    according to the following convention: The first 5 characters of thename are the same as the last 5 characters of the program name. Thesixth character is an identification code for the particular contents of theinclude, for example, O for a PBO module, F for form routines(subroutines). The seventh and eighth characters are 01, except in thecase of the TOP include. Example: the TOP include for ABAP/4 modulepool SAPMZXXX would be MZXXXTOP; the include for the PAI module of

    this program would be MZXXXI01. In the program attributes, you maintain the title, the program type and

    the application. For program type, enter the value M (module pool) andselect appropriate application.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    29/64

    Creating a Program Overview

  • 8/3/2019 ABAP4 Dialog Programming Basics

    30/64

    Creating dialog program from SE80Step1 : Go to SE80 select package and right click to create program .

  • 8/3/2019 ABAP4 Dialog Programming Basics

    31/64

    Step2 : Give program name like SAPMZSAMPLEPRG

    Creating dialog program from SE80 (cont)

  • 8/3/2019 ABAP4 Dialog Programming Basics

    32/64

    Step3 : TOPINCLUDE will be created with name MZSAMPLEPRGTOP.

    TOP include Creation

  • 8/3/2019 ABAP4 Dialog Programming Basics

    33/64

    Step 4 : Give the title and select the program attributes as TYPE : MStatus : S. save it in the package.

    Saving Program

  • 8/3/2019 ABAP4 Dialog Programming Basics

    34/64

    Main program viewThe main program screen will appear like this, with TOP include and

    PBO,PAI includes commented at first.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    35/64

    PBO,PAI Includes creationTo create PBO,PAI include for screen right click on program->create->

    PBO module (OR) uncomment PBO,PAI include in main program and

    double click to create.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    36/64

    Complex structure of Main program

  • 8/3/2019 ABAP4 Dialog Programming Basics

    37/64

    Defining screens

  • 8/3/2019 ABAP4 Dialog Programming Basics

    38/64

    To create screen for TransactionRight click on program to create screen.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    39/64

    Screen creation initial screenProvide the screen number and proceed.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    40/64

    Screen AttributesProvide the details and save it.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    41/64

    Screen Flow Logic Screen will contain attributes, elements list, flow logic parts.

    Flow logic part will as in below screen.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    42/64

    Creating PBO,PAI ModulesUncomment PBO module (MODULE STATUS_9000) and double to

    create and the appropriate subroutine. similarly for PAI module.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    43/64

    some points about Screen painter Screen Layout (Graphical Screen Painter) .

    To design screens, you use the Screen Painter.

    The interface of the graphical Screen Painter contains easy-to-usefunctions for defining the various screen elements (e.g. input/outputfields, field texts, boxes, etc.). You choose each screen element and

    position it on the screen using the mouse. This is WYSIWYGgraphical design using drag-and-drop.

    To delete screen elements, you select the element with the mouseand then choose Delete.

    To move screen elements, you use the mouse to drag the element to

    the required position.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    44/64

    Graphical Drawing Elements

    Current Field Properties

    Field AttributesImport Dictionary/Tables Fields

    Field List

    sample screen of Screen painter

    Flow logic

  • 8/3/2019 ABAP4 Dialog Programming Basics

    45/64

    Screen LayoutClick on lay out it will take to screen painter.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    46/64

    DICT/PROG fields initial screenClick on (F6) or get form dictionary\program then screen will be like this.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    47/64

    Dict/Program Fieldsselection viewTable/Field NameSelect Field/s

    Copy Field/s to Screen Painter

    Retrieve Table/Field

    From

  • 8/3/2019 ABAP4 Dialog Programming Basics

    48/64

    Selecting Fields required on ScreenProvide table name and click on get from dictionary button. and

    select required fields. and click on enter to place on screen.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    49/64

    Placing required fields on screen

  • 8/3/2019 ABAP4 Dialog Programming Basics

    50/64

    Cosmetic changes on screenArrange some boxes around fields to look good and provide appropriate

    names to them.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    51/64

    Screen Design

  • 8/3/2019 ABAP4 Dialog Programming Basics

    52/64

    Ok_code Declaration in screen elements listIn elements list declare ok as ok_code and in program ok_code like

    sy-ucomm.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    53/64

    In PBO Code SET PF-STATUS will be commented initially. uncomment SET

    pf-status and give status name in caps (ZSAMPLE),double click to create.

    PBO initial code

  • 8/3/2019 ABAP4 Dialog Programming Basics

    54/64

    Status Creation (Menu painter)It will go to se41(menu painter), after filling The initial screen details

    select function buttons required the screen will appear like this.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    55/64

    Menu painter OverviewUse of Menu Painter

    You use the Menu Painter to define functions on a screen in aparticular status and assign them to the appropriate menu bar,standard toolbar and application toolbar.

    You also define the title.

    In general, you define a menu bar for each dialog program andassign it to a status. For each status, you define which menufunctions are to be active/inactive.

    All the statuses of a dialog program make up the user interface. Ifyou add a new status, you have to regenerate the interface.

    You assign a status and a title to a screen in the appropriate PBOmodule using the SET PF-STATUS and SET TITLEBAR statements

    respectively. The status can be up to 8 characters long, while thetitle code should consist of no more than 3 characters.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    56/64

    Setting PF-status For screen Select the functions required on the screen and provide names.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    57/64

    PBO Module CodeFinal PBO code will be like this. with code for selected functions on screen.

    (PBO Include).

  • 8/3/2019 ABAP4 Dialog Programming Basics

    58/64

    PAI Module CodeIn the PAI module write the code code for display button (PAI Include).

  • 8/3/2019 ABAP4 Dialog Programming Basics

    59/64

    Transaction creationCreate transaction to test the report.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    60/64

    Transaction creation initial screen It will take to SE93 (transaction creation initial screen). give name as

    ZSAMPLE ,provide short text &object type save it, activate it.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    61/64

    Test Transaction Click on F8 to test the transaction on se93of transaction or give

    transaction name on command filed or on se80 right click on

    transaction->execute->direct processing. Provide the carrid and connid in the respective fields and click on

    display for result.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    62/64

    ResultThe required details will be displayed on the corresponding fields in the

    same screen.

    Conclusion

  • 8/3/2019 ABAP4 Dialog Programming Basics

    63/64

    Conclusion

    This is the way we will create dialog program .

    We can also insert, update the data from database with thisscreen by adding some other buttons and we can also Add tablecontrol on the screen by Using Dialog programming.

    The PPT will cover the Basics ,I hope it will be helpful for beginners.

  • 8/3/2019 ABAP4 Dialog Programming Basics

    64/64

    References

    References:

    www.help.sap.com

    http://www.help.sap.com/http://www.help.sap.com/