2022 Jun 01 3:11 PM
2022 Jun 01 3:11 PM
Thank you for visiting SAP Community to get answers to your questions.
Since you're asking a question here for the first time, I'd like to recommend you with the following steps so you can get the most out of your community membership:
I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.
I hope you find this advice useful, and we're happy to have you as part of SAP Community!
All the best,2022 Jun 02 7:59 AM
Hi bsarcia19,
One solution might be:
SUM( bsis~dmbtr ) + SUM( bsas~dmbtr ) AS total_amount
Best regards,
Lena
2022 Jun 13 1:00 AM
2022 Jun 02 11:15 AM
Hi,
Refer if this simple example may help you.
Data : LV_AMT1 type DMBTR.<br>
SELECT A~belnr as a_belnr ,
B~belnr as b_belnr ,
A~gjahr as a_yr ,
B~gjahr as b_yr ,
A~dmbtr as a_amt ,
B~dmbtr as b_amt
INTO TABLE @DATA(IT_BS)
FROM BSIS AS A
INNER JOIN BSAS AS B ON A~BELNR = B~BELNR AND A~GJAHR = B~GJAHR.
LOOP AT IT_BS ASSIGNING FIELD-SYMBOL(<LFS_BS>).
IF <LFS_BS>-A_BELNR = <LFS_BS>-B_BELNR AND <LFS_BS>-A_YR = <LFS_BS>-B_YR .
LV_AMT1 = LV_AMT1 + <LFS_BS>-A_AMT + <LFS_BS>-B_AMT.
ENDIF.
ENDLOOP.
Write : LV_AMT1.
2022 Jun 13 1:01 AM
2022 Jun 02 12:58 PM
Hi,
types:
begin of ty_bsis,
bukrs type bukrs,
dmbtr type dmbtr,
END OF ty_bsis.
data:
it_bsis type table of ty_bsis,
wa_bsis type ty_bsis.
select
a~bukrs,
sum( a~dmbtr ) + sum( b~dmbtr ) as total
from bsis_view as a
INNER JOIN bsas_view as b
on a~bukrs = b~bukrs
group by a~bukrs
into table @it_bsis.
if sy-subrc eq 0.
loop at it_bsis into wa_bsis.
write:/ wa_bsis-bukrs,
wa_bsis-dmbtr.
ENDLOOP.
ENDIF.
Regards,
Anuja Kawadiwale
2022 Jun 13 1:01 AM
2022 Jun 13 3:56 AM
Hope this helps you.
DATA : LV_TOTAL TYPE DMBTR,
LV_A LIKE LV_TOTAL,
LV_B LIKE LV_TOTAL.
SELECT A~BUKRS AS BUKRS,
A~DMBTR AS A_AMT,
B~DMBTR AS B_AMT
FROM BSIS AS A
INNER JOIN BSAS AS B ON A~BUKRS = B~BUKRS AND
A~HKONT = B~HKONT AND
A~AUGDT = B~AUGDT AND
A~ZUONR = B~ZUONR AND
A~BELNR = B~BELNR AND
A~GJAHR = B~GJAHR AND
A~BUZEI = B~BUZEI
INTO TABLE @DATA(IT_AB).
SORT IT_AB BY BUKRS ASCENDING.
LOOP AT IT_AB INTO DATA(WA_AB).
LV_A = LV_A + WA_AB-A_AMT.
LV_B = LV_B + WA_AB-B_AMT.
AT END OF BUKRS.
LV_TOTAL = LV_A + LV_B.
WRITE / LV_TOTAL.
CLEAR: LV_A, LV_B, LV_TOTAL.
ENDAT.
CLEAR: WA_AB.
ENDLOOP.
2022 Jun 16 3:42 PM
You could look at the UNION option of the SELECT statement in the latest versions.
Otherwise, be careful with the cardinality of a JOIN between BSIS and BSAS, if several items are cleared or not in the same document, or if there are only cleared, resp. non cleared, items...