블로그 이미지
모에샹동

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

  • total
  • today
  • yesterday

2009. 6. 11. 13:59 SAP/MM

FORM GET_START_STOCK USING    P_V_WERKS
                              P_S_DATE
                              P_V_MATNR
                     CHANGING P_V_STOCK.

  DATA: v_year(4), v_mon(2).

  v_year = p_s_date(4).
  v_mon  = p_s_date+4(2).

  CLEAR: p_v_stock.

  SELECT * FROM mbew WHERE ( ( lfgja < v_year ) OR
                             ( lfgja = v_year AND lfmon <= v_mon ) )
                       AND matnr = p_v_matnr
                       AND bwkey = p_v_werks.
    p_v_stock = mbew-lbkum.
    EXIT.
  ENDSELECT.

  IF sy-subrc <> 0.
    SELECT SINGLE lbkum INTO p_v_stock
                        FROM mbewh
                       WHERE lfgja = v_year
                         AND lfmon = v_mon
                         AND matnr = p_v_matnr
                         AND bwkey = p_v_werks.
    IF SY-SUBRC <> 0.
      SELECT * FROM mbewh WHERE ( lfgja = v_year AND lfmon > v_mon )
                            AND matnr = p_v_matnr
                            AND bwkey = p_v_werks.
        p_v_stock = mbew-lbkum.
        EXIT.
      ENDSELECT.

      IF sy-subrc <> 0.
        SELECT * FROM mbewh WHERE ( lfgja > v_year )
                              AND matnr = p_v_matnr
                              AND bwkey = p_v_werks.
          p_v_stock = mbew-lbkum.
          EXIT.
        ENDSELECT.
      ENDIF.
    ENDIF.
  ENDIF.

ENDFORM.                    " GET_START_STOCK

'SAP > MM' 카테고리의 다른 글

Reservation Processing  (0) 2012.10.18
자재 기간 마감 (MMPV, MMRV)  (0) 2009.05.22
Movement Type 정리  (0) 2009.05.22
Subcontracting(외주임가공) 에서의 Movement Type  (1) 2009.05.22
posted by 모에샹동