Application Development 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: 

Select - SUM - inner join

Former Member
0 Kudos

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

Former Member
0 Kudos

Please help...

7 REPLIES 7

kesavadas_thekkillath
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

Please help...

0 Kudos

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

Former Member
0 Kudos

zero value in it_test.

0 Kudos

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

Former Member
0 Kudos

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