SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Finding depending and independent requirements for materials



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Oct 08, 2007 5:07 pm    Post subject: Finding depending and independent requirements for materials Reply with quote

I've got the code here for finding the depending and independent requirements PLUS stock for materials.

Code:
*****
select mara~matnr mara~mtart mara~matkl mara~meins
marc~werks
makt~maktx
into corresponding fields of table it_list
from ( ( mara inner join marc
on mara~matnr eq marc~matnr )
inner join makt
on mara~matnr eq makt~matnr )
where mara~matnr in s_matnr
and mara~mtart in s_mtart
and mara~matkl in s_matkl
and marc~werks in s_werks
and makt~spras eq sy-langu.

loop at it_list into wa_list.
*get dependent requirements
select matnr werks sum( bdmng )
* into (wa_list-matnr, wa_list-werks, wa_list-bdmng)
appending table it_mdrs
from mdrs
where matnr eq wa_list-matnr
and werks eq wa_list-werks
and bdart = 'SB'
and xloek ne 'X' "item not deleted
and bdter between p_from and p_to
"requirements date
group by matnr werks.
endif.
endloop.

loop at it_list into wa_list.
*get planned independent requirements
select matnr werks sum( plnmg )
* into (wa_list-matnr, wa_list-werks, wa_list-bdmng)
appending table it_mdpb
from mdpb
where matnr eq wa_list-matnr
and werks eq wa_list-werks
and vervs = 'X' "active for MRP planning
and pdatu between p_from and p_to
"order delivery date
group by matnr werks.
endif.
endloop.

*for each material, get the stock level
loop at it_list into wa_list.
*get description
* MOVE wa_list-matnr TO wa_makt-matnr.
* READ TABLE it_makt INTO wa_makt FROM wa_makt.
* IF sy-subrc EQ 0.
* MOVE wa_makt-maktx TO wa_list-maktx.
* ENDIF.
call function 'MCB_S033_MITBEST'
exporting
material = wa_list-matnr
werk = wa_list-werks
bisdatum = p_from
vondatum = p_to
meins = 'ST'
importing
mitbestand = wa_list-stock
exceptions
no_statistics = 1
others = 2.
if sy-subrc <> 0.
move 0 to wa_list-stock.
endif.
modify table it_list from wa_list.
endloop.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.