cancel
Showing results for 
Search instead for 
Did you mean: 

SQ REPORTS

Former Member
0 Kudos

Hi all,

I'm trying to create a new field that will be calculated sum totals from table FMIOI .

please find attached script:

clear : sum_order .

select sum(fkktr)

from fmioi into sum_order

where

  WRTTP = '83' .

i'm getting null's .

thanks from advance.

Roy

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member186998
Contributor
0 Kudos

Hi Roy,

Can you try the following SQL statement?

For example----------

select sum(fkktr)

into table sum_order

from fmioi

where WRTTP = '83'

---------------------


SELECT statement

http://dcx.sap.com/index.html#sqla170/en/html/3be640936c5f10149013d54460eaabb0.html


INTO clause

Following are the three uses of the INTO clause:


INTO hostvar-list clause

This clause is used in Embedded SQL only. It specifies where the results of the SELECT statement go. There must be one host variable item for each item in the select-list. select-list items are put into the host variables in order. An indicator host variable is also allowed with each host variable, so the program can tell if the select-list item was NULL.

If the query results in no rows being selected, the variables are not updated, and a row not found warning appears.


INTO variable-list clause

This clause is used in procedures and triggers only. It specifies where the results of the SELECT statement go. There must be one variable for each item in the select-list. select-list items are put into the variables in order.


INTO table-name clause

This clause is used to create a table and fill it with data.

For tables to be created, the query must satisfy one of the following conditions:

  -The table-name is a temporary table name or is specified as owner.table-name.

  -The select-list contains a * ore more than one item.

To create a permanent table with one column, the table name must be specified as owner.table.

This statement causes a COMMIT before execution as a side effect of creating the table. No privileges are granted on the new table: the statement is a short form for CREATE TABLE followed by INSERT...SELECT.

Tables created using this clause do not have a primary key defined. You can add a primary key using ALTER TABLE. A primary key should be added before applying any updates or deletes to the table; otherwise, these operations result in all column values being logged in the transaction log for the affected rows.


INTO LOCAL TEMPORARY TABLE

This clause is used to create a local, temporary table and populate it with the results of the query. When you use this clause, it is not necessary to start the temporary table name with #.


INTO TABLE table-name

This clause always creates a table and populates it with the results of the query. The INTO TABLE clause behaves the same way as the INTO table-name clause, with the exception that the query does not need to satisfy the select-list conditions of the INTO table-name clause.


INTO VARIABLE variable-list

This clause specifies where the results of the SELECT statement go. The values returned by the query are assigned to the fields of the row variable in order.

If there is a single item in the INTO clause and multiple items in the select-list, then the single item is interpreted as a row variable and the returned column values are assigned to the fields of the row variable in order. If the INTO clause contains more than one item, then the INTO variable-list semantics are applied.


Thanks,

Atsushi

Former Member
0 Kudos

Hi,

I have tried it and the result was duplicated and each record got the same result.

my result should be that each fund center would get his sum of "83".

I wrote the abap code in  record processing .

maybe I should add group by?

Thanks

Roy

former_member186998
Contributor
0 Kudos

Hi,


>maybe I should add group by?
Yes.

Thanks,

Atsushi

Former Member
0 Kudos

Hi Roy,

is it FKBTR (not FKKTR) you are talking about? If so, Please do take care of the fact that it is a CURRENCY field.. so sum_order should be declared of appropriate abap datatype.

Data Types in the ABAP Dictionary - ABAP Programming (BC-ABA) - SAP Library

Hope this solves your issue.

Regards.

Former Member
0 Kudos

Hi,

in the extra command I have had the field sum_order like fmioi-fkbtr .

and still , it doesn't work

Roy