Register Login

What is CHAIN-ENDCHAIN in SAP

Updated May 31, 2019

CHAIN and ENDCHAIN define processing chain in SAP ABAP Dynpro Flow logic. User can execute FIELD and MODULE between CHAIN and ENDCHAIN. Also, the statements between CHAIN and ENDCHAIN form a processing chain which cannot be nested. CHAIN statement starts a processing chain whereas ENDCHAIN statement ends a processing chain.

Example:

CHAIN. //starts of processing chain//

FIELD: p_bike, p_car MODULE input_validation.

ENDCHAIN. //ends of the processing chain.//

What is use CHAIN and ENDCHAIN? 

If in case the user wants to check several fields as a group, then in order to do that user must include the fields in a FIELD statement, and enclose all the fields in a CHAIN-ENDCHAIN statement block.  

If any error is detected inside a chain, the screen will be re-displayed, and all fields found anywhere in the chain are input-enabled. And all non-chain fields remain disabled.

Where we use Chain and End chain?

In PAI if you want to validate a group of fields put in CHAIN & ENDCHAIN statement. If you don't want to use these statements then only single fields will be validated & for single field validation you can use Field_name and Module_name.

What If we didn't declare chain and end chain? What happens if validations fail? 

If the screen field contains flow logic validations than the remaining fields will also get disabled because in a group of fields validation one field data is dependent on another. Therefore to overcome this issue use CHAIN end ENDCHAIN.

Example Code of CHAIN-ENDCHAIN 

PROCESS AFTER INPUT.
  MODULE cancel_dynpro AT EXIT-COMMAND.
  CHAIN.
    FIELD: input1, input2. 
    MODULE examine _1 ON CHAIN-INPUT.
    FIELD  input3 MODULE MODULE_* ON *-INPUT.
    MODULE examine _1 ON CHAIN-INPUT.
  ENDCHAIN.
  FIELD input1 MODULE user_command AT CURSOR-SELECTION.

 


×