Friday, April 10, 2015

Read Dynamic Table using Fields Symbols


Below is the code snippet.


PARAMETERS p_bukrs TYPE bukrs.

DATA: dref TYPE REF TO data.

AT SELECTION-SCREEN ON p_bukrs.
  FIELD-SYMBOLS:
   TYPE STANDARD TABLE,
   TYPE ANY.

  CREATE DATA dref TYPE STANDARD TABLE OF t001.
  ASSIGN dref->* TO .

  SELECT * FROM t001 INTO TABLE .
  IF sy-subrc = 0.
    SORT  BY ('BUKRS').
    READ TABLE  ASSIGNING 
    WITH KEY ('BUKRS') = p_bukrs.
    IF sy-subrc <> 0.
      MESSAGE 'Invalid Comp. Code' TYPE 'E'.
    ENDIF.
  ENDIF.

No comments:

Post a Comment