Your SlideShare is downloading. ×
0
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
The ABAP Query
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

The ABAP Query

20,840

Published on

12 Comments
33 Likes
Statistics
Notes
No Downloads
Views
Total Views
20,840
On Slideshare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
0
Comments
12
Likes
33
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. The ABAP Query
  • 2. ABAP Query <ul><li>The ABAP Query can be used to meet most of the custom reporting needs within a business structure. </li></ul><ul><li>Existing reporting strategy should be used to determine the best tool to use, but if BW or Report Writer/Painter do not satisfy the requirement, ABAP Query can be used in all cases. There should be no need for an ABAP developed report. ALV grid and drill-down processing is already part of the ABAP Query functionality. </li></ul><ul><li>The use of external programs as a data source allows for creation of performance efficient data extracts, while still using the other benefits of ABAP Query. </li></ul>
  • 3. ABAP Query Components <ul><li>An ABAP Query is comprised of 3 components: </li></ul><ul><li>         InfoSets - InfoSets determine to which tables or fields within a table, a query can refer. InfoSets are based on a data extract from table joins, a logical database, or an external program extract. These should be created with sharability in mind since multiple queries can be written against an InfoSet. </li></ul><ul><li>         User Groups - Allows you to to specify the users who are authorized to run and/or create/change queries under that user group. </li></ul><ul><li>         Queries - Allows you to select and format the data identified in the InfoSet to create the desired report. </li></ul>
  • 4. Standard vs. Global Areas
  • 5. <ul><li>ABAP query components can be created in either the standard area or global area: </li></ul><ul><li>Standard Area - Allows for creation of client-dependent objects that have to be exported to a transport and then imported into each required client. Functionality exists to import, export, upload, and download query components. Dev objects are automatically created that include the client number. </li></ul><ul><li>Global Area - Allows for creation of client-independent objects that get transported via the normal transport process. A transport is required on save of an object. </li></ul>Standard vs. Global Areas
  • 6. <ul><li>To ensure you are in the Global Area, each of the query transaction codes will show the following at the top of the screen: Query area Global Area (Cross-client) </li></ul><ul><li>If it does not, you are in the Standard Area. To switch to the Global Area, select from any of the query transactions: Environment > Query areas </li></ul><ul><li>A pop-up box will be displayed. Choose Global Area (Cross-client). </li></ul>Standard vs. Global Areas
  • 7. InfoSet Design Strategy
  • 8. <ul><li>InfoSets can be based on a data extract from table joins, a logical database, or an external program extract. </li></ul><ul><li>Prior to creating an InfoSet the current and potential reporting needs and required and optional selection criteria should be analyzed to determine the most efficient means to use as a source. Required and data selections will be used to determine the best method for key access. </li></ul><ul><li>Optional data selections will be used to determine if there might be an alternate method for the best key access when certain optional selection criteria is entered. </li></ul><ul><li>Output fields will be used to determine which tables are required, keeping in mind that some fields reside in multiple tables. In this case, the table to use will also be based on the best method for key access. </li></ul>InfoSet Design Strategy
  • 9. <ul><li>If a logical database exists for the desired data. </li></ul><ul><li>If the required selection criteria allows for efficient access to the starting table of the logical database. </li></ul><ul><li>If frequently used optional selection criteria will not alter the best access path. </li></ul><ul><li>If selection criteria derived from the query is sufficient to access the logical database efficiently (no calculated criteria is required or no validation for the criteria is required for performance). </li></ul><ul><li>If all data required on the report that needs to be retrieved from additional tables can be retrieved one for one for the existing relational records from the logical database result. </li></ul><ul><li>NOTE: If a logical database exists, whether you use it or not, it is a good means of seeing how standard SAP links tables together. </li></ul>InfoSet Design Strategy – When to use a Logical Database
  • 10. <ul><li>If a logical database does not exist for the desired data or has been ruled out. </li></ul><ul><li>If the required selection criteria allows for efficient access to the data via simple table joins. </li></ul><ul><li>If frequently used optional selection criteria will not alter the best access path. </li></ul><ul><li>If selection criteria derived from the query is sufficient to access the tables efficiently (no calculated criteria is required or no validation for the criteria is required for performance). </li></ul><ul><li>If only one left outer join is required. </li></ul><ul><li>If all data required on the report that needs to be retrieved from additional tables can be retrieved one for one for the existing relational records from the table join result. </li></ul>InfoSet Design Strategy – When to use Table Joins
  • 11. <ul><li>If both a logical database and table joins have been ruled out. </li></ul>InfoSet Design Strategy – When to use an External Program
  • 12. InfoSet Creation
  • 13. <ul><li>Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > InfoSets </li></ul><ul><li>Transaction: SQ02 </li></ul>InfoSet - Creation <ul><li>Enter your InfoSet </li></ul><ul><li>name and hit the </li></ul><ul><li>button. </li></ul><ul><li>An InfoSet can be created with a data source of: </li></ul><ul><li>Logical Database </li></ul><ul><li>Table Join </li></ul><ul><li>External Program </li></ul>
  • 14. <ul><li>Logical databases have already been set up and should be used if they contain the appropriate data and access to that data. A logical database is a series of tables arranged in a hierarchical structure. </li></ul><ul><li>Enter your description and your data source. </li></ul>InfoSet - Data Source - Logical Database
  • 15. <ul><li>To find the available databases, select the possible entries on the Logical database field and enter a required table name. </li></ul><ul><li>Possible entries will be displayed and select one. </li></ul>InfoSet - Data Source - Logical Database <ul><li>Select the nodes (tables of the logical database) you require. </li></ul>
  • 16. <ul><li>To display the structure of the logical database, select the magnifying glass next to Logical database field on the InfoSet: Title and Database screen. </li></ul>InfoSet - Data Source - Logical Database
  • 17. <ul><li>A table join data source should be used if you have ruled out a logical database and the appropriate keys are available in the selection criteria to efficiently use the join and the required data can be easily retrieved. </li></ul>InfoSet - Data Source - Table Join <ul><li>Enter your description and your data source. </li></ul>
  • 18. InfoSet - Data Source - Table Join <ul><li>Select to insert another table. </li></ul><ul><li>A pop-up will appear, enter the table name </li></ul><ul><li>The system will automatically propose joins. </li></ul><ul><li>Press the Green arrow to back out. </li></ul><ul><li>The pop-up on the right will appear, select include key fields. </li></ul>
  • 19. <ul><li>It is possible to create an InfoSet using data retrieval by either an internal (integrated) or external program. </li></ul><ul><li>A custom data structure must be created first using SE11 that contains the output record layout of the data retrieval program. </li></ul><ul><li>An integrated program allows you to create the code within the InfoSet to populate the specified structure. We have ruled out this method in favor of the benefits of the external program. </li></ul><ul><li>An external program allows you to create the code outside the InfoSet to populate the specified structure. Standard ABAP Editor is used and standard programming documentation can be created. Code Inspector, Pretty Printer, and other standard tools are available to you. Versions and transports are easily visible. </li></ul>InfoSet - Data Source – Data Retrieval Program
  • 20. <ul><li>Create the data structure and external program before you generate the InfoSet for the first time. </li></ul><ul><li>A custom data structure must be created using SE11 that contains the output record layout the structure you want to populate. </li></ul><ul><li>You use the ABAP editor to create/maintain the program. </li></ul><ul><li>The external program must meet the following requirements: </li></ul><ul><ul><ul><ul><li>Its structure must conform to certain conventions. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>It must not contain any syntax errors. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>It must use the same fixed point arithmetic as the InfoSet. </li></ul></ul></ul></ul><ul><li>You must make sure that the InfoSet and the external program are transported together. This is one case where you would put the dictionary, external program, and InfoSet changes all within the same transport. </li></ul><ul><li>The basic structure and operating sequence of the external program is as follows in the next slide: </li></ul>InfoSet - Data Source – External Program
  • 21. InfoSet - Data Source - External Program   * End of data retrieval loop for individual records (ENDSELECT, ENDDO, ENDLOOP) Comment to finish the statement in the loop. The data must be available in the tab structure. * <Query_body>   * Code to define the itab table, if such a table is used. * Start of a loop to retrieve, one at a time, each of the records that you want to report on, and place them in the tab structure (SELECT, DO, LOOP) * Code for formatting data Comment to finish off a data statement. * <Query_head> Definition of an internal table itab with structure tab providing the records that you want to report on. DATA: BEGIN OF itab OCCURS xxx.       INCLUDE STRUCTURE tab. DATA: END of itab.   DATA:   Select-Options:… Definition of parameters, selection criteria, and fields. Parameters . Definition of the dictionary structure used to set up the InfoSet. This structure must contain the records that you want to report on. Tables tab .   Report xxxxxxxx .
  • 22. <ul><li>The structure created must be declared in the external program. </li></ul><ul><li>Selection criteria needed for processing in the external program must be coded in the external program. This also allows for validation. </li></ul><ul><li>The purpose of the data retrieval is to populate a table in the declared structure. </li></ul><ul><li>Data retrieval will start after the <QUERY HEAD> comment. The LOOP to populate the output table will be within this section. The ENDLOOP of the output table must be after the <QUERY END> comment. </li></ul><ul><li>If different access paths are needed based on selection criteria then control these within the code by calling different FORM routines to populate the data. </li></ul>InfoSet - Data Source – External Program
  • 23. <ul><li>Once the data structure and external program are created, you can create the InfoSet: </li></ul>InfoSet - Data Source - External Program <ul><li>Enter your description in the Name field. </li></ul><ul><li>Select the data retrieval by program radio button. </li></ul><ul><li>Enter your data structure. </li></ul><ul><li>Select the external program radio button. </li></ul><ul><li>Enter the external program name. </li></ul><ul><li>NOTE: Use the same name for the structure and external program. </li></ul>
  • 24. <ul><li>Additional tables, structures, and fields allow you to enhance the selected data source. The point (event) at which SAP Query reads an additional table or performs a calculation on an additional field depends on the type of data source. </li></ul><ul><li>For a logical database table, the associated ABAP code becomes part of the GET event processing that table. For non-logical database sources, it becomes part of the record processing event. </li></ul><ul><li>Additional tables will be retrieved automatically by the InfoSet. </li></ul><ul><li>Any query for the InfoSet can address both additional fields and additional table fields, provided they are assigned to a field group of that InfoSet. </li></ul><ul><li>The sequence associated with a field or structure determines the point that the underlying code for that object is executed within either the record processing or GET events. These objects can also be populated within the record processing or GET events additional code if it makes more sense for performance or maintainability, but a warning will occur when the InfoSet is generated. </li></ul>InfoSet – Additional Tables, Structures, and Fields
  • 25. <ul><li>InfoSet functionality to generate additional code makes additional tables, structures, fields, parameters and selection criteria more flexible. These options generate ABAP code for all queries of an InfoSet, but this is transparent to the end-user. The coding areas are as follows: </li></ul><ul><li>DATA for global data declarations (Use this section for Modification History). </li></ul><ul><li>INITIALIZATION for initializing data fields. </li></ul><ul><li>AT-SELECTION for selection screen processing. </li></ul><ul><li>START-OF-SELECTION which precedes the first database access. </li></ul><ul><li>GET/GET Late for these events for a logical database table. </li></ul><ul><li>Record Processing for processing individual records for non-logical databases. </li></ul><ul><li>Free Coding for forms routines at end of the program. </li></ul><ul><li>END-OF-SELECTION either before or after output of the list. </li></ul><ul><li>TOP-OF-PAGE for just before the instructions for output of the page header. </li></ul><ul><li>NOTE: Additional data retrieval can be done in the code sections for tables that you may not want to or cannot join relationally. </li></ul>InfoSet - Additional Code
  • 26. <ul><li>To define an additional table for a data source table, proceed as follows: </li></ul><ul><li>Double-click on a table that you want to assign to an additional table and choose the function Extras. </li></ul><ul><li>Choose the function Create. </li></ul><ul><li>A dialog box appears where you enter the table name and select the Additional table radio button. </li></ul><ul><li>The system then creates the SELECT statement in another dialog box with proposed values and a proposed sequence that you can overwrite. </li></ul>InfoSet – Assigning Additional Tables
  • 27. <ul><li>To define an additional field for a data source table, proceed as follows: </li></ul><ul><li>Double-click on a table that you want to assign to the field and choose the function Extras. </li></ul><ul><li>Choose the function Create. </li></ul><ul><li>A dialog box appears where you enter the field name and select the Additional field radio button. </li></ul><ul><li>Another dialog box appears where you can enter the field attributes. </li></ul><ul><li>NOTE: When assigning fields to a table best practice is to put the name of the table as the prefix of the field name for visibility. </li></ul>InfoSet – Assigning Additional Fields
  • 28. <ul><li>The new additional field now appears in the Extras list. To add code for this field: </li></ul><ul><li>Select the field and then the Coding additions button. </li></ul><ul><li>Choose the function Create. </li></ul><ul><li>A dialog box appears where you can enter additional code and the sequence of code. </li></ul><ul><li>You will actually need to move a value to this field in this section (i.e. VBAK_FIELD = ‘X’.) </li></ul>InfoSet – Assigning Additional Fields
  • 29. <ul><li>A field group combines related fields together into a meaningful unit. It provides you with a pre-selection, so that you do not have to search through all fields of a data source just to produce a simple list. </li></ul><ul><li>Fields must be assigned to a field group before they can be used in queries. </li></ul>InfoSet – Assigning Fields to Field Groups <ul><li>Predefined field groups are created for logical databases. </li></ul><ul><li>You can use drag & drop to add a field to a field group or you can click on the field and the field group and then select “Add fields to field groups” or the relevant function from the context menu. </li></ul>
  • 30. InfoSet – Changing Field Labels <ul><li>It is possible to change field labels of existing fields so that they are consistent in all queries of the InfoSet. </li></ul><ul><li>Double-click on the field name. </li></ul><ul><li>A sub-screen will be displayed that allows you to change either the Long text of Header text of the field. </li></ul>
  • 31. <ul><li>Selection criteria and parameters can be stored in the InfoSet: </li></ul><ul><li>These are only available for the coding sections and will not be used automatically in the data retrievals to reduce records from the database. The CHECK command needs to be used. </li></ul><ul><li>InfoSet selection criteria can be validated. </li></ul><ul><li>InfoSet selection criteria and Query selection criteria appear in two different sections in the Query. </li></ul><ul><li>NOTE: Regardless of where selection criteria are created, it is critical that key fields are required. Within the Query this can be controlled via the variant. </li></ul>InfoSet – Selection Criteria and Parameters
  • 32. <ul><li>When you are done with your changes, you need to save your InfoSet. </li></ul><ul><li>Click on the check InfoSet to perform a global syntax check. </li></ul><ul><li>Click on the generate button to generate the InfoSet. Any errors need to be resolved before you can create any queries using the InfoSet. </li></ul><ul><li>If there are differences between the InfoSet and the Data Dictionary, you can use the Adjust function to correct. This may also need to be done if you change the source structure of an External Program. </li></ul><ul><li>You can use the Environment->Directories function to show usage of the fields in the InfoSet. </li></ul><ul><li>From the main menu, you can select the Description icon to get a full view of the report in HTML. </li></ul>InfoSet – Management
  • 33. <ul><li>You can copy a Query to another InfoSet or copy a Query and InfoSet, etc.: </li></ul><ul><li>From SQ02 main screen select Goto->More Functions->Copy Functions. </li></ul><ul><li>To copy a Query to another InfoSet, both InfoSets need to have the same data as required by the Query. </li></ul><ul><li>This is how you would make Y versions. The prefix would be “Y”. </li></ul><ul><li>Select the “i” icon for program documentation for further information. </li></ul>InfoSet – Copy InfoSets/Queries
  • 34. User Group Creation and Assignment
  • 35. <ul><li>Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > User Groups </li></ul><ul><li>Transaction: SQ03 </li></ul>User Group - Creation Enter your User Group name and hit the button. Enter a description and hit save. You will be prompted for a transport.
  • 36. <ul><li>Press the to assign users to your User Group. Select the checkbox next to the user name if you want them to create or change queries. </li></ul><ul><li>Press save and green arrow back. </li></ul>User Group – Assign Users
  • 37. <ul><li>Press the next to the InfoSet field on the main screen. Be sure your InfoSet name is in the field. </li></ul>User Group – Assign InfoSets <ul><li>Select your User Group name and press save. Your User Group is now assigned to your InfoSet. </li></ul>
  • 38. Query Creation
  • 39. <ul><li>Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > Queries </li></ul><ul><li>Transaction: SQ01 </li></ul>Query - Creation Select your user group. Enter your Query name and hit the button. Select an InfoSet. Enter a description and hit save. You will be prompted for a transport.
  • 40. Query - Creation Use Notes to document the Remedy ticket number, date of creation, and brief description. Enter CUS&STANDARD as the standard variant to be used by this query. The naming convention of CUS& allows this to be transported. Enter your Query description, list and output format. Hit to continue.
  • 41. Query – Selecting Fields <ul><li>Select the field groups you want to use in this Query. </li></ul><ul><li>Select the fields and selection criteria. </li></ul>
  • 42. Query – Graphical Query Painter <ul><li>Select a report type and the Graphical Query Painter: </li></ul><ul><ul><li>Basic List – Simple Reports </li></ul></ul><ul><ul><li>Statistics – Reports with statistical functions such Avg, %. </li></ul></ul><ul><ul><li>Ranked List – Analytical Reports </li></ul></ul>
  • 43. Query – Graphical Query Painter
  • 44. Query – Graphical Query Painter <ul><li>Select or double-click the fields from the left to move to </li></ul><ul><li>your report. </li></ul><ul><li>Press save and test to execute your report. </li></ul>
  • 45. Query – Report Assignment Report Assignment allows you to drill into another report or transaction. <ul><li>Navigate to Query > Change > Goto > Report Assignment. </li></ul><ul><li>Click on Insert Row. </li></ul><ul><li>To select an ABAP Query, check Global area, enter User Group, Query, and Variant. </li></ul>
  • 46. Query – Report Assignment To drill into another transaction: <ul><li>Click on Other report type > Select TR. </li></ul><ul><li>Enter a transaction code. </li></ul><ul><li>To transport a report assignment, click on the transport button and include in your query transport. </li></ul>
  • 47. <ul><li>When you are done with your changes, you need to save your Query. </li></ul><ul><li>Select Query->More Functions->Generate program to generate the ABAP code. </li></ul><ul><li>Select Query->More Functions->Display report name to see the name of the program. </li></ul><ul><li>If there are differences between the Query and the InfoSet, you can use the Adjust function to correct. This may also need to be done if you change the source structure of an External Program. </li></ul><ul><li>You can select Goto->Maintain variants to create your CUS&STANDARD variant. </li></ul><ul><li>You can use the Environment->Directories function to show usage of the fields in the Query. </li></ul>Query – Management
  • 48. Query – Program Generation Results <ul><li>The Query and the InfoSet information is merged together into a program. The generated program has all of the components of the InfoSet and Query inserted into specific locations in a program template, in the sequence specified. </li></ul><ul><li>The naming convention is AQZZuuuuuuuuuuuuqqqqqqqqqqqqqq where “ZZ” represents Global (ZZ would be replaced with a client number if it was standard), “u” represents the User Group, right-filled with equal signs, and “q” represents the Query name, right-filled with equal signs. </li></ul><ul><li>Database access is optimized to only retrieve those fields necessary for the Query. This is known as SQL optimization, which can be turned off. You could have issues with fields you need for testing in the code that do not print on the report. This can be resolved with a FIELDS statement in the additional code to explicitly name a field. </li></ul><ul><li>To debug a Query, you can set breakpoints in the program and execute via SE38. </li></ul>
  • 49. Query – Transaction Code Creation To create a transaction code for your query use transaction SE93: <ul><li>Enter a transaction code. Typically it would be named with Z plus the domain name plus “_” plus a short name. </li></ul><ul><li>Enter a short text which would typically be the Query Title with (AQ) behind it for clarification. </li></ul><ul><li>Select Transaction with parameters (parameter transaction). </li></ul>
  • 50. Query – Transaction Code Creation To create a transaction code for your query use transaction SE93: <ul><li>Enter START_REPORT as the Transaction and check the Skip initial screen and Inherit GUI attributes boxes. </li></ul><ul><li>Enter the above screen fields and values where EXTDREPORT is the Query name, VARIANT is the starting variant name (optional), and REPORT is the user group (1 st twelve characters) plus “G” for global area. </li></ul>
  • 51. InfoSet Examples
  • 52. InfoSet: ZSD_OPEN_ORDERS User Group: ZSD Query: ZSD_OPEN_ORDER_D Program: AQZZZSD=========ZSD_OPEN_ORD_D Purpose: Make open sales order information available at the order/item/ schedule line level with associated material master information. Separates confirmed and unconfirmed values and quantities and makes totals available at the order, item, and schedule line levels. Values are based on KZWI2 (Sub-total 2) since this represents shipment dollars. Requested date and earliest schedule line date is available at each level. Partial delivery or billing quantities are applied against the schedule lines to determine true open quantities and values at the delivery date level. An open order date allows only orders due to deliver in that time period to be considered. Logical Database Example
  • 53. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>If you go into SQ02 in change mode for ZSD_OPEN_ORDERS and then select Goto->Global Properties: </li></ul><ul><li>The global properties shows the logical database is VAV. </li></ul><ul><li>The left hand side contains the tables and data fields of the logical database. </li></ul><ul><li>The top right shows the field groups organized as standard nodes of the logical database. </li></ul>
  • 54. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>You can see that MARC is an additional table at the Sales Document Item Data level: </li></ul><ul><li>If you display the definition of the table, you will see the join condition. </li></ul><ul><li>This particular table is buffered as the records are retrieved 1 for 1 from the sales document items and a material plant combo may need to be retrieved more than once. </li></ul>
  • 55. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>You can see that there are also additional fields at the Sales Document Item Data level: </li></ul><ul><li>If you display the definition of the field, you will see the format and length. </li></ul><ul><li>There is no underlying code here as it is performed in the additional code sections. </li></ul>
  • 56. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>Select the Extras icon to see the additional code fields, and table for VBAP in the Extras tab: </li></ul><ul><li>Sequence is important and will be checked at generation time. </li></ul><ul><li>There is no underlying code here as it is performed in the additional code sections. </li></ul>
  • 57. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>Select the Selections tab to see the selection criteria for the InfoSet: </li></ul><ul><li>The Standard checkbox denotes the selection is part of the logical database. </li></ul><ul><li>The Required checkbox denotes the selection is required. </li></ul><ul><li>The As default on selection screen checkbox means it will automatically display in the InfoSet Query. </li></ul><ul><li>The code icon will take you to the AT SELECTION-SCREEN code for the item. </li></ul>
  • 58. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>GET/GET LATE Events: </li></ul><ul><li>These exist for logical databases and allow for coding at the event. </li></ul><ul><li>These events are nested within the hierarchical structure (i.e. GET VBAK could initialize order fields, GET LATE VBAP could sum them, and GET LATE VBAK could test them): </li></ul><ul><ul><li>GET VBAK. </li></ul></ul><ul><ul><li>GET VBAP. </li></ul></ul><ul><ul><li>GET VBEP. </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><ul><li>GET LATE VBEP. </li></ul></ul><ul><ul><li>GET LATE VBAP. </li></ul></ul><ul><ul><li>GET LATE VBAK. </li></ul></ul>
  • 59. InfoSet – Logical Database – ZSD_OPEN_ORDERS <ul><li>GET/GET LATE Events – Other Information: </li></ul><ul><li>Code from these events are processing a single record from the table at a time. </li></ul><ul><li>CHECK and REJECT commands can be used to eliminate records. </li></ul><ul><li>If data is needed in an event from a table in a future event, you may need to code the SELECT to that table in the current event. </li></ul><ul><li>Only used fields outputted in the Query are retrieved from the table in the GET/GET LATE Events. </li></ul><ul><li>Tables that have no fields in the field group, are not used in the Query, and have no code for their events are not retrieved. </li></ul><ul><li>Coding conventions and standards, including the use of Pretty Printer, should be applied here when developing code within an InfoSet. </li></ul>
  • 60. Purpose: Join material master information from MARA, MARC, MVKE, and MBEW for the purposes of downloading the information to an HWS Data Warehouse. Material data is merged with pricing data for the B0, B1, and B2 price lists for 3 input divisions (3A, 3B, 3C). Characteristic data for the material is also merged as well as Unit of Measure conversions. There are many additional calculated fields for the pricing and classification data. InfoSet: ZMM_DATAMINE User Group: ZMM Query: ZMM_DATAMINE Program: AQZZZMM=========ZMM_DATAMINE== Table Join Example
  • 61. InfoSet – Table Join – ZMM_DATAMINE <ul><li>If you go into SQ02 in change mode for ZMM_DATAMINE then select Goto->Global Properties: </li></ul><ul><li>The global properties shows the Table join using basis table MARC. </li></ul><ul><li>The left hand side contains the tables and data fields of the table join and additional fields. </li></ul><ul><li>The top right shows the field groups organized by table and then other created field groups. </li></ul>
  • 62. InfoSet – Table Join – ZMM_DATAMINE <ul><li>If you select the Join icon you can see the graphical display of the table joins: </li></ul><ul><li>This is the screen where you would initially add the tables, starting with the basis table MARC. </li></ul><ul><li>You can see the keys used and that MARC is a Left Outer Join to the other tables. </li></ul>
  • 63. InfoSet – Table Join – ZMM_DATAMINE <ul><li>Record Processing Event: </li></ul><ul><li>Instead of the GET/GET LATE events, table joins use the Record Processing event. </li></ul><ul><li>At this point you are working with a single record from the table join result and you can refer to fields from the table and field they were retrieved from. </li></ul><ul><li>In this particular report, you can see how additional table data is retrieved that could not be linked relationally and also that variables are being set to later populate the additional fields. </li></ul><ul><li>You can also see that field symbols are being used. </li></ul><ul><li>Keep in mind that you could even call function modules from this code. In this case, it made more sense to retrieve the pricing tables directly. </li></ul>
  • 64. Purpose: Retrieve orders blocked by delivery block at either the schedule line and/or header level. An index was created on VBEP for schedule line delivery block for this report. If a schedule line delivery block is entered as selection criteria, data is retrieved starting with VBEP. If no schedule line delivery block is entered, data is retrieved starting with VBAK. InfoSet: ZSD_SO_BLOCK_E External Program: ZSDQ_SO_BLOCK Data Structure: ZSDQ_SO_BLOCK User Group: ZSD Query: ZSD_SO_BLOCK_E Program: AQZZZSD=========ZSD_SO_BLOCK_E External Program Example
  • 65. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you go into SQ02 in change mode for ZSD_SO_BLOCK_E then select Goto->Global Properties: </li></ul><ul><li>The global properties shows the Data structure and external program ZSDQ_SO_BLOCK. </li></ul><ul><li>The left hand side contains the tables and data fields of the structure. </li></ul><ul><li>The top right shows the field groups that were manually created. Best practice is to organize these based on the source of the data in the structure. </li></ul>
  • 66. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you go into SE11 you can see the properties of the structure: </li></ul><ul><li>Every field that is to be retrieved by the external program and passed to the InfoSet must exist here. </li></ul><ul><li>Entry help/check must be entered for the selection criteria fields if you want to be able get help on them. </li></ul><ul><li>This is not the final output of the InfoSet as additional tables and fields could be added there, but this is typically more efficient as you have full ABAP control and can use internal tables. </li></ul>
  • 67. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you go into SE38 you can see the external program: </li></ul><ul><li>The program will contain modification history and data declarations like any other ABAP. </li></ul><ul><li>The data structure ZSDQ_SO_BLOCK needs to be declared. </li></ul>
  • 68. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you page down in SE38 you can see the following: </li></ul><ul><li>The selection screen blocks for fields required for the external data retrieval need to be coded here. </li></ul><ul><li>NOTE: The *<QUERY_HEAD> comment exists as required. </li></ul>
  • 69. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you page down further in SE38 you can see the following: </li></ul><ul><li>NOTE: The *<QUERY_HEAD> comment is prior to the actual code. </li></ul><ul><li>In this particular program, the access path to get the VBAK, VBAP, and VBEP data is different depending on whether a schedule line or header delivery block is entered so there are 2 different routines to get the data. </li></ul><ul><li>You are working with internal tables here so to get MARC, you can use a FOR ALL ENTRIES. </li></ul>
  • 70. InfoSet – External Program – ZSD_SO_BLOCK_E <ul><li>If you page down further in SE38 you can see the following: </li></ul><ul><li>When all of the data is gathered, it is sorted for best key access to the other internal tables. </li></ul><ul><li>It is processed at the lowest level, table VBEP. </li></ul><ul><li>Data is moved to the ZSDQ_SO_BLOCK work area. </li></ul><ul><li>NOTE: The *<QUERY_BODY> comment exists prior to the ENDLOOP as required. </li></ul><ul><li>FORM routines can then be placed after the ENDLOOP. </li></ul>
  • 71. <ul><li>END </li></ul><ul><li>ABAP QUERY </li></ul>

×