Home > SAP Tips > ABAP/Java developer tips > Look up tables/views for specific fields
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ABAP/JAVA DEVELOPER TIPS

Look up tables/views for specific fields


Vineet Bhalla
10.12.2001
Rating: -4.20- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This program extracts the tables list for given field names. On double clicking the table it will take you to SE11.

Note: If you are using this program in 4.0 then the parameter id used in the at line selection should be 'DOB' as againt 'DTB'.



Code

REPORT ZLOOKTABLES LINE-SIZE 120 LINE-COUNT 60 .

TABLES : DD02L,
         DD03L,
         DD02T.

DATA : BEGIN OF I_DD02L OCCURS 0.
        INCLUDE STRUCTURE DD02L.
DATA : END OF I_DD02L.

DATA : BEGIN OF I_DD03L OCCURS 0,
        TABNAME LIKE DD03L-TABNAME,
        FIELDNAME LIKE DD03L-FIELDNAME,
        KEYFLAG LIKE DD03L-KEYFLAG,
        DDTEXT LIKE DD02T-DDTEXT,
  END OF I_DD03L.

DATA : COUNT TYPE I,
       DBCOUNT TYPE I,
       D_TABNAME LIKE DD03L-TABNAME.

DATA : BEGIN OF I_FLDNAME OCCURS 0,
         NAME(72),
       END OF I_FLDNAME.

SELECT-OPTIONS: FLDNAME FOR DD03L-FIELDNAME NO INTERVALS.

TOP-OF-PAGE.
  PERFORM HEADER.

START-OF-SELECTION.

  DESCRIBE TABLE FLDNAME LINES COUNT.
  SELECT * FROM DD03L INTO CORRESPONDING FIELDS OF DD03L
           WHERE FIELDNAME IN FLDNAME.
    I_DD03L-TABNAME = DD03L-TABNAME.
    I_DD03L-FIELDNAME = DD03L-FIELDNAME.
    I_DD03L-KEYFLAG = DD03L-KEYFLAG.
    APPEND I_DD03L.
  ENDSELECT.
  SORT I_DD03L BY TABNAME FIELDNAME.
  DBCOUNT = COUNT + 1.

  LOOP AT I_DD03L.
    AT NEW TABNAME.
      IF COUNT > DBCOUNT.
        DELETE I_DD03L WHERE TABNAME = D_TABNAME.
      ENDIF.
      DBCOUNT = 0.
    ENDAT.
    D_TABNAME = I_DD03L-TABNAME.
    DBCOUNT = DBCOUNT + 1.
    AT LAST.
      IF COUNT > DBCOUNT.
        DELETE I_DD03L WHERE TABNAME = D_TABNAME.
      ENDIF.
      DBCOUNT = 0.
    ENDAT.
  ENDLOOP.

  SELECT *  FROM DD02L INTO TABLE I_DD02L FOR ALL ENTRIES IN I_DD03L
            WHERE TABNAME = I_DD03L-TABNAME AND TABCLASS = 'TRANSP'.
  CLEAR I_DD03L.
  LOOP AT I_DD03L.
    SELECT SINGLE * FROM DD02T WHERE TABNAME = I_DD03L-TABNAME
    AND DDLANGUAGE = 'EN'.
    MOVE DD02T-DDTEXT TO I_DD03L-DDTEXT .
    MODIFY I_DD03L TRANSPORTING DDTEXT.
*  endselect.
  ENDLOOP.
  PERFORM PRINT.
  DATA : VALUE(25),                      " value For get cursor line
       FIELD(25),                      " For get cursor field
       LINE(4) ,                       " For get cursor line
       VALUE1(255).                    " value For get cursor field
AT LINE-SELECTION.
GET CURSOR FIELD FIELD VALUE VALUE.
GET CURSOR LINE LINE VALUE VALUE1.
CONDENSE VALUE .
CASE FIELD .
WHEN 'I_DD03L-TABNAME' .
SET PARAMETER ID 'DTB' FIELD VALUE(18).
CALL TRANSACTION 'SE11' AND SKIP FIRST SCREEN.
ENDCASE .

END-OF-SELECTION.

*---------------------------------------------------------------------*
*       FORM PRINT                                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM PRINT.
  LOOP AT I_DD02L.
    LOOP AT I_DD03L WHERE TABNAME = I_DD02L-TABNAME.
      AT NEW TABNAME.
        SKIP 1.
        WRITE : /  I_DD03L-TABNAME.
        ULINE.
      ENDAT.
     WRITE : /02 I_DD03L-KEYFLAG,06 I_DD03L-FIELDNAME,38 I_DD03L-DDTEXT.
    ENDLOOP.
  ENDLOOP.
ENDFORM.


*---------------------------------------------------------------------*
*       FORM CONCAT                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  VALUE(P_0062)                                                 *
*---------------------------------------------------------------------*
FORM CONCAT USING    VALUE(P_0062).
  CONCATENATE 'FIELDNAME = ''' P_0062 ''''  INTO I_FLDNAME.
  APPEND I_FLDNAME. CLEAR I_FLDNAME.
  CONCATENATE 'AND' ' ' INTO I_FLDNAME.
  APPEND I_FLDNAME.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  CONCAT1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_FLDNAME+3(28)  text                                        *
*      -->P_PERFORM  text                                              *
*      -->P_CONCAT  text                                               *
*      -->P_FLDNAME+3(28)  text                                        *
*----------------------------------------------------------------------*
FORM CONCAT1 USING VALUE(VAL1).
  CONCATENATE 'FIELDNAME = ''' VAL1 ''''  INTO I_FLDNAME.
  APPEND I_FLDNAME. CLEAR I_FLDNAME.
ENDFORM.                               " CONCAT1

*---------------------------------------------------------------------*
*       FORM HEADER                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM HEADER.
  FORMAT COLOR COL_HEADING.
  WRITE : / 'Tablename'.
  WRITE : /02 'Key' ,06 'Field Name', 30 'Description' .

  ULINE.
  FORMAT RESET.

ENDFORM.

Rate this Tip
To rate tips, you must be a member of SearchSAP.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
ABAP/Java developer tips
Select Text fields: Case-insensitive
Finding BADIs you can use
Is this the quickest way to find a BADI?
ABAP Objects in SAP Workflow to provide improved performance
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects
Find a BADI in a minute
Top 10 SAP tips of 2007
How to transport an SAP query in R/3 4.6x
How to switch off message determination in BAPI_PO_CREATE1

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsBlogsTipsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts