REPORT ZUT80007 MESSAGE-ID Z1 LINE-COUNT 65 LINE-SIZE 132.
*               NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* Description: This program lists all tables that contain the field    *
*              defined in the selection criteria.  In addition, you    *
*              will be able to select a line and then have which will  *
*              then transfer you to transaction SE12.
*              Youcan also select the line and use PF8 for SE16        *
*                                                                      *
* Customizing: You need not to make any customizing to use this program*
*                                                                      *
* Change of    You only have to check that tables, functions and       *
* release:     includes still exist.                                   *
*                                                                      *
* Programmer:  Howard Caras                                            *
* Date:        May 1997                                                *
*                                                                      *
* SAP R/3      2.2C                                                    *
*----------------------------------------------------------------------*

TABLES: DD03P,
        DD02L.

DATA: BEGIN OF DYNTAB OCCURS 2000.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF DYNTAB.
DATA: BEGIN OF FIELDS OCCURS 100,
        TABNAME    LIKE DD03P-TABNAME,
        TABCLASS   LIKE DD02L-TABCLASS,
        FIELDNAME  LIKE DD03P-FIELDNAME,
        POSITION   LIKE DD03P-POSITION,
        KEYFLAG    LIKE DD03P-KEYFLAG,
        MANDATORY  LIKE DD03P-MANDATORY,
        ROLLNAME   LIKE DD03P-ROLLNAME,"data element
        CHECKTABLE LIKE DD03P-CHECKTABLE,
        INTLEN     LIKE DD03P-INTLEN,
        DOMNAME    LIKE DD03P-DOMNAME,
        ROUTPUTLEN LIKE DD03P-ROUTPUTLEN,
        MEMORYID   LIKE DD03P-MEMORYID,"parameter ID
      END OF FIELDS.

PARAMETERS:
  FIELD           LIKE DD03P-FIELDNAME,
  DOWNLOAD        AS CHECKBOX,
  FILENAME(65)    TYPE C DEFAULT 'C:\DOWNLOAD\--------.---',
  FILETYPE(3)     TYPE C DEFAULT 'ASC'.

TRANSLATE FIELD    USING '*%'.
SELECT * FROM DD03P
  WHERE DDLANGUAGE = SY-LANGU
    AND FIELDNAME LIKE FIELD.
  MOVE-CORRESPONDING DD03P TO FIELDS.
  SELECT * FROM DD02L
   WHERE TABNAME = DD03P-TABNAME.
ENDSELECT.
  IF SY-SUBRC = 0.
    MOVE DD02L-TABCLASS TO FIELDS-TABCLASS.
  ENDIF.
  APPEND FIELDS.
  HIDE DD03P-TABNAME.
ENDSELECT.
IF NOT SY-SUBRC = 0.
  ULINE.
  WRITE: / 'No tables found for field', FIELD.
  ULINE.
ENDIF.

SORT FIELDS.

LOOP AT FIELDS.
  WRITE: / FIELDS-TABNAME,
           FIELDS-TABCLASS,
           FIELDS-FIELDNAME,
           FIELDS-POSITION,
           FIELDS-KEYFLAG,
           FIELDS-MANDATORY,
           FIELDS-ROLLNAME,
           FIELDS-CHECKTABLE,
           FIELDS-INTLEN,
           FIELDS-DOMNAME,
           FIELDS-MEMORYID.
ENDLOOP.

IF DOWNLOAD NE ''.
  CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
            FILENAME = FILENAME
            FILETYPE = FILETYPE        "ASC, WK1, DBF, DAT, BIN, WK1
       TABLES
            DATA_TAB = FIELDS.
ENDIF.

AT LINE-SELECTION.
  SET PARAMETER ID 'DOB' FIELD SY-LISEL(30) .
  CALL TRANSACTION 'SE12' AND SKIP FIRST SCREEN.

AT PF8.
  CHECK SY-LISEL <> ''.
  SET PARAMETER ID 'DTB' FIELD SY-LISEL(10) .
  REFRESH  DYNTAB.
  PERFORM DYNPRO USING:
     'X'  'SAPMSTAZ'     '0100'        "Selection screen
    ,' '  'DD02V-TABNAME'  SY-LISEL(10).
  CALL TRANSACTION 'SE16' USING DYNTAB MODE 'A' .

*---------------------------------------------------------------------*
*       FORM DYNPRO                                                   *
*---------------------------------------------------------------------*
FORM DYNPRO USING DYNBEGIN NAME VALUE.

  IF DYNBEGIN = 'X'.
    CLEAR DYNTAB.
    MOVE :  NAME TO DYNTAB-PROGRAM,
            VALUE TO DYNTAB-DYNPRO,
            DYNBEGIN TO DYNTAB-DYNBEGIN.
    APPEND DYNTAB.
  ELSE.
    CLEAR DYNTAB.
    MOVE:  NAME TO DYNTAB-FNAM,
           VALUE TO DYNTAB-FVAL.
    APPEND DYNTAB.
  ENDIF.

ENDFORM.