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
0 Kudos

Hello everyone,

I am working on a module pool. I have 5 firlds on screen. I am fetching data from a table to populate the 5th field upon entering 4 fields on screen. Now if no data is returned to 5th screen field i need to output an error message and and make all the filds ready for input.

For that purpose, i am using a <b>chain ...endchain</b>. Now,

If i am unable to fecth data if i use chain endchain after selcting the data, i checked in debugging and the screen fields are not getting populated for some reason, if i dont use the chain end chain, the data is fetching properly.

What is the reason behind this.

I am posting the code below.

************************

flow logic

**********************

PROCESS BEFORE OUTPUT.
  MODULE status_2000.

  MODULE assign_data.


PROCESS AFTER INPUT.
  MODULE exit AT EXIT-COMMAND.
  MODULE select_data.
  CHAIN.
    FIELD gtab_bukrs.
    FIELD gtab_belnr.
    FIELD gtab_gjahr.
    FIELD gtab_j_1iintchln.
    FIELD  gtab_j_1iextchln.
    MODULE check ON CHAIN-INPUT.
  ENDCHAIN.
  MODULE user_command_2000.

*********************************************

ABAP logic

********************************************

PROGRAM  zexternal_challan_change
         MESSAGE-ID zchallan.

TYPES: BEGIN OF tw_gtab,
       bukrs       TYPE bukrs,                "Company code
       belnr       TYPE belnr_d,              "Document Number
       gjahr       TYPE gjahr,                "Fiscal Year
       j_1iintchln TYPE j_1iintchln,          "Challan Number
       j_1iextchln TYPE j_1iextchln,          "Challan Numbers- External
      END OF tw_gtab,
      tt_gtab TYPE STANDARD TABLE OF tw_gtab.

DATA: lw_gtab    TYPE tw_gtab,
      lt_gtab    TYPE tt_gtab,
      gtab_bukrs TYPE bukrs,
      gtab_belnr TYPE belnr_d,
      gtab_gjahr TYPE gjahr,
      gtab_j_1iintchln TYPE j_1iintchln,
      gtab_j_1iextchln TYPE j_1iextchln.


*&---------------------------------------------------------------------*
*&      Module  STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*

MODULE status_2000 OUTPUT.
  SET PF-STATUS 'CHLAN'.
*  SET TITLEBAR 'xxx'.
  CASE sy-ucomm.
    WHEN 'EXIT' OR
         'CANCEL' OR
         'BACK'.
      LEAVE TO SCREEN 0.

  ENDCASE.
ENDMODULE.                 " STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  select_data  INPUT
*&---------------------------------------------------------------------*
* Select Data from required table
*----------------------------------------------------------------------*
MODULE select_data INPUT.

  SELECT bukrs
         belnr
         gjahr
         j_1iintchln
         j_1iextchln
    FROM j_1iewtchln
    INTO  TABLE lt_gtab
    WHERE bukrs = gtab_bukrs
     AND  belnr = gtab_belnr
     AND  gjahr = gtab_gjahr
     AND  j_1iintchln = gtab_j_1iintchln.

ENDMODULE.                 " select_data  INPUT
*&---------------------------------------------------------------------*
*&      Module  assign_data  OUTPUT
*&---------------------------------------------------------------------*
*       Assign data to screen fields
*----------------------------------------------------------------------*

MODULE assign_data OUTPUT.

  LOOP AT lt_gtab INTO lw_gtab.
    gtab_bukrs = lw_gtab-bukrs.
    gtab_belnr = lw_gtab-belnr.
    gtab_gjahr = lw_gtab-gjahr.
    gtab_j_1iintchln = lw_gtab-j_1iintchln.
    gtab_j_1iextchln = lw_gtab-j_1iextchln.
  ENDLOOP.
ENDMODULE.                 " assign_data  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  check  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE check INPUT.

  LOOP AT lt_gtab INTO lw_gtab.
    IF lw_gtab-j_1iextchln IS INITIAL.
      MESSAGE e001(zchallan) WITH lw_gtab-belnr lw_gtab-j_1iintchln.
    ENDIF.
  ENDLOOP.
ENDMODULE.                 " check  INPUT
*&---------------------------------------------------------------------*
*&      Module  exit  INPUT
*&---------------------------------------------------------------------*
*       EXIT
*----------------------------------------------------------------------*
MODULE exit INPUT.
  CASE sy-ucomm.
    WHEN 'EXIT'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " exit  INPUT

Regards

1 REPLY 1

Former Member
0 Kudos

Hi

Use the CHAIN-REQUEST instead of CHAIN-INPUT and see

MODULE check ON CHAIN_REQUEST.

See the doc of chain..endchain..

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.

CHAIN.

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

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

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

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

...

ENDCHAIN.

When this command is used, 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. Whenever the MODULE statement appears within a processing chain, even if there is only one FIELD attached to it, all of the fields in the chain (not only the affected field) are made ready for input again, allowing the user to enter new values. If the fields in the processing chain are only checked once, the PAI processing continues directly after the FIELD statement, and the preceding modules are not called again.

CHAIN.

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

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

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

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

...

ENDCHAIN.

Check this out

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabbd35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_47x200/helpdata/en/d1/801ca2454211d189710000e8322d00/frameset.htm

Reward points for useful Answers

Regards

Anji