Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Chain -endchain command

Former Member
0 Likes
760

Hi friends,

I am new to dialog programming.Please let me know the purpose of

chain endchain command in dialog programming.

Regards,

Hari

1 ACCEPTED SOLUTION
Read only

abdul_hakim
Active Contributor
0 Likes
670

hi

CHAIN ENDCHAIN is used for validating the multiple fields of the screen.

Check the sample programs in the transaction ABAPDOCU.

Cheers,

Abdul Hakim

Mark all useful answers...

4 REPLIES 4
Read only

Former Member
0 Likes
670

For example if there are 10 fields in the screen and for 5 fields whenever the user enters wrong values u like to give some error message. You can declare that fields in the chain enchain so that only those fields will be input enabled and all other fields will disabled.

CHAIN.

FIELD chk_connobj.

FIELD chk_inst.

FIELD chk_devloc.

FIELD ehaud-haus.

FIELD eanl-anlage.

MODULE modify_screenfields.

ENDCHAIN.

&----


*& Module modify_screenfields INPUT

&----


  • text

----


MODULE modify_screenfields INPUT.

CLEAR okcode.

okcode = sy-ucomm.

CASE okcode.

WHEN 'ENTER' OR 'EXECUTE'.

IF chk_connobj IS INITIAL AND chk_inst EQ c_x AND

chk_devloc EQ c_x.

IF ehaud-haus IS INITIAL.

SET CURSOR FIELD 'EHAUD-HAUS'.

MESSAGE e000(zo_spa) WITH text-017. " Enter Connection obj

ELSE.

PERFORM conn_obj_check.

ENDIF.

ENDIF.

ENDMODULE. " modify_screenfields INPUT

Read only

Former Member
0 Likes
670

Hi Hari,

You can ensure that a PAI module is only called when a certain condition applies by using the following statement:

<b>FIELD <f> MODULE <mod> ON INPUT|REQUEST|*-INPUT.</b>

The additions have the following effects:

  • 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

<b>Conditions for Multiple Screen Fields</b>

To ensure that one or more PAI modules are only called when several screen fields meet a particular condition, you must combine the calls in the flow logic to form a processing chain. You define processing chains as follows:

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.

<b>CHAIN.

FIELD: <f1>, <f 2>,...

MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.

FIELD: <g1>, <g 2>,...

MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.

...

ENDCHAIN.

</b>

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:

<b>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.

</b>

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.

<b>EXAMPLE</b>

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

CHAIN.

FIELD: INPUT1, INPUT2.

MODULE MODULE_1 ON CHAIN-INPUT.

FIELD INPUT3 MODULE MODULE_* ON *-INPUT.

MODULE MODULE_2 ON CHAIN-REQUEST.

ENDCHAIN.

FIELD INPUT1 MODULE C1 AT CURSOR-SELECTION.

CHAIN.

FIELD: INPUT2, INPUT3.

MODULE C2 AT CURSOR-SELECTION.

ENDCHAIN.

MODULE CURSOR AT CURSOR-SELECTION.

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.

Read only

abdul_hakim
Active Contributor
0 Likes
671

hi

CHAIN ENDCHAIN is used for validating the multiple fields of the screen.

Check the sample programs in the transaction ABAPDOCU.

Cheers,

Abdul Hakim

Mark all useful answers...

Read only

Former Member
0 Likes
670

hari,

All of the fields on the screen that belong to the processing chain (all of the fields listed in the field statements) are made ready for input again. Other fields are not ready for input.

Pls. reward if useful