Tuesday 31 July 2007

ABAP: Responding to changes on screen fields

The general case for checking user input during PAI can be summarized as follows :

PROCESS AFTER INPUT.

  FIELD fieldA MODULE check_fieldA ON REQUEST.
  ...
  FIELD fieldB MODULE check_fieldB ON REQUEST.

Any messages of type e or w executed during execution of the corresponding modules will cause SAPGui to stop processing, return focus to the appropriate field and execute the module again until no messages are thrown.

If you wish to perform the same check on both fields then the fields can be chained.

PROCESS AFTER INPUT.
  CHAIN.
    FIELD :
            fieldA,
            fieldB

    MODULE check_fieldA_and_B ON CHAIN-REQUEST.
  ENDCHAIN.

if the field to be checked belongs to an internal table accessed via a table control then the checking and processing phase should be carried out as follows:

PROCESS AFTER INPUT. 
  ...
  LOOP AT tbl_mydata.
    CHAIN.
      FIELD
              tbl_mydata-my_field.

      MODULE check_tbl_mydata_my_field ON CHAIN-REQUEST.
    ENDCHAIN.

    MODULE write_table_line.

  ENDLOOP.

No comments :