Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select with calculation in function module

emrhkls
Explorer
0 Likes
1,326

Hi All!

I have a function module which gathering data from a ztable.

My ztable:

I wanted to populate ZEYCARPAN field as "ZEYTUFE * ZEYGH" when I used SELECT statement.

Is it possible?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,249

Yes, it's possible to do the calculation immediately in the SELECT. See ABAP langauage documentation: SELECT sql_exp

At least on basis NW 7.4 SP08

Example:

SELECT a, b, a * b AS c FROM abc INTO @data(lt_abc).

Your internal table has three fields: a, b and c

5 REPLIES 5
Read only

matt
Active Contributor
0 Likes
1,249

Have you read the ABAP keyword documentation? Does it offer such a possibility?

Read only

Former Member
0 Likes
1,249

If you want to get the ZEYCARPAN value as "ZEYTUFE * ZEYGH" into an INTERNAL table then it is possible BUT you should have SAP_BASIS/SAP_ABA components latest version. I think you should have at least 7.4 version to have this.

-Chandra

Read only

Former Member
0 Likes
1,249

Hi

First you get the data through select statement into first internal table, then send the first internal table data to final internal table.

Finally you can loop there:

Sample Code:

LOOP AT IT_FIRST INTO WA_FIRST.

WA_FINAL-ZEYCARPAN = WA_FIRST-ZEYTUFE * WA_FIRST-ZEYGH.

CLEAR : WA_FIRST.

APPEND WA_FINAL TO IT_FINAL.

ENDLOOP.

Please let me know if my understood is correct.

Thanks,

Divya.

Read only

Former Member
0 Likes
1,250

Yes, it's possible to do the calculation immediately in the SELECT. See ABAP langauage documentation: SELECT sql_exp

At least on basis NW 7.4 SP08

Example:

SELECT a, b, a * b AS c FROM abc INTO @data(lt_abc).

Your internal table has three fields: a, b and c

Read only

0 Likes
1,249

Dear Armin,

Here is my select statement as you suggested and its worked!

SELECT ( zeytufe * zeygh ) AS zeycarpan FROM zhrp008 INTO @wa_data.

By the way, the operator / is not allowed in integer expressions.

Thank you for your help.

Have a nice day!