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 - SUM - inner join

Former Member
0 Likes
6,755

Hi,

select sum( a~dmbtr )

into o_debit

from bsik as A inner join FAGLFLEXA as B

on abukrs = bRBUKRS

and agjahr = bRYEAR

and abelnr = bdocnr

where a~bukrs = x_bukrs

and a~lifnr = p_lifnr

and a~shkzg = 'S'

and a~budat in s_budat

and a~hkont gt '0000000000'

and a~hkont le '9999999999'

and b~prctr = p_prctr.

Above query is not giving result in o_debit though data is available in both the table. Please guide me, if I have written something wrong.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,969

Please help...

7 REPLIES 7
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,969

Check your where clause values whether it matches the table values.. i thin something may be wrong with the values in where clause

Read only

Former Member
0 Likes
2,969

Where caluse values are correct. My problem is with Select Statement. Without inner join it is providing me the value. Can I use SUM() functionality with inner join.

Read only

Former Member
0 Likes
2,970

Please help...

Read only

0 Likes
2,969

Hi, Raj.

Test the following Sample It is working fine for me hope will work for you too, I did some little change.

TYPES: BEGIN OF ty_test,
  dmbtr LIKE bsik-dmbtr,
  END OF ty_test.
DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.

SELECT SUM( a~dmbtr ) as dmbtr
INTO CORRESPONDING FIELDS OF TABLE it_test
FROM bsik AS a INNER JOIN faglflexa AS b ON ( a~bukrs = b~rbukrs AND a~gjahr = b~ryear AND a~belnr = b~docnr )
WHERE a~bukrs = x_bukrs
AND a~lifnr = p_lifnr
AND a~shkzg = 'S'
AND a~budat IN s_budat
AND a~hkont GT '0000000000'
AND a~hkont LE '9999999999'
AND b~prctr = p_prctr.

Please Reply if still any Issue,

Best Regards,

Faisal

Read only

Former Member
0 Likes
2,969

zero value in it_test.

Read only

0 Likes
2,969

Hi, Raj

Please Remove the Where Conditions and try again i think data is not available according to your conditions.

Only use the following line of Code with out where conditions.

TYPES: BEGIN OF ty_test,
  dmbtr LIKE bsik-dmbtr,
  END OF ty_test.
DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
 
SELECT SUM( a~dmbtr ) as dmbtr
INTO CORRESPONDING FIELDS OF TABLE it_test
FROM bsik AS a INNER JOIN faglflexa AS b ON ( a~bukrs = b~rbukrs AND a~gjahr = b~ryear AND a~belnr = b~docnr ).

Please Reply Back if any problem,

Best Regards,

Faisal

Read only

Former Member
0 Likes
2,969

Thanks Faisel, The query is working perfectly. Thanks for helping me.