메뉴 건너뛰기

SAP 한국 커뮤니티



REPORT ZPSFC001.
*----------------------------------------------------------------------*
* This reports inactivates the deletion indicator for production orders.
* Please run this report in testmode first to check if only orders are
* included which should not be archived.
* It will not remove the deletion flag from the order. This must be
* done manually by inactivating the deletion flag within the order.
* --> Testmode: 'X' -> no update performed
* --> PARTDLVD: 'X' -> partially delivered orders will not be updated
* --> PARTCONF: 'X' -> partially confirmed orders will not be updated
* --> ORDER   : Range of orders to be selected
* --> MATNR   : Range of materials for which orders exist
*----------------------------------------------------------------------*
* Caution: If you want to use this report for other order types than   *
*          production orders please modify lines where
*          'auftragstyp-fert' is used
*----------------------------------------------------------------------*
* I0010(stk_tru)-partially confirmed, I0074(stk_tli)-partially deliverd

INCLUDE LCOKOSTA.                      "get constants for status
INCLUDE LCOKOTYP.                      "get constants for order type

* parameter definition
TABLES: VJAUFK, AUFK.
PARAMETERS:
  TESTMODE   DEFAULT 'X',
  PARTDLVD   DEFAULT 'X',              "check for partially delivered
  PARTCONF   DEFAULT 'X'.              "check for partially confirmed
SELECT-OPTIONS:
  ORDER     FOR VJAUFK-AUFNR MATCHCODE OBJECT ORDE,
  MATNR     FOR VJAUFK-MATNR MATCHCODE OBJECT MAT1.

DATA: BEGIN OF FERT OCCURS 1.
        INCLUDE STRUCTURE VJAUFK.
DATA: END OF FERT.
DATA: BEGIN OF COLL_TAB OCCURS 1,
        AUFNR LIKE AUFK-AUFNR,
      END OF COLL_TAB.
DATA: BEGIN OF STATUS OCCURS 1.
        INCLUDE STRUCTURE JSTAT.
DATA: END OF STATUS.
DATA: LAST_LEAD_AUFNR LIKE AFKO-LEAD_AUFNR.

* To set status I0013 - stk_loe inactive
STATUS-STAT = STK_LOE.
STATUS-INACT = 'X'.
APPEND STATUS.

IF MATNR[] IS INITIAL AND
   ORDER[] IS INITIAL.
  message i889(CO) with
          'Please enter at least one selection criteria.'.
  exit.
ENDIF.

SELECT * FROM VJAUFK INTO TABLE FERT
         WHERE AUFNR IN ORDER
         AND   MATNR IN MATNR
         AND   STAT  = STK_LOE
         AND   INACT = SPACE
         AND   AUTYP = AUFTRAGSTYP-FERT.

IF SY-SUBRC <> 0.
  WRITE 'NO PRODUCTION ORDERS FOUND'.
  EXIT.
ENDIF.

* for collective orders we have to guarantee, that all orders for
* one collective order are member of the selection
* --> we need to add orders not included yet.

PERFORM CORRECT_COLLECTIVE_ORDER.

LOOP AT FERT.

* Commit - Logic:
* With first enter in loop do not commit (commit_flag)
* For each single order commit work
* Collective orders are committed at once

    IF FERT-PRODNET EQ 'X'.
*       collective order
      IF LAST_LEAD_AUFNR NE FERT-LEAD_AUFNR.
*         there is a new (collective) order --> commit amd refresh
        IF TESTMODE IS INITIAL.
          COMMIT WORK.
        ENDIF.
        CALL FUNCTION 'STATUS_BUFFER_REFRESH'.
        LAST_LEAD_AUFNR = FERT-LEAD_AUFNR.
      ENDIF.
    ELSE.
      IF TESTMODE IS INITIAL.
        COMMIT WORK.
      ENDIF.
      CALL FUNCTION 'STATUS_BUFFER_REFRESH'.
    ENDIF.

  IF NOT PARTDLVD IS INITIAL.
*   check if order is partially delivered if requested
    CALL FUNCTION 'STATUS_CHECK'
         EXPORTING
              OBJNR             = FERT-OBJNR
              STATUS            = STK_TLI
         EXCEPTIONS
              STATUS_NOT_ACTIVE = 2.
    IF SY-SUBRC = 2.
      CONTINUE.
    ENDIF.
  ENDIF.

  IF NOT PARTCONF IS INITIAL.
*   check if order is partially confirmed if requested
    CALL FUNCTION 'STATUS_CHECK'
         EXPORTING
              OBJNR             = FERT-OBJNR
              STATUS            = STK_TRU
         EXCEPTIONS
              STATUS_NOT_ACTIVE = 2.
    IF SY-SUBRC = 2.
      CONTINUE.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'STATUS_CHECK'
       EXPORTING
            OBJNR             = FERT-OBJNR
            STATUS            = STK_LOE
       EXCEPTIONS
            STATUS_NOT_ACTIVE = 2.
  IF SY-SUBRC = 2.
    WRITE: / 'ORDER ', FERT-AUFNR, ': DELETION INDICATOR NOT ACTIVE'.
    CONTINUE.
  ENDIF.

  IF TESTMODE IS INITIAL.
    CALL FUNCTION 'STATUS_CHANGE_INTERN'
         EXPORTING
              OBJNR  = FERT-OBJNR
         TABLES
              STATUS = STATUS.
    UPDATE AUFK SET  AENAM = SY-UNAME
                     AEDAT = SY-DATUM
                     aezeit = sy-uzeit              "as of release 4.0
            WHERE    AUFNR = FERT-AUFNR.
    LAST_LEAD_AUFNR = FERT-LEAD_AUFNR.
  ENDIF.

  IF SY-SUBRC IS INITIAL.
    WRITE: / 'ORDER ', FERT-AUFNR, ': DELETION INDICATOR REMOVED'.
  ENDIF.
  IF NOT TESTMODE IS INITIAL.
    WRITE: ' - TESTMODE'.
  ENDIF.
ENDLOOP.

COMMIT WORK.
SKIP 1.
WRITE: 'Program finished'.

*---------------------------------------------------------------------*
*       FORM CORRECT_COLLECTIVE_ORDER                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM CORRECT_COLLECTIVE_ORDER.
  DATA: HELP_DATE LIKE SY-DATUM,
        HELP_COUNTER TYPE I.

  SORT FERT BY LEAD_AUFNR AUFNR.
* add each leading order into coll_tab
  LOOP AT FERT WHERE LEAD_AUFNR NE SPACE.
*   CHECK fert-aufnr NE fert-lead_aufnr.
    COLL_TAB-AUFNR = FERT-LEAD_AUFNR.
    COLLECT COLL_TAB.
  ENDLOOP.

  IF NOT COLL_TAB[] IS INITIAL.
    SELECT * FROM VJAUFK APPENDING TABLE FERT
                                  FOR ALL ENTRIES IN COLL_TAB
                                  WHERE LEAD_AUFNR EQ COLL_TAB-AUFNR
                                  AND   STAT  = STK_LOE
                                  AND   AUTYP = AUFTRAGSTYP-FERT
                                  AND   LOEKZ = 'X'.
    SORT FERT BY LEAD_AUFNR AUFNR.
    DELETE ADJACENT DUPLICATES FROM FERT.
  ENDIF.

ENDFORM.

번호 제목 글쓴이 날짜 조회 수
179 Production order 와 Process order 의 차이 모포 2015.10.23 3681
178 구품번 조회관련 질문입니다. [1] pssk 2015.10.21 2749
177 MRP 및 MPS 관련 질문입니다. [1] 샤샨 2015.08.29 3388
176 라우팅 구성부품 다운로드방법 문의.. [3] 기러기소리 2015.06.23 2215
175 415 이동전기시 생산계획오더의 재생성에 관련하여 고수분들의 고견 여쭈어봅니다. [1] 오물이 2015.05.09 2348
174 처리유형 관련질문 [1] 샤샨 2015.04.14 2418
173 이게 PP관련 질문이 맞나 모르겠는데.. PP 관련 ABAP 개발자의 지식은 어디까지일까요? [1] 두리형빠이 2015.04.04 2439
172 sap 초보 질문드립니다.. ㅜㅜ(표준가 & 이동평균가) [5] 샨티 2015.03.26 6757
171 CS03 (BOM조회에서) 아래와 같이 Item 넘버 안보임 [2] 미래 2015.02.26 2889
170 TCODE;CO15에 대해서 [2] 땅굴파기 2014.10.06 3275
169 PP모듈의 생산버젼에 대한 의견 여쭙고자 합니다. [2] 필삽 2014.09.26 4475
168 REM 생산방식에서 불량을 재처리해서 양품으로 하는방법이 궁금합니다!! [2] SAP 초짜 2014.09.17 3714
167 완성품 등록??고수님들help me [8] 땅굴파기 2014.09.02 3066
166 Kanban 자료 올립니다. jeinny 2014.07.07 2780
» pp deletion indicator 삭제 프로그램(상태변경 프로그램) sapjoy 2014.05.26 3783
164 plannig verson copy 오류 신동신동 2014.05.22 2383
163 원가계산 오류 [2] file 페이머스킴 2014.05.15 3773
162 BOM 변경번호 없이 수정 못하도록 방법 문의 [2] 멋진석환 2014.04.14 4197
161 Backflush 수행시 특정 Material Type에 대해서 G/I를 Block 할 수 있는 방법이 있나요? [1] 천승원 2014.04.09 3177
160 CO1P 의 정의 및 원인 요청 [1] 멋진석환 2014.04.07 3508