Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

problem in module pool on chain-input and on chain-request.

Dear abapers,

       i have faced a problem in module pool. i have create a normal screen and also create 4 i/p fields in it.

my code is:

DATA DECLARATION.

PROGRAM  SAPMZCHAINEXITCOMMAND.
DATA: VBELN TYPE VBELN_VA,
BUKRS
TYPE BUKRS,
EBELN
TYPE EBELN VALUE '4500036',
MATNR
TYPE MATNR VALUE '2201'.
DATA: BEGIN OF IT1 OCCURS 0,
VBELN
TYPE VBELN_VA,
END OF IT1.

DATA: BEGIN OF IT2 OCCURS 0,
BUKRS
TYPE BUKRS,
END OF IT2.

DATA: BEGIN OF IT3 OCCURS 0,
EBELN
TYPE EBELN,
END OF IT3.

DATA: BEGIN OF IT4 OCCURS 0,
MATNR
TYPE MATNR,
END OF IT4.

SCREEN-FLOWLOGIC.

PROCESS BEFORE OUTPUT.
MODULE STATUS_0001.
*
PROCESS AFTER
INPUT.

CHAIN.
FIELD: VBELN.
FIELD: BUKRS.
MODULE MOD_INP ON CHAIN-INPUT.
*ENDCHAIN.
*CHAIN.
FIELD: EBELN.
FIELD: MATNR.
MODULE MOD_REQ ON CHAIN-REQUEST.
ENDCHAIN.


MODULE MOD AT EXIT-COMMAND.

MODULE USER_COMMAND_0001.



  INCLUDE MZCHAINEXITCOMMANDTOP                   .    " global Data

* INCLUDE MZCHAINEXITCOMMANDO01                   .  " PBO-Modules
* INCLUDE MZCHAINEXITCOMMANDI01                   .  " PAI-Modules
* INCLUDE MZCHAINEXITCOMMANDF01                   .  " FORM-Routines

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0001 INPUT.
CASE SY-UCOMM.
WHEN 'DISPLAY'.
LEAVE TO LIST-PROCESSING.
WRITE:/ 'HI'.

ENDCASE.
ENDMODULE.                 " USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*&      Module  MOD  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

" MOD  INPUT


*&---------------------------------------------------------------------*
*&      Module  MOD  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE MOD INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.

ENDMODULE.                 " MOD  INPUT
*&---------------------------------------------------------------------*
*&      Module  MOD_INP  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE MOD_INP INPUT.
CASE SY-UCOMM.
WHEN 'DISPLAY'.
SELECT VBELN FROM VBAK INTO TABLE IT1 WHERE VBELN = VBELN.
SELECT BUKRS FROM EKKO INTO TABLE IT2 WHERE BUKRS = BUKRS.
IF IT1[] IS INITIAL.
MESSAGE 'SALES ORDER DOES NOT EXIST' TYPE 'E'.
ENDIF.
IF IT2[] IS INITIAL.
MESSAGE 'COMPANY CODE DOES NOT EXIST' TYPE 'E'.
ENDIF.
ENDCASE.
ENDMODULE.                 " MOD_INP  INPUT
*&---------------------------------------------------------------------*
*&      Module  MOD_REQ  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE MOD_REQ INPUT.
SELECT EBELN FROM EKKO INTO TABLE IT3 WHERE EBELN = EBELN.
SELECT MATNR FROM MARA INTO TABLE IT4 WHERE MATNR = MATNR.

IF IT3[] IS INITIAL.
MESSAGE 'PURCHASE ORDER DOES NOT EXIST' TYPE 'E'.
ENDIF.
IF IT4[] IS INITIAL.
MESSAGE 'MATERIAL NO DOES NOT EXIST' TYPE 'E'.
ENDIF.

ENDMODULE.             

i dont change i/p field ebeln and matnr value in screen. but

(FIELD: EBELN.
FIELD: MATNR.
MODULE MOD_REQ ON CHAIN-REQUEST.) when i debug my code i watch that

  this module is also trigger. as definition i know, when we change initial value of a i/p field then on chain-request module will

trigger. but here it always trigger. why??? what is my fault?

   kindly solve it and also correct my concept if i am wrong.

regards

Sabyasachi Karforma

Former Member
Former Member replied

Hi

because ON CHAIN-REQUEST option triggers a module if any fields of a CHAIN/ENDCHAIN section (but before module call) section is changed;

it doesn't matter if you place the module after EBELN/MATNR:

all fields between CHAIN ​​/ ENDCHAIN ​​and placed before MODULE MOD_REQ ON CHAIN-REQUEST

will be considered, so VBELN/BUKRS too.

So you can try this:

   CHAIN.

     FIELD: EBELN.

     FIELD: MATNR.

     MODULE MOD_REQ ON CHAIN-REQUEST.

     FIELD: VBELN.

     FIELD: BUKRS.

     MODULE MOD_INP ON CHAIN-INPUT.

   ENDCHAIN.

Now module MOD_REQ is triggered only if EBELN or MATNR will be changed, but MOD_INP will be triggered if any input will be inserted if all fields (EBELN, MATNR, VBELN and BUKRS), because they are before MODULE MOD_INP ON CHAIN-INPUT.

Max

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question