AC400 - Programming in Financials
AC400 - Programming in Financials
Di cti onary
reference
Di cti onary
reference
Select ion screen
Selection Texts
The field names appear as text in front of the input fields of a selection screen by default. You
can replace them with selection texts and translate them into the required language. The
selection texts appear for the user in the logon language.
If the input field is typed directly or indirectly with a data element, you can copy the field
labels from one of the texts stored in the Dictionary.
SAP AG AC400 4-139
SAP AG 2006
Database
table
ABAP program
pa_car
LH
Selection
screen
PARAMETERS pa_car TYPE s_carr_id.
...
LH
SELECT * FROM spfli
DATA wa_spfli TYPE spfli.
INTO wa_spfli
WHERE carrid = pa_car .
WRITE: / ...
ENDSELECT.
Using Parameters
To get the standard selection screen in an executable program, all you need to do is program a
PARAMETERS statement.
The statement PARAMETERS name TYPE typename or PARAMETERS name LIKE
data_object generates an elementary input field on the selection screen and declares a data
object name of the same type.
If the user enters a value and chooses Execute, the input value is placed in the internal data
object name for the program. Only entries that conform to the type are permitted.
SAP AG AC400 4-140
SAP AG 2006
Database
table
ABAP program
Selection
screen
SELECT-OPTIONS
so_car FOR wa_spfli-carrid .
...
DATA wa_spfli TYPE spfli.
SELECT * FROM spfli
INTO wa_spfli
WHERE carrid IN so_car .
WRITE: / ...
ENDSELECT.
AA DL
( Sel ecti on condi tions )
Internal t abl e so_car
si gn opti on l ow hi gh
I
I
E
EQ
EQ
BT
LH
AA DL
BA
Using Select Options
You define selection options using the SELECT-OPTIONS name FOR data_object
statement: Two data objects of the same type appear on the selection screen as input fields for
entering range limits by default. A pushbutton also appears for carrying out complex range
selections.
The ABAP runtime system defines an internal table name with four columns as a data object
inside the program:
sign to indicate whether the value or the interval should be included (I) or excluded from the
range (E),
option for the operator (BT, ...): You will find all the possible operators in the keyword
documentation for SELECT-OPTIONS,
low for the lower limit of an interval or individual value,
high for the upper limit of an interval.
This selection table name always refers to a data object that has already been defined. The data
object normally serves as the target field in data selection and the selection table as the
possible range of values. For this reason there is a special form of WHERE clause for the
database selection that queries whether the corresponding field is contained in the range on the
database.
Note:
A similar inclusion query is also define for the IF statement.
SAP AG AC400 4-141
SAP AG 2006
...
PARAMETERS pa_car TYPE s_carr_id.
CONSTANTS actvt_display(2) VALUE '03'.
* Event processed after leaving the selection screen
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD pa_car
ID 'ACTVT' FIELD actvt_display.
IF sy-subrc NE 0.
* Show selection screen again with error message
MESSAGE e045(bc400) WITH pa_car.
ENDIF.
START-OF-SELECTION.
...
Example: Authorization Check for the Selecti on Screen
By way of example of an additional input check with an error dialog, a program with an input
field for the abbreviation of an airline is to be extended.
The authorization check is to be performed at the selection screen:
If the user has display authorization for the airline that was entered, the program is to
continue processing.
If the user has no display authorization, the selection screen should be displayed again with
an error message in the status bar.
SAP AG AC400 4-142
SAP AG 2006
Consi stency check
at data input
Fl exible
program flow
200
120
140
100
300
Type checks
Possi ble values
Input help
?
Formatting
options
Dynpro Properties
Dynpros contain not only screen layouts with input and output fields but also their own
processing logic.
By integrating the ABAP Dictionary, automatic consistency checks are available for screen
input fields. As well as the type check, this also includes foreign key checks and checks against
fixed values. Information from the Dictionary is automatically used for these checks.
The checks can be extended to include checks specific to the program. Technology is available
for dynpros that controls the check sequence and makes the fields ready for input again when
errors are discovered.
The layout can be structured very flexibly, with input fields, output fields, radio buttons,
checkboxes, and above all, pushbuttons that enable the user to influence the further course of
the program.
The same formatting options are available for the dynpro as for the list and the selection
screen: Fixed point numbers and dates are formatted according to the settings in the user fixed
values, time according to hh:mm:ss, amounts according to the contents of a currency field and
lengths, weights and so on according to the content of a unit of measure field.
SAP AG AC400 4-143
SAP AG 2006
Dynpro sequence
100
200
300
120
140
CALL SCREEN 100.
ABAP program
Next dynpro = 0
Dynpro calls
You start a dynpro sequence
by specifying the first dynpro as the start dynpro for a transaction code belonging to the
"dialog transaction" type, or
by calling a dynpro from any ABAP processing block in the program.
In this unit we will limit ourselves to the latter option.
SAP AG AC400 4-144
SAP AG 2006
Properti es El ement li st
Fl ow l ogi c
(flow control)
4 Dynpro number
4 Short descri pti on
4 Dynpro type
4 Next dynpro
4 . . .
PROCESS BEFORE OUTPUT.
MODULE clear_ok_code.
PROCESS AFTER INPUT.
MODULE user_command.
Layout
Departure
Screen Pai nter
Arrival
Layout editor
4 Field A
CHAR20
Required
Entry fiel d
...
4 Field B
...
4 . . .
4 . . .
Dynpro Components
The following components belong to a dynpro:
Properties:
- They contain a four figure number for the dynpro name, a short text and information
about the dynpro type (for example normal for full screen).
Layout:
- You can place elements on your dynpro. Elements that appear on the dynpro are called
screen elements.
Element list:
- This contains the properties of the screen elements such as position, size and data type.
Flow control:
- This contains processing logic that should be processed before the dynpro is sent to the
presentation server (PBO) and processing logic that should be processed after a user
action (PAI).
SAP AG AC400 4-145
SAP AG 2006
Properties
of an element
Element l ist
Creat e f iel ds
wi th Dict ionary
reference
Toolbar
Graphical Layout Editor
Layout area
The Graphical Layout Editor
You can start other functions from the graphical Layout Editor:
Element properties:
- This dialog box shows all the attributes for a screen element. You can change some of
these attributes directly in the dialog box.
Example: Readiness for input of an input/output field.
Fetch from Dictionary / Fetch from Program:
- In this dialog box you can generate fields with typing for a global type or fields of the
same type for data objects in the program.
Element list:
- This shows all the elements displayed on the dynpro together with the relevant attributes.
Attributes can be changed directly here too.
SAP AG AC400 4-146
SAP AG 2006
100
...
CALL SCREEN 100.
...
MODULE abc OUTPUT.
...
ENDMODULE.
PBO
MODULE abc.
MODULE xyz INPUT.
...
ENDMODULE.
PAI
MODULE xyz.
ABAP program
Dynpro 100
Calling Modules
The ABAP statement CALL SCREEN <nnnn> interrupts processing of the processing block
and calls the dynpro.
Two event blocks are available for each dynpro:
PROCESS BEFORE OUTPUT (PBO) is processed before the dynpro is displayed. At this
event, modules can be called that preassign values to the screen fields, for example.
PROCESS AFTER INPUT (PAI) is processed after a user action. The program logic,
which depends on the user action, has to be encoded at PAI.
Beachten Sie:
The source text for the PBO and PAI events is created with the Screen Painter and not with
the ABAP Editor. Both event blocks together are termed the flow logic of the dynpro.
A separate, small command record (no ABAP statement!) is available for programming the
flow logic. The most important statement in this record is MODULE module_name. This
calls the ABAP processing block module_name, within which you can enter ABAP code as
normal.
Modules are processing blocks without an interface that can only be called from the flow
logic. A module is enclosed by the ABAP statements MODULE and ENDMODULE.
SAP AG AC400 4-147
SAP AG 2006
PROCESS BEFORE OUTPUT.
...
Back Save
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'. ...
WHEN 'SAVE'. ...
ENDCASE.
ENDMODULE.
PROCESS AFTER INPUT.
ABAP program
MODULE user_command_0100.
Dynpro 100
...
CALL SCREEN 100.
...
Analyzing the Function Code for PAI
You can analyze the user actions in a PAI module. This PAI module is normally named
user_command_nnnn (nnnn stands for the dynpro number). Analyze the function code in this
module in the ok_code field.
Note:
For historical reasons, modules have no interface and no local variables. In modules you can
access all the global data in the ABAP program.
SAP AG AC400 4-148
SAP AG 2006
PROCESS BEFORE OUTPUT.
...
PROCESS AFTER INPUT.
MODULE user_command_100.
MODULE user_command_100 INPUT.
ENDMODULE.
Cancel Yes No
Creat e obj ect
PAI module USER_COMMAND_100 does not
exist.
Do you want to create the object?
Doubl e-cl i ck
USER_COMMAND_0100 PAI module
New include
Framework program
Include election
ZBC400_00_DYNPRO
Creat e PAI module
Screen
painter
Dynpro fl ow control
ABAP
Editor
...
Creating Modules Using Forward Navigation
In the flow control (PBO and PAI) you normally implement MODULE calls. The modules
themselves are created in ABAP.
There are two options for creating a module:
Forward navigation: From the Screen Painter you create a module by double-clicking on
the module name in the flow logic.
Navigation area: If you want to create a module from the object list of the program, choose
a new program object "PBO module" or "PAI module".
A module can be called from several dynpros (reusability).
Note that a module that you call at the PBO event is defined with the MODULE ... OUTPUT
statement; you can only call a module that is defined with the MODULE ... INPUT statement
at the PAI event.
SAP AG AC400 4-149
SAP AG 2006
100
...
CALL SCREEN 100.
...
MODULE abc OUTPUT.
...
ENDMODULE.
PBO
MODULE abc.
MODULE xyz INPUT.
...
ENDMODULE.
PAI
MODULE xyz.
Dynpro 100
Next dynpro: 100
Fixed Screen Sequences
Dynpro attributes:
ABAP program
If the next dynpro for dynpro 100 is set to 100, the dynpro is processed again after PAI has
finished.
SAP AG AC400 4-150
SAP AG 2006
100
...
CALL SCREEN 100.
...
MODULE abc OUTPUT.
...
ENDMODULE.
PBO
MODULE abc.
MODULE xyz INPUT.
...
ENDMODULE.
PAI
MODULE xyz.
Dynpro 100
Dynpro attributes
:
Next dynpro: 0
Ending Dynpro Sequences - Fixed Rule
ABAP program
By specifying the next dynpro here, you determine that after the dynpro has been completely
processed, processing continues at the dynpro callpoint.
SAP AG AC400 4-151
SAP AG 2006
100
...
CALL SCREEN 100.
...
MODULE abc OUTPUT.
...
ENDMODULE.
PBO
MODULE abc.
MODULE xyz INPUT.
SET SCREEN 0.
ENDMODULE.
PAI
MODULE xyz.
Dynpro 100
Dynpro attributes
:
Next dynpro: 100
0
ABAP program
Endi ng Dynpro Sequences - Variable Rule
The next dynpro can be set dynamically from a PAI module using the ABAP statement SET
SCREEN nnnn. This represses the static entry.
The system enters the number of the current dynpro as the next dynpro by default. As a result,
the enter key or the green checkmark only leads to a field check, and the dynpro is sent again
after this, with a corresponding error message, if applicable. You can only exit it using a
pushbutton intended for this purpose that is caught in a PAI module.
Note that when the same dynpros are processed again, all the PBO modules are run again. If
you decide to fill the TABLES structure in a PBO module, you must ensure that this does not
overwrite the changes made to the data on the dynpro by the user when it is called again.
SAP AG AC400 4-152
SAP AG 2006
DATA ok_code LIKE sy-ucomm.
START-OF-SELECTION.
...
AT LINE-SELECTION.
...
CALL SCREEN 100.
...
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'.
SET SCREEN 0.
MESSAGE s057(bc400).
WHEN 'SAVE'.
* Saving changes in data base
...
SET SCREEN 0.
MESSAGE s058(bc400).
ENDCASE.
ENDMODULE.
Syntax Example: Analyzing the Function Code
For our scenario, two pushbuttons should be caught:
With 'BACK', the next dynpro is set to 0 dynamically. This takes you back to the callpoint.
In our case, this means returning to the basic list. The message 057 appears in the status bar
in the following screen.
With 'SAVE' the program behaves in the same way as for 'BACK'. It returns to the basic
list, however, a different message appears in the status bar. In the unit Cross-Program
Modularization the program is extended with a change to the data record.
SAP AG AC400 4-153
SAP AG 2006
Flight dat a Edit Goto System Help
Help F1
Select F2
Back F3
. . .
Function key
sett ings
Change fl ight ti mes
GUI ti tle
Menu bar
Toolbar
Appl icati on t ool bar
Functi on key set tings
Terms for the User Interface
GUI status
The user interface appears with the following elements:
The title bar contains the title of the actual screen.
The menu bar contains expandable menus.
The menus contain the functions that you can execute in the program. Menus can contain
submenus (cascading menus). The "System" and "Help" menus are available with identical
functions on all screens in the R/3 system. Neither of these menus can be changed or hidden.
The toolbar contains icons for functions that are used very frequently. The toolbar contains the
same icons on every screen in the R/3 system with function keys that have been permanently
assigned. The icons for functions that cannot be executed on the actual screen are grayed out.
The (function) key setting can be displayed with a right mouse click. All functions that can be
executed by way of the menu should also be executable by way of a function key.
The application toolbar enables frequently used function keys on a screen to be executed by
clicking on an icon or a pushbutton too.
An interface is created for each program that contains the elements listed above. Views can be
created on the user interface for different screens: GUI status.
SAP AG AC400 4-154
SAP AG 2006
F2
F9
...
Toolbar
%EX BACK RW
PICK
%PRI %SC P--
Menu bar Menu bar fli ght data
i
Appli cation toolbar
i
Function keys Function keys fli ght dat a
i
Appli cation toolbar f li ght dat a
P-
q
q +
+
+
q
P+ P++
?
%SC+
Choose
Recommended funct ion key setti ngs
User-det ermined f unction keys
F5
F6
...
<...> Select
Status in the Menu Painter Function Keys
The key assignment is divided into three areas:
Toolbar: Specific function codes are required for the functions Save, Back, Program Exit,
Cancel, Print and the Scroll icons, as well as for the Enter key. The corresponding function
key is automatically assigned when you assign a function code to the icon in the toolbar.
Recommended function key settings: Functions are proposed here that should normally be
assigned to specific function keys.
User-determined function keys: All the other function codes are listed here that are not
covered by standard icons. You can look for suitable keys here for functions specific to a
particular program.
In addition, you can define a pushbutton in the application toolbar for function keys that are
often required. Icons or text can be represented on pushbuttons.
SAP AG AC400 4-155
SAP AG 2006
Menu bar
Menu bar fli ght data
i
Appli cation toolbar
i
Function keys
Function keys fli ght dat a
i
Appli cation toolbar f li ght dat a
Flight dat a
Code Text
Edit Goto
Code Text Code Text
PICK
%SC
%SC+
RW
Select
Search
Extend search
Cancel
PRI
%EX
Return BACK Print
Save/Send
Exit
>
Status in the Menu Painter Menu Bar
The system proposes standard layouts for the menu bar which you can also modify, however.
The menu bar can contain a maximum of eight menus, six user-definable menus as well as
System and Help, which are automatically inserted as standard menus.
SAP AG AC400 4-156
SAP AG 2006
Menu bar
SCREEN
SCREEN
SCREEN
i
i
i
Select ion and Integrat ion
of subobject s of an
already defi ned stat us
Appli cation toolbar
Function keys
Including Existing Status Elements
Create a new status for the dynpro and use an icon to display all the menu bar or function key
assignments that have already been defined. In the example program only one menu bar or
function key assignment is displayed.
Double-click on this to select it so that you can reference the same menu bar and the same
function key assignment for the dynpro status as in the list status.
SAP AG AC400 4-157
SAP AG 2006
Function code
Flight dat a Edit Goto
Code Text
Select
function code
Back BACK
Appli cation toolbar
i
Function keys Function keys fli ght dat a
i
Appli cation toolbar f li ght dat a
Menu bar Menu bar fli ght data
i
1
Set to active/
inact ive
2
Deactivating Status Functions
To set an active or inactive status for functions, proceed as follows:
Switch to change mode status by double-clicking and the Display * Change icons.
Place the cursor on the required function code and click on the active * inactive icons in the
application toolbar
In our example, we add the SAVE function, which does not belong to the standard list
functions, to the toolbar and the Flight Data menu. The system points out that we are
referencing the menu bar and the toolbar. If we confirm the dialog box, the SAVE function is
automatically included in the status for the menu bar and the toolbar and displayed as inactive
there.
The functions BACK and SAVE in our example are analyzed in the PAI module
user_command_0100.
SAP AG AC400 4-158
SAP AG 2006
SET TITLEBAR 'T_ABC'.
Program
Title code
Title
Creat e t itl e
xxxxx
T_ABC
Change flight times
GUI interface: Title T_ABC does not exist.
Do you want to create the object?
Cancel
Creat e obj ect
Yes No
Confirm
START-OF-SELECTION block ( for list )
or
PBO module ( for dynpro )
Doubl e-
cl i ck
Defining GUI Titles
There are three options for creating or maintaining a title:
From the object list of the repository browser,
by forward navigation from the ABAP Editor, or
directly, using the Menu Painter tool.
A name of a title can have a maximum of 20 characters.
Note: If you create the proposed PBO module status_nnnn by forward navigation, the SET
TITLEBAR 'XXX'. statement is automatically generated in the module. It is turned into a
comment. You can use this proposal by deleting the asterisk and entering the number of the
title. Then you can create the title by forward navigation.
SAP AG AC400 4-159
SAP AG 2006
attr1
attr2
...
meth1
meth2
...
Class
(Formal descript ion of objects)
Object attribut e
Object methods
attr1 8
ABC
Objects (instances) of the class
attr2
met h1
met h2
attr1 3
XYZ
attr2
met h1
met h2
attr1 5
SAP
attr2
met h1
met h2
Concept of Object-Oriented Programming
The first impression of a class is that it is like a function group:
It contains data objects (attributes) and functions (methods). These components can be
protected from external access. Then only methods can be used to access them.
In contrast to function groups, however, classes can be instanced several times. In other words,
more than one runtime object can be generated for a class for each program. Another way of
looking at it is that a class contains the technical description of objects (instances). All these
objects therefore have the same attributes and offer the same methods. They can all be
physically distinguished from one another, however. Their attributes can have different
characteristic values.
Classes can be defined locally, within an executable program, or globally.
As of release 4.6a, the ABAP runtime system supports standard object-oriented syntax
elements. However, these cannot be discussed properly in the time available in this training
course. You will find detailed information about this in the SAP Library.
SAP AG AC400 4-160
SAP AG 2006
ABAP program
DATA ref1 TYPE REF TO myclass.
DATA ref2 TYPE REF TO myclass.
CREATE OBJECT ref1 ...
...
CREATE OBJECT ref2 ...
CALL METHOD ref1->meth1
EXPORTING ...
IMPORTING ...
EXCEPTIONS ...
CALL METHOD ref2->meth1
EXPORTING ...
IMPORTING ...
EXCEPTIONS ...
ref1 ref2
met h1
met h2
met h2
met h1
Instantiation of Objects and Method Calls
To generate and address class instances you need so-called reference variables. These are
pointers to the instances. You define such reference variables with
DATA reference_nameTYPE REF TO class_name.
The data objects are created in the memory when the program starts. However, because no
instances have yet been generated, the reference variables are still empty at this point.
At runtime you can generate as many class instances as you want using
CREATE OBJECT reference_name.
- The import parameters for a special method, the CONSTRUCTOR, may have to be
populated. This special method is executed immediately after the instance has been
generated. Basic settings for the actual instance are normally made.
You call the methods for an instance using
CALL METHOD reference_name->method_name.
- In contrast to calling a function module, the function name is not sufficient here,
as several instances of a class normally exist for each program. You use the reference
variable, followed by the object component selector ->, to cause a specific instance to call
its method.
SAP AG AC400 4-161
SAP AG 2006
AA
0017
0064
LH
0400
0402
Airlines
Tree control
http://www.sap.com
HTML viewer control
Grid control Pict ure control
CL_GUI_ALV_GRID CL_GUI_PICTURE
CL_GUI_HTML_VIEWER CL_SIMPLE_TREE_MODEL
EnjoySAP Controls as Standard Classes
As of release 4.6a the ABAP Workbench offers a large range of new EnjoySAP controls to
relocate dialog functions from the application server to the presentation server. The steering of
these controls is object-oriented, and takes place with the help of classes, the SAP Control
Framework.
Method calls steer the controls from your ABAP program. The Control Framework sends your
requirements to the presentation server, where they are converted in accordance with the
platform.
You can give the user the option of triggering events on the presentation server. These are
converted in turn by the Control Framework, so that your ABAP program can respond to them.
You will find detailed information about EnjoySAP controls and the Control Framework in the
SAP Library.
SAP AG AC400 4-162
SAP AG 2006
17
64
AA
AA
AA
AA
LH
LH
LH
LH
LH
17
17
400
402
400
400
402
2000-01-17
2000-02-20
2000-03-11
2000-05-19
2000-01-13
2000-02-26
2000-03-21
2000-03-04
2000-05-28
USD
USD
USD
USD
EUR
EUR
EUR
EUR
EUR
513,69
1234,56
1234,56
513,69
513,69
369,00
1234,56
1234,56
1234,56
A321
747-400
A310-300
A319
A319
A310-300
A310-300
A321
747-400
Details
Sort
Search
Filt er
Total
Print
Download
Di splay vari ant
Toolbar
The SAP Grid Control
The ALV grid control is used for displaying non-hierarchical data in a table. Numerous user
functions are already implemented.
In the control, the columns can be made wider and smaller, or adapted to fit the data that is
currently being output using the Optimum Width function. Columns can also be swapped
around by selecting a column and dragging it to another position.
Standard functions are offered in the control toolbar. The Details View displays the fields in
the line on which the cursor was positioned in a modular dialog box.
The ALV control provides a Sort Function for any number of columns. You can determine
complex sort criteria and arrange the columns in ascending or descending order.
With the Search function you can search in lines or columns within a selected area for a
character string (generic search without *).
Totals can be requested for one or more numeric columns. Using the Subtotals function you
can then build control level lists: You select the column (non-numeric fields only) you want to
consider and the system provides you with the control level totals.
With Print and Download the complete list is always processed and not just the section in the
screen display.
The user can also make Display Variant settings.
SAP AG AC400 4-163
SAP AG 2006
Area
Custom
cont ainer
control
SAP gri d control
Dynpro 100
Process
Before
Output
Process
After
Input
PBO module
Control
area
...
...
Container
instance
Grid
instance
The Custom Container as a Dynpro Object
An EnjoySAP control must be embedded in an SAP container control. This manages the
embedded controls and provides a physical area for visualization.
The container becomes the parent of the embedded control.
Since containers are themselves controls, they can be nested within one another. This allows
you to work with controls both flexibly and in a modular way.
You require at least one container and an ALV grid instance in order to use an ALV grid
control in your program.
SAP AG AC400 4-164
SAP AG 2006
Area
Custom
cont ainer
control
SAP gri d control
Container
instance
Grid
instance
CL_GUI_CUSTOM_CONTAINER
CL_GUI_ALV_GRID
CLASS BUILDER
The SAP Grid in the Custom Container
Global classes (object types) are available in the Class Builder for steering the custom
container control and the ALV grid control :
CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID.
SAP AG AC400 4-165
SAP AG 2006
Int. types Events
Supercl asses
Methods
CONSTRUCTOR
CL_GUI_CUSTOM_CONTAINER
Class CL_GUI_CUSTOM_CONTAINER
Attributes Interfaces Propert ies Methods
Parameter for method CONSTRUCTOR
Parameter
PARENT
CONTAINER_NAME
...
Value Optional ... Associ ated type ... Descript ion
. .
.
.
.
.
.
Mandatory parameter
of the CONSTRUCTOR method
have t o be suppli ed with CREATE
OBJECT.
Cl ass Buil der
Is called impli cit ly with
CREATE OBJECT
The Constructor Method
For more detailed information about the global class CL_GUI_CUSTOM_CONTAINER,
navigate to the Class Builder: Display the object list for the class in the navigation area of the
Object Navigator. Then display the entire class or individual components in the editing area.
Alternatively, you can double-click on the class name from an ABAP program to access the
Class Builder. Depending on the display mode you then click on Parameter or Signature to get
detailed information about the interface parameters.
The global class CL_GUI_CUSTOM_CONTAINER only has the CONSTRUCTOR
method. When the instance is generated using CREATE OBJECT in the program, you have
to transfer at least the mandatory parameter container_name. The name of a custom container
area on a dynpro must be transferred to this parameter.
SAP AG AC400 4-166
SAP AG 2006
Supercl asses
Interfaces
Attributes
Methods
. . .
CONSTRUCTOR
. . .
SET_TABLE_FOR_FIRST_DISPLAY
. . .
REFRESH_TABLE_DISPLAY
. . .
Redefinitions
Events
CL_GUI_ALV_GRID
If an i mpli cit call i s made at
CREATE OBJECT;
Mandatory parameter :
i_parent
Mandatory parameter :
it_outtab (Display data)
Optional parameter :
i_structure_name
(global structure for describing
the table line type)
Important SAP Grid Control Methods
The global class CL_GUI_ALV_GRID has numerous methods.. To display the content of an
internal table with an ALV grid control it is sufficient to examine three methods more closely.
CONSTRUCTOR:
The pointer to the container control instance must be transferred to the constructor.
SET_TABLE_FOR_FIRST_DISPLAY:
The internal table with the data to be displayed must be transferred to the it_outtab
parameter. This table must be a standard table so that the user can deploy the sort functions.
In addition, technical information is required for formatting the grid columns. The easiest
thing to do is to use a flat structure or a transparent table - in other words, a global type - as
the line type for the internal table. In this case, all you need to do now is transfer the name of
the line type to the i_structure_name parameter.
Alternatively, you can also construct a so-called field catalog and transfer it to
it_fieldcatalog.
REFRESH_TABLE_DISPLAY:
You only need to execute this method if the contents of the internal table have changed since
the first time they were displayed.
SAP AG AC400 4-167
SAP AG 2006
Custom
control
area
Type: Cust om control
Name: CONTAINER_1
Resizing
Verti cal : Min. li nes: 5
Horizont al : Min. columns: 20
C
Screen Pai nter
Pl acing the Custom Control Container on the Dynpro
To reserve an area for an EnjoySAP control on a dynpro, you have to use the Screen Painter
(Layout pushbutton) to create a custom container area.
To the left of the toolbar next to the editing area you will find an icon with the description
Custom Control:
Choose the Custom Control pushbutton. Then determine the size and position of the area on
the dynpro. To do this, you should proceed as follows: You determine the top left corner of
the area by pressing the selection key of your mouse. Holding the mouse button down, drag
the mouse diagonally to the bottom right as far as the required lower right corner of the area
to be created. As soon as you release the mouse button, the lower right corner is fixed.
You can change the size and position of the area at any time by drag and drop using the
"pull symbol" that appears on the edge of the area.
Assign a name to your newly created dynpro element (here: CONTAINER_1).
You can use the attributes Vertical Resizing and Horizontal Resizing to determine whether or
not the area should be extended accordingly when you resize the dynpro. If you set the
attributes, you can determine the minimum size to which the area can be reduced using the
additional attributes Min. Lines and Min. Columns. The upper limit is determined by the size of
the area.
SAP AG AC400 4-168
SAP AG 2006
cont ainer_r
gdt_spf li
ok_code
grid_r
Custom Control Containers as Data Objects
DATA gdt_spfli TYPE sbc400_t_spfli.
DATA: container_r TYPE REF TO cl_gui_custom_container ,
grid_r TYPE REF TO cl_gui_alv_grid .
DATA ok_code TYPE sy-ucomm.
START-OF-SELECTION.
* fill internal table ...
CALL SCREEN 100.
Two reference variables are required in the ABAP program.
The reference variable that points to the container control instance is called container_r here,
and is typed with the global class cl_gui_custom_container.
The reference variable that points to the grid control instance is called grid_r here, and is
typed with the global class cl_gui_alv_grid.
SAP AG AC400 4-169
SAP AG 2006
cont ainer_r
grid_r
Instantiation of Custom Control Containers
MODULE create_control OUTPUT.
IF container_r IS INITIAL.
CREATE OBJECT container_r
EXPORTING container_name = 'CONTAINER_1'
CREATE OBJECT grid_r
EXPORTING i_parent = container_r.
...
ENDIF.
ENDMODULE.
You generate control instances with the CREATE OBJECT statement.
Make sure that you let the system create the statement for you. In this way, you avoid spelling
mistakes and errors. Similar to function module calls, the complete interface is implemented in
your program. CREATE OBJECT is the interface for the constructor method. Optional
parameters are inserted as a comment.
Control editing must be processed before the dynpro is displayed. It should also be coupled in
a modular way to the processing of the respective dynpro. For this reason we recommend you
implement a PBO module here.
The controls should be instantiated only once - before the dynpro is first displayed. This can
be realized simply by querying the content of one of the two reference variables.
Since the instantiation of the container control is implemented in the corresponding PBO
module here, it is sufficient to supply the name of the customer container area. In other cases,
the program name and dynpro number can be given as well.
When instantiating the grid control, it is sufficient to transfer the pointer to the container
instance. Thus the container control manages the technical linking of the grid control to the
dynpro.
SAP AG AC400 4-170
SAP AG 2006
MODULE create_control OUTPUT.
IF container_r IS INITIAL.
CREATE OBJECT container_r
EXPORTING container_name = 'CONTAINER_1' .
CREATE OBJECT grid_r
EXPORTING i_parent = container_r .
ENDIF.
ENDMODULE.
cont ainer_r
grid_r
CALL METHOD CALL METHOD
grid_r grid_r- -> >set_table_for_first_display set_table_for_first_display
EXPORTING EXPORTING i_structure_name i_structure_name = 'SPFLI' = 'SPFLI'
CHANGING CHANGING it_outtab it_outtab = = gdt_spfli gdt_spfli . .
Containing SAP Grids
To send the content of the internal table and the line type to the grid control, you have to call
the method set_table_for_first_display.
You transfer the name of the internal table to the it_outtab parameter.
Since the internal table was typed with the transparent table SPFLI as the line type, it is
sufficient to transfer this name to the i_structure_name parameter.
Basic settings for the grid control could also be supplied here too.
If the content of the internal table changes while the program is running, you have to call the
refresh_table_display method before you display the dynpro again.
SAP AG AC400 4-171
SAP AG 2006
Dialogs are programmed with the help of dynpro
technology.
By using the custom container, ALV reports can
be linked to dynpro technology.
Dialogs and ALV Reports: Summary
SAP AG AC400 4-172
Exercises
Unit 1: Dialogs and ALV Reports
At the conclusion of this exercise, you will know about:
The program library
The basic concept of dynpro logic
The custom control container
Database accesses
ALV as a tool for creating reports
1-1 The program library
1-1-1 Search for the custom container and ALV grid control documentation
in the program library.
1-1-2 Select a simple example program for an ALV grid control. Analyze the
program. Use the debugger for this too. Is a customer container used in
the ALV grid control?
1-2 Programming an ALV report using a template
1-2-1 Copy the program BCALV_GRID_DEMO with all the subobjects to
your local objects under the new name Y##ALV_GRID_DEMO.
1-2-2 Change the program Y##ALV_GRID_DEMO so that it displays
company codes instead of flights.
1-2-3 Change the screen output. Remove the text This belongs to the
dynpro. Then maximize the screen and the custom container to use all
the existing screen space to display the data.
1-2-4 Enter the title List of all company codes for your company code list.
SAP AG AC400 4-173
SAP AG AC400 4-174
Solutions
Unit 1: Dialogs and ALV Reports
1-1 The program library
1-1-1 Search for the custom container and ALV grid control documentation
in the program library.
Tools>ABAP Workbench>Overview>Reuse Library
Function Subscribe to Library
Selection SAP Technology
Navigation in the structure tree
SAP Technology >Controls>Control Container or
SAP Technology>Controls>ALV Grid Control
You will learn more about programs under the four tab pages
Overview, Documentation, Examples, and Program Objects.
1-1-2 Select a simple example program for an ALV grid control. Analyze the
program. Use the debugger for this too. Is a customer container used in
the ALV grid control?
Tools>ABAP Workbench>Overview>Reuse Library
Navigation in the structure tree
SAP Technology>Controls>ALV Grid Control
Tab page Examples
Examples>Simplest Call>BCALV_GRID_DEMO
The custom container G_CUSTOM_CONTAINER is typed under the
data declaration. The custom container is instantiated in the PBO
module. G_CUSTOM_CONTAINER is listed under the Element
List tab page for dynpro 100.
SAP AG AC400 4-175
1-2 Programming an ALV report using a template
1-2-1 Copy the program BCALV_GRID_DEMO with its subobjects to your
local objects under the new name Y##ALV_GRID_DEMO.
Tools>ABAP Workbench>Overview>Object Navigator
View Program
Program BCALV_GRID_DEMO
Selection Folder BCALV_GRID_DEMO
Context menu Copy
Target program Y##ALV_GRID_DEMO
Selection for Interface, dynpros, includes
Function Copy
Function Local object
1-2-2 Change the program Y##ALV_GRID_DEMO so that it displays
company codes instead of flights.
First you have to ascertain in which table the company codes are
listed. You can do this, for example, by following the path
Tools>ABAP Workbench>Overview>Business Object Browser.
The company code can be found under the Financial Accounting
application components. Double-click on it to see a list of the key
fields. By double-clicking on the key field you will see the reference
table T001.
Call the editor in change mode.
Function Find/Replace
Find SFLIGHT
Replace with T001
Function Activate (activate all subobjects)
Test your program.
SAP AG AC400 4-176
1-2-3 Change the screen output. Remove the text This belongs to the
dynpro. Then maximize the screen and the custom container to use all
the existing screen space to display the data.
Edit the dynpro 100. Under the Properties tab page, set the
maintainable coordinates to 200 / 255.
Function Layout
In the new layout mode, remove the text This belongs to the dynpro.
Then select close.
Function Attribute window
Visualized length 255
Visualized height 196
Function Close
Function Activate
Exit layout maintenance and the flow logic of the dynpro. Test your
program again.
1-2-4 Enter the title List of all company codes for your company code list.
Edit your program. Include a new line before the IF condition in the
module PBO.
SET TITLEBAR '100'.
Double-clicking on the title 100 allows you to create the title
manually.
Title List of all company codes
Function Copy
Function Activate (all objects)
Test your program again.
SAP AG AC400 4-177
SAP AG AC400 5-178
SAP AG 2006
Course Overview Diagram: Customer
Enhancements
Cust omer Enhanc ement s
Cust omer Enhanc ement s
The ABAP Wor k benc h
The ABAP Wor k benc h
Fi r st At t empt s at Pr ogr ammi ng
Fi r st At t empt s at Pr ogr ammi ng
Templ at e Al l oc at i on
Templ at e Al l oc at i on
Ex t r ac t i on
Ex t r ac t i on
Di al ogs and ALV Repor t s
Di al ogs and ALV Repor t s
SAP AG AC400 5-179
SAP AG 2006
Customer Enhancements - Unit Overview
This unit presents customer modifications and
enhancements. A Business Add-In is implemented.
Contents:
SAP AG AC400 5-180
SAP AG 2006
Differentiate between modifications and
enhancements
Implement BAdIs
Customer Enhancements: Unit Objectives
At the conclusion of this unit, you will be able to:
SAP AG AC400 5-181
SAP AG 2006
R/3 Busi ness
Appl i cati ons
(Standard SAP
system)
Customer
programs
Custom
develop-
ment
Enhance-
ment
Modification Customizi ng
Customi zi ng ABAP
Workbench
Personalizing
Change Levels
You can adapt the R/3 system to your requirements in the following ways:
Customizing: For configuring your business processes and functions using the
Implementation Guide. Possible changes are thus planned and organized.
Personalizing: For changing the global display properties of fields (default settings,
hidden/visible), user-specific menu navigation.
Modification: Changes to SAP Repository objects in the customer's system. If SAP ships a
modified version of the object, the customer version must be adjusted with regard to the new
SAP version. Up to Release 4.0B, this must be performed manually using the upgrade
utilities. As of Release 4.5A, this technical adjustment is largely automated by means of the
Modification Assistant.
Enhancement: For creating customer Repository objects that are integrated in SAP
Repository objects.
Custom development: For creating custom Repository objects in line with customer
namespaces.
Customizing and most personalizing settings are configured with the Business Engineer tools.
Custom developments, enhancement concepts, and modifications, on the other hand, are are
managed with the ABAP Workbench tools.
SAP AG AC400 5-182
SAP AG 2006
Originals and Copies
Copy
Original
Copy
Copy
Original
SAP obj ect SAP obj ect SAP obj ect
Customer object Customer object
Transport of
development
Development syst em
Foll ow-on system
An original object can exist in one system only. In the case of objects shipped by SAP, the
"original system" is located at SAP. These objects are merely copies in your customer system.
This applies to both your development system and all other follow-on systems.
If you create your own objects, these objects are original objects in your development system.
You always assign developments to a change request using a "development/correction" task.
This request is then used to transport the objects from your development system to your
follow-on systems.
SAP AG AC400 5-183
SAP AG 2006
Corrections and Repairs
Modified
copy
Corrected
original
Copy
Copy
Corrected
origi nal
SAP obj ect
Transport
of correcti on
SAP obj ect SAP obj ect
Customer object
Customer object
Correct ion
Repair Correct ion
Transport
of the repair
Foll ow-on system
Development syst em
Changes to original objects are referred to as corrections. For this reason, the system records
these changes in a transport request along with tasks of the type "development/correction".
If a copy is changed (that is, an object is not changed in the original system), this change is
included in a task of the type"repair". Repairs to SAP objects are known as modifications.
When you make repairs to your own objects (for example, following an emergency in your
production system), you can also make the changes to the original objects in your development
system straight away. It is essential that any changes you make to copies are also made to
the original objects immediately.
This option is not available for SAP objects because the originals are not available in one of
your systems.
You should only make modifications to the standard system if these are essential for
optimizing certain processes in your company. You should also be aware that good
background knowledge of the structure and process flow of an application is essential as a
basis for assessing modification options and for designing effective modifications to change
the standard system.
SAP AG AC400 5-184
SAP AG 2006
Modifications During an Upgrade
Modified
copy
Copy
Corrected
origi nal
SAP obj ect
Transport
of adjust ment
SAP obj ect SAP obj ect
Upgrade Upgrade
Modification
adjustment
Foll ow-on system
Corrected
original
Copy
Customer object Customer object
Development syst em
Conflicts can occur when you import an upgrade, Support Package, or any other transport
request from SAP to your system.
Conflicts only occur when you modify an SAP object and the same object is shipped again by
SAP. In this case, the object shipped by SAP becomes the active object in the Repository
within your R/3 system.
If you want to rescue your changes, you have perform a modification adjustment for the
objects in question. If you have modified many SAP objects, you may experience considerable
delays when you install an upgrade.
To ensure consistency between your development system and your follow-on systems, we
recommend that you perform the modification adjustment in your development system only.
The adjustment objects are then transported to your follow-on systems.
SAP AG AC400 5-185
SAP AG 2006
Procedure for Functional Changes
Modi fi cati on
Custom devel opment wi th
SAP program as templ ate
No
No
Yes
Does the standard SAP system
contain a similar function at all?
No
Does the
SAP application support
the integration of additional functions with
enhancements?
Yes
Enhancement
Is there a standard function
that can be adapted to the customer's requirements
in Customizing?
Yes
Customi zi ng
Personal i zi ng
No
Custom devel opment
CSP sol uti on
C
u
s
t
o
m
i
z
i
n
g
D
e
v
e
l
o
p
m
e
n
t
If the standard functions cannot be adapted to the customer's requirements using the available
Customizing or personalizing options, a development project must be started or, if available, a
CSP solution (CSP =Complementary Software Product) must be used. A list of CSP solutions
certified by SAP is available on SAP Service Marketplace under the alias /softwarepartner.
Development projects are used to manage custom developments if similar functions are not
available in the standard SAP system. Otherwise, standard SAP objects are used as a basis for
enhancements, user exits, modifications, or copies of SAP programs.
Modifications are problematic because, following a system upgrade, the new SAP version
must be adjusted with regard to the modified customer version. Up to Release 4.0B, this must
be performed manually using the upgrade utilities. As of Release 4.5A, this technical
comparison is largely automated by means of the Modification Assistant.
For this reason, you should only use modifications if
The Customizing or personalizing options do not satisfy your requirements
Suitable enhancements or user exits are not available or planned
Copying the SAP object to the customer namespace is not practical.
SAP AG AC400 5-186
SAP AG 2006
ABAP Workbench Change Levels
R/3 Busi ness
Appl i cati ons
(Standard SAP system)
Customer
programs
With call of SAP obj ects
Without call of SAP
object s
Custom
development
Modification Assi stant
Modification
User exits
ABAP Dict ionary
Tables
Data elements
Program enhancements
Function module exits
Business Transaction
Events
Business Add-Ins
Menu enhancements
Menu exits
Business Add-Ins
Screen enhancements
Screen exits
Business Add-Ins
Enhancement
Modifications are changes to SAP objects in customer systems. They are:
Located at user exits (subroutines reserved for customers in objects within the SAP
namespace)
Hard-coded at various positions in SAP Repository objects.
In custom developments, SAP Repository objects can be called from custom-defined
programs. Example: A customer writes a program that calls an SAP function module.
In the enhancement concepts, the roles are reversed: Repository objects that you have created
or changed are called by programs shipped by SAP. Example: You are using a function
module exit that is called by SAP. Enhancements can be made at the following levels:
In the ABAP program (function module exit)
In the GUI (menu exit)
In screens for displaying a subscreen in a screen area provided by SAP (screen exit)
As runs of custom program sections based on a screen field (field exit)
In tables or structures of the ABAP Dictionary (table enhancement).
SAP AG AC400 5-187
SAP AG 2006
Program Enhancements: Functionality
*** SAP program ***
*********************************
PROGRAM <name of SAP program>.
< <Enhancement Enhancement cal l cal l > >
<Obj ect i n customer namespace>
Customer exit
Exi t functi on modul e
Business Transacti on Event
Functi on modul e
Business Add-In
Method
The basic purpose of a program enhancement is to call an object in the customer namespace.
There are various ways of doing this:
Customer exits
- A special exit function module is called by the SAP application program. The function
module is part of a function group that is handled by the system in a specific manner.
Business Transaction Events
- A function module is called dynamically by the SAP application program in the customer
namespace.
Business Add-Ins
- The application program calls a method of a class or instance of a class. This class is in
the customer namespace.
SAP AG AC400 5-188
SAP AG 2006
Program Enhancements: SAP and Customer
SAP Customer
Customer exi t:
Functi on modul e exit
FM codi ng
Busi ness Transacti on Events
Functi on modul e
i n customer
namespace
Busi ness Add-Ins
Method in
customer cl ass
Cal l
Admi n.
Interface
Documentati on
Program enhancements enable you to define additional program logic for an SAP application
program. At present, SAP provides the options shown above.
The advantages and limitations of each enhancement option are discussed in greater detail in
the relevant units.
SAP AG AC400 5-189
SAP AG 2006
SAP Customer
PROGRAM ... .
...
*Original Coding..
...
...
...
...
*Original Coding..
...
SAP Program
Modifications
PROGRAM ... .
...
*Original Coding..
...
...
...
...
*Original Coding..
...
* Added/changed by customer
* Coding
SAP Program
When you make a modification, you modify the object shipped by SAP directly.
This has certain consequences the next time you perform an upgrade. If the object is shipped
again, you have to decide whether the new object shipped by SAP or the one you modified is
to be valid in your system.
Up to Release 4.0B, the finest level of granularity at which modifications were recorded was
the Repository object itself, such as an include program.
As of Release 4.5A, modifications are recorded with a finer level of granularity. This is
facilitated by the Modification Assistant, which is discussed in the Unit on "Modifications".
The modification adjustment concept was also thoroughly revised as a result. The procedure
for adjusting modifications is also discussed in this unit.
SAP AG AC400 5-190
SAP AG 2006
Business Add-Ins: Components
BAdI
FCodes
Program
<prog> +ABC
Function Code
Propert ies.
Multiple Use
Filt er Dependent
INTERFACE
<badi-interface>.
DATA: a1 ...
ENDINTERFACE.
METHODS m2 ...
METHODS m1
EXPORTING
e_par1
e_par2
IMPORTING
i_par1.
Subscreens
Calling Program
<prog> 0200
Screen No.
ABCD
Subscreen Area
Scr..
Desc.
Generat ed
BAdI
Class
Business Add-Ins group the components of an enhancement. A Business Add-In can provide
the following enhancement options:
Program enhancement: The interfaces for program enhancements are defined in the Business
Add-In in the form of interface methods. This interface is used to implement the
enhancement. The SAP program calls the interface methods for the generated BAdI class.
Menu enhancement: Like customer exits, function codes can be entered in a BAdI. The
corresponding menu entries are included in the CUA definition and are visible when the
BAdI is implemented.
Screen enhancement: Like customer exits, screen enhancements can be defined in a BAdI
and then implemented.
Several components are created when you define a BAdI:
Interface
Generated class (BAdI class) that implements the interface
The generated class (BAdI class) has the following tasks:
Filtering: If a BAdI is to be executed under certain conditions only, the BAdI class ensures
that only the valid implementations are called.
Control: The BAdI class calls the active implementations.
SAP AG AC400 5-191
SAP AG 2006
Business Add-Ins: Flowchart
Appli cation prog.
Service class
CL_EXITHANDLER
Inst ance of
BAdI class
<badi-cl ass>
BAdI: Instance of
implement. class
Process active
implementations
1 1
2 2
This slide shows the process flow of a program that contains a BAdI call. You can use this
slide to help you understand the features and limitations of Business Add-Ins.
Not shown: A reference variable that refers to the BAdI interface must be declared in the
declaration section.
An object reference is generated in the first step. This is carried out by the service class
CL_EXITHANDLER shipped by SAP. The exact syntax will be explained on a later slide. The
requirements for calling the methods of the program enhancement are thus fulfilled.
The BAdI class that implements the interface is generated in the BAdI definition. The interface
method of the BAdI class is called in the second call (2). The BAdI class searches for all of the
active implementations for the Business Add-In and calls the implemented methods.
SAP AG AC400 5-192
SAP AG 2006
Business Add-Ins: Calling Program
REPORT <program_using_badi>.
START-OF-SELECTION.
END-OF-SELECTION.
DATA: r_var
TYPE REF TO <badi-interface>.
CALL METHOD
cl_exithandler=>get_instance
CHANGING
instance = r_var.
CALL METHOD r_var->method
EXPORTING
<i_variables>
IMPORTING
<e_variables>.
r_var
1
2
Inst ance of
<badi-class>
The above syntax is required to call a Business Add-In. The numbers shown correspond to the
calls on the last slide.
First, you have to define a reference variable that refers to the BAdI interface. The name of the
reference variable does not have to contain the name of the BAdI.
An object reference is generated in the first call (1). This creates an instance of the generated
BAdI class. This object reference can address only the methods of the interface.
This object reference can then be used to call the methods provided by the enhancement (2).
SAP AG AC400 5-193
SAP AG 2006
Implementing BAdIs: Methods
FCodes Interface Propert ies
Method
BAdI method
Description
<badi-int erface>
Interface Name
<i mpl-cl ass>
Name of ImplementingClass
<method>
Class Buil der: Edi t Method <badi-i nterface>~<m...>
METHOD <badi-interface>~<method>.
*...
ENDMETHOD.
You can choose any name for the implementing class. However, SAP recommends that you
follow the proposed naming convention. The proposed name consists of
Namespace prefix, Y or Z
CL_ (stands for class)
IM_ (stands for implementation)
Name of the implementation (without namespace prefix)
By double-clicking the name of the method, you can go to the editor for implementing the
method.
Finally, you have to activate the objects.
SAP AG AC400 5-194
SAP AG 2006
Implementing BAdIs: Private Methods
Class Buil der: Edi t Method <badi-i nterface>~<m...>
METHOD <badi-interface>~<method>.
ENDMETHOD.
CALL METHOD < CALL METHOD <priv_method priv_method> EXPORTING ... . > EXPORTING ... .
Class Buil der: Change Cl ass <i mpl-cl ass>
Events Methods Propert ies
Method
New method in implementation
Description
<priv_method>
Type
Parameters Excepti ons
In the implementing class, you can create private methods that you call from the interface
method.
To do so, you edit the implementing class directly in the Class Builder. Here, you create the
private method and interface. You specify whether the method should be visible and
implement it.
SAP AG AC400 5-195
SAP AG 2006
Implementing BAdIs: Activation
Business Add-Ins: Implem. Mai ntenance Initi al Screen
<i mpl >
ImplementationName
Acti vate
Undo activation
Di spl ay Create Change
You can use the relevant icons to activate the implementation of a Business Add-In. From this
point on, the methods of the implementation are processed when the calling program is
executed.
If you deactivate the implementation, the methods are no longer called. The calls in the
application program are still processed. However, the instance of the adapter class is no longer
able to find an active implementation. Unlike the call "CALL CUSTOMER-FUNCTION", the
call "CALL METHOD CL_EXITHANDLER=>GET_INSTANCE" is still executed even
though there is no implementation. This also applies to the method call that calls the method of
the adapter class.
You can activate or deactivate a BAdI only in the original system of the implementation
without having to make actual modifications. When you do so, you have to transport the
activation/deactivation to the downstream systems.
Multiple implementations can exist in a system for a Business Add-In that can have only one
implementation. Only one implementation can be active at any one time.
SAP AG AC400 5-196
SAP AG 2006
Modifications must be maintai ned when SAP
Notes and system upgrades are implemented.
SAP recommends that customer enhancements
do not contain modifications.
BAdIs are used in particul ar to i mplement
customer enhancements without the need for
modi fications.
Customer Enhancements Unit Summary:
SAP AG AC400 5-197
SAP AG AC400 5-198
Exercises
Unit: Customer Enhancements
At the conclusion of this exercise, you will be able to:
Explain the concept of BAdIs
Implement BAdIs
1-1 Research the BAdIs shipped as standard
1-1-1 Use the Repository Information System of the Object Navigator to find
out how many BAdIs are shipped for Financial Accounting and Cost
Accounting.
1-1-2 Take a closer look at BAdI FAGL_AUTHORITY_CHECK. To which
component does the BAdI FAGL_AUTHORITY_CHECK belong?
How many methods does the BAdI have?
1-1-3 What parameters does the CHECK_LEDGER_AUTHORITY method
have? How does the method output the result of an authorization
check?
1-1-4 How many implementations already exist for the BAdI
FAGL_AUTHORITY_CHECK?
1-1-5 Implement the BAdI FAGL_AUTHORITY_CHECK. Use the
implementation name Y##FAGL_AUTHORITY. Save your
implementation as a local object. You do not have authorization for
ledger AL but do have authorization to display documents for ledger
0L.
As an optional requirement, you could use the function module
Y##AUTHORIZATION in your implementation to evaluate the
authorization that you grant according to the ledger. In this case, you
have to enhance the function module and your authorization object.
1-1-6 Now test your implementation in the BAdI environment. Then post a
G/L account document and check the document display.
SAP AG AC400 5-199
SAP AG AC400 5-200
Solutions
Unit: Customer Enhancements
1-1 Research the BAdIs shipped as standard
1-1-1 Use the Repository Information System of the Object Navigator to find
out how many BAdIs are shipped for Financial Accounting and Cost
Accounting.
Use transaction SE84 or choose Tools ABAP Workbench
Overview Information System..
Open the "Enhancements" folder in the object tree. Look for
"Definitions" under "Business Add-Ins". Use the following search
criteria
Application component FI* and CO*
Max. no. of hits 5000
1-1-2 Take a closer look at BAdI FAGL_AUTHORITY_CHECK. To which
component does the BAdI FAGL_AUTHORITY_CHECK belong?
How many methods does the BAdI have?
Use the following search criterion this time:
BAdI Name FAGL_AUTHORITY_CHECK
The "Attributes" tab page shows the package
"FAGL_POSTING_SERVICES". Double-click this package to view
the package properties. The package belongs to the component "FI-
GL". The "Interface" tab page lists exactly one method
"CHECK_LEDGER_AUTHORITY".
1-1-3 What parameters does the CHECK_LEDGER_AUTHORITY method
have? How does the method output the result of an authorization
check?
The "Interface" tab page lists the method
"CHECK_LEDGER_AUTHORITY". Double-click the method to
view its parameters. It has six import parameters. You can view the
exception messages by choosing the "Exceptions" pushbutton. The
result of the authorization check is provided by means of the
"NO_AUTHORITY" exception.
SAP AG AC400 5-201
1-1-4 How many implementations already exist for the BAdI
FAGL_AUTHORITY_CHECK?
You can view the implementations from the menu on the initial screen
by choosing Implementation Overview.
1-1-5 Implement the BAdI FAGL_AUTHORITY_CHECK. Use the
implementation name Y##FAGL_AUTHORITY. Save your
implementation as a local object. You do not have authorization for
ledger AL but do have authorization to display documents for ledger
0L.
As an optional requirement, you could use the function module
Y##AUTHORIZATION in your implementation to evaluate the
authorization that you grant according to the ledger. In this case, you
have to enhance the function module and your authorization object.
You can create your own implementations from the menu on the initial
screen by choosing Implementation Create. On the "Interface" tab
page, you can double-click a method to program it.
1-1-6 Now test your implementation in the BAdI environment. Then post a
G/L account document and check the document display.
On the "Interface" tab page, you can both program and test methods.
SAP AG AC400 6-202
SAP AG 2006
Overview Diagram: Extraction
Ex t r ac t i on
Ex t r ac t i on
The ABAP Wor k benc h
The ABAP Wor k benc h
Fi r st At t empt s at Pr ogr ammi ng
Fi r st At t empt s at Pr ogr ammi ng
Templ at e Al l oc at i on
Templ at e Al l oc at i on
Cust omer Enhanc ement s
Cust omer Enhanc ement s
Di al ogs and ALV Repor t s
Di al ogs and ALV Repor t s
SAP AG AC400 6-203
SAP AG 2006
Extraction Overview
This unit describes how data is extracted to the BW
system. In particular, it explains how to extract data
using function modules that you have created
yourself.
Contents:
SAP AG AC400 6-204
SAP AG 2006
Describe how data is extracted to the BW
system
Write your own extraction functions
Extraction: Unit Objectives
At the conclusion of this unit, you will be able to:
SAP AG AC400 6-205
SAP AG 2006
The Administrator Workbench
Model i ng
Moni t or i ng
Sc hedul i ng
Admi ni st r at or
Wor k benc h
BW creation
Maintenance
Admi ni strat ion
Schedul e dat a
transfer
Load data
Monitor data transf er
Monitor updat e process
The Administrator Workbench is a tool for maintaining, controlling, and monitoring Business
Information Warehouse.
For this reason, the Administrator Workbench is used at all levels in the BW system:
To create all the components of Business Information Warehouse, including Customizing
settings.
To schedule data transfer from different data sources.
To load data
To monitor data transfer and data updates
SAP AG AC400 6-206
SAP AG 2006
BW ser ver
Transfer structure
SAP syst em
Fi l e syst em
Communicationstructure
Transfer structure
Extraction
structure
Transfer structure Transfer structure
DataSource DataSource
Flatfile
DataSource
DataSource
(replicate)
DataSource
(replicate)
InfoSource
Data targets
Transfer structure
Extraction
structure
File
Mapping & transfer rules
Update rules
Data Flow from the Source to the Target System
An InfoSource is a set of logically related information that is grouped together in one unit.
InfoSources contain transaction data (stored in InfoCubes) and master data (attributes, texts,
and hierarchies - stored in separate tables).
InfoSources describe the set of all available information about a business transaction or a type
of business transaction (such as cost center accounting).
Transfer structures are used to transfer data in a DataSource between a source system and the
associated SAP BW system. The transfer structure transports the data in the DataSource from a
source system to an SAP BW system and forwards it to the InfoSource using transfer rules.
The communication structure is independent of the source system and is generated from the
InfoSource. It is filled from the transfer structure in accordance with the transfer rules. The
communication structure contains all the fields in an InfoSource. The process of extracting and
transferring cleansed data to the communication structure is referred to as "data staging".
SAP AG AC400 6-207
SAP AG 2006
BWserver
SAP sour c e syst em
DataSource
When the DataSource is
replicated, fields in the
extraction structure are used as
a template for the transfer
structure in BW.
1
2
When the(local) transfer
rules are activated, the transfer
structure is generated both
in the BW system and in the
SAP source system.
Extraction
structure
Transfer structure
Transfer structure
2 1
DataSource (replicate)
Verification Between the Source and Target System
The extraction tables in the source system represent the basis for a DataSource in an R/3
source system. The structure is created in the source system using the data elements that
describe the available data (usually in a table view).
With an R/3 source system, the "DataSource Replication" step copies the DataSource
extraction source structure as a template from the source system to the BW system.
SAP AG AC400 6-208
SAP AG 2006
Transfer Rules Transfer structure
Communication Str./Transfer Rules
0COMP_CODE
InfoObject Tp Rule
0CO_AREA
COSTC##
0CURRENCY
0PROFIT_CTR
0CO_AREA
COSTC##
0CURRENCY
0PROFIT_CTR
0COMP_CODE
InfoObject Field Assignment
InfoObject Field
0COMP_CODE
0PROFIT_CTR
0CURRENCY
COSTC##
KOKRS
WAERS
PRCTR
BUKRS
KOSTL
0CO_AREA
IDOC
Transfer Method
PSA
InfoSource COSTC## GR## Cost Center 13
Communicati on Structure
InfoObject Descript ion Status Type Length
0CO_AREA
COSTC##
0CURRENCY
0PROFIT_CTR
CHAR
CHAR
CHAR
CUKY
13
4
5
10
Controlling area
GR## Cost Center 13
Currency
Profit Center
Source Syst em IDES R/3
DataSource ZGR##CC_ATTR
Defining Transfer Rules
Transfer rules determine which fields in the transfer structure are transferred to which fields in
the communication structure. You can create detailed conversion rules to change or extend the
data that is transferred.
You can choose only one of the three types of transfer rule for each InfoObject in the
communication structure:
The fields are copied from the transfer structure and are not modified.
You can assign a fixed value to a field.
You can create/assign local transfer routines. Local transfer routines are ABAP programs
that you can copy or modify. The routine affects only the selected InfoObject in the
associated communication structure.
You have to activate the transfer rules before they can be applied.
SAP AG AC400 6-209
SAP AG 2006
You can use function modules to select the data
in the source system that you want to extract.
Extraction Unit Summary:
SAP AG AC400 6-210
Extraction - Exercises
Unit: Extraction
At the conclusion of this exercise, you will be able to transfer data from a
source system (such as R/3) to a BW system. You will be familiar with:
The data export concept using DataSources and extraction from the
source system
The procedure for importing data using InfoSources in the target
system
How to program an extraction using function modules.
1-1 Program an extraction module
1-1-1 Create the function module Y##BW. Use the extraction documentation
in SAP Library to define the interface. Use your function module to
select certain cost centers, such as all cost centers that belong to profit
center 1402 or those where Mr. J anning is the cost center manager.
1-1-2 Configure your function module Y##BW as an extractor by specifying
Y##DS as the master data DataSource. When you define the
DataSource, also enter "AC400AKR3" as the application component
and the export structure of your function module as the extraction
structure.
1-1-3 Test your extractor and use the debugger to analyze the extraction.
1-1-4 Log onto the BW system. Replicate the DataSource.
SAP AG AC400 6-211
1-2 Transfer data from the source system to the BW data model
After you have imported the data from the source system by replicating the
DataSource, you can transfer it to the BW data model. To do so, you first have
to define a data model and then verify the DataSource.
1-2-1 Define the characteristic TE_Y##M with the description "Y##Cost
Center" as an InfoObject for the BW model. The data type is CHAR
with length 10. Choose ALPHA as the conversion routine. Define the
following fields as characteristic attributes:
0CO_AREA
0COMP_CODE
0BUS_AREA
0PROFIT_CTR
0RESP_PERS
0EVCURRCOST.
1-2-2 Create the InfoSource TE_Y##M in the component "AC400AKBW"
to update master data of the InfoObject with the same name
(TE_Y##M) directly. Assign the DataSource Y##DS to the
InfoSource. In the transfer rules, assign your BW field TE_Y##M to
the source field KOSTL.
1-2-3 Control the transfer by creating an InfoPackage. On the "Processing"
tab page, choose "PSA and then in the InfoObject"; on the "Update"
tab page, choose "Full Update" and on the "Schedule" tab page, choose
"Start Data Load Immediately".
1-2-4 Load the cost centers from the source system. Observe the transfer in
the monitor and analyze the result.
SAP AG AC400 6-212
Solutions
Unit: Extraction
1-1 Program an extraction module
1-1-1 Create the function module Y##BW. Use the extraction documentation
in SAP Library to define the interface. Use your function module to
select certain cost centers, such as all cost centers that belong to profit
center 1402 or those where Mr. J anning is the cost center manager.
The extraction documentation is available at:
SAP Library SAP NetWeaver Information Integration
Business Intelligence
Then choose: SAP Business Information Warehouse Data
Warehousing Data Retrieval Data Extraction from SAP Source
Systems Customizing Extractors Maintaining Generic Data
Sources Function Module: Interface Description and Procedure
You can display a list of the existing cost centers in transaction KS13
by choosing Accounting Controlling Cost Center Accounting
Information System Reports for Cost Center Accounting Master
Data Indexes Cost Centers: Master Data Report
Table CSKS contains the cost center master data. This table must type
the export parameter E_T_DATA.
1-1-2 Configure your function module Y##BW as an extractor by specifying
Y##DS as the master data DataSource. When you define the
DataSource, also enter "AC400AKR3" as the application component
and the export structure of your function module as the extraction
structure.
DataSources are defined with transaction RSO2.
IMG Integration with Other mySAP.com Components Data
Transfer to the SAP Business Information Warehouse Generic
DataSources Maintain Generic DataSources
1-1-3 Test your extractor and use the debugger to analyze the extraction.
DataSources are also tested with transaction RSO2.
IMG Integration with Other mySAP.com Components Data
Transfer to the SAP Business Information Warehouse Generic
DataSources Maintain Generic DataSources
You can simulate the extraction by choosing DataSource Test
Extraction in the maintenance transaction.
SAP AG AC400 6-213
1-1-4 Log onto the BW system. Replicate the DataSource.
SAP AG AC400 6-214
1-2 Transfer data from the source system to the BW data model
After you have imported the data from the source system by replicating the
DataSource, you can transfer it to the BW data model. To do so, you first have
to define a data model and then verify the DataSource.
1-2-1 Define the characteristic TE_Y##M with the description "Y##Cost
Center" as an InfoObject for the BW model. The data type is CHAR
with length 10. Choose ALPHA as the conversion routine. Define the
following fields as characteristic attributes:
0CO_AREA
0COMP_CODE
0BUS_AREA
0PROFIT_CTR
0RESP_PERS
0EVCURRCOST
1-2-2 Create the InfoSource TE_Y##M in the component "AC400AKBW"
to update master data of the InfoObject with the same name
(TE_Y##M) directly. Assign the DataSource Y##DS to the
InfoSource. In the transfer rules, assign your BW field Y##_KOSTL to
the source field KOSTL.
1-2-3 Control the transfer by creating an InfoPackage. On the "Processing"
tab page, choose "PSA and then in the InfoObject"; on the "Update"
tab page, choose "Full Update" and on the "Schedule" tab page, choose
"Start Data Load Immediately".
1-2-4 Load the cost centers from the source system. Observe the transfer in
the monitor and analyze the result.
SAP AG AC400 7-215
SAP AG 2006
Overview Diagram: Template Allocation
Templ at e Al l oc at i on
Templ at e Al l oc at i on
The ABAP Wor k benc h
The ABAP Wor k benc h
Fi r st At t empt s at Pr ogr ammi ng
Fi r st At t empt s at Pr ogr ammi ng
Cust omer Enhanc ement s
Cust omer Enhanc ement s
Ex t r ac t i on
Ex t r ac t i on
Di al ogs and ALV Repor t s
Di al ogs and ALV Repor t s
SAP AG AC400 7-216
SAP AG 2006
Template Allocation Unit Overview
This unit presents the concept of templ ate
allocation and describes interfaces that allow you to
i mpl ement specific data access and cost
calculations.
Contents:
SAP AG AC400 7-217
SAP AG 2006
Use your own methods in template allocati on.
Template Allocation: Unit Objectives
At the conclusion of this unit, you will be able to:
SAP AG AC400 7-218
SAP AG 2006
The Template as a Costing Tool
Templ ate
BOM
No. BOM
Items
Standard cost
estimat e
Lot size
Mat erial mast er data
Wei ght
External -
systems
Meas. dat a
Rout ing
No. work centers
CO-PA
No. val ue fi elds
Cost drivers can originate from many areas in the integrated R/3 system.
Bills of material can provide the number of components in a cost object, for example, and the
routing can indicate the number of work centers through which the cost object must pass.
The standard cost estimate can provide the lot size of the material produced.
SAP AG AC400 7-219
SAP AG 2006
Product Costing with Templates
Rout -
ing
Bi ll of
mat eri al s
Material Lot size
CO - values
Material
Activities
Overhead
Processes:
300000
300100
Cost
element:
R-4000
Functions
Templ ate
Prod_1
Material:
R-4000
Stati sti cal
key fi gures
Processes
Ot her
SAP sources
P
ro
cess
q
u
an
tities
Product cost planning includes the quantities and prices from the planned consumption of
process quantities.
The cost component view can be maintained in Customizing to include processes in an
aggregated view of process costs and quantities for individual product cost plans.
In Customizing for cost components, you can define each component as valuation relevant if
the process costs should be included in inventory.
In the itemization view of the product cost estimate, process values are marked "X."
Overhead values calculated using a costing sheet are marked "G".
SAP AG AC400 7-220
SAP AG 2006
Material:
R 4000
Unit cost est imate/
standard cost esti mate
Derivation of Templates in the Cost Estimate
Template Prod _1
Template Prod_2
10
20
10
20
QuantityValuation time
Cleaning
Q. insp.
Process
30
20
Order-start
Delivery
Template Prod _3
Main template
Costi ng
sheet
Overhead
key
Overhead group:
SAP900
Val uati on
variant 001
Costi ng
variant PPC1
The link between the template and the cost estimate is created through a template assignment
function in Customizing.
The template is assigned to a combination of overhead key and costing sheet.
The costing sheet is linked to a valuation variant, which, in turn, is linked to a costing variant
that is linked to the order type.
The overhead group belongs to the material master data. It is assigned to an overhead key in
Customizing.
You can still use a costing sheet for overheads that are not modeled using processes.
SAP AG AC400 7-221
SAP AG 2006
Template for cost element
Pl. Qty. Pl. Act iv. Obj ect Act. Qty . Act. Act iv. . Act. Val. Ev.
Which
process?
Which process quantity?
When?
Under what condit ions?
Template Rows as Formula Vectors
A template is created within a certain environment, which is determined by the cost object
that will consume the process quantities. A process that is consumed by a PP production
order, for example, is controlled by a template created in environment 001. Conversely, a
process (possibly the same process) that is consumed by a sales order is controlled by a
template created in environment 008.
A template consists of pre-defined columns. Each of these columns looks for information -
that is, it asks a question. The answer may be entered by the user, or determined dynamically
by the system.
The real power of Activity-Based Costing in R/3 is realized when the system answers these
questions dynamically.
SAP AG AC400 7-222
SAP AG 2006
" Functions" as Form Components
Template for cost element
Pl. Qty. Pl. Act iv. Obj ect Act. Qty . Act. Act iv. . Act. Val. Ev.
Which
process?
How much of t he process
quant ity?
When?
Under what condit ions?
F
u
n
c
t
i
o
n
s
F
u
n
c
t
i
o
n
s
F
u
n
c
t
i
o
n
s
F
u
n
c
t
i
o
n
s
Each environment contains a specific set of functions for the user to select in order to answer
the questions shown above. You create a template using the functions in the individual cells.
Each template can contain as many rows as are necessary.
There are 3 different types of rows that can be created and combined in one template. Each
type of row serves a different purpose. A Comment row is used for documentation. A
Business Process row is used for process consumption by a cost object. A Subtemplate row is
used to link templates for a nested template structure. A Calculation row can be used when
multiple Business Process rows use the results of a single calculation (in the same template
only). If the template is created in the SBP (Structured Business Process) environment, an
additional TASK row type is available so that a cost center or activity type can be used in the
"Object" column.
SAP AG AC400 7-223
SAP AG 2006
Under what
conditi ons?
Subenvironment 101: Processes
Functi ons: ......
......
Subenvironment 103: Materi al
Functi ons: Material _Characterist ic_value
......
Subenvironment 107: General data
Functi ons: ......
......
Whi ch
process?
When?
Whi ch
process quantity?
PP producti on
order
Subenvironments as Function Groups
Each cost object in the system is permanently assigned to an environment. You cannot change
these assignments.
Each environment contains predefined subenvironments. This assignment is also fixed and
cannot be changed.
Each subenvironment contains a collection of specific functions that refer to the data in that
particular subenvironment. For instance, a function designed to read the material
characteristics assigned to a material in the material master is located in the Material
subenvironment in the environment defined by the consuming cost object.
The template, which is assigned to a specific environment when it is created, can access all
the functions that are assigned to the subenvironments.
SAP AG AC400 7-224
SAP AG 2006
Environments and Subenvironments
Subenvironment 105:
Routi ng
Subenvironment 103:
Materi al
New functions
Subenvironment 107:
General data
Envi ronment 001: mat. c. est./
producti on orders
Envi ronment 003: matl c. est.
wi thout quanti ty structure
Envi ronment PAC:
costi ng-based
profitability analysis
Subenvironment 101:
Sender process
Standard Opti onal
A subenvironment can be assigned to more than one environment, which means that the
functions within the subenvironment are available to more than one type of cost object. For
instance, the functions of the subenvironment that involve routings are available for sales
orders and production orders, but not for cost estimates without a quantity structure.
You can assign your own functions to either a subenvironment or an environment directly.
Assigning functions to a subenvironment provides you with greater flexibility, because more
than one type of cost object can use the available functions.
In Customizing, you can restrict the use of each new function to a single cell in the template.
Inside each cell, you can restrict how the function is used even further. By doing so, you can
ensure that the functions are used effectively. For instance, if a function requires a material
number as a parameter, only material number functions are made available.
SAP AG AC400 7-225
SAP AG 2006
Function Modules as Functions
Functions
Table field ABAP-Functions
Storage location: 0001
Material Master View:MRP. 2
Procurement
K_ABC_ORDER_MAT_CONFIRMATION
Table name:
MARC
Field name:LGPRO
There are two different kinds of functions: table-field and ABAP functions.
A table-field function allows a function to use fields from tables that have been allowed in the
specific, shipped environments.
An ABAP function is required if you need access to a field in a table that is not included in
the specific, shipped environments.
New functions must be created within the template environment area in Customizing.
When you create new functions, you must observe the three-level naming convention that
requires an external name, an internal name, and a logical function name.
Functions can be copied, changed, and/or renamed.
SAP AG AC400 7-226
SAP AG 2006
You can create your own allocation methods in
template allocation.
By doing so, you can implement your own
access types and cost calculations.
The al location methods are realized by function
modules.
Template Allocation Unit Summary:
SAP AG AC400 7-227
Exercises
Unit: Function Modules in Template Allocation
At the conclusion of this exercise, you will be able to:
Use function modules in template allocation
1-1 Program your own function module for template allocation
1-1-2 Analyze the storage conditions for material R-F100 in plant 1000 at
storage location 002. Does a temperature condition exist?
1-1-3 Create a function module Y##WHENERGY that calculates and
outputs the warehouse energy consumption for a specific material
number, whose volume is measured in cubic meters, according to the
following formula: energy =volume x 1000 x temperature condition
1-1-4 Before your function module Y##WHENERGY can be used in the
template allocation, it must satisfy certain interface requirements. Find
out what these requirements are. To do so, use SAP Library or analyze
a function module that is already used in the template allocation.
1-2 Use your own function modules in the template allocation
1-2-1 First analyze the process costs in the cost estimate for material R-
F100. Which processes are involved and in what quantity? How is the
output quantity maintained?
1-2-2 Create a Y##Energy_consumption function with the same logical
function name in the "Materials" subenvironment in environment 001
(material cost estimate/production orders) . Assign your
Y##WHENERGY function module to this function. On the "Usage"
tab page for business processes, allow the function to calculate
quantities.
1-2-3 Create a template Y##. In this template, the quantity of the business
process 300901 ("Cooling") is calculated as a product of the
warehouse energy consumption for the order material and the total
material quantity for the order.
1-2-4 Add your template Y##to the template COPC-10 as a subtemplate.
1-2-5 Check the rate specified in annual planning for business process
300901 ("Cooling").
1-2-6 Recalculate the cost of goods manufactured for material R-F100.
SAP AG AC400 7-228
SAP AG AC400 7-229
Solutions
Unit: Function Modules in Template Allocation
1-1 Program your own function module for template allocation
1-1-1 Analyze the storage conditions for material R-F100. Does a
temperature condition exist? Which fields contain a temperature
condition and volume?
Start transaction MM03 by choosing Logistics Materials
Management Material Master Material Display Display
Current
Material R-F100
Pushbutton "Select (views)"
Choose General Plant Data / Storage 1
Choose General Plant Data / Storage 2
Choose "Continue"
Plant 1000
Storage location 0002
The "Plant Data / Stor. 1" tab page shows the temperature condition
01; the "Plant Data / Stor. 2" tab page shows the volume 0.75 M3. You
can use the input help to display the "Technical Information" for a
selected field. This information provides the names of the database
fields. These fields are:
Temperature conditions MARA-TEMPB
Volume MARA-VOLUM
Volume Unit MARA-VOLEH
SAP AG AC400 7-230
1-1-2 Before your function module Y##WHENERGY can be used in the
template allocation, it must satisfy certain interface requirements. Find
out what these requirements are. To do so, use SAP Library or analyze
a function module that is already used in the template allocation.
You can find the interface conditions in SAP Library by choosing
Financials Controlling Activity-Based Costing Template
Environment of Templates Implementing ABAP Functions.
In the template allocation function in the system (transaction CTU6),
you can find the "MaterialCharacteristicValue" function in the
"Materials" subenvironment of environment 001 by choosing IMG
Controlling Activity-Based Costing Templates Define
Environments and Function Trees. This is assigned to the function
module K_ABC_MATERIAL_FEATURE_VALUE and can be
analyzed with transaction SE37, for example.
1-1-3 Create a function module Y##WHENERGY that calculates and
outputs the warehouse energy consumption for a specific material
number, whose volume is measured in cubic meters, according to the
following formula: energy =volume x 1000 x temperature condition
* The t abl e par amet er RTABLE_VAL of t ype TPLI C_RVAL_TAB
* i s def i ned i n t he t ype gr oup TPLI C. Thi s must be st or ed i n
t he
* t op i ncl ude i n t he f ol l owi ng f or mat :
* TYPE- POOLS: t pl i c.
FUNCTI ON Y##WHENERGY.
*" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
*" *" Local i nt er f ace:
*" I MPORTI NG
*" REFERENCE( I D_MATNR) TYPE MATNR
*" REFERENCE( PERI OD_FROM)
*" REFERENCE( PERI OD_CNT)
*" REFERENCE( CALL_PROG) TYPE SY- REPI D
*" TABLES
*" RTABLE_VAL TYPE TPLI C_RVAL_TAB
*" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
* dat a
DATA: l s_mar a TYPE mar a.
DATA: l d_t emp_f akt or TYPE i .
DATA: l d_quant i t y TYPE t pl i c_r val - val ue.
DATA: l d_wa_r val TYPE t pl i c_r val .
* Cl ear out put
CLEAR r t abl e_val [ ] .
* Get mast er dat a
SELECT SI NGLE *
FROM mar a
I NTO l s_mar a
SAP AG AC400 7-231
WHERE mat nr = i d_mat nr .
* Mast er r ecor d f ound?
CHECK sy- subr c = 0.
* Eval uat e t emper at ur e condi t i on
CASE l s_mar a- t empb.
WHEN ' 01' .
l d_t emp_f akt or = 1.
WHEN ' 02' .
l d_t emp_f akt or = 2.
WHEN ' 03' .
l d_t emp_f akt or = 3.
WHEN OTHERS.
ENDCASE.
* Eval uat e vol ume and det er mi ne r esul t
CASE l s_mar a- vol eh.
WHEN ' M3' .
l d_quant i t y = l s_mar a- vol um* 1000 * l d_t emp_f akt or .
WHEN OTHERS.
" not hi ng t o do.
ENDCASE.
* i f no per i odi c r esul t , f i l l t he r esul t t abl e f or per i ods
DO per i od_cnt TI MES.
l d_wa_r val - per i od = per i od_f r om+ sy- i ndex - 1.
l d_wa_r val - val ue = l d_quant i t y.
APPEND l d_wa_r val TO r t abl e_val .
ENDDO.
ENDFUNCTI ON.
1-1-4 Test your function module for material R-F100.
1-2 Use your own function modules in the template allocation
1-2-1 First analyze the process costs in the cost estimate for material R-
F100. Which processes are involved and in what quantity? How is the
output quantity maintained?
To find the material cost estimate (transaction CK13N), choose
Accounting Controlling Product Cost Controlling Product
Cost Planning Material Costing Cost Estimate with Quantity
Structure Display.
Material R-F100
Plant 1000
Costing variant PPC1
The costing structure functions include the "Materials Only/All Items"
pushbutton. You can use this pushbutton to expand the list to show all
SAP AG AC400 7-232
cost items and, in particular, the list of processes. A process is
allocated for the cost of goods manufactured:
Process Number Quantity
Work Scheduling 300900 1 pc
1-2-2 Create a Y##Energy_consumption function with the same logical
function name in the "Materials" subenvironment in environment 001
(material cost estimate/production orders) . Assign your
Y##WHENERGY function module to this function. On the "Usage"
tab page for business processes, allow the function to calculate
quantities.
Start the template allocation function in the system (transaction CTU6)
by choosing IMG Controlling Activity-Based Costing
Templates Define Environments and Function Trees
and select the "Materials" subenvironment in the object tree. Choose
"Create Function" from the context menu.
Function Y##Energy_consumption
Radio button "Lower Level"
Tab page "Basic Data"
Log. Function Name Y##WHENERGY
Tab page "Implementation"
ABAP Function Name Y##WHENERGY
Tab page "Usage"
Tab page "All Columns"
Select "Quantity Plan" in the "Business Process" row.
Pushbutton "Save"
SAP AG AC400 7-233
1-2-3 Create a template Y##. In this template, the quantity of the business
process 300901 ("Cooling") is calculated as a product of the
warehouse energy consumption for the order material and the total
material quantity for the order.
Start the template allocation function (transaction CTU6) in the system
by choosing
IMG Controlling Activity-Based Costing Templates
Maintain Templates
and choose "Create Template:
Template Y##
Environment 001
Enter another row:
Type "Business Process"
Object "300901"
Plan Quantity Double-click the field
In the editor, enter:
Y##Energy_consumption ( ID_MATNR =OrderMaterial ) *
OrderTotalQuantity
Pushbutton "Confirm Plan Quantity"
Enter "ACTIVE" in the "Plan Activation" column.
1-2-4 Add your template Y##to the template COPC-10 as a subtemplate.
Start the template allocation function (transaction CTU6) in the system
by choosing
IMG Controlling Activity-Based Costing Templates
Maintain Templates
and choose "Change Template":
Template COPC-10
Environment 001
Enter another row:
Pushbutton "Insert Row"
Type "Subtemplate"
Object Y##
Plan Activation "ACTIVE"
SAP AG AC400 7-234
1-2-5 Check the rate specified in annual planning for business process
300901 ("Cooling").
Start transaction CP26 by choosing
Accounting Controlling Activity-Based Costing Planning
Process Quantities/Prices Change
Version 0
From Period: Current period
To Period current period
Fiscal Year Current fiscal year
Pushbutton Overview Screen
Make sure that a price has been defined.
1-2-6 Recalculate the cost of goods manufactured for material R-F100.
You can find the material cost estimate (transaction CK13N) by
choosing
Accounting Controlling Product Cost Controlling
Product Cost Planning Material Costing Cost Estimate with
Quantity Structure Create
Material R-F100
Plant 1000
Costing variant PPC1
The costing structure functions include the "Materials Only/All Items"
pushbutton. You can use this pushbutton to expand the list to show all
cost items and, in particular, the list of processes. Process "300901"
here shows the quantity that was calculated using your function
module.
SAP AG AC400 8-235
SAP AG 2006
Appendix
Optional exercise 1
Write a program for maintaining customer address data
Optional Exercise 2
Write a program for opening and closing FI periods
Optional exercise 3
Program a report for master data groups in Cost
Accounting
SAP AG AC400 8-236
SAP AG AC400 8-237
Optional Exercise F1
Write a Program for Maintaining Customer Address Data
At the conclusion of this exercise, you will be able to:
Create tables
Select records from tables and write to tables
Call function modules
Requirement
The following function is available for vendors and is also required for customers:
Changes to addresses that are already known but will not take effect until a future date
can be maintained in advance. This takes place in three steps: Future changes can be
entered on a key-date basis using transaction MK12 (see path below). The planned
changes can be viewed with transaction MK14. Changes that have been flagged for key
dates can be activated with transactions MKH3 and MKH4. The paths are as follows:
MK12 Logistics Materials Management Purchasing Master Data
Vendor
Purchasing Change (Planned)
MK14 Logistics Materials Management Purchasing Master Data
Vendor
Purchasing Planned Changes
MKH3 Vendor Activate Planned Changes Activation Online
System Analysis
Find out which tables store the customer master data. If necessary, use the ABAP
Workbench or debugger to do so.
Program Design
The following functions are required to maintain the future customer address data:
(a) The existing address data is modeled as a template for future changes in
the form of a copy of the customer address data stored in a custom address
table
(b) There must be an option of maintaining the custom address table so that
key-date based updates can be flagged.
(c) The release of flagged updates is modeled in the form of a copy of the
custom address data to the standard address data table.
(d) It must be possible to reactivate the previous address data so that any
update errors can be rectified.
The custom address table is a copy of the standard address table ADRC with the name
Y##ADRC. If the definition of table Y##ADRC allows data to be displayed and
SAP AG AC400 8-238
maintained ("Delivery and Maintenance" tab page), you do not need to program the
function listed under (b) because you can use transaction SE16 instead.
In this case, write a program that offers three options:
(a) "INITI" for modeling the function listed under (a)
(b) "ACTIV" for modeling the function listed under (c)
(c) "REACT" for modeling the function listed under (d)
Task
F1-1 Create table Y##ADRC as a copy of table ADRC. Allow table maintenance.
F1-2 Create a domain Y##ACTION called "Action". The data type is CHAR and the
number of characters 10. For the range, define three fixed values "INITI" with the
description "Initialize", "ACTIV" with the description "Activate Changes", and
"REACT" with the description "Undo Changes".
F1-3 Create a data element Y##ACTION with the name "Action". Assign the domain
Y##ACTION to the data element.
F1-4 Create a Y##CUSTOMER program that contains the functions of the actions.
SAP AG AC400 8-239
Solution for Optional Exercise F1
Write a Program for Maintaining Customer Address Data
Requirement
The following function is available for vendors and is also required for customers:
Changes to addresses that are already known but will not take effect until a future date
can be maintained in advance. This takes place in three steps: Future changes can be
entered on a key-date basis using transaction MK12 (see path below). The planned
changes can be viewed with transaction MK14. Changes that have been flagged for key
dates can be activated with transactions MKH3 and MKH4. The paths are as follows:
MK12 Logistics Materials Management Purchasing Master Data
Vendor
Purchasing Change (Planned)
MK14 Logistics Materials Management Purchasing Master Data
Vendor
Purchasing Planned Changes
MKH3 Vendor Activate Planned Changes Activation Online
System Analysis
Find out which tables store the customer master data. If necessary, use the ABAP
Workbench or debugger to do so.
Program Design
The following functions are required to maintain the future customer address data:
(a) The existing address data is modeled as a template for future changes in
the form of a copy of the customer address data stored in a custom address
table
(b) There must be an option of maintaining the custom address table so that
key-date based updates can be flagged.
(c) The release of flagged updates is modeled in the form of a copy of the
custom address data to the standard address data table.
(d) It must be possible to reactivate the previous address data so that any
update errors can be rectified.
The custom address table is a copy of the standard address table ADRC with the name
Y##ADRC. If the definition of table Y##ADRC allows data to be displayed and
maintained ("Delivery and Maintenance" tab page), you do not need to program the
function listed under (b) because you can use transaction SE16 instead.
In this case, write a program that offers three options:
(a) "INITI" for modeling the function listed under (a)
(b) "ACTIV" for modeling the function listed under (c)
SAP AG AC400 8-240
(c) "REACT" for modeling the function listed under (d)
Task
F1-1 Create table Y##ADRC as a copy of table ADRC. Allow table maintenance.
Tools ABAP Workbench Development ABAP Dictionary
(SE11)
Select "Database table"
Database table ADRC
Function "Copy"
From Table ADRC
To Table Y##ADRC
Function Local Object
Tools ABAP Workbench Development ABAP Dictionary
(SE11)
Select "Database table"
Database table Y##ADRC
Function Change
Tab page "Delivery and Maintenance"
Date Browser X Display/Maintenance Allowed
Function "Activate"
F1-2 Create a domain Y##ACTION called "Action". The data type is CHAR and the
number of characters 10. For the range, define three fixed values "INITI" with the
description "Initialize", "ACTIV" with the description "Activate Changes", and
"REACT" with the description "Undo Changes".
Tools ABAP Workbench Development ABAP Dictionary
(SE11)
Select "Domain"
Domain Y##ACTION
Function "Create"
Short description Action for program Y##Customer
Tab page "Definition"
Data Type "CHAR"
No. Characters 10
Tab page "Value Range"
Fixed Value INITI
SAP AG AC400 8-241
Short Text Initialize
Fixed Value ACTIV
Short Text Activate changes
Fixed Value REACT
Short Text Undo changes
Function "Activate"
Function Local Object
F1-3 Create a data element Y##ACTION with the name "Action". Assign the domain
Y##ACTION to the data element.
Tools ABAP Workbench Development ABAP Dictionary
(SE11)
Select "Data Type"
Data Type Y##ACTION
Function "Create"
Select "Data Element"
Short Text Action for program Y##Customer
Tab page "Data Type"
Select "Elementary Type"
Select "Domain"
Domain Y##ACTION
Tab page "Field Label"
Short label Action
Medium label Action
Long label Action
Heading Action
Function "Activate"
Function "Local Object"
F1-4 Create a Y##CUSTOMER program that contains the functions of the actions.
You can create the message of class AC400 with the number 600 in the same way
as described for program Y##CUSTOMER. As soon as you have created the
program (as described below), you can maintain the selection texts in the editor
menu under
Goto Text Elements Selection Texts
by referencing the Data Dictionary.
Tools ABAP Workbench Overview Object Navigator
SAP AG AC400 8-242
View Local objects
Local objects AC400-##
Select the rood node $TMP AC400-##
Context menu Create Program
Program Y##CUSTOMER (without top
include)
Title Maintain future customer master data
Type "1 Executable Program"
Function "Save"
Function "Local Object"
In the proposed solution, we will use "AC400" instead of "Y##".
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*& Repor t AC400CUSTOMER
*&
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*&
*&
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
REPORT ac400cust omer .
* Tabl es
TABLES: kna1.
* Par amet er s
PARAMETERS: p_dat e TYPE dat e_f r omDEFAULT sy- dat umNO- DI SPLAY.
SELECT- OPTI ONS: r _kunnr FOR kna1- kunnr .
PARAMETERS: p_act i on TYPE ac400act i on.
* Types
TYPES: yt _kunnr LI KE TABLE OF r _kunnr .
TYPES: yt _kna1 TYPE TABLE OF kna1.
TYPES: ys_kna1 TYPE kna1.
TYPES: ys_adr c TYPE adr c.
TYPES: yt _adr c TYPE TABLE OF ys_adr c.
TYPES: ys_ac400adr c TYPE ac400adr c.
TYPES: yt _ac400adr c TYPE TABLE OF ys_ac400adr c.
* Const ant s
CONSTANTS: gc_f i r st _dat e LI KE sy- dat umVALUE ' 00010101' .
CONSTANTS: gc_l ast _dat e LI KE sy- dat umVALUE ' 99991231' .
SAP AG AC400 8-243
CONSTANTS: gc_empt y_nat i on TYPE ad_nat i on VALUE I S I NI TI AL.
* Cal l t he mai n pr ogr am
PERFORM mai n
USI NG p_dat e
r _kunnr [ ]
p_act i on.
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m mai n
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* t ext
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* - - >P_P_DATE t ext
* - - >P_R_KUNNR[ ] t ext
* - - >P_P_ACTI ON t ext
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM mai n
USI NG i d_dat e LI KE sy- dat um
i t _kunnr TYPE yt _kunnr
i d_act i on TYPE ac400act i on.
* dat a
DATA: l t _kna1 TYPE yt _kna1.
DATA: l s_kna1 TYPE ys_kna1.
DATA: l d_answer TYPE char 3.
* Aut hor i zat i on check
CALL FUNCTI ON ' Y_AC400AUTHORI TY'
I MPORTI NG
ed_answer = l d_answer .
CASE l d_answer .
WHEN ' I ES' .
" ok
WHEN OTHERS.
MESSAGE e600( f 1) WI TH sy- uname t ext - 001.
ENDCASE.
* sel ect f r omkna1
SELECT *
FROM kna1
I NTO TABLE l t _kna1
WHERE kunnr I N i t _kunnr [ ] .
* i nser t ykna1
LOOP AT l t _kna1
I NTO l s_kna1.
* Eval uat e accor di ng t o act i on
CASE p_act i on.
* I ni t i al i ze
WHEN ' I NI TI ' .
PERFORM i ni t i al i ze
SAP AG AC400 8-244
USI NG p_dat e
l s_kna1.
* Act i vat e
WHEN ' ACTI V' .
PERFORM act i vat e
USI NG p_dat e
l s_kna1.
* React i vat e
WHEN ' REACT' .
PERFORM r eact
USI NG p_dat e
l s_kna1.
* Undef i ned i nput
WHEN OTHERS.
MESSAGE I D ' AC400' TYPE ' E' NUMBER ' 600'
WI TH ' Choose a val i d act i on" .
ENDCASE.
WRI TE: / ' Vendor ' , l s_kna1- kunnr , ' has been mai nt ai ned' .
ENDLOOP.
ENDFORM. " mai n
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m i ni t i al i ze
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM i ni t i al i ze
USI NG i d_dat e TYPE dat e_f r om
i s_kna1 TYPE ys_kna1.
* dat a
DATA: l s_adr c TYPE ys_adr c.
DATA: l s_yadr c TYPE ys_ac400adr c.
SELECT SI NGLE *
FROM adr c
I NTO l s_adr c
WHERE addr number = i s_kna1- adr nr
AND dat e_f r om = gc_f i r st _dat e
AND nat i on = gc_empt y_nat i on.
* Del et e exi st i ng ent r i es
DELETE FROM ac400adr c
WHERE addr number = i s_kna1- adr nr .
* I nser t new f r omkna1
MOVE- CORRESPONDI NG l s_adr c TO l s_yadr c.
l s_yadr c- dat e_f r om= i d_dat e.
I NSERT ac400adr c FROM l s_yadr c.
ENDFORM. " i ni t i al i ze
SAP AG AC400 8-245
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m act i vat e
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* t ext
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* - - >P_I D_DATE t ext
* - - >P_LS_KUNNR t ext
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM act i vat e
USI NG i d_dat e TYPE dat e_f r om
i s_kna1 TYPE ys_kna1.
* dat a
DATA: l s_adr c TYPE ys_adr c.
DATA: l s_ac400adr c TYPE ys_ac400adr c.
DATA: l s_adr c_ol d TYPE ys_adr c.
DATA: l s_adr c_new TYPE ys_adr c.
SELECT SI NGLE *
FROM adr c
I NTO l s_adr c
WHERE addr number = i s_kna1- adr nr
AND dat e_f r om = gc_f i r st _dat e
AND nat i on = gc_empt y_nat i on.
SELECT SI NGLE *
FROM ac400adr c
I NTO l s_ac400adr c
WHERE addr number = i s_kna1- adr nr
AND dat e_f r om = i d_dat e
AND nat i on = gc_empt y_nat i on.
I F sy- subr c = 0.
* i ni t l s_kna1_new
MOVE- CORRESPONDI NG l s_ac400adr c TO l s_adr c_new.
l s_adr c_new- dat e_f r om= gc_f i r st _dat e.
* Updat e cust omer s
UPDATE adr c FROM l s_adr c_new.
* Ar chi ve pr evi ous ent r y
l s_adr c_ol d = l s_adr c.
l s_adr c_ol d- dat e_f r om= i d_dat e - 1.
l s_adr c_ol d- dat e_t o = i d_dat e - 1.
MODI FY adr c FROM l s_adr c_ol d.
ELSE.
" not hi ng t o do
ENDI F.
ENDFORM. " act i vat e
SAP AG AC400 8-246
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m r eact
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM r eact
USI NG i d_dat e TYPE dat e_f r om
i s_kna1 TYPE ys_kna1.
* dat a
DATA: l s_adr c_r TYPE ys_adr c.
DATA: l s_adr c_f TYPE ys_adr c.
DATA: l t _adr c TYPE yt _adr c.
DATA: l d_l en LI KE sy- t abi x.
SELECT *
FROM adr c
I NTO TABLE l t _adr c
WHERE addr number = i s_kna1- adr nr
AND dat e_f r om <= i d_dat e
AND nat i on = gc_empt y_nat i on.
SORT l t _adr c ASCENDI NG BY dat e_f r om.
DESCRI BE TABLE l t _adr c LI NES l d_l en.
I F l d_l en > 0.
* I ncor r ect sent ence
LOOP AT l t _adr c
I NTO l s_adr c_f
WHERE dat e_f r om= gc_f i r st _dat e.
EXI T.
ENDLOOP.
l s_adr c_f - dat e_f r om= i d_dat e - 1.
l s_adr c_f - dat e_t o = i d_dat e - 1.
MODI FY adr c FROM l s_adr c_f .
* Cor r ect sent ence
READ TABLE l t _adr c I NDEX l d_l en I NTO l s_adr c_r .
l s_adr c_r - dat e_f r om= gc_f i r st _dat e.
l s_adr c_r - dat e_t o = gc_l ast _dat e.
MODI FY adr c FROM l s_adr c_r .
ENDI F.
ENDFORM. " r eact
SAP AG AC400 8-247
Optional Exercise F2
Write a Program for Opening and Closing FI Periods
At the conclusion of this exercise, you will be able to:
Create tables
Select records from tables and write to tables
Call function modules
Display data records
Evaluate pushbuttons pressed by the user
Requirement
In Customizing for Accounting, periods can be opened or closed for posting. The relevant
path is:
IMG Financial Accounting Financial Accounting Global Settings
Document Posting Periods
For selected variants, you want the open periods interval to be shifted by one period on a
recurring key date (such as the end of the month). Assume that today is April 1 and this is
our key date. The periods open for posting up to now are February and March. As of
today, March and April are open for posting.
System Analysis
Find out which table contains the interval for open periods. If necessary, use the ABAP
Workbench or debugger to do so.
Program Design
The following objects are required to maintain the future customer address data:
(a) A custom table containing an (optional) key date for each period interval
(b) A program with the variant of the posting periods as a parameter. When called, it
determines the corresponding key date for the entered period interval variant. If the key
date has been exceeded, the period interval is shifted by one period. Before the data is
saved, the current and new statuses are displayed.
Task
Implement the above requirement. Your custom table is Y##T001B. Your program for
maintaining the posting periods is Y##PV.
SAP AG AC400 8-248
SAP AG AC400 8-249
Solution for Optional Exercise F2
Write a Program for Opening and Closing FI Periods
Requirement
In Customizing for Accounting, periods can be opened or closed for posting. The relevant
path is:
IMG Financial Accounting Financial Accounting Global Settings
Document Posting
Periods
For selected variants, you want the open periods interval to be shifted by one period on a
recurring key date (such as the end of the month). Assume that today is April 1 and this is
our key date. The periods open for posting up to now are February and March. As of
today, March and April are open for posting.
System Analysis
Find out which table contains the interval for open periods. If necessary, use the ABAP
Workbench or debugger to do so.
For example, call the transaction for maintaining the open periods:
IMG Financial Accounting Financial Accounting Global Settings Document
Posting Periods Open and Close Posting Periods
Select the first variant ("0001"). Press F1. Choose the "Technical Information"
pushbutton. The referenced table is "V_T001B" (this is actually a table view). You can
use the Data Dictionary (SE11) to take a look at this view. The table referenced in view
V_T001B is T001B. The entries in table T001B (which you can view with SE16) are
those that are proposed for maintenance in Customizing for open periods.
Program Design
The following objects are required to maintain the future customer address data:
(a) A custom table containing an (optional) key date for each period interval
(b) A program with the variant of the posting periods as a parameter. When called, it
determines the corresponding key date for the entered period interval variant. If the key
date has been exceeded, the period interval is shifted by one period. Before the data is
saved, the current and new statuses are displayed.
Task
Implement the above requirement. Your custom table is Y##T001B. Your program for
maintaining the posting periods is Y##PV.
SAP AG AC400 8-250
For more information on how to create a program and tables, refer to the solution for the
task "Write a Program for Maintaining Customer Address Data".
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& Repor t AC400PV
*&
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* The cust omt abl e ac400t 001b r ef er enced i n t he r epor t i s
* act i vat ed f or mai nt enance and bel ongs t o del i ver y cl ass c.
* The t echni cal set t i ngs ar e dat a t ype APPL2 and
* si ze cat egor y 0.
* The t abl e has t he f ol l owi ng st r uct ur e:
* Fi el d Key Dat a el ement Dat a t ype Lengt h
* Mandt x Mandt
* Rr ct y x Rr ct y
* Opvar x Opvar
* Mkoar x Mkoar
* Key dat e Numc 2
* St at us 1000 r ef er enced i n t he r epor t uses t he f unct i ons
* of t he f unct i on keys:
* SAVE f or save
* ENTR f or cont i nue
REPORT ac400pv.
* Types
TYPES: ys_t 001b TYPE t 001b.
TYPES: yt _t 001b TYPE TABLE OF ys_t 001b.
TYPES: ys_ac400t 001b TYPE ac400t 001b.
TYPES: yt _ac400t 001b TYPE TABLE OF ys_ac400t 001b.
* Par amet er s
PARAMETERS: p_opvar TYPE opvar OBLI GATORY.
* Dat a
DATA: l s_t 001 TYPE t 001.
DATA: l s_t 001b_ol d TYPE ys_t 001b.
DATA: l s_t 001b_new TYPE ys_t 001b.
DATA: l t _t 001b_ol d TYPE yt _t 001b.
DATA: l t _t 001b_new TYPE yt _t 001b.
DATA: l s_ac400t 001b TYPE ys_ac400t 001b.
DATA: l t _ac400t 001b TYPE yt _ac400t 001b.
DATA: l d_r esul t TYPE c.
DATA: l d_day_f ound TYPE c.
* Set st at us
SET PF- STATUS ' 1000' .
* Load T001b wi t h t he open per i ods f or sel ect ed var i ant
PERFORM l oad_t 001b
USI NG p_opvar
CHANGI NG l t _t 001b_ol d.
SAP AG AC400 8-251
* Load ac400t 001b wi t h t he key dat es f or sel ect ed var i ant
PERFORM l oad_ac400t 001b
USI NG p_opvar
CHANGI NG l t _ac400t 001b.
* Load Per i v f r omr ef er ence company code f or var i ant
PERFORM l oad_per i v
USI NG p_opvar
CHANGI NG l s_t 001.
* Edi t t he r ecor ds f or t he var i ant
LOOP AT l t _t 001b_ol d
I NTO l s_t 001b_ol d.
* Rest r i ct t abl e ac400t 001b dependi ng on t 001b r ecor d
PERFORM get _day
USI NG l t _ac400t 001b
l s_t 001b_ol d
CHANGI NG l s_ac400t 001b
l d_day_f ound.
* Dependi ng on key dat e mai nt enance
CASE l d_day_f ound.
* Key dat e mai nt ai ned
WHEN ' Y' .
* Key dat e r eached?
PERFORM check_day
USI NG l s_t 001
l s_ac400t 001b
l s_t 001b_ol d
CHANGI NG l d_r esul t .
* Br anch accor di ng t o l d_r esul t
CASE l d_r esul t .
* Key dat e r eached => mai nt ai n per i ods
WHEN ' Y' .
* Cal cul at e Cust omi zi ng
PERFORM cal c_t 001b
USI NG l s_t 001
l s_t 001b_ol d
CHANGI NG l s_t 001b_new.
* Di spl ay Cust omi zi ng
PERFORM show_t 001b
USI NG l s_t 001b_ol d
l s_t 001b_new.
APPEND l s_t 001b_new TO l t _t 001b_new.
SAP AG AC400 8-252
* Key dat e NOT r eached
WHEN ' N' .
* Undef i ned
WHEN OTHERS.
ENDCASE.
* Key dat e not mai nt ai ned
WHEN OTHERS.
" not hi ng t o do
ENDCASE.
ENDLOOP.
* at user - command
AT USER- COMMAND.
PERFORM do_ucomm
USI NG sy- ucomm
l t _t 001b_new.
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m l oad_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM l oad_t 001b
USI NG i d_opvar TYPE opvar
CHANGI NG et _t 001b TYPE yt _t 001b.
* Cl ear out put
CLEAR et _t 001b.
* dat a
DATA: l d_empt y_bkont TYPE bkont _001b.
* sel ect
SELECT *
FROM t 001b
* I NTO es_t 001b
I NTO TABLE et _t 001b
WHERE r r ct y = ' 0'
AND bukr s = i d_opvar .
* AND mkoar = ' +'
* AND bkont = l d_empt y_bkont .
ENDFORM. " l oad_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m l oad_ac400t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM l oad_ac400t 001b
USI NG i d_opvar TYPE opvar
CHANGI NG et _ac400t 001b TYPE yt _ac400t 001b.
* Cl ear out put
SAP AG AC400 8-253
CLEAR et _ac400t 001b[ ] .
* Sel ect
SELECT *
FROM ac400t 001b
I NTO TABLE et _ac400t 001b
WHERE opvar = i d_opvar
AND r r ct y = ' 0' .
ENDFORM. " l oad_ac400t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m l oad_per i v
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM l oad_per i v
USI NG i d_opvar TYPE opvar
CHANGI NG es_t 001 TYPE t 001.
* Cl ear out put
CLEAR es_t 001.
* get pr i v
SELECT *
FROM t 001
I NTO es_t 001
WHERE opvar = i d_opvar .
EXI T.
ENDSELECT.
ENDFORM. " l oad_per i v
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m get _day
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM get _day
USI NG i t _ac400t 001b TYPE yt _ac400t 001b
i s_t 001b TYPE ys_t 001b
CHANGI NG es_ac400t 001b TYPE ys_ac400t 001b
ed_day_f ound TYPE c.
* Cl ear out put
CLEAR es_ac400t 001b.
ed_day_f ound = ' N' .
* Get sent ence
LOOP AT i t _ac400t 001b
I NTO es_ac400t 001b
WHERE opvar = i s_t 001b- bukr s
AND mkoar = i s_t 001b- mkoar
AND r r ct y = i s_t 001b- r r ct y.
ed_day_f ound = ' Y' .
ENDLOOP.
SAP AG AC400 8-254
ENDFORM. " get _day
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m check_day
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM check_day
USI NG i s_t 001 TYPE t 001
i s_ac400t 001b TYPE ys_ac400t 001b
i s_t 001b TYPE ys_t 001b
CHANGI NG ed_r esul t TYPE c.
* Cl ear out put
CLEAR ed_r esul t .
* dat a
DATA: l d_syst emday TYPE n LENGTH 2.
DATA: l d_act buper TYPE poper .
DATA: l d_act gj ahr TYPE bdat j .
DATA: l d_check TYPE i .
* Det er mi ne cur r ent dat e
l d_syst emday = sy- dat um+6( 2) .
* Get cur r ent per i od
CALL FUNCTI ON ' DATE_TO_PERI OD_CONVERT'
EXPORTI NG
i _dat e = sy- dat um
i _per i v = i s_t 001- per i v
I MPORTI NG
e_buper = l d_act buper
e_gj ahr = l d_act gj ahr .
* 1. ) Check whet her key dat e exceeded
I F l d_syst emday >= i s_ac400t 001b- st i cht ag.
l d_r esul t = l d_r esul t + 1.
ENDI F.
* 2. ) Check whet her set per i od < cur r ent per i od
I F i s_t 001b- t ope1 < l d_act buper
AND i s_t 001b- t oye1 = l d_act gj ahr .
l d_r esul t = l d_r esul t + 1.
* 3. ) Check whet her set year < t oday
ELSEI F i s_t 001b- t oye1 < l d_act gj ahr .
l d_r esul t = l d_r esul t + 1.
ENDI F.
I F l d_r esul t = 2.
ed_r esul t = ' Y' .
ELSE.
ed_r esul t = ' N' .
ENDI F.
ENDFORM. " check_day
SAP AG AC400 8-255
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m cal c_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM cal c_t 001b
USI NG i s_t 001 TYPE t 001
i s_t 001b_ol d TYPE ys_t 001b
CHANGI NG es_t 001b_new TYPE ys_t 001b.
* set out put
es_t 001b_new = i s_t 001b_ol d.
* Def i ne new st ar t per i od
CALL FUNCTI ON ' CKML_F_GET_NEXT_PERI OD'
EXPORTI NG
i nput _per i od = i s_t 001b_ol d- f r pe1
i nput _year = i s_t 001b_ol d- f r ye1
i nput _per i v = i s_t 001- per i v
I MPORTI NG
next _per i od = es_t 001b_new- f r pe1
next _year = es_t 001b_new- f r ye1.
* Def i ne new t ar get per i od
CALL FUNCTI ON ' CKML_F_GET_NEXT_PERI OD'
EXPORTI NG
i nput _per i od = i s_t 001b_ol d- t ope1
i nput _year = i s_t 001b_ol d- t oye1
i nput _per i v = i s_t 001- per i v
I MPORTI NG
next _per i od = es_t 001b_new- t ope1
next _year = es_t 001b_new- t oye1.
ENDFORM. " cal c_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m show_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM show_t 001b
USI NG i s_t 001b_ol d TYPE ys_t 001b
i s_t 001b_new TYPE ys_t 001b.
WRI TE: / i s_t 001b_ol d- mkoar .
* Out put f i r st l i ne wi t h cur r ent st at us
WRI TE: / t ext - 001, " Cur r ent open per i ods
i s_t 001b_ol d- f r pe1,
i s_t 001b_ol d- f r ye1,
' - ' ,
i s_t 001b_ol d- t ope1,
i s_t 001b_ol d- t oye1.
* Out put second l i ne wi t h new st at us
WRI TE: / t ext - 002, " Open per i ods f r omnow on
i s_t 001b_new- f r pe1,
SAP AG AC400 8-256
i s_t 001b_new- f r ye1,
' - ' ,
i s_t 001b_new- t ope1,
i s_t 001b_new- t oye1.
WRI TE: / .
ENDFORM. " show_t 001b
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m do_ucomm
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM do_ucomm
USI NG i d_ucommLI KE sy- ucomm
i t _t 001b TYPE yt _t 001b.
CASE i d_ucomm.
WHEN ' ENTR' .
" not hi ng t o do.
WHEN ' SAVE' .
PERFORM save
USI NG i t _t 001b.
LEAVE SCREEN.
WHEN OTHERS.
LEAVE SCREEN.
ENDCASE.
ENDFORM. " do_ucomm
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m save
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM save
USI NG i t _t 001b TYPE yt _t 001b.
UPDATE t 001b FROM TABLE i t _t 001b.
ENDFORM. " save
SAP AG AC400 8-257
Optional Exercise F3
Program a Report for Master Data Groups in Cost
Accounting
At the conclusion of this exercise, you will be able to:
Select records from tables and display them with the ALV
Use custom containers
Use the PBO and PAI dialog programming events to modify your user
interface
Define and evaluate required entry fields
Define a transaction for calling your report
Requirement
In Cost Accounting, you can group cost centers, cost elements, internal orders, and so on.
You want to program a report that lists these groups. The report should display both the
selection parameters and the results list on one screen. The group type (cost center, cost
element, and so on) and also the name of the object should be available as selection
parameters. The group type should be a required entry. If only the type is entered, all
groups of this type should be listed. The second parameter can be used to filter out a
specific element of this type. Depending on the selected type, the description of the field
should change for positioning purposes:
Initial call:
Set class ___________
Set ID ____________
Results list empty
After 0102 has been entered as the set class, the screen should change to:
Set class 0102
Cost element group ____________
Results list contains all cost element groups
System Analysis
Found out which table stores the master data groups. If necessary, use the ABAP
Workbench or debugger to do so.
Task
Implement the above requirement. Your program Y##SET is part of your local objects.
SAP AG AC400 8-258
SAP AG AC400 8-259
Solution for Optional Exercise F3
Program a Report for Master Data Groups in Cost
Accounting
Requirement
In Cost Accounting, you can group cost centers, cost elements, internal orders, and so on.
You want to program a report that lists these groups. The report should display both the
selection parameters and the results list on one screen. The group type (cost center, cost
element, and so on) and also the name of the object should be available as selection
parameters. The group type should be a required entry. If only the type is entered, all
groups of this type should be listed. The second parameter can be used to filter out a
specific element of this type. Depending on the selected type, the description of the field
should change for positioning purposes:
Initial call:
Set class ___________
Set ID ____________
Results list empty
After 0102 has been entered as the set class, the screen should change to:
Set class 0102
Cost element group ____________
Results list contains all cost element groups
Finally, the program should be executable via a transaction.
System Analysis
Found out which table stores the master data groups. If necessary, use the ABAP
Workbench or debugger to do so.
Use the transaction, for example, to display the cost element groups (KAH1). After you
have entered the cost element group OAL on the initial screen, use the /h command to
activate the debugger before you release the data. In debugger mode, set a breakpoint for
the "SELECT" command to analyze the further table accesses. Check the tables at which
the debugger stops by listing their entries, for example. The table containing the cost
element groups must be included in the accesses.
Task
Implement the above requirement. Your program Y##SET is part of your local objects.
Your transaction is Y##SET and is also defined locally.
SAP AG AC400 8-260
Instructions on how to use the Program Editor and define screens are provided in the
exercise on maintaining customer address data.
Once you have created the program (see template below), define a transaction. You can
create transactions in the same way as programs using the Object Navigator (SE80).
When you define the transaction Y##Set, select "Program and Selection Screen (Report
Transaction)" as the initial object. Enter your program Y##SET with selection screen
"1000".
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& Report AC400SET
*&
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* Scr een 1000 r ef er enced i n t he r epor t has t he f ol l owi ng set t i ngs
*Pr oper t i es
*Mai nt enance 200 240
*
*El ement l i st
*Name Type Row Col umn Def . L. Vi s. L. Hght Scr ol l abl e For mat
*SETHEADER- SETCLASS Text 1 1 22 22 1
*SETHEADER- SETCLASS I / O 1 26 4 4 1 CHAR
*GD_SETCLSTEXT I / O 2 1 22 22 1 CHAR
*SETHEADER- SETNAME I / O 2 26 24 24 1 CHAR
*ALV CuCt r 4 1 240 240 197
*
* El ement l i st ( cont i nued)
*Name I np. Out p. Out p Onl y. Di ct Fl d
*SETHEADER- SETCLASS x
*SETHEADER- SETCLASS x x x
*GD_SETCLSTEXT x x
*SETHEADER- SETNAME x x x
*ALV
*
* El ement l i st ( speci al at t r i but es and di spl ay at t r i but es)
*Name I nput Two- di mensi onal As desc. l ef t
*SETHEADER- SETCLASS x
*SETHEADER- SETCLASS O obl .
*GD_SETCLSTEXT N n. poss. x
*SETHEADER- SETNAME poss.
*ALV
*
*Fl ow l ogi c
*pr ocess bef or e out put .
*
** Set st at us
* modul e st at us_1000.
*
** Adj ust f i el d name and l i st
* modul e adj ust _wi ndow.
**
*pr ocess af t er i nput .
** Cal l f ol l owi ng modul e at " CANC"
SAP AG AC400 8-261
* modul e user _command_1000 at exi t - command.
*
** Al so wi t h al l ot her commands
* modul e user _command_1000.
* St at us 1000 has t he f ol l owi ng pr oper t i es
* Funct i on keys
* Gr een ar r ow BACK
* Yel l ow ar r ow EXI T
* Red cr oss CANC ( def i ned as exi t command)
* Ti t l e 1000 i s " Mast er Dat a Gr oups"
REPORT ac400set .
*Ref er enced t abl es
TABLES: set header .
*Types f or mast er dat a gr oups
TYPES: ys_set header TYPE set header .
TYPES: yt _set header TYPE TABLE OF ys_set header .
*Dat a decl ar at i on.
DATA: gt _out t ab TYPE yt _set header .
DATA: gd_set cl st ext TYPE set cl st ext .
DATA: go_cont ai ner TYPE REF TO cl _gui _cust om_cont ai ner .
DATA: go_al v TYPE REF TO cl _gui _al v_gr i d.
*Dat a i nst ant i at i on
CREATE OBJ ECT go_cont ai ner
EXPORTI NG r epi d = sy- r epi d
dynnr = ' 1000'
cont ai ner _name = ' ALV' .
CREATE OBJ ECT go_al v
EXPORTI NG i _par ent = go_cont ai ner .
*Cal l di al og box
CALL SCREEN 1000.
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& Modul e USER_COMMAND_1000 I NPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
MODULE user _command_1000 I NPUT.
* Eval uat i on of pushbut t on pr essed by user
CASE sy- ucomm.
* Ot her or undef i ned
WHEN ' ENTR'
OR ' ' .
PERFORM set _sel ect i on_st at us
USI NG set header
CHANGI NG gt _out t ab.
SAP AG AC400 8-262
* Ot her commands
WHEN OTHERS.
* Exi t t he t r ansact i on
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " USER_COMMAND_1000 I NPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& Modul e STATUS_1000 OUTPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
MODULE st at us_1000 OUTPUT.
SET PF- STATUS ' 1000' .
SET TI TLEBAR ' 1000' .
ENDMODULE. " STATUS_1000 OUTPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m set _sel ect i on_st at us
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* Thi s r out i ne det er mi nes t he st at us of t he sel ect i on par amet er s.
* Possi bl e st at uses:
* UNDEF no sel ect i on par amet er s pr ovi ded
* I DENT al r eady sel ect ed wi t h sel ect i on par amet er
* FI RST f i r st sel ect i on cal l
* NEW f ur t her sel ect i on cal l wi t h new par amet er s
FORM set _sel ect i on_st at us
USI NG i s_set header TYPE set header
CHANGI NG ct _out t ab TYPE yt _set header .
* dat a
DATA: l s_empt y_set header TYPE ys_set header .
STATI CS: l s_ol d_set header TYPE ys_set header .
DATA: l d_st at us TYPE st r i ng.
* Eval uat e ent er ed par amet er s and set st at us
CASE i s_set header .
* Undef i ned/ empt y par amet er s
WHEN l s_empt y_set header .
l d_st at us = ' UNDEF' .
* Unchanged par amet er s
WHEN l s_ol d_set header .
l d_st at us = ' I DENT' .
* Sel ect i on par amet er s not used
WHEN OTHERS.
* Fi r st t i me
I F l s_ol d_set header = l s_empt y_set header .
SAP AG AC400 8-263
l d_st at us = ' FI RST' .
* Change
ELSE.
l d_st at us = ' NEW' .
ENDI F.
* get dat a
PERFORM get _dat a
USI NG i s_set header
CHANGI NG ct _out t ab.
* Updat e l s_ol d_set header
l s_ol d_set header = i s_set header .
ENDCASE.
* Remember st at us
PERFORM r emi nd_st at us
USI NG ' SET'
CHANGI NG l d_st at us.
ENDFORM. " set _sel ect i on_st at us
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m get _dat a
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM get _dat a
USI NG i s_set header TYPE ys_set header
CHANGI NG et _out t ab TYPE yt _set header .
* Cl ear out put
CLEAR et _out t ab[ ] .
* dat a
DATA: l d_empt y_set name LI KE set header - set name.
* Sel ect accor di ng t o set I D
CASE i s_set header - set name.
* Al l obj ect s
WHEN l d_empt y_set name.
SELECT *
FROM set header
I NTO TABLE et _out t ab
WHERE set cl ass = i s_set header - set cl ass.
* One obj ect
WHEN OTHERS.
SELECT *
FROM set header
I NTO TABLE et _out t ab
WHERE set name = i s_set header - set name
AND set cl ass = i s_set header - set cl ass.
ENDCASE.
SAP AG AC400 8-264
ENDFORM. " get _dat a
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& Modul e adj ust _wi ndow OUTPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
MODULE adj ust _wi ndow OUTPUT.
PERFORM adj ust _wi ndow
USI NG gt _out t ab
set header
CHANGI NG gd_set cl st ext .
ENDMODULE. " adj ust _wi ndow OUTPUT
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m adj ust _wi ndow
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM adj ust _wi ndow
USI NG i t _out t ab TYPE yt _set header
i s_set header TYPE ys_set header
CHANGI NG cd_set cl st ext TYPE set cl st ext .
* dat a
DATA: l d_st at us TYPE st r i ng.
* set l d_st at us
PERFORM r emi nd_st at us
USI NG ' GET'
CHANGI NG l d_st at us.
* Eval uat e st at us
CASE l d_st at us.
* Undef i ned
WHEN ' UNDEF' .
* Mai nt ai n cd- set cl st ext
PERFORM get _set cl st ext
USI NG i s_set header
CHANGI NG cd_set cl st ext .
* Exi st i ng sel ect i on
WHEN ' I DENT' .
" not hi ng t o do
* Fi r st sel ect i on
WHEN ' FI RST' .
* Gener at e ALV
CALL METHOD go_al v- >set _t abl e_f or _f i r st _di spl ay
EXPORTI NG
i _st r uct ur e_name = ' SETHEADER'
CHANGI NG
i t _out t ab = gt _out t ab.
* Mai nt ai n cd_set cl st ext
PERFORM get _set cl st ext
USI NG i s_set header
SAP AG AC400 8-265
CHANGI NG cd_set cl st ext .
* New ot her sel ect i on
WHEN ' NEW' .
CALL METHOD go_al v- >r ef r esh_t abl e_di spl ay.
* Mai nt ai n cd_set cl st ext
PERFORM get _set cl st ext
USI NG i s_set header
CHANGI NG cd_set cl st ext .
WHEN OTHERS.
* Mai nt ai n cd_set cl st ext
PERFORM get _set cl st ext
USI NG i s_set header
CHANGI NG cd_set cl st ext .
ENDCASE.
ENDFORM. " adj ust _wi ndow
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m r emi nd_st at us
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
* Thi s r out i ne st or es t he st at us of sel ect i on par amet er s and
* r et ur ns t hemon r equest .
* PBO and PAI communi cat e vi a t hi s r out i ne
* The f ol l owi ng act i ons ar e possi bl e:
* SET: Remember st at us
* GET: Ret ur n st at us
FORM r emi nd_st at us
USI NG i d_act i on TYPE st r i ng
CHANGI NG cd_st at us TYPE st r i ng.
* dat a
STATI CS: l d_st at us TYPE st r i ng.
* Eval uat e act i on
CASE i d_act i on.
* Set st at us
WHEN ' SET' .
l d_st at us = cd_st at us.
* Read st at us
WHEN ' GET' .
cd_st at us = l d_st at us.
ENDCASE.
ENDFORM. " r emi nd_st at us
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*& For m get _set cl st ext
*&- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
FORM get _set cl st ext
SAP AG AC400 8-266
USI NG i s_set header TYPE ys_set header
CHANGI NG ed_set cl st ext TYPE set cl st ext .
* Cl ear out put
CLEAR ed_set cl st ext .
* dat a
DATA: l s_set cl st TYPE set cl st .
DATA: l d_empt y_set cl ass TYPE set cl st .
DATA: l s_dd04v_wa TYPE dd04v.
* Pr ocessi ng accor di ng t o i s_set header - set cl ass.
CASE i s_set header - set cl ass.
* Cl ass not set
WHEN l d_empt y_set cl ass.
CALL FUNCTI ON ' DDI F_DTEL_GET'
EXPORTI NG
name = ' SETNAMENEW'
l angu = sy- l angu
I MPORTI NG
dd04v_wa = l s_dd04v_wa.
* set out put
ed_set cl st ext = l s_dd04v_wa- ddt ext .
* Cl ass set
WHEN OTHERS.
* sel ect
SELECT SI NGLE *
FROM set cl st
I NTO l s_set cl st
WHERE l angu = sy- l angu
AND set cl ass = i s_set header - set cl ass.
* set out put
ed_set cl st ext = l s_set cl st - descr i pt .
ENDCASE.
ENDFORM. " get _set cl st ext