cancel
Showing results for 
Search instead for 
Did you mean: 

How to add calcuated field in the Query

Former Member
0 Kudos

Hi

Can anyone guide me the process to add addtional field say "rate" in the query (sq01) where i am having "Qty" & "Total Amount" fields available from the standard table.

Rate = Total Amount / Qty

Thanks in advance

Tejpal

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tejpal,

In SQ01

- Open your query for change

- Select the field groups that contain the data items you need to use to create your new data item. Move to the field display page.

- Once you have the field names displayed on the screen, Edit>Short Names>Switch on.

- Now, find each data item you will need to use to create your new data item. In the short name field create a new 'nickname' for each of these eg 'TOTAMT' and 'QTY' to represent total amount & quantity

- Now, Edit>local field>create.

- short name=the name of your new field, eg 'RATE' & Field desc= description of yr new field

- Heading=how it will be displayed in the header of your output report

- Select Calculation field

- Define number of digits and decimal places

- In the Calculation formula, use the 'nicknames' you previously defined to create your calculation. Simple arithmetic functions are supported, eg 'TOTAMT / QTY' would be the formula

Hope the above answers your query.

Regards,

Vivek

Former Member
0 Kudos

Hi Vivek,

I have a similar requirement wherein I have been able to capture Gross Amount and Tax in the query output. Now I need to have new column which would be a total(addition) of Gross amount and Tax amount. I have created this query in SQVI. Is it possible to have this ?

Thanks for your help.

Rgds

Former Member
0 Kudos

Hi,

In SQVI, there is no option to add a custom field like in SQ01. So maybe if you want the same feature, create a query in SQ01 or select the SQVI query, click on SAP query & convert the same & then you can add a field.

Regards,

Vivek

Former Member
0 Kudos

Dear Vivek

i had done all the steps but output is following runtime error due to new local field (without this field it works fine.)

-


Error analysis |

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_ARITHMETIC_OVERFLOW', was not

caught in

procedure "/1BCDWB/IQT000000000030EXTR" "(FUNCTION)", nor was it propagated by

a RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

An overflow was discovered in an ongoing arithmetical operation with

operands of type P. Possible causes are:

1. The result field of type P is too small for the result.

2. The result or a intermediate result has more than 31 decimal places.

-


Also when i add qty=1 in the CONDITION ( below the CALCULATION FORMULA) in the Field defination as per your last point. it works fine & gives the rate values for the qty=1 only

Further if i put qty >1 or Amt>1 or both it gives the above error.

Regards

Tejpal Singh

Former Member
0 Kudos

Hi Friends

Any Suggesstions ??

Regards

Tejpal

Former Member
0 Kudos

Hi Tejpal,

Can you let me know the values your passing for the numerator & that for the denominator. Also how have yu defined this field?

I suspect the overflow is happening because of the field declaration & the values being passed to them.

Await your inputs.

Regards,

Vivek