Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

simple QA

Former Member
0 Likes
562

data : z_cnt like s033-magbb,

z_cnt_mz like s033-mzubb,

z_sum like s033-mzubb.

LOOP AT imard ASSIGNING <ls_mard>.

clear z_cnt.

clear z_cnt_mz.

clear z_sum.

LOOP AT is033 ASSIGNING <ls_s033>

WHERE matnr = <ls_mard>-matnr

AND lgort = <ls_mard>-lgort.

z_cnt = z_cnt + <ls_s033>-magbb .

z_cnt_mz = z_cnt_mz + <ls_s033>-mzubb.

z_sum = z_cnt - z_cnt_mz.

is033_b = <ls_s033>.

is033_b-zlbkum = <ls_mard>-e_stock + z_sum.

APPEND is033_b.

ENDLOOP.

SORT is033_b BY sptag matnr lgort.

<b>****i need to update min max for matnr per lgort in imard

****i need to update avrage num lines + 2</b> ENDLOOP.

1 REPLY 1
Read only

Manohar2u
Active Contributor
0 Likes
456

To update min max for matnr per lgort in imard

Assume that is033_b table has all the totals per matnr and lgort, then

Loop at imard.

Based on the unique records you can use AT NEW control statement here.

AT NEW of matnr or lgort. 
sort is033_b by zlbkum lgort matnr ascending.

read table is033_b with key matner = imard-matnr
                            lgort  = imard-lgort.
if sy-subrc = 0
i_mard-min = is033_b-zlbkum.
endif.

sort is033_b by zlbkum lgort matnr descending.
read table is033_b with key matner = imard-matnr
                            lgort  = imard-lgort.
if sy-subrc = 0
i_mard-max = is033_b-zlbkum.
endif.

modify imard index sy-tabix.

endat.
endloop.

Regds

Manohar