Application Development 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: 

chain endchain

Former Member

Hi

i have a requirement where i need to use Chain Endchain for a particular groups of fields from Infotypes.(seperate group for different Infotype fields.. ex: fields from Infotype 0001 are grouped in a CHAIN.. ENDCHAIN, fields from Infotype 0002 are grouped in another CHAIN.. ENDCHAIN, so on)

Initially the fields will be populated with some values. if any of those group field's values is changed i have to update a flag, and accordingly i will be doing the database modification.

Please provide me Inputs on how to implement this. or any sample code will also do

Thanks,

Manjari

2 REPLIES 2

Former Member
0 Kudos

hi Manjari,

Here is some information about how CHAIN.. ENDCHAIN. statement works.

chain and endchain are used for validations in the flow logic itself.

chain and end chain are used for multiple validation on

module pool programming and for example we use the below

syntax field <field name> module <module name>

module keyword give the place where you write your piece of code

If you want to ensure that more than one field is ready for input following an error dialog, you must list all

of the relevant fields in the FIELD statement, and include both that and the MODULE statement in a

CHAIN u2026 ENDCHAIN block.

You can include individual fields in more than one CHAIN u2026 ENDCHAIN block.

Note that the FIELD statement does not only make the field ready for input again; it also means that field

contents changed during the current PAI processing are only visible if the field in question was also included in the FIELD statement of the current CHAIN block.

PROCESS AFTER INPUT.

FIELD A MODULE check_A.

FIELD B MODULE check_B.

CHAIN.

FIELD: C,D.

MODULE check_CD.

ENDCHAIN.

CHAIN.

FIELD: C,B.

MODULE check_CB.

ENDCHAIN.

If the system sends an error or warning message, the current screen is sent again, but the PBO is not

processed again.

Only the fields to which the module is assigned are ready for input again.

After the user has entered new values, the PROCESS AFTER INPUT module is not completely

reprocessed, but restarted somewhere within the processing block.

The system finds out which field the user changed and resumes processing at the first corresponding

FIELD statement.

If the user merely confirms a warning message (without changing the fieldu2019s contents), the system

restarts the PAI processing after the MESSAGE statement where the error was triggered.

Regards,

Jyothi

0 Kudos

Hi Manjari,

See the sample code below.

For example I ahve created 4 fields ( ISU module)

Premise(VSTELLE), Premise ID, Installation(ANLAGE), Division (SPARTE)

the Flow Logic is as follows:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

CHAIN.

FIELD : P_VSTELLE, P_PREMISE_ID.

MODULE CHECK_PREMISE. "Here u can validate these fields and update database

ENDCHAIN.

chain.

field : p_anlage, p_sparte.

MODULE M2. "Here u can validate these fields and update database

endchain.

<Module Pool Program>

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ABC'.

SET TITLEBAR 'ABC'.

CLEAR G_FLAG1.

ENDMODULE. " STATUS_0100 OUTPUT

MODULE USER_COMMAND_0100 INPUT.

case sy-ucomm.

when 'BACK'.

leave to screen 0.

when 'CANC'.

LEAVE SCREEN.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'ENTE'.

if g_flag1 = 'X'.

loop at screen.

if screen-name = 'P_VSTELLE' OR screen-name = 'P_PREMISE_ID'.

SCREEN-INPUT = 1.

ENDIF.

MODIFY SCREEN.

endloop.

endif.

IF P_VSTELLE IS NOT INITIAL.

SELECT SINGLE ANLAGE SPARTE

FROM EANL

INTO (P_ANLAGE, P_SPART)

WHERE VSTELLE = P_VSTELLE.

IF SY-SUBRC <> 0.

MESSAGE E053 WITH 'Installation does nto exist for Premise' P_VSTELLE.

ENDIF.

ENDIF.

endcase.

ENDMODULE. " USER_COMMAND_

MODULE CHECK_PREMISE INPUT.

IF P_PREMISE_ID IS NOT INITIAL and P_VSTELLE IS INITIAL.

SELECT SINGLE VSTELLE

FROM EVBS

INTO P_VSTELLE

WHERE PREMISE_ID = P_PREMISE_ID.

IF SY-SUBRC <> 0.

g_flag1 = 'X'.

MESSAGE E053 WITH 'Premise ID is not valid' P_PREMISE_ID.

ENDIF.

ENDIF.

ENDMODULE. " CHECK_PREMISE INPUT

Regards,

Jyothi