SAP Query Key figure signs

SAP Query key figure signs

SAP stores all the SD key figures (net value, weight, volume, cost) in the data base as absolute values. In my billing query I had an invoice of 100 and a credit note of 100. Both with positive signs. In the query their sum was 200. Obviously I need to do something.

In the accounting document there is a special field(SHKZG) that indicates whether it is as  debit or credit posting. Is there something similar in billing document?

In the billing header table (VBRK) there are no fields that uniquely determine the sign. Only the Billing Type (VBRK-FKART) and Document Category (VBRK-VBTYP) could be used for this purpose. Disadvantage is that you need to know, which types are used and which of them produce negative values.

In tSAP Query billing: SHKZhe item table (VBRP) there is are promising field VBRP-SHKZG with somewhat strange name ‘Returns Item’. In accounting document the field  SHKZG indicates debit and credit. A closer look at VBRP reveals that field SHKZG does  identify the sign also in sales documents. Value X indicates  that the value is negative. Multiplication with -1 corrects the sign in the report.

As I was unsure of the alternative values (A,B,X) I used QuickViewer to check the values in IDES and a couple of productive ECC systems. Billing types RE, G2, S1 all had value X in this field.

Local Field solution

First I tried to solve the sign problem at query level using Local fields. The formulas for both Billing type (VBRK-FKART) and Returns Item (VBRP-SHKZG) worked fine. The shortage of Local field solution is the need to define them separately in every query.

Additional Field solution

The ideal solution would be to include the definition in the InfoSet, but it requires coding. In Stephan Kaleske’s excellent book ‘SAP Query Reporting’ I learned how this is done using field SHKZG. I am borrowing the code  in my query.

You can check the result in the picture above.

Below you find two documents that describe both solutions.

 


 SAP Query VBRK_VBRP: Determine Key Figure signs using Local fields 

 SAP Query VBRK_VBRP: Determine Key Figure signs using Additional Fields


SAP Query: additional fields (Month, Year)

SAP Query: additional fields (posting period, fiscal year)

Accounting asks you to add month (posting period) and year (fiscal year) to the billing query. You find both fields in the billing header table VBRK.  The bad thing is that both Posting period (POPER) and Fiscal year (GJAHR) are empty. What to do? You can add these fields to the query using SAP Query: additional fields functionality.

Invoice date is the only date in the query . To get the figures for a certain month or year, you must enter a date intervall in the report selection. Totals or subtotals by period are no possible. The period  is not a  possible selection criteria, either.

Is it possible to derive the period from the billing date? SAP Query: additional fields solves the problem. In the example below we add two additional fields (month and year) to the query. The values for these fields come from the invoice date VBRP-FKDAT, which is in the database in format YYYMMDD. The first four characters (YYYY) define the year and the next two (MM) the month. With a small code snippet these can be added to the infoset.


Additional fields (posting period and fiscal year) <HTML>


SAP Query Output Format

SAP Query: Output Format

SAP Query: Output Format defines the look and formatting of a finished SAP Query report.  The output format is selected on the report’s selection screen.  Output format ABAP list is defaulted.

SAP List Viewer

The output format ‘SAP List Viewer’, which uses the ALV functionality, frees you from the choices of the Basic List (order, sort, total).

ALV functions allow you to order the columns, sort, filter and summarize  their contents. You can save and choose between several layouts.

Saved Lists

Running queries can be very time and resource consuming. You consider running them in background. The result is disappointing. You can no longer edit or drill down. Even the output format ‘Spreadsheet’ turns into plain Abap List.

The best solution is to run the query in background with the option “Save with ID” option. This saves the output as a ‘Saved list’. You can later access these from the query screen (SQ00/Sq01) menu Goto/Saved lists.

If the query has been assigned to an Area menu, it has a transaction code. You can start ‘Saved list’ from there, too.

Below an example of a query transaction added to the user’s favorites.

SAP Query: output format - saved lists

Right click the transaction and a menu, where ‘Saved Lists’ is an option, opens.

 

Read more about query output formats.

SAP Query Output Options <HTML>