1) read the material master data (MARC) to obtain the availability check settings (mtvfp), and enterVBAP-MTVFP
This field is from the main material data "sales: General/factory"-"General Data"-"availability check"
2) First, set it in the code of the unit fv45vf0b_bedarf_lesen.Initial availability check (TMVFP-OBVFP)
The Code excerpt is as follows:
Da_aufrufer = chara.
If TVAK-LISOF ne space. "immediate delivery
If XVBUK-VBELN ne VBAK-VBELN.
Perform xvbuk_lesen (sapfv45k) using VBAK-VBELN.
Endif.
If XVBUK-LFSTK ne charb and XVBUK-LFSTK ne charc.
Da_aufrufer = charb.
Endif.
Endif.
Call the same value
Call function 'rv _ requirement_get'
Exporting
Aufrufer = da_aufrufer
Material = us_matnr
Pruefgruppe = us_mtvfp
Werk = us_werks
Beleg = us_vbeln
Position = us_posnr
Vpmat = us_vpmat
Vpwrk = us_vpwrk
Pzmng_loeschen = da_korri
Korr_b7-= us_korri
Korr_alt = da_kopiermodus
Call_modus = da_call_modus
Nicht_sperren = da_nicht_sperren
Vbtyp = VBAK-VBTYP
Importing
Summierung = sumbd
Mat_gesperrt = da_gesperrt
Tables
Avbbd = avbbd
Xmverf_pos = xmverf_pos
Xquot_vb = xquot_vb
Xquot_ch = xquot_ch
Exceptions
Marc_matnr_gesperrt = 01
Marc_vpmat_gesperrt = 02
Enqueue_fehler = 03.
3) In the rv_requirement_get function, set the read Based on the read availability check.Availability check control (tmvf) and availability check freeze (tmvfp)
Perform tmvf_select using pruefgruppe aufrufer charx SY-SUBRC.
3.1) extract the code of reading the usable check and freezing (tmvfp)
Code unit: lv03vft2
Form tmvfp_select using us_mtvfp
Us_obvfp
Us_error
Us_subrc.
Us_subrc = 0.
If TMVFP-MTVFP ne space and TMVFP-OBVFP ne space.
Check: us_mtvfp ne TMVFP-MTVFP or
Us_obvfpne TMVFP-OBVFP.
Endif.
* Wenn in TMVF-ACENQ gesetzt wird tmvfp eigentlich nicht gebraucht,
* Verwendet wird allerdings obvfp als aufrufer.
* Ebint32 wenn verpn (keine PR Ung) gesetzt
If (TMVF-ACENQ ne space or "material frozen in availability checks with transfer requirements
TMVF-VERPN ne space) and "no availability check
Us_mtvfp ne space and
Us_obvfp ne space.
TMVFP-MTVFP = us_mtvfp.
TMVFP-OBVFP = us_obvfp.
TMVFP-VFPSP = space.
Endif.
Check TMVF-ACENQ EQ space and TMVF-VERPN EQ space.
If us_mtvfp EQ space.
Us_subrc = 4.
Else.
Select single * From tmvfp where mtvfp = us_mtvfp
And obvfp = us_obvfp.
If SY-SUBRC Ne 0.
Us_subrc = 4.
Endif.
Endif.
If us_subrc Ne 0.
If us_error ne space.
Clear: tmvfp.
Message i305 (vv) with us_mtvfp us_obvfp.
Endif.
Endif.
Endform. "tmvfp_select
4) in the code unit lv03vfa7 (Prreg) Rules for Checking availabilityThe code is excerpted as follows:
P_atpcs-prreg = tmvfp-obvfp.
P_atpcs-prreg + 1 (1) = p_mverf_pos-sobkz. "sobkz: special stock identification
If p_mverf_pos-sobkz ne space and
P_mverf_pos-sobkz ne chare and
P_mverf_pos-sobkz ne charq.
P_atpcs-kunnr = p_mverf_pos-kunnr.
Else.
Clear p_atpcs-kunnr.
Endif.
5) The two factors that control the availability check are determined.Check rules and inspection team (mtvfp prreg ),In this way, you can readT441v tableAnd used for availability check.
6) related tcode
Ovz2
Ovz1
Ovz9