Skip to Content
0
Former Member
Jul 03, 2007 at 04:39 AM

chain...endchain

82 Views

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