Validations in Module Pool
Validations in Module Pool
Regards,
Narender
Hi,
Do the validation in the CHAIN...ENDCHAIN stmt.
Regards
Subramanian
hi Subramanian ,
Regards,
Narender
Naren,
Hi, you just need to put a validation module in the PAI in the screen
flow logic. eg if your field is zzz-field1, use a statement in the PAI like
this:
if you have several fields you need to chain them eg ZZZ-FIELD1 and
ZZZ-FIELD2:
CHAIN.
FIELD: ZZZ-FIELD1, ZZZ-FIELD2.
MODULE VALIDATE_FIELDS ON CHAIN-INPUT " (or ON
CHAIN-REQUEST)
ENDCHAIN.
in the PAI..
module check_data.
select single * from <table>
where <tablefield> = <screenfield-value>.
if sy-subrc = 0.
else.
message E000(00) with '<ScreenField-Value> does not exit'.
endif.
endmodule.
Regards
Gopi
Hi,
In PAI,
MODULE m1 input.
<do validation code>.
ENDMODULE.
regards
shiba dutta
ON INPUT
The ABAP module is called only if the field contains a value other than its initial value. This initial
value is determined by the data type of the field: Space for character fields, zero for numeric
fields. Even if the user enters the initial value of the screen as the initial value, the module is not
called. (ON REQUEST, on the other hand, does trigger the call in this case.)
ON REQUEST
The module <mod> is only called if the user has entered something in the field. This includes
cases when the user overwrites an existing value with the same value, or explicitly enters the
initial value.
In general, the ON REQUEST condition is triggered through any form of "manual input". As well
as user input, the following additional methods of entering values also call the module:
The element attribute PARAMETER-ID (SPA/GPA parameters).
The element attribute HOLD DATA
CALL TRANSACTION ... USING
Automatic settings of particular global fields
ON *-INPUT
The ABAP module is called if the user has entered a "*" in the first character of the field, and the
field has the attribute *-entry in the Screen Painter. When the input field is passed to the program,
the * is removed. * behaves like an initial field in the ON INPUT condition.
The functions of the FIELD statement for controlling data transport also apply when you use MODULE.
CHAIN.
...
ENDCHAIN.
All flow logic statements between CHAIN and ENDCHAIN belong to a processing chain. The fields in the
various FIELD statements are combined, and can be used in shared conditions.
CHAIN.
FIELD: <f1>, <f 2>,...
MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.
FIELD: <g1>, <g 2>,...
MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
...
ENDCHAIN.
The additions ON CHAIN-INPUT and ON CHAIN-REQUEST work like the additions ON INPUT and ON
REQUEST that you use for individual fields. The exception is that the module is called whenever at least
one of the fields listed in a preceding FIELD statement within the chain meets the condition. So <mod1>
is called when one of the fields <fi> meets the condition. <mod2> is called when one of the fields <f i> or
<g i> meets the condition.
Within a processing chain, you can combine individual FIELD statements with a MODULE statement to
set a condition for a single field within the chain:
CHAIN.
FIELD: <f1>, <f 2>,...
FIELD <f> MODULE <mod1> ON INPUT|REQUEST|*-INPUT
|CHAIN-INPUT|CHAIN-REQUEST.
MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
ENDCHAIN.
The module <mod1> is called when screen field <f> meets the specified condition for individual fields.
<mod2> is called when one of the fields <fi> or <f> meets the condition. If you use the addition ON
CHAIN-INPUT or ON CHAIN-REQUEST with FIELD <f>, the condition also applies to the entire chain and
module <mod1> and <mod2> are both called.
In cases where you apply conditions to various combinations of screen fields, it is worth setting up a
separate processing chain for each combination and calling different modules from within it.
The functions of the FIELD statement for controlling data transport also apply when you use processing
chains. Within a processing chain, screen fields are not transported until the FIELD statement.
Processing chains also have another function for the FIELDS statements that they contain. This is
described in the section on validity checks.
The module <mod> is called whenever the function code of the user action is CS with function type S. If
you use this statement, it is best to assign the function code CS to function key F2. This also assigns it to
the mouse double-click.
The module is called in the sequence in which it occurs in the flow logic. It does not bypass the automatic
input checks. Data is transported from screen fields in the order in which it is defined by the FIELD
statements. The function code is empty, and neither SY-UCOMM nor the OK_CODE field is affected. You
can also combine this MODULE statement with the FIELD statement:
CHAIN.
FIELD: <f1>, <f 2>,...
MODULE <mod> AT CURSOR-SELECTION.
ENDCHAIN.
The module <mod> is only called if the cursor is positioned on an input/output field <f> or an input/output
field <fi> in the processing chain. You can only apply this statement to input/output fields.
It is irrelevant whether the statements occur within a CHAIN ... ENDCHAIN block or not.
PROGRAM DEMO_DYNPRO_ON_CONDITION.
DATA: OK_CODE LIKE SY-UCOMM,
INPUT1(20), INPUT2(20), INPUT3(20),
FLD(20).
MODULE C1 INPUT.
MESSAGE I888(BCTRAIN) WITH TEXT-005 '1'.
ENDMODULE.
MODULE C2 INPUT.
MESSAGE I888(BCTRAIN) WITH TEXT-005 '2' TEXT-006 '3'.
ENDMODULE.
The next screen (statically defined) for screen 100 is itself. It has the following layout:
The screen fields INPUT1, INPUT2, and INPUT3 are assigned to the input fields. The
function code of the pushbutton is EXECUTE.
In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL
and function type E. The function key F2 is also active with function code CS and function
type S. The F8 key is active with the function code EXECUTE and no special function
type.
The program uses information messages to show which modules are called following
user interaction and which data is transported.
Whenever one of the input fields 1 or 2 is not initial, the system calls the module MODULE_1 for
any user interaction.
Whenever one of the three input fields is changed, the system calls the module MODULE_2 for
any user interaction.
Whenever input field 3 contains a * entry, the system calls module MODULE_* for any user
interaction.
If the user chooses F2 or double-clicks a text field on the screen, the system calls the module
CURSOR.
If the user chooses F2 or double-clicks input field 1, the system calls the module C1.
If the user chooses F2 or double-clicks input field 2 or 3, the system calls the module CURSOR.
Module C2 is never executed, since the MODULE ... AT CURSOR SELECTION statement occurs
twice, and only the last is processed.
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801ca2454211d189710000e8322d00/frameset.h
tm
You define the flow logic in the flow logic editor of the Screen Painter, using the following keywords:
Keyword Description
CALL Calls a subscreen.
CHAIN Starts a processing chain.
ENDCHAIN Ends a processing chain.
ENDLOOP Ends loop processing.
FIELD Refers to a field. You can combine this with the MODULE and SELECT
keywords.
LOOP Starts loop processing.
MODIFY Modifies a table.
MODULE Identifies a processing module.
ON Used with FIELD assignments.
PROCESS Defines a processing event.
SELECT Checks an entry against a table.
VALUES Defines allowed input values.
For more information about transaction programming, see the ABAP User’s Guide
*------------------------------------------------
* Sample Code
*---------------------------------------------------
MODULE INIT_FIELDS.
* Self-programmed F1 Help
PROCESS ON HELP-REQUEST.
CHAIN.
FIELD GSSG-KTNRG
MODULE ENQUEUE_CUSTOMER_MASTER.
MODULE READ_CUSTOMER_MASTER.
MODULE READ_GSSG.
ENDCHAIN.