recalculate remaining sdorder quantity

SAP R/3 Vertrieb: Auftragsverwaltung, Versand und Transport, Fakturierung, Kreditmanagement, Außenhandel/Zoll...
2 Beiträge • Seite 1 von 1
2 Beiträge Seite 1 von 1

recalculate remaining sdorder quantity

Beitrag von chrisumisu (ForumUser / 1 / 0 / 0 ) »
Hi everyone,
has anyone an idea how i can realize following situation:

i have to calculate the remaing sd-orders quantity.
for example an internal table like this:

just one single line, when vbeln & posnr are the same, but more than one vbbe-slno entry
sdorder.png

thanks for any suggestions!


Re: recalculate remaining sdorder quantity

Beitrag von Lukas Sanders (ForumUser / 33 / 6 / 18 ) »
Hi,

you could use the LOOP AT... GROUP BY statement. First group the datasets by VBELN and POSNR, then within those groups calculate the sum and add it to another internal table.

Code: Alles auswählen.

DATA: lt_input TYPE ..., 
      ...,
      lt_output TYPE ..., 
      lv_omeng TYPE vbbe-omeng.

" get data ... 

" groups by VBELNR
LOOP AT lt_input ASSIGNING FIELD-SYMBOL(<fs_vbel>) GROUP BY <fs_vbel>-vbelnr ASCENDING.

  "group by POSNR 
  LOOP AT GROUP <fs_vbel> ASSIGNING FIELD-SYMBOL(<fs_pos>) GROUP BY <fs_pos>-posnr ASCENDING.
     
    CLEAR lv_omeng. 

    " add up value of OMENG within group 
    LOOP AT GROUP <fs_pos> ASSIGNING FIELD-SYMBOL(<fs_sl>).
      ADD <fs_sl>-omeng TO lv_omeng. 
    ENDLOOP.

    " append aggregated structure to output table 
    APPEND VALUE #( vbeln = <fs_sl>-vbeln posnr = <fs_sl>-posnr slno = 1 omeng = lv_omeng ) TO lt_output.

  ENDLOOP. 

ENDLOOP.

" do something... 

There are some good examples here: https://codezentrale.de/abap-gruppierun ... up-member/

It might also work with the COLLECT statement. This requires an internal table with VBELN and POSNR as key and would also add SLNO as it adds all numeric non-value fields together.

Code: Alles auswählen.

DATA: lt_output TYPE HASHED TABLE OF ... WITH UNIQUE KEY vbelnr posnr,
      .... 

" get data ...

LOOP AT lt_input INTO ls_input. 
  " new line for each key pair, sums for SLNO and OMENG 
  COLLECT ls_input INTO lt_output. 
ENDLOOP.

" correct the SLNO value 
LOOP AT lt_output ASSIGNING FIELD-SYMBOL(<fs_output>). 
  <fs_output>-slno = 1.
ENDLOOP.

" do something ...

Seite 1 von 1

Über diesen Beitrag



ABAP & SAP eBook Flatrate von Espresso Tutorials Sponsorlink
Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Aktuelle Forenbeiträge

Nacharbeiten SAP Systemkopie
vor 18 Minuten von L0w-RiDer 1 / 2
Set Cursor on ALV GRID - CL_GUI_ALV_GRID
vor 17 Stunden von AlexVienna gelöst 11 / 96
Dynamische WHERE-Klausel bei LOOP
vor 22 Stunden von DeathAndPain 4 / 174

Vergleichbare Themen

SAP Query: IR quantity
von RR » 07.07.2008 22:04
Formatierte Ausgabe von QUANTITY und UNIT
von a-dead-trousers » 22.01.2019 10:55