Skip to Content
avatar image
Former Member

another problem about select..sum..

HI,

I'm back, and there is another select ..sum problem.

the following code:

SELECT aufnr SUM( wrbtr ) AS jfje FROM bsis
 into CORRESPONDING FIELDS OF TABLE it_syye
 WHERE bukrs = '1500'
 AND   aufnr = it_num-aufnr
 AND   budat >= '20040131'
 AND   budat <= q_date2
 AND   hkont = '0041010013'
 AND   shkzg = 'S'
 GROUP by aufnr.

SELECT aufnr SUM( wrbtr ) AS dfje FROM bsis
 into  CORRESPONDING FIELDS OF TABLE it_syye1
 WHERE bukrs = '1500'
 AND   aufnr = it_num-aufnr
 AND   budat >= '20040131'
 AND   budat <= q_date2
 AND   hkont = '0041010013'
 AND   shkzg = 'H'
 GROUP by aufnr.

I want to select the credit amount and debit amount from the table BSIS,but using the select sum , it looks like the field SHKZG doesn't work.

It select all the amount no matter what the SHKZG is 'S' or 'H'.

Could anyone explain that ,and give a good solution?

Thank you very much.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 09, 2008 at 06:32 AM

    Hi Bill,

    You wanna say that u give any of the 3 condition i.e.

    SHKZG = 'H'.

    SHKZG = 'S'.

    SHKZG = ' '.

    Its gives the same result???

    Regards,

    Surinder

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Bill,

      There might be the case the value of debit and credit are same so it is showing the same output. You can try the below code

      SELECT aufnr SUM( wrbtr ) AS jfje FROM bsis

      into CORRESPONDING FIELDS OF TABLE it_syye

      WHERE bukrs = '1500'

      AND aufnr = it_num-aufnr

      AND budat >= '20040131'

      AND budat <= q_date2

      AND hkont = '0041010013'

      AND ( shkzg = 'S' or shkzg = 'H' )

      GROUP by aufnr.

      If the result now generated is different then that solves your query.

      Regards,

      Surinder

  • Oct 09, 2008 at 06:26 AM

    strange... as a workaround can you try to replace SHKZG with BSCHL (posting key)

    shkzg = 'S' ==> bschl = '40'

    shkzg = 'H' ==> bschl = '50'

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 21, 2009 at 01:13 AM

    Hi Bill Gu,

    I think you cannot use " INTO CORRESPODING FIELDS" with SELECT SUM ( ) statement.

    Thanks & regards,

    Sunny.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 21, 2009 at 01:58 AM

    Hi Bill,

    The answer is very simple... both amounts must be the same alway, if you get any difference you have to check. That's a financial concept, Debit less Credit must be zero. Remember that table BSIS have G/L open items, if you check any document on BSIS all of them have the same amount in credit and debit.

    I hope is helps.

    Dimas B. Salazar P.

    ABAP Consultant

    Caracas - Venezuela

    Add comment
    10|10000 characters needed characters exceeded