Home > SAP software/management Tips > SAP ABAP/Java developer tips > Programming dynamic selections
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

SAP ABAP/JAVA DEVELOPER TIPS

Programming dynamic selections


Bernd Matzke
11.06.2001
Rating: -3.44- (out of 5)


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


Programming dynamic selections
By Bernd Matzke

Excerpted from ABAP/4: Programming the SAP R/3 System by Bernd Matzke, published by Addison Wesley.


You require two things before you can implement a dynamic selection in a logical database. One is a special statement in the database program's selection include (DBxxxSEL). This special statement ensures that the user can enter the corresponding selection criterion. You enter the selection criterion for a dynamic selection in a different way from simply parameters or selection tables, and the program also evaluates it in a different way. Therefore, the selection statement must be tailored to the paritcular table so that the table can evalutate this selection criterion. This section will introduce you to the statements you require in more detail.

In the DBxxxSEL section include, the following statement defines the database table for which a dynamic selection is to be implemented:

SELECTION-SCREEN DYNAMIC SELECTIONS
   FOR TABLE table
   [ID ident].

If dynamic selections are to be supported for several tables, a statement is required for each table. If the report uses a table that is intended for a DYNAMIC SELECTION, the Dynamic selections pushbutton appears in the selection screen. Any entries made when the application is running for any dynamic selections are stored in a complex data object called DYN_SEL. This data object contains an internal table called CLAUSES. Each data record in this table contains another internal table called WHERE_TAB. The selection criteria for all the dtabase tables are stored in this internal table. You must use this special variant of the SELECT statement to evaluate these selection criteria.

SELECT * FROM table
   WHERE (itab).

This variant of the SELECT statement reads the selection criteria from an internal table. You can also enter other conditions in the WHERE clause. Before you do this, the internal table used in the WHERE clause must be filled with data from the DYN_SEL dataset.

The DYN_SEL data object has a very complex structure. The definition is stored in the RSDS type pool. Its most elementary component is the dype definition for an internal RSDS_WHERE_TAB table. This internal table is derived from a structure stored in the Data Dictionary. It merely consists of a CHAR-type field with a length of 72 characters.

   TYPES: RSDS_WHERE_TAB LIKE RSDSWHERE OCCURS 5.

This definition flows into the definition of the RSDS_WHERE structure. This structure has a TABLENAME field, in which you enter a table name, and a WHERE_TAB internal table. The selection criteria for the table defined in the TABLENAME field are stored in the WHERE_TAB internal table.

TYPES:
   BEGIN OF RSDS_WHERE,
      TABLENAME LIKE RSDSTABS-PRIM_TAB,
      WHERE_TAB WHERE_TAB TYPE RSDS_WHERE_TAB,
   END OF RSDS_WHERE.

You use this type of structure to define another internal table. This second internal table stores the selection criteria for several Data Dictionary tables.

TYPES: RSDS_TWHERE TYPE RSDS_WHERE OCCURS 5.

Finally, the table definition shown above is incorporated into the RSDS_WHERE type description. This type now contains the CLAUSES field, which contains an RSDS_TWHERE-type table.

TYPES:
   BEGIN OF RSDS_TYPE,
      CLAUSES TYPE RSDS_TWHERE,
      TEXPR TYPE RSDS_TEXPR,
      TRANGE TYPE RSDS_TRANGE,
   END OF RSDS_TYPE.

This data type has two additional fields that also contain very complex objects. The TEXPR field ocntains the selection criteria in a form that can be stored, whereas the TRANGE field saves tehse criteria in some of the RANGES tables. If necessary, the CHECK statement can use these RANGES tables. Finally, you use data type RSDS_TYPE to generate a real data object. You sue the following statement to do this:

DATA DYN_SEL TYPE RSDS_TYPE.

You will find more details about the structure of the other components in DYN_SEL in the type pool we mentioned above.

From the data types dicussed above, you can see that DYN_SEL always stores data in all talbes where dynamic selections have been used to enter selection criteria. Therefore, you suually access values in DYN_SEL by using the name of the database table as a limiting criterion.


To read more about this and other ABAP/4 programming issues, click to find out about ABAP/4: Programming the SAP R/3 System.


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
SAP ABAP/Java developer tips
How to do additional dialog processing after SAP COMMIT WORK statement
How to find a piece of SAP ABAP code without debugging
How to read an SAP transaction in an ABAP code
How to provide an SAP R/3 4.5B application server with a Web service interface
How to find owners and transports of deleted ABAP programs
Fixing a common OPEN_FORM and START_FORM error in SAPscript
Select Text fields: Case-insensitive
Is this the quickest way to find a BADI?
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects

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.



NetWeaver SAP White Papers
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, 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