Things to Remember

Things to Remember

  • You can prepare fixed-width positional text files, often known as extracts, by using the SAP Query tool.

  • Before creating any extracts, you need to be sure that you have a formal spec to work against.

  • You should always change the format and column width on the Title Format screen when creating extract files.

  • You can never change the width of a currency, date, or time field.

  • Microsoft Notepad is a good tool to use when checking to make sure you have properly created positional extract files.

Chapter 9. Creating Basic Calculated Fields with the SAP Query Tool

In this chapter

  • Creating a Basic SAP Query for This Chapter 120

  • Using a Simple Mathematical Formula to Create a Basic Calculated Field 121

  • Using a Simple Condition to Create a Basic Calculated Field 126

  • Using an Input Value to Create a Basic Calculated Field 129

In earlier chapters, you used the SAP Query tool to create reports. This chapter teaches you how to create basic calculated fields within those reports by using the SAP Query tool. A regular end user can perform the calculations explained in this chapter by using the SAP Query tool; no special ABAP training or security provisions are required.

As discussed in earlier chapters, you can use the SAP Query tool to create robust reports of your SAP data from any application module within SAP R/3. In addition to creating detailed reports, there may be times when you want to perform calculations on your data. A popular method many users use is to take advantage of the built-in integration with the Microsoft applications. A user can download a SAP R/3 report into Microsoft Excel and perform the calculations there, using Excel's easy-to-use formula tool. However, a more efficient and easy-to-learn method of performing calculations in reports is to use the SAP Query tool to do basic calculations.

The following are examples of calculations you might want to perform by using the SAP Query tool:

  • HR/payroll You could analyze how much it would cost for an employee on the third shift to work on a holiday by calculating the cost of increasing the hourly rate from straight time to time and a half.

  • Finance You could subtract the invoice date from the current date to determine the number of days that payment is past due.

  • Logistics You could subtract the inventory item count from the on-order item count to assist with determining restocking order amounts.

You can use calculated fields to perform if...then statements. For example, you might want to say that if the order value is greater than $100.00, enter the value $0.00 in the Shipping Cost column. You could also use a field that inserts a fixed value, such as the current date, in a column of your report output.

The ability to perform calculations on SAP data is a remarkable function because it means you are no longer required to extract your data into a third-party application such as Microsoft Excel to perform the calculations. In this chapter you will learn how to create a very basic mathematical calculation within an SAP query. You will also learn how to perform calculations when certain conditions are met (for example, "If X = 100, then multiply Y by 29"). Finally, this chapter shows you how to create a field for output based on real-time, dynamically decided input.

Creating a Basic SAP Query for This Chapter

For the examples in this chapter, you need to follow along in your own SAP system. To do so, you need to create a basic SAP query, using the instructions outlined in Chapter 3, "Creating Basic Reports with the SAP Query Tool," that contains the fields shown in Table 9.1. For my example, I named my report DLS_QUERY_09, where DLS is my initials.

Table 9.1. Sample SAP Query IDES Report for Use in Chapter 9 Exercises

Field Name



Airline carrier ID



Departure time



Arrival time






Flight class



Text:Flight class



Figure 9.1 shows an example of the report output of this report.

Figure 9.1. Your report output may vary from what is shown here based on your system's data.

When your SAP query is completed and your report output appears in the same format as the example shown in Figure 9.1, you are ready to insert a basic mathematical formula into the report.