Skip to Content

ABAP: Any new syntax for 'AT END OF' functionality in ABAP 7.4

Hello ABAPers,

I am new for ABAP7.4 syntax, but I want to sum up tslvt field as per racct ,prctr,rmvct,rfarea,rassc. Below logic working correctly, but look old. Can someone help me, how can convert below logic with new ABAP 7.4 syntax.

SELECT ryear rmvct rldnr racct rbukrs prctr rfarea rassc tslvt
FROM faglflext
INTO CORRESPONDING FIELDS OF TABLE mt_fagleflext
WHERE rldnr EQ mv_rldnr "Fiscal year
AND ryear IN mt_gjahr "Ledger Accounting
AND rbukrs IN mt_bukrs. "Companycode
IF sy-subrc = 0.
SORT mt_fagleflext BY racct prctr rmvct rfarea rassc.
DELETE mt_fagleflext WHERE prctr EQ space.
* Summing up the balancing carry forward amount on the basis account, profit center, Transaction type, Functional Area, Trading partner
CLEAR: ls_fagleflext.
LOOP AT mt_fagleflext INTO ls_fagleflext.
lv_gjahr = ls_fagleflext-ryear. lv_rmvct = ls_fagleflext-rmvct. lv_rldnr = ls_fagleflext-rldnr.
lv_bukrs = ls_fagleflext-rbukrs.lv_rfarea = ls_fagleflext-rfarea. lv_rassc = ls_fagleflext-rassc.
lv_tslvt = lv_tslvt + ls_fagleflext-tslvt.
AT END OF rassc.
ls_fagleaccount-racct = ls_fagleflext-racct. ls_fagleaccount-prctr = ls_fagleflext-prctr.
ls_fagleaccount-ryear = lv_gjahr. ls_fagleaccount-rmvct = lv_rmvct.
ls_fagleaccount-rldnr = lv_rldnr. ls_fagleaccount-rbukrs = lv_bukrs.
ls_fagleaccount-rfarea = lv_rfarea. ls_fagleaccount-rassc = lv_rassc.
ls_fagleaccount-tslvt = lv_tslvt.
APPEND ls_fagleaccount TO mt_fagle_account.
CLEAR: lv_tslvt, ls_fagleaccount, lv_gjahr, lv_rmvct, lv_rldnr, lv_bukrs, lv_rfarea, lv_rassc.
ENDAT.
ENDLOOP.

Regards,

Himansu Gyala

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 27, 2019 at 01:12 PM

    Something like (approximately) :

    mt_fagle_account = VALUE #( FOR GROUPS <group_fagleflext> OF <ls_fagleflext> IN mt_fagleflext
                       GROUP BY ( racct  = <ls_facleflext>-racct
                                  prctr  = <ls_facleflext>-prctr
                                  rmvct  = <ls_facleflext>-rmvct
                                  rfarea = <ls_facleflext>-rfarea
                                  rassc  = <ls_facleflext>-rassc )
                       ( racct  = <group_fagleflext>-racct
                         prctr  = <group_fagleflext>-prctr
                         rmvct  = <group_fagleflext>-rmvct
                         rfarea = <group_fagleflext>-rfarea
                         rassc  = <group_fagleflext>-rassc 
                         tslvt  = REDUCE #( INIT sum_tslvt TYPE tslvt FOR <ls_fagleflext2> IN GROUP <group_fagleflext> 
                                            NEXT sum_tslvt = sum_tslvt + <ls_fagleflext2>-tslvt ) ) ).
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.