Beruflich Dokumente
Kultur Dokumente
REPORT ztest_events_list_report.
START-OF-SELECTION.
WRITE 'Click me!' COLOR = 5 HOTSPOT.
AT LINE-SELECTION.
ELSE.
SKIP.
WRITE: 'THAT''s THE END' COLOR = 1.
ENDIF.
OUTPUT:
On Clicking “More…”
MORE PROGRAMS ON REPORT PROGRAMMING:
In this tutorial you will learn how to create HOTSPOT using ABAP, this HOTSPOT will allow you to click on the text and then pass the value to be used as a
parameter for your query.
Here’s the ABAP Sample code to create the HOTSPOT. In this example, we will retrieve the customer name and address.
ZREPORT_HOTSPOT.
*&———————————————————————*
*& FREESAPTUTORIAL.COM
*&———————————————————————*
tables:
vbak,
kna1.
START-OF-SELECTION.
Today I want to share some ABAP code samples that you can use to convert numbers or amount into words using SPELL_AMOUNT function module.
data:
lw_spell LIKE spell,
saywords(150),
lv_text TYPE ltext,
p_amt TYPE eban-preis,
p_amt2(15),
p_waers type eban-waers.
START-OF-SELECTION.
p_amt = ‘123450′.
p_waers = ‘USD’.
“end code
Run the program and you will see the number has been converted into words.
BDC
Today I want to teach you how to create a BDC program using SHDB, this recording tool will be useful for you if you want to create an upload program from a flat
file into SAP tables.
In this tutorial, I want to record a transaction from QS21, it’s transaction to create MIC (Master inspection Characteristic) in QM module.
2. Now just name the recording as ZR_QS21, the tcode name is QS21 to create Master inspection Characteristic, of course you can enter any other tcode that you
want to record, after that click on the “Start Recording” button.
3. Now you will be entering the recording mode to record transaction Qs21, as you can see on the picture below, you will be taken into this specified tcode.
4. Now just create the MIC as usual, because this is not a tutorial on how to create an MIC, then I will skip the creation process. After you’ve done creating the
MIC, you will see this screen below.
BDC is a collection of screens to process the transaction, as you can see there are several screens used to create the MIC. Just double click on the each screen
name to see the screen layout.
5. Don’t forget to click on the “SAVE” button to save the BDC.
6. Now to use the BDC in ABAP, we need to transfer this BDC into an ABAP Program.
7. Execute tcode SHDB again, and locate the BDC we’ve just created. ZR_QS21 and click on the “Program” icon on the tool bar.
8. Now enter the ABAP program name for this BDC, and then choose “Transfer from recording” from the Field Contents block. Click OK or enter to continue.
9. Type in the program title name and click on the “Source Code” button and press enter.
10. Now you can see the BDC code has been successfully transferred into you ABAP program.
Usually you will need to modify the program by adding a code to get the flat file and then convert it into an internal table and then you pass the internal table data
using this BDC program code that will save it into SAP tables
Whenever we generate a negative value, SAP usually will put the negative sign after the value, now there’s a function module called
CLOI_PUT_SIGN_IN_FRONT that could put all the negative sign before or in front of the value.
d_value = d_sum.
Run the program and enter value in p_num2 to be greater than p_num1 so that you can get the negative value, as you can see the result before and after the
function, where the negative sign is now in front of the number.
start-of-selection.
get mdtb.
check field-name
end-of-selection.
• Basically a Logical Database can be used to read the same data for several programs.
• A Logical Database provides a consistent user interface.
• In Logical Database Authorizations are carried out centrally
• Performance is improved
The Logical Database is special type of ABAP program that combines the contents of certain related database tables and retrieve some related data and
make it available to application programs.
In other words, a LDB is a method by which ABAP programs read and process the data. The sequence in which the data is supplied to the program is
determined by a tree structure.
The LDB usually consists of the following components:
• Structure
• Selections
• Database programs
Logical databases have a tree structure.A logical database can contain a maximum of 300 tables.
For example: SAPDBPNP is the name of the database program for the logical database PNP.
How are logical database used:
1.Logical databases when generating an ABAP program
The selection screen generated contains the selections (SELECT-OPTIONS AND PARAMETERS) of both the logical database and
the program.
The only database-specific selections displayed on the selection screen are those needed by the program for data retrieval purposes.
2. Logical databases at run-time of an ABAP program
At run-time, the system processes the events in the program and in the logical database in the following order:
Before displaying the selection screen, certain initializations (e.g. calculating default values such as key date, etc.) are performed for the selection screen
by the logical database and the program. The selection screen is displayed and the user enters data in the input fields.
The logical database and the program check that the input is correct and complete, but also that the user has the appropriate authorizations. If an error
occurs, some fields are made ready for input again, so that the user can make the necessary correction(s).
In the event START-OF-SELECTION, the ABAP program performs any preliminary work (for example, importing files).
The logical database reads the selected data and the program processes it within the GET events according to the sequence specified by the structure.
In the event END-OF-SELECTION, the ABAP program performs any concluding operations (for example, calculating totals, exporting files).
3 . Designing the selection screens
The standard selection screen of a logical database has a standard layout where SELECT-OPTIONS and PARAMETERS appear in the sequence they are
declared, each on a new line. The system automatically generates such a screen for each program that does not have its own selection screen entered in
the attributes. You can define your own selection screens for any logical database . If the attributes of a program include the number of its own selection
screen, the system uses this screen as a model when generating. Any program-specific selections appear after the database selections. The flow logic for
such screens is also generated automatically and therefore cannot be modified. You cannot delete database selections.
Functions of LDB:
Data retrieval :
The personnel data of each employee is loaded into the main memory where it can be accessed for processing.
Screening :
Employees can be selected according to the organizational criteria entered on the selection screen.
E.g…Hourly wage earners in a particular personnel sub area.
There are two types of screening..Person selection and data selection period. Person selection defines those employees for whom a report is to
be run. E.g..Monthly wage earners in a specific personnel sub-area.
E.g..Personnel number range
E.g..Features of org.Assignment…Employees who assigned to certain cost center.
E.g..Employee status..Active or inactive.
The data selection period delimits the time period for which data is evaluated. When you enter the data selection period,the provide loop retrieves
the infotype records whose validity period overlaps with at least one day of this period.
Logical databases for increasing efficiency
Why else would you want to create a logical database? Consider that the logical databases already available to you begin with a root node
and proceed downward from there. If the data object you wish to construct consists of items that are all below the root node, you can use
an existing logical database program to extract the data, then trim away what you don’t want using SELECT statements—or you can
increase the speed of the logical database program considerably by redefining the logical database for your object and starting with a table
down in the chain. Either way, you’ll eliminate a great deal of overhead.
• Table structure: Your logical database includes data from specified tables in SAP. There is a hierarchy among
these tables defined by their foreign keys (all known to SAP), and you are going to define a customized
relationship between select tables. This structure is unique and must be defined and saved.
• Data selection: You may not want or need every item in the referenced tables that contributes to your
customized database. There is a selection screen that permits you to pick and choose.
• Database access programming: Once you’ve defined your logical database, SAP will generate the access
subroutines needed to pull the data in the way you want it pulled.
1. Call up transaction SLDB (or transaction SE36). The path you want is Tools | ABAP Workbench | Development |
Programming Environment | Logical Databases. This screen is called Logical Database Builder.
2. Enter an appropriate name in the logical database name field. You have three options on this screen: Create,
Display, and Change. Choose Create.
3. You’ll be prompted for a short text description of your new logical database. Enter one. You’ll then be prompted
to specify a development class.
4. Now comes the fun part! You must specify a root node, or a parent table, as the basis of your logical database
structure. You can now place subsequent tables under the root table as needed to assemble the data object you
want. You can access this tree from this point forward, to add additional tables, by selecting that root node and
following the path Edit | Node | Create. Once you’ve saved the structure you define in this step, the system will
generate the programming necessary to access your logical database. The best part is you don’t have to write a
single line of code.
What is SAP Query? Purpose and Advantages of SAP Query?
SAP Query is SAP’s tool to define and execute once own reports without knowing ABAP
programming language.
Topic # Topic
1 What is Query?
Purpose of Query.
Advantages of Query
2 Infosets/UserGroups/Query in Detail
3 Practical session covering important working models - I
4 Practical session covering important models-II
Many times a need arises for SAP Users and Functional Consultants to generate quick
reports without getting any ABAP coding done – time taken to complete the coding in
development, transport and test it in QA system and then transport to production – is
sometimes too long. In such cases, SAP query is a tool provided by SAP for generating
these kinds of reports.
Purpose
The SAP Query application is used to create reports not already contained in the default. It has been designed for users with
little or no knowledge of the SAP programming language ABAP.
SAP Query offers users a broad range of ways to define reports and create different types of reports such as basic lists,
statistics, and ranked lists.
These outputs can include lists on screens in table format, ALV grids, downloadable spreadsheets, and downloadable flat files.
The internal report generator creates an ABAP program corresponding to the definition of the list.
Features:
Queries
InfoSet Query
InfoSets
User Groups
Translation/Query
Classic reporting- the creation of lists, statistics and ranked lists- are covered by
theInfoSet Query and Queries components. Other components’ range of functions
cover the maintenance of InfoSets, the administration of user groups and also the
translation of texts created in the SAP Query. All data required by a user for a report
can be read from various tables.
To define a report, you first have to enter individual texts, such as titles, and select the
fields and options, which determine the report layout. In the WYSIWYG (What You
See Is What You Get) mode, you can edit the lists using Drag & Drop and various
toolbars.
Overview:
The following sections describes the individual SAP Query components and provides
general information about query areas, transport and authorizations
Query Components
Define Queries
Change Queries
Infosets Components
InfoSets are special views of data sources.
End-users are able to work only with those InfoSets that are relevant to their
particular area, as designated by the role or user group that they are assigned to.
1. The User Groups component is used to maintain user groups. The system administrator uses it to set up the work environment for end-
users.
2. Every user assigned to the user group is able to execute the query.
3. Users are not allowed to modify queries from other user groups, although they may, under certain circumstances, copy and execute
Translation/Query Component
A great deal of text is generated when defining queries, InfoSets, and user groups.
The SAP Query displays these texts in the language that you chose when you
logged on to the SAP system.
You can compare the text languages using the component Translation/Query.
A related text in one or more additional languages is made available for each of
the texts created when defining the query.
Query Areas
A query area contains a set of query objects (queries, InfoSets, and user groups) that are
discrete and consistent.
Standard area
Global area
Standard Area
1.Client specific
2.Query objects are not attached to the Workbench Organizer
Advantage :-End users can develop queries (ad-hoc reports) in their own client that are
not meant for use in the rest of the system.
Global Area
1.Cross client
Advantage:-The global query area is well suited for centrally developing queries meant
for use and distribution throughout the system.
Authorizations
End-users, system administrators, and translators must all be assigned the appropriate
authorizations allowing them to work with the SAP Query.
In order to give individual users targeted, specific rights, the following options are
available:
Roles/user groups
Authorizations
The following are the tools to manage, create and change queries.
Infoset Query
Queries
Quick viewer
End-users are able to work only with those InfoSets that are relevant to their
particular area, as designated by the role or user group that they are assigned to.
Do you need additional information which is not available in the data source?
(This means you are going to have to connect additional tables and the definitions
of additional fields.)
Do you need parameters and selection criteria? (Parameters and selection criteria
appear on the selection screens of queries that are created using the InfoSet).
Table join using a table: Is used when Query is prepared for retrieving data from
more than one database tables having relationships.
Reading tables directly: Is used when Query is prepared for retrieving data from
one table.
Logical databases: Is used when Query is prepared for retrieving data based on a
Logical database (LDB)
4. Using programs to retrieve data: Here a program can be written with own logic. Declaration in data section of the program will help the
query to select the elements of data to be retrieved from database. As per the logic, data is validated, processed. The selection screen
can be prepared in Query and data is retrieved for output.
Sequential datasets
4. Options
Display/Change Infoset
The InfoSet display allows you to examine or change the structure of the InfoSet.
Extras
Selections
Further Code
Fields must be assigned to a field group before they can be used in queries.
Note:
Logical Database having more than 4 structures has different way of creating field
groups.Eg: PNP
The User Groups component is used to maintain user groups. The system
administrator uses it to set up the work environment for end-users.
Every user assigned to the user group is able to execute the query.
Users are not allowed to modify queries from other user groups, although they
may, under certain circumstances, copy and execute
1.Creating infosets or functional areas
Tcode-SQ02
Continued...
...Previous
2. To create user groups and assign to infosets
Tcode-SQ03
Continued...
...Previous
3. To create a query
Tcode-SQ01
Steps to create selection criteria to the query
Tcode-SQ01
Step-by-step procedure in configuring SAP Query
SAP R/3 Query tools (SAP Query) are based on the following four main components:
• Query Areas
• Query Groups
• InfoSets
• Administrative Decisions (Company-specific)
• Go to Transaction SQ03.
• Ensure that you are in the correct SAP Query area by navigating to
Environment Query Areas
• Now in the main screen, enter the name of the Query Group in the User Group field
and click on
CREATE
• Enter the description of the User Group in the next popup that
appears.
• Enter the SAP User-Ids of all the users you wish to include in the test group.
Click on SAVE to save your entries.
Continued...
Create InfoSets
• Go to transaction SQ02
• Ensure that you are in the correct SAP Query area by navigating to
Environment Query Areas
• Enter the name of the InfoSet you wish to create and click on
CREATE.
• Enter the title and the logical database on the popup screen that
appears.
We have used the LDB F1S (Flight bookings related) for our demo purpose.
• Change InfoSet screen
appears.
• Expand the tree on the left hand side to view the fields in each table. As seen on the
screen, the left side of the screen shows the tables and the fields. The right side
displays the field groups.
• Now we need to assign fields to the field groups. These field groups will display in
the SAP Query tool during reporting. Please note that only the fields that are included
here will be available for field selection in the SAP Query Tool that uses this infoSet
as a data source.
• Select the field group on the right side and then drag and drop the fields from the left
side to this field
group.
•
When all the required fields are added, click on SAVE.
• Go to transaction SQ02
• Enter the InfoSet name created above and click on “User Group Assignment”
button.
• Select the query group “ZSAPTECH_GRP” from the above list and click on SAVE.