Upload
rajiv-kumar
View
214
Download
0
Embed Size (px)
Citation preview
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 1/12
Programming an Application:
Programming an Application
ABAP/4 Programs can be report or dialog programs.
Reports:
As you have previously explored, a report is a program that typically reads and analyzesdata in database tables ithout changing the database.
!ialog Programs:
A dialog program allos you to or" interactively ith the
system and to change the contents o# the database tables.
$ach dialog program has a certain se%uence o# screens that
are processed by the system one a#ter the other. &rom the vie o# a user, a dialog step consists o# receiving
a screen #or entering data, then a#ter the users clic"s a
button or selects a menu entry, processing is started. &romthe vie o# the 'AP system, the screen is prepared and
sent. A#ter this, the user receives it and #ills it out. (hen the
system analyzes and processes the data contained on thescreen a#ter receiving it #rom the user.
A dialog program must o##er:
a user)#riendly user inter#ace
#ormat and consistency chec"s #or the data entered
by the user
easy correction o# input errors
access to data by storing it in the database.
ABAP/4 o##ers a variety o# tools and language elements to
meet the re%uirements #or creating and running dialog
programs.
'ample (ransaction: 'ample (ransaction
(ransaction (*+ -development class '!A is delivered ith thesystem. (his transaction consists o# one dynpro only. (he user enters the
0! o# an airline company and a #light number to re%uest #light in#ormation.
hen the user chooses !isplay, the system retrieves the re%uested data
#rom the database and displays it.
'AP (ransaction 'creens:'AP (ransaction 'creens
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 2/12
An R/1 transaction is a series o# business)related, logically consistent
dialog steps. (he transaction uses a program that conducts a dialog ith
the user. 0n a typical dialog, the system displays a screen on hich the user can enter or re%uest in#ormation. As a reaction on the the user input or
re%uest, the program executes the appropriate actions: it branches to the
next screen, displays an output, or changes the database.$xample (ransaction
A travel agent ants to boo" a #light. (he agent enters the corresponding
data on the screen. (he system either con#irms the desired re%uest, that is,the agent can boo" the #light and the customer travels on the desired day
on the reserved seat to the chosen destination, or the system displays the
in#ormation that the #light is already boo"ed up.
Processing (ransactionso Recall that an R/1 23 -2ogical 3nit o# or" is all the dialog steps o# a
transaction plus the update in the database. &rom a database vie, an
23 is the change o# the database #rom one logically consistent state to
the next.o (ransactions are processed by the R/1 system in a combination o#
dispatcher, or" processes, en%ueue/de%ueue server, message handler, andupdate tas"s.
o (he processing o# individual steps o# an R/1 transaction or R/1 23 can
be done by di##erent or" processes. (his is hy it is important todi##erentiate beteen R/1 23 and database 23 because there are no
process)spanning transaction processes in database management systems.
o &or a 'AP transaction, the graphical representation o# the screen and
related processing logic is called a dynpro -dynamic program. $ach
dynpro consists o# a PB/PA0 module to prepare and process the data
displayed or entered on the screen.o PB -Process Be#ore utput: A processing event hich is called be#ore
the screen is displayed. 0ts tas"s include the initialization o# the screen
#ields and supply de#ault data values #or the screen.
o PA0 -Process A#ter 0nput: A processing event ta"ing place a#ter you leave
a screen. 0ts tas"s are to process the input data or initiate the update o# the
database.
o PB and PA0 processing are speci#ic 'AP activities5 hoever, they are
similar to other processing that occurs ith screen processing in general.
'tructure o# a !ialog Program:
'tructure o# a !ialog ProgramA dialog program consists o# the #olloing basic components:
'creens -dynpros$ach dialog in an 'AP system is controlled by dynpros. A dynpro
-!6namic PRgram consists o# a screen and its #lo logic and controls
exactly one dialog step. (he #lo logic determines hich processing ta"es
place be#ore displaying the screen -PB)Process Be#ore utput and a#terreceiving the entries the user made on the screen -PA0)Process A#ter
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 3/12
0nput.
(he screen layout #ixed in the 'creen Painter determines the positions o#input/output #ields, text #ields, and graphical elements such as radio
buttons and chec"boxes. 0n addition, the 7enu Painter allos to store
menus, icons, pushbuttons, and #unction "eys in one or more 830 statuses.!ynpros and 830 statuses re#er to the ABAP/4 program that control the
se%uence o# the dynpros and 830 statuses at runtime.
ABAP/4 module pool$ach dynpro re#ers to exactly one ABAP/4 dialog program. 'uch a dialog
program is also called a module pool, since it consists o# interactive
modules. (he #lo logic o# a dynpro contains calls o# modules #rom the
corresponding module pool. 0nteractive modules called at the PB eventare used to prepare the screen template in accordance to the context, #or
example by setting #ield contents or by suppressing #ields #rom the display
that are not needed. 0nteractive modules called at the PA0 event are used to
chec" the user input and to trigger appropriate dialog steps, such as theupdate tas".
All dynpros to be called #rom ithin one transaction re#er to a common
module pool. (he dynpros o# a module pool are numbered. By de#ault, the
system stores #or each dynpro the dynpro to be displayed next. (hisdynpro se%uence or chain can be linear as ell as cyclic. &rom ithin a
dynpro chain, you can even call another dynpro chain and, a#ter
processing it, return to the original chain.
!ialog Program 7ain 9omponents:(he 7ain 9omponents o# a !ialog Program
o 6ou use the 'creen Painter and the 7enu Painter to create and designscreen templates and screen programs.
o 6ou de#ine the processing logic in an ABAP/4 program -module pool.
o !ata structures are de#ined in the ABAP/4 !ictionary. 6ou can access
these structures #rom the ABAP/4 program and hen de#ining screen
#ields.
o (he dialog processor controls the #lo o# your dialog program.
Dynpro
!ynpro$ach screen contains #ields used to display or re%uest in#ormation. &ields can betext strings, input or output #ields, radio buttons, chec"boxes, or pushbuttons. (he
screen o# (ransaction (*+ contains only texts and input/output #ields.
An 'AP dynpro consists o# several components:
o &lo logic: 9alls o# the ABAP/4 modules #or a screen.
o 'creen layout: Positions o# the texts, #ields, pushbuttons, and so on #or a
screen.
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 4/12
o 'creen attributes: umber o# the screen, number o# the subse%uent screen,
and others.
o &ield attributes: !e#inition o# the attributes o# the individual #ields on a
screen.
6ou create and edit all components o# a dynpro in the 'creen Painter. (o call the'creen Painter, create a dynpro in the b;ect Broser or double)clic" on anexisting dynpro. (he b;ect Broser then calls the 'creen Painter. (here, you can
enter the #lo logic o# the ne dynpro. By pressing the corresponding pushbutton
you can maintain the 'creen attributes, branch to the &ull 'creen)$ditor or you
choose the pushbutton &ield list and change the attributes o# #ields.&or morein#ormation on the 'creen Painter, see the documentation ABAP/4 !evelopment
or"bench: (ools.
'creen Attributes&rom the user<s point o# vie, a transaction is a se%uence o# screens, displayed
one a#ter another. =o do 0 determine this se%uence> (he transaction<s attributes
determine the #irst screen to be displayed. (he attributes o# the individual dynprosdetermine hich screen to display a#ter the current screen. 6ou can also set the
number o# the subse%uent screen dynamically #rom ithin the ABAP/4 program.
&or the sample transaction, the screen attributes need not be changed, since nosubse%uent screen is called.
2ayout
9hoose &ullscreen to go to the screen editor. =ere you can determine the layout o#
the screen. &or (ransaction (*+, the desired #ields can be copied #rom (able'P&20 o# the ABAP/4 !ictionary. &or more in#ormation on the #ullscreen editor,
see ABAP/4 !evelopment or"bench: (ools.
&ield Attributes
(o display and modi#y the attributes o# the individual #ields -input/output #ields,input re%uired, possible entries button, invisible, and so on, use the &ield list.
(he #ields 9ompany -'P&20)9ARR0! and &light number -'P&20)90! arede#ined as input/output #ields. All other #ields are used only #or outputting the
#light data.
&lo 2ogic
(he #lo control code o# a dynpro consists o# a #e statements that syntacticallyresemble ABAP/4 statements. =oever, you cannot use #lo control "eyords in
ABAP/4 and vice versa. 6ou enter the #lo control code in the 'creen Painter as
one component o# the dynpro.(he #lo control #or the dynpro o# (ransaction (*+ loo"s li"e this:
PR9$'' B$&R$ 3(P3(.
7!32$ '$(?'(A(3'?+.
@
PR9$'' A&($R 0P3(7!32$ 3'$R?977A!?+.
(he PR9$'' statement names the event type #or the dynpro and the 7!32$
statement tells the system hich ABAP/4 routine to call #or this event. 0n this
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 5/12
example, there is only one 7!32$ #or each event PB and PA0. =oever, an
event can contain several statements ith several "eyords. -(he #lo control
language contains only #e statement types. (he most important are 7!32$,&0$2!, 9=A0, 2P, 9A22 '3B'9R$$.
(o display in#ormation on the statement syntax in the #lo logic, choose 3tilities
)) =elp on... in the #lo logic editor. 0n the subse%uent dialog indo, mar"&lo logic "eyord, enter the name o# the desired "eyord, and press $($R.
'creen Painter ABAP/4:'creen Painter ABAP/4
o (o create a screen, ta"e the #olloing steps:
!e#ine the basic #eatures o# a screen -screen attributes
!esign the screen layout -in the #ullscreen editor
!e#ine the #ield attributes -#ield list
rite the screen #lo logic
o (he most important ABAP/4 program components are #ound in the
#olloing ob;ects:
8lobal data or !ictionary structures in the (P include program-data declarations
PB -Process Be#ore utput module
PA0 -Process A#ter 0nput module
'ubroutines -i# re%uired
ABAP/4 7odule Pool:ABAP/4 7odule Pool0n the b;ect Broser, the module pool code belongs to one o# the #olloing
categories:
8lobal #ields: data declarations that can be used by all modules in themodule pool
PB modules: modules that are called be#ore displaying the screenPA0 modules: modules that are called in response to the user input
'ubroutines: subroutines that can be called #rom any position ithin the
module pool
By de#ault, the system divides a module pool into one or several include programs. An include program can contain several modules o# the same type
-only PB modules or only PA0 modules. (he main program then consists o# a
se%uence o# 0923!$ statements that lin" the modules to the module pool:
0nteraction beteen 'creens and ABAP/4 7odules:0nteractions beteen 'creens and ABAP/4 7odules0n its most simple #orm, a transaction is a collection o# screens and
ABAP/4 routines, controlled and executed by a dialog processor. (he
dialog processor processes screen a#ter screen, thereby triggering theappropriate ABAP/4 processing #or each screen.
&or each screen, the system executes the #lo logic that contains the
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 6/12
corresponding ABAP/4 processing. (he control passes #rom screen #lo
logic to ABAP/4 code and bac".
(he se%uence o# events #or (ransaction (*+, #or example, loo"s li"e this:
+. 0n the PB event, the statement 7!32$ '(A(3'?+ passes
control to the corresponding ABAP/4 module. 0n the ABAP/4 module pool, the screen to be displayed receives a menu inter#ace.
C. A#ter processing the module '(A(3'?+, control returns to the #lologic &or the PB event, no #urther processing is re%uired. (he system
display the screen and receives entries #rom the user. (he entries are:
) the values #or the #ields 9ompany and &light number.
) the #our)character #unction code that tells hich pushbutton the useractivated.
1. (he user input triggers the PA0 event. (he #irst PA0 statement passes
control to the ABAP/4 module 3'$R?977A!?+. 7odule3'$R?977A!?+ processes the re%uests o# the user. 0n our
example, only one re%uest is possible: displaying the #light data #or thespeci#ied #light. (he ABAP/4 statement '$2$9( retrieves the data #rom
the database and displays it.
4. A#ter processing 7!32$ 3'$R?977A!?+, control returns
to PA0. (his terminates the dialog.
9ommunication: 'creen ABAP/4 7odule Pool:9ommunication: 'creen ABAP/4 7odule Pool
o (he screen #lo logic is divided into to events #or each screen:
(he PR9$'' B$&R$ 3(P3( event -PB is executed be#ore the screen is displayed.
(he PR9$'' A&($R 0P3( event -PA0 is executed a#ter the
user has pressed $($R.
o (he system processes the modules in an event se%uentially.
o 0n each module, control passes #rom the dialog processor to the ABAP/4
processor. A#ter processing, control is returned to the dialog processor.
o hen all the PB modules have been processed, the contents o# #ields in
the ABAP/4 or" area are copied to the identically named #ields in the
screen or" area.
o Be#ore the PA0 module is processed, the contents o# #ields in the screen
or" area are copied to the identically named #ields in the ABAP/4 or"area
vervie: 9reating a !ialog Program:vervie: 9reating a !ialog Program
o 0n the #olloing, e are going to create a dialog program hich displays a
planned #light connection. n the #irst screen, the user can enter values #or
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 7/12
the "ey #ields o# the planned #light connection. n the second screen, the
system displays the contents o# the corresponding entry in table 'P&20.
9reating a Program:9reating a Program
o 6ou create your program -ABAP/4 module pool in the ABAP/4!evelopment or"bench.
o
o 9ustomer dialog programs must be called 'AP7*xxx or 'AP76xxx.
o
o (he (P include program contains only the PR8RA7 statement at #irst,
but ill later also contain all data declarations and (AB2$' statements-global data.
o
o 0# you are or"ing ith includes, the system proposes names #or them
according to the #olloing convention: (he #irst D characters o# the name
are the same as the last D characters o# the program name. (he sixthcharacter is an identi#ication code #or the particular contents o# theinclude, #or example, #or a PB module, & #or #orm routines
-subroutines. (he seventh and eighth characters are +, except in the case
o# the (P include. $xample: the (P include #or ABAP/4 module pool
'AP7*EEE ould be 7*EEE(P5 the include #or the PA0 module o#this program ould be 7*EEE0+.
o
0n the program attributes, you maintain the title, the program type
and the application. &or program type, enter the value 7 -module
pool and select appropriate application.
o
Program Attributes
Program Attributes
o 0n the program attributes, you maintain the title, the program type and the
application. &or program type, enter the value 7 -module pool. 'elect '
-Basis 9omponent as the application.
Defining Screens!e#ining 'creens
o 9reate the relevant screens #or your module pool #rom the ob;ect list.
o A#ter you have entered the screen number, the system branches to the
screen attribute maintenance. $nter a short description, select the screen
type ormal and speci#y the number o# the #ollo)up screen.
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 8/12
Using ABAP/4 Dictionary Fields
3sing ABAP/4 !ictionary &ields
o 8enerally, you de#ine screen #ields by using existing ABAP/4 !ictionary
#ield attributes.o 6ou can also use #ield attributes already stored in the module pool. (o do
this, a generated version o# the module pool must exist.
o 6ou can copy the #ield texts and the output templates individually or
together.
Screen Layout (rap!ical Screen Painter"
'creen 2ayout -8raphical 'creen Painter
o (o design screens, you use the 'creen Painter.
o (he inter#ace o# the graphical 'creen Painter contains easy)to)use#unctions #or de#ining the various screen elements -e.g. input/output #ields,
#ield texts, boxes, etc.. 6ou choose each screen element and position it on
the screen using the mouse. (his is 6'068 graphical design usingdrag)and)drop.
o (o delete screen elements, you select the element ith the mouse and then
choose !elete.
o (o move screen elements, you use the mouse to drag the element to the
re%uired position.
ote:
&rom Release 1., the graphical 'creen Painter is supported by
indos (, indos FD and 30E. 0# you are using otheroperating systems, you use the alphanumeric 'creen Painter.
Alp!anumeric Screen Painter
Alphanumeric 'creen Paintero (he alphanumeric 'creen Painter provides the same #unctionality as the
graphical 'creen Painter to design the layout o# your screens.
o 0n the alphanumeric #ullscreen editor, you enter underscores #or
input/output #ields.
o &or radio buttons and chec"boxes, you #irst de#ine a one)byte longinput/output #ield and then enter a #ield text.
o A#ter maintaining the #ield list, you de#ine both #ields as a graphical
element.
o (o create a group box, enter a title and then choose a graphical element
and a group box.
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 9/12
Field List #ie$s
&ield 2ist Gies
o (here are six #ield list vies available #or maintaining the screen #ield
attributes. Alternatively, you can de#ine them #rom one o# the lists.Attribute maintenance #or one #ield is also possible in the #ullscreen editor.
o 0n the 'creen Painter, you use external data types. (he external data types
o# #ields that you select #rom the ABAP/4 !ictionary are displayed in the
H&ormatI column. 0n the case o# #ields -templates that do not have any
ABAP/4 !ictionary re#erence, you de#ine an external data type yoursel#.o 6ou can #ind out the correspondence o# external data types to internal data
types -i.e. ABAP/4 data types by re#erring to the documentation on the
ABAP/4 "ey ord (AB2$'. $xamples are as #ollos: ABAP/4!ictionary data type ABAP/4 data type 9=AR 9 379
Field Attributes&ield Attributes
o 6ou can also maintain the attributes o# your screen #ields #rom the 'creen
Painter by selecting a #ield and then choosing the Attributes #unction.
!e#ining the &lo 9ontrol:!e#ining the &lo 9ontrol
o 6ou speci#y your 7!32$ statements in the #lo logic.
o 0# you choose a module by double)clic"ing, the system creates suitable
7!32$ ... $!7!32$ statements in the appropriate include program. (his is "non as #orards navigation.
o 0# no include program exists, the system ill create one i# you ish. 0t also
inserts an 0923!$ statement in the main program.
9reating ABAP/4 7odules:9reating ABAP/4 7odules
o hen creating PB and/or PA0 modules, you can assign them to an
include or the main program via a dialog box. ormally, the system
automatically assigns your PB modules to the include programxxxxx0+.
9omplex Program 'tructure:9omplex Program 'tructure
o 0n complex programs, it is a good idea to or" ith include programs
hich are ob;ects that are automatically generated by the system.
o (he names o# include programs consist o# the last D characters o# the
program name, a single)character identi#ication code and an increasing
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 10/12
to)digit number. (he (P include is an exception to this. 0ts name is
alays the last D characters o# the program name #olloed by (P.
o As ell as giving an easier overvie o# the program, this construction also
has the advantage that the syntax chec" "nos hich includes belong to
the program and can there#ore be used success#ully in them all.
Processing in t!e %odule Pool
Processing in the 7odule Pool
o (he ABAP/4 7!32$ statements #or PB modules contain the addition
3(P3(, hile the 7!32$ statements #or PA0 modules contain theaddition 0P3(.
Defining Fields in t!e %odule Pool
!e#ining &ields in the 7odule Pool
o 0n dialog processing, data is passed beteen the screens and the ABAP/4
program at runtime. (he system per#orms this communication
automatically, but you must use identical names in the screens and the
module pool.o !e#ine the relevant data ob;ects in the (P include program.
o 6ou access the (P include program via the !ictionary structures, global
data or includes ob;ect types.
&reating Follo$'up Screens9reating &ollo)up 'creens
o &or screens ith a similar structure, you can copy an existing screen and,
i# necessary, modi#y it -e.g. layout, #lo logic.
o (o do this, you or" in the ABAP/4 !evelopment or"bench by
positioning the cursor on the screen you ant to copy -usually the ob;ectand choose the 9opy #unction.
o hen you have success#ully copied the screen, the system displays the
screen as a ne sub)ob;ect o# the module pool and you can edit it.
Defining &alls (ransaction &odes"!e#ining 9alls -(ransaction 9odes
o 6ou can start an ABAP/4 dialog program -JtransactionJ by speci#ying a
transaction code.
o 9ustomer transactions must begin ith * or 6.
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 11/12
o (he system stores your speci#ications in the table ('(9. -0nstead o#
creating a transaction #rom the ob;ect list, you can maintain the table
itsel#.
Field Format &!ec)ing&ield &ormat 9hec"ing
o (he dialog processor chec"s the input against the #ormat attributes o# the
relevant #ield.
o 0# the system detects an incorrect input value, it displays an error message
and ma"es the #ield ready #or input again.
%enu Painter: *+er+ie$
7enu Painter: vervieo 6ou use the 7enu Painter to de#ine #unctions on a screen in a particular
status and assign them to the appropriate menu bar, standard toolbar and
application toolbar.
o 6ou also de#ine the title.
o 0n general, you de#ine a menu bar #or each dialog program and assign it to
a status. &or each status, you de#ine hich menu #unctions are to be
active/inactive.
o All the statuses o# a dialog program ma"e up the user inter#ace. 0# you add
a ne status, you have to regenerate the inter#ace.
o 6ou assign a status and a title to a screen in the appropriate PB module
using the '$( P&)'(A(3' and '$( (0(2$BAR statements respectively.(he status can be up to K characters long, hile the title code should
consist o# no more than 1 characters.
Defining t!e ,nterface ,
!e#ining the 0nter#ace 0
o n re%uest, the system proposes de#ault values #or the menu bar and the
#unction "ey setting, but you can modi#y these.
o 7enu bars can contain up to eight menus. 6ou can de#ine up to six o#
these yoursel#, but the 'ystem and =elp menus are added automatically bythe system.
o A single menu can contain up to +D entries, including the #unctions and
their descriptions, sub)menu names and separator lines.
o 6ou should also speci#y all the #unctions that are active in a status as
active in the menu bar -'AP ergonomic standard.
8/12/2019 DYNPRO
http://slidepdf.com/reader/full/dynpro 12/12
Defining t!e ,nterface ,,
!e#ining the 0nter#ace 00
o 6ou assign the active #unctions that a user is most li"ely to need in the
current status to the Application toolbar. Be#ore you can do this, the#unction code must be assigned to a #unction "ey.
o 6ou assign #unction codes to #unction "eys by entering them in the
Recommended #unction "ey settings or the &reely assigned #unction "eys
sections.
o (he system automatically assigns the #unctions in the standard toolbar to
special #unction "eys.