Skip to content

Instantly share code, notes, and snippets.

@EkremGungormez
Created May 19, 2013 11:54
Show Gist options
  • Save EkremGungormez/5607453 to your computer and use it in GitHub Desktop.
Save EkremGungormez/5607453 to your computer and use it in GitHub Desktop.
tables: mara.
data : lt_mara type table of mara,
ls_mara type mara,
lt_mard type table of mard..
select-options : s_matnr for mara-matnr.
Select * from mara into table lt_mara
where matnr in s_matnr.
** this will not work.
select sum(labst) matnr werks lgort from mard
into corresponding fields of table lt_mard
for all entries lt_mara
where matnr = lt_mara-matnr
and werks = '0000' "it is up to your selection criterias
and lgort = 'abdc'."it is up to your selection criterias
***
** if you get your materials to a range table and than you can use sum statement.
DATA: gr_matnr type range of matnr,
gs_matnr like line of gr_matnr.
gs_matnr-sign = 'I'.
gs_matnr-option = 'EQ'.
loop at lt_mara into ls_mara.
gs_matnr-low = ls_mara-matnr.
append gs_matnr to gr_matnr.
endloop.
** now we have our materials in our range table
sort gr_matnr by low.
delete adjacent duplicates from gr_matnr.
select sum(labst) matnr werks lgort from mard
into corresponding fields of table lt_mard
* for all entries lt_mara we dont use for all entries here we use our range table
where matnr IN gr_matnr
and werks = '0000' "it is up to your selection criterias
and lgort = 'abdc'."it is up to your selection criterias
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment