Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2012 at 02:28 PM

    Hi

    You need to create 2 dinstict CHAIN/ENDCHAIN section:

    CHAIN.
        FIELD: VBELN.
        FIELD: BUKRS.
        MODULE MOD_INP ON CHAIN-INPUT.
    ENDCHAIN.

    CHAIN.
       FIELD: EBELN.
       FIELD: MATNR.
       MODULE MOD_REQ ON CHAIN-REQUEST.
    ENDCHAIN.

    Max


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI MAX,

               in case 2) if only the value of 'MATNR' field change the MODULE MOD_REQ ON REQUEST will trigger.

       

      but in case1) not only 'MATNR' FIELD VALUE BUT WHEN (VBELN , BUKRS)   fields value changes , the MODULE MOD_REQ ON CHAIN-REQUST WILL TRIGGER.....

      please tell me the above concepts are right or wrong???