Skip to Content
-1
4 days ago

I want last record from each asset from multiple asset internal table

33 Views Last edit 4 days ago 2 rev

I want last record from each asset from multiple asset internal table

LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<fs_data>) ." WHERE anln1 = s_asset.

gw_data-bukrs = <fs_data>-bukrs.
gw_data-anln1 = <fs_data>-anln1.
gw_data-zujhr = <fs_data>-zujhr.
gw_data-txt50 = <fs_data>-txt50.
gw_data-zugdt = <fs_data>-zugdt.
gw_data-gjahr = <fs_data>-gjahr.
gw_data-afabe = <fs_data>-afabe.
gw_data-kansw = <fs_data>-kansw.
gw_data-nafag = <fs_data>-nafag.
gw_data-nafap = <fs_data>-nafap.
gw_data-answl = <fs_data>-answl.
* IF gw_data-wr_d_v EQ 0.
* gw_data-wr_d_v = gw_data-kansw + gw_data-nafag.

IF '1' <= s_dd AND s_dd <= '15'.
IF sy-tabix = 1.
"IF '20210801' <= s_date AND s_date <= '20210815'.
* IF '1' <= s_dd AND s_dd <= '15'.

IF gw_data-zujhr EQ gw_data-gjahr.
gw_data-wr_d_v = gw_data-answl + gw_data-nafag.

total_nafag = total_nafag + gw_data-nafag .
gw_data-total_nafag = total_nafag.
ELSEIF gw_data-zujhr NE gw_data-gjahr.
gw_data-wr_d_v = gw_data-wr_d_v + gw_data-nafag.
total_nafag = total_nafag + gw_data-nafag .
gw_data-total_nafag = total_nafag.
ENDIF.
ELSE.
gw_data-wr_d_v = x_wr_d_v + gw_data-nafag.
total_nafag = total_nafag + gw_data-nafag .
gw_data-total_nafag = total_nafag.

ENDIF.

READ TABLE lt_data INTO lw_data WITH KEY anln1 = <fs_data>-anln1.
"ENDIF.

IF sy-subrc = 0.
gw_data-anln1 = lw_data-anln1.
ENDIF.

APPEND gw_data TO gt_data.
CLEAR:gw_data.