Skip to Content
Technical Articles
Author's profile photo Jigang Zhang 张吉刚

Dump when edit production order cause of missing status

There’s one Dump of ‘MESSAGE_TYPE_X’ for the program SAPLCOKO1 when the user tries to modify one particular production order.

The dump point is the return of the function module ‘STATUS_TEXT_EDIT’, and the root error message is BS(001) which is “No status object is available for ORD XXXXXX” when the program fetches the status object from DB for this production order.

So why this production order doesn’t have a status entry at JSTO?

Check 1: Notes 52546 – Status object does not exist in the sales order?

This particular production order comes from one sales order, check the linkage of the sales order and production order by AFPO-KDAUF = VBAK-VBELN where AFPO-AUFNR equals the production order number.

After creating a sales order, the status profile does not exist on the header or item level. The system displays the error message BS001 “No status object is available for &” when you change the sales document.

You can use the repair program SDSTATU2 to correct the incorrect sales and distribution documents. You can also use report SDSTATU1 to list all incorrect documents.

Nothing special after checking the order header level profile setting by VOV8 and item level profile setting by VOV7. Field VBAK-OBJNR is blank at the header and got valid VBAP-OBJNR per SO items. Seems no issue from the SO level.

If we check program SDSTATU1/SDSTATU2 will find that only VBAK-OBJNR <> SPACE will be considered, VBAK-OBJNR is blank should be fine. Besides, it’ll try to use FM ‘STATUS_OBJECT_CREATE’ to re-create the status for the order.

 

Check 2: Notes 2720065 – Object status is not updated to table JEST?

Object statuses with object types e.g. OKP, ORH are not updated to table JEST even if the production order can be saved successfully.
Due to this, unexpected issues (e.g. short dump :MESSAGE_TYPE_X) occur when changing the production order.

Indeed, there’s no entry from JEST for this production order; but In T-code: BS12, the “External status” indicator is not been ticked for object type: OKP or ORH, should not be this one~

Check 3: Notest 94699 – Production order/network/process order: Objects without status object

There are no entries in the table JEST or JSTO.
There can be various causes for objects without a status object:

A “commit work” is triggered within a user exit or a modification before the actual “commit work” of the production order is started and, therefore, before the number assignment of the status objects. A “commit work” statement must not be executed within a user exit or a modification in an SAP transaction!

One customized program called ZPSFC008B should be created which should be able to fix the errored production order.

And this works for me.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo VENKATESH GOLLA
      VENKATESH GOLLA

      well documneted, Thanks

      Author's profile photo Jigang Zhang 张吉刚
      Jigang Zhang 张吉刚
      Blog Post Author
      *$*$----------------------------------------------------------------$*$* 
      *$ Correction Inst.         0120024545 0000036286                     $*
      *$--------------------------------------------------------------------$*
      *$ Valid for       :                                                  $*
      *$ Software Component   SAP_APPL   SAP Application                    $*
      *$  Release 30C          To SAPKH30C14                                $*
      *$  Release 30D          All Support Package Levels                   $*
      *$  Release 30E          To SAPKH30E27                                $*
      *$  Release 30F          All Support Package Levels                   $*
      *$  Release 31G          To SAPKH31G13                                $*
      *$  Release 31H          All Support Package Levels                   $*
      *$  Release 31I          All Support Package Levels                   $*
      *$  Release 40A          To SAPKH40A25                                $*
      *$  Release 40B          All Support Package Levels                   $*
      *$  Release 45A          To SAPKH45A29                                $*
      *$  Release 45B          All Support Package Levels                   $*
      *$  Release 46A          To SAPKH46A34                                $*
      *$  Release 46B          All Support Package Levels                   $*
      *$  Release 46C          All Support Package Levels                   $*
      *$  Release 470          All Support Package Levels                   $*
      *$  Release 500          Fm SAPKH50001                                $*
      *$  Release 600          Fm SAPKH60001                                $*
      *$  Release 602          All Support Package Levels                   $*
      *$  Release 603          All Support Package Levels                   $*
      *$  Release 604          Fm SAPKH60401                                $*
      *$  Release 605          All Support Package Levels                   $*
      *$  Release 606          Fm SAPKH60601                                $*
      *$  Release 616          All Support Package Levels                   $*
      *$  Release 617          Fm SAPKH61701                                $*
      *$  Release 618          All Support Package Levels                   $*
      *$  Release 619          All Support Package Levels                   $*
      *$--------------------------------------------------------------------$*
      *$ Changes/Objects Not Contained in Standard SAP System               $*
      *$*$----------------------------------------------------------------$*$*
      *&--------------------------------------------------------------------*
      *& Object          REPS ZPSFC008B
      *& Object Header   PROG ZPSFC008B
      *&--------------------------------------------------------------------*
      *& REPORT ZPSFC008B
      *&--------------------------------------------------------------------*
      *>>>> START OF INSERTION <<<<
      *&---------------------------------------------------------------------*
      *& Report  ZPSFC008B                                                   *
      *&---------------------------------------------------------------------*
      *& Corrects status objects of objects within production orders with
      *& incorrect status. This may include objects with no status objects,
      *& objects with temporary status object numbers, objects with only
      *& partially created status objects (only JEST or only JSTO entries).
      *& Correct status objects for those objects will be created and an
      *& initial status 'Created' will be generated.
      *& Objects within the production orders handled within this report
      *& can be: header, sequences, operations, PRTs, components
      *&---------------------------------------------------------------------*
      *& Version: 2.3                                                        *
      *& Author:  SAP                                                        *
      *& Date:    23.07.2018                                                 *
      *&---------------------------------------------------------------------*
      
      REPORT zpsfc008b.
      
      INCLUDE lcokotyp.                                          "#EC INCL_OK
      
      TABLES: caufv,                                              "#EC NEEDED
              aufk,                                               "#EC NEEDED
              affl,                                               "#EC NEEDED
              afvc,                                               "#EC NEEDED
              affh,                                               "#EC NEEDED
              crfh,                                               "#EC NEEDED
              resb,                                               "#EC NEEDED
              onr00,                                              "#EC NEEDED
              jsto,                                               "#EC NEEDED
              jest.                                               "#EC NEEDED
      
      * constant definitions
      CONSTANTS: stk_ero LIKE jest-stat VALUE 'I0001',
                 stk_rel LIKE jest-stat VALUE 'I0002',
                 obj_number_tmp(2) TYPE c  VALUE 'TM',
                 yx VALUE 'X',
                 material  LIKE tcf02-fhmar  VALUE 'M',
                 dokument  LIKE tcf02-fhmar  VALUE 'D',
                 sonstige  LIKE tcf02-fhmar  VALUE 'S',
                 equipment LIKE tcf02-fhmar  VALUE 'E',
                 objekttyp_fhm_son LIKE tj03-obtyp VALUE 'OFS',
                 objekttyp_fhm_mat LIKE tj03-obtyp VALUE 'OFM',
                 objekttyp_fhm_dok LIKE tj03-obtyp VALUE 'OFD',
                 objekttyp_fhm_equ LIKE tj03-obtyp VALUE 'OFE'.
      
      * help variables
      DATA: flg_jsto,                                             "#EC NEEDED
            flg_jest,                                             "#EC NEEDED
            obtyp            LIKE jsto-obtyp,                     "#EC NEEDED
            obtyp_header     LIKE jsto-obtyp,                     "#EC NEEDED
            obtyp_oper       LIKE jsto-obtyp,                     "#EC NEEDED
            prefix_header(2) TYPE c,                              "#EC NEEDED
            prefix_oper(2)   TYPE c,                              "#EC NEEDED
            prefix_prt(2)    TYPE c,                              "#EC NEEDED
            flg_error        TYPE c VALUE 'X'.                    "#EC NEEDED
      
      * table definitions
      * Initial status for objects ('Created')
      DATA: BEGIN OF init_tab OCCURS 1.                           "#EC NEEDED
              INCLUDE STRUCTURE jstat.
      DATA: END OF init_tab.
      * Initial status for objects ('Released')
      DATA: BEGIN OF init_tab_rel OCCURS 1.                       "#EC NEEDED
              INCLUDE STRUCTURE jstat.
      DATA: END OF init_tab_rel.
      * Insert table jsto
      DATA: BEGIN OF jsto_tab OCCURS 0.                           "#EC NEEDED
              INCLUDE STRUCTURE jsto.
      DATA: END OF jsto_tab.
      * table for orders
      DATA: BEGIN OF caufv_tab OCCURS 0.                          "#EC NEEDED
              INCLUDE STRUCTURE caufv.
      DATA: END OF caufv_tab.
      * table for sequences
      DATA: BEGIN OF affl_tab OCCURS 0.                           "#EC NEEDED
              INCLUDE STRUCTURE affl.
      DATA: END OF affl_tab.
      * table for operations
      DATA: BEGIN OF afvc_tab OCCURS 0.                           "#EC NEEDED
              INCLUDE STRUCTURE afvc.
      DATA: END OF afvc_tab.
      * table for PRTs
      DATA: BEGIN OF affh_tab OCCURS 0,                           "#EC NEEDED
              aufpl LIKE affh-aufpl,
              pzlfh LIKE affh-pzlfh,
              objty LIKE affh-objty,
              objid LIKE affh-objid,
              objnr LIKE affh-objnr,
              fhmar LIKE crfh-fhmar,
            END OF affh_tab.
      * table for reservations
      DATA: BEGIN OF resb_tab OCCURS 0.                           "#EC NEEDED
              INCLUDE STRUCTURE resb.
      DATA: END OF resb_tab.
      
      * selection screen definition
      SELECTION-SCREEN COMMENT /1(80) text1.                      "#EC *
      SELECTION-SCREEN COMMENT /1(80) text2.                      "#EC *
      SELECTION-SCREEN COMMENT /1(80) text3.                      "#EC *
      SELECTION-SCREEN COMMENT /1(80) text4.                      "#EC *
      SELECTION-SCREEN ULINE.                                     "#EC *
      SELECTION-SCREEN COMMENT /1(80) text_1.                     "#EC *
      SELECT-OPTIONS: order FOR caufv-aufnr.                      "#EC *
      SELECTION-SCREEN ULINE.                                     "#EC *
      SELECTION-SCREEN COMMENT /1(80) text_2.                     "#EC *
      PARAMETERS: header   AS CHECKBOX DEFAULT yx,                "#EC *
                  sequence AS CHECKBOX DEFAULT yx,                "#EC *
                  oper     AS CHECKBOX DEFAULT yx,                "#EC *
                  prt      AS CHECKBOX DEFAULT yx,                "#EC *
                  comp     AS CHECKBOX DEFAULT yx.                "#EC *
      SELECTION-SCREEN ULINE.                                     "#EC *
      SELECTION-SCREEN BEGIN OF BLOCK block WITH FRAME TITLE title. "#EC *
      SELECTION-SCREEN COMMENT /1(72) text_a.                     "#EC *
      SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME.          "#EC *
      PARAMETERS: testmode RADIOBUTTON GROUP mode DEFAULT 'X'.    "#EC *
      PARAMETERS: update RADIOBUTTON GROUP mode.                  "#EC *
      SELECTION-SCREEN END OF BLOCK block2.                       "#EC *
      SELECTION-SCREEN COMMENT /1(72) text_b.                     "#EC *
      SELECTION-SCREEN END OF BLOCK block.                        "#EC *
      
      INITIALIZATION.
        text1 = 'This report checks and corrects the status objects'. "#EC *
        text2 = 'of production orders, networks, maintenance orders'. "#EC *
        text3 = 'and process orders: missing or incomplete status'. "#EC *
        text4 = 'objects or temporary object numbers.'.           "#EC *
        text_1 = 'Please specify order numbers.'.                 "#EC *
        text_2 = 'Please specify which objects to check / correct.'. "#EC *
        text_a = 'If TESTMODE is set, no database update will occur.'. "#EC *
        text_b = 'Activate UPDATE for updating the database entries.'. "#EC *
        title = 'Mode'.                                           "#EC *
      
      START-OF-SELECTION.
      
      * first check if orders exist
        IF NOT order IS INITIAL.
          SELECT *
                 FROM  caufv
                 INTO  TABLE caufv_tab
                 WHERE aufnr IN order
                 AND ( autyp = auftragstyp-fert OR
                       autyp = auftragstyp-netw OR
                       autyp = auftragstyp-inst OR
                       autyp = auftragstyp-bord ).
          IF NOT sy-subrc IS INITIAL.
            WRITE: / 'No orders found in the specified range.'(t01). "#EC *
            EXIT.                         ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          ENDIF.
        ELSE.
          WRITE: / 'Please enter an order number'(t02).           "#EC *
          EXIT.                           ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        ENDIF.
      
      * initialize initial status to be set
        init_tab-stat  = stk_ero.
        init_tab-inact = space.
        APPEND init_tab.
      * deactivate created status
        init_tab_rel-stat  = stk_ero.
        init_tab_rel-inact = yx.
        APPEND init_tab_rel.
      * initialize initial status to be set
        init_tab_rel-stat  = stk_rel.
        init_tab_rel-inact = space.
        APPEND init_tab_rel.
      
        LOOP AT caufv_tab INTO caufv.
      
          REFRESH jsto_tab.
      
      *   initialize prefixes and object types for different order types
          CASE caufv-autyp.
            WHEN auftragstyp-fert.
              obtyp_header  = 'ORH'.
              obtyp_oper    = 'OVG'.
              prefix_header = 'OR'.
              prefix_oper   = 'OV'.
              prefix_prt    = 'OF'.
            WHEN auftragstyp-netw.
              obtyp_header  = 'NPH'.
              obtyp_oper    = 'NVO'.
              prefix_header = 'NP'.
              prefix_oper   = 'NV'.
              prefix_prt    = 'OF'.
            WHEN auftragstyp-bord.
              obtyp_header  = 'ORB'.
              obtyp_oper    = 'OVB'.
              prefix_header = 'OR'.
              prefix_oper   = 'OV'.
            WHEN auftragstyp-inst.
              obtyp_header  = 'ORI'.
              obtyp_oper    = 'OVG'.
              prefix_header = 'OR'.
              prefix_oper   = 'OV'.
              prefix_prt    = 'OF'.
            WHEN OTHERS.
              WRITE: / 'Order'(t03),                              "#EC *
                       caufv-aufnr,                               "#EC *
                       'category'(t04),                           "#EC *
                       caufv-autyp,                               "#EC *
                       'not supported yet'(t05).                  "#EC *
            CONTINUE.                     ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          ENDCASE.
      
      ************************************************************************
      * edit HEADER if requested
      ************************************************************************
          IF NOT header IS INITIAL.
      *     provide valid object number if necessary
            IF caufv-objnr IS INITIAL OR
               caufv-objnr+0(2) = obj_number_tmp.
      *       build object number
              PERFORM build_object_number_header USING    caufv-aufnr
                                                          prefix_header
                                                 CHANGING caufv-objnr.
              IF testmode IS INITIAL.
      *         Update object number in AUFK
                UPDATE aufk   SET objnr = caufv-objnr
                            WHERE aufnr = caufv-aufnr.
              ENDIF.
            ENDIF.
            obtyp = obtyp_header.
            CLEAR: flg_jsto, flg_jest.
            PERFORM check_status_exists USING caufv-objnr
                                              flg_jsto
                                              flg_jest
                                              flg_error.
            PERFORM repair_status_object USING caufv-objnr
                                               obtyp
                                               caufv-aufnr
                                               testmode
                                               flg_jsto
                                               flg_jest.
          ENDIF.
      
      ************************************************************************
      * edit SEQUENCES if requested.
      ************************************************************************
          IF NOT sequence IS INITIAL AND
             ( caufv-autyp = auftragstyp-fert OR
               caufv-autyp = auftragstyp-bord ).
            SELECT * FROM affl INTO TABLE affl_tab
                               WHERE aufpl = caufv-aufpl.
            obtyp = 'OSF'.
            IF NOT affl_tab[] IS INITIAL.
              LOOP AT affl_tab.
                IF affl_tab-objnr IS INITIAL OR
                  affl_tab-objnr+0(2) = obj_number_tmp.
                  PERFORM build_object_number_sequence USING  affl_tab-aufpl
                                                               affl_tab-aplzl
                                                      CHANGING affl_tab-objnr.
                  IF testmode IS INITIAL.
      *             Update object number in AFFL
                    UPDATE affl SET objnr = affl_tab-objnr
                                WHERE aufpl = affl_tab-aufpl
                                  AND aplzl = affl_tab-aplzl.
                  ENDIF.
                ENDIF.
                CLEAR: flg_jsto, flg_jest.
                PERFORM check_status_exists USING affl_tab-objnr
                                                  flg_jsto
                                                  flg_jest
                                                  flg_error.
                PERFORM repair_status_object USING affl_tab-objnr
                                                   obtyp
                                                   caufv-aufnr
                                                   testmode
                                                   flg_jsto
                                                   flg_jest.
              ENDLOOP.
            ENDIF.
          ENDIF.
      
      ************************************************************************
      * edit OPERATIONS if requested.
      ************************************************************************
          IF NOT oper IS INITIAL.
            SELECT * FROM afvc INTO TABLE afvc_tab
                               WHERE aufpl = caufv-aufpl.
            obtyp = obtyp_oper.
            IF NOT afvc_tab[] IS INITIAL.
              LOOP AT afvc_tab.
      
                IF afvc_tab-objnr IS INITIAL OR
                   afvc_tab-objnr+0(2)  = obj_number_tmp OR
                   afvc_tab-objnr+2(10) NE afvc_tab-aufpl OR
                   afvc_tab-objnr+12(8) NE afvc_tab-aplzl.
                  PERFORM object_number_build_oper USING   afvc_tab-aufpl
                                                           afvc_tab-aplzl
                                                           prefix_oper
                                                   CHANGING afvc_tab-objnr.
                  IF testmode IS INITIAL.
      *             Update object number in AFVC
                    UPDATE afvc SET objnr = afvc_tab-objnr
                                WHERE aufpl = afvc_tab-aufpl
                                  AND aplzl = afvc_tab-aplzl.
                  ENDIF.
                ENDIF.
                CLEAR: flg_jsto, flg_jest.
                PERFORM check_status_exists USING afvc_tab-objnr
                                                  flg_jsto
                                                  flg_jest
                                                  flg_error.
      
      *         when changing network activity, check network header status
                IF flg_jest IS INITIAL AND obtyp = 'NVO'.
                  PERFORM check_network_head USING afvc_tab-aufpl
                                                   testmode.
                ENDIF.
      
                PERFORM repair_status_object USING afvc_tab-objnr
                                                   obtyp
                                                   caufv-aufnr
                                                   testmode
                                                   flg_jsto
                                                   flg_jest.
              ENDLOOP.
            ENDIF.
          ENDIF.
      
      ************************************************************************
      * edit Production resource tools if requested
      ************************************************************************
          IF NOT prt IS INITIAL.
            SELECT aufpl pzlfh objty objid objnr
                   FROM affh
                   INTO CORRESPONDING FIELDS OF TABLE affh_tab
                   WHERE aufpl = caufv-aufpl.
            IF NOT affh_tab[] IS INITIAL.
              LOOP AT affh_tab.
      *         determine kind of PRT
                SELECT SINGLE fhmar FROM crfh INTO affh_tab-fhmar
                                    WHERE objty = affh_tab-objty
                                      AND objid = affh_tab-objid.
                IF sy-subrc IS INITIAL.
                  MODIFY affh_tab.
                ENDIF.
              ENDLOOP.
            ENDIF.
            IF NOT affh_tab[] IS INITIAL.
              LOOP AT affh_tab.
      *         determine object type dependent on kind of PRT
                CASE affh_tab-fhmar.
                  WHEN material.
                    obtyp = objekttyp_fhm_mat.
                  WHEN dokument.
                    obtyp = objekttyp_fhm_dok.
                  WHEN sonstige.
                    obtyp = objekttyp_fhm_son.
                  WHEN equipment.
                    obtyp = objekttyp_fhm_equ.
                  WHEN OTHERS.
                    CONTINUE.
                ENDCASE.
                IF affh_tab-objnr IS INITIAL OR
                   affh_tab-objnr+0(2) = obj_number_tmp.
                  PERFORM object_number_build_prt USING affh_tab-aufpl
                                                        affh_tab-pzlfh
                                                        prefix_prt
                                                  CHANGING affh_tab-objnr.
                  IF testmode IS INITIAL.
      *             Update object number in AFFH
                    UPDATE affh SET objnr = affh_tab-objnr
                                WHERE aufpl = affh_tab-aufpl
                                  AND pzlfh = affh_tab-pzlfh.
                  ENDIF.
                ENDIF.
                CLEAR: flg_jsto, flg_jest.
                PERFORM check_status_exists USING affh_tab-objnr
                                                  flg_jsto
                                                  flg_jest
                                                  flg_error.
                PERFORM repair_status_object USING affh_tab-objnr
                                                   obtyp
                                                   caufv-aufnr
                                                   testmode
                                                   flg_jsto
                                                   flg_jest.
              ENDLOOP.
            ENDIF.
          ENDIF.
      
      ************************************************************************
      * edit COMPONENTS if requested.
      ************************************************************************
          IF NOT comp IS INITIAL.
            SELECT * FROM resb INTO TABLE resb_tab
                               WHERE rsnum = caufv-rsnum.
            obtyp = 'OKP'.
            IF NOT resb_tab[] IS INITIAL.
              LOOP AT resb_tab.
                IF resb_tab-objnr IS INITIAL OR
                   resb_tab-objnr+0(2) = obj_number_tmp.
                  PERFORM object_number_build_comp USING    resb_tab-rsnum
                                                            resb_tab-rspos
                                                            resb_tab-rsart
                                                   CHANGING resb_tab-objnr.
                  IF testmode IS INITIAL.
      *             Update object number in RESB
                    UPDATE resb SET objnr = resb_tab-objnr
                                WHERE rsnum = resb_tab-rsnum
                                  AND rspos = resb_tab-rspos
                                  AND rsart = resb_tab-rsart.
                  ENDIF.
                ENDIF.
                CLEAR: flg_jsto, flg_jest.
                PERFORM check_status_exists USING resb_tab-objnr
                                                  flg_jsto
                                                  flg_jest
                                                  flg_error.
                PERFORM repair_status_object USING resb_tab-objnr
                                                   obtyp
                                                   caufv-aufnr
                                                   testmode
                                                   flg_jsto
                                                   flg_jest.
                IF NOT resb_tab-xwaok IS INITIAL AND
                       testmode IS INITIAL.
                  CALL FUNCTION 'STATUS_CHANGE_INTERN'
                    EXPORTING
                      objnr  = resb_tab-objnr
                    TABLES
                      status = init_tab_rel.
                ENDIF.
              ENDLOOP.
            ENDIF.
          ENDIF.
      
      *   Update JSTO entries and status objects (commit work)
          IF testmode IS INITIAL.
            IF NOT jsto_tab[] IS INITIAL.
              INSERT jsto FROM TABLE jsto_tab.
            ENDIF.
            COMMIT WORK.                                          "#EC *
          ENDIF.
      
        ENDLOOP.
      
      * Was an incomplete status found ?
        IF NOT flg_error IS INITIAL.
          WRITE:/ 'No wrong or incomplete status objects were found'. "#EC *
        ENDIF.
      
      * help routines
      
      ************************************************************************
      * check_status_exists: checks which parts of the status object
      *                      already exists
      *  -> objnr_imp: Object number to check
      *  <- jsto_exists: set to X if jsto entry exists
      *  <- jest_exists: set to X if jest entrie for initial status exists
      ************************************************************************
      FORM check_status_exists USING objnr_imp   LIKE jsto-objnr
                                     jsto_exists
                                     jest_exists
                                     c_flg_error.
      
        CLEAR jsto_exists.
        CLEAR jest_exists.
      
        SELECT SINGLE * FROM jsto WHERE objnr = objnr_imp.
        IF sy-subrc IS INITIAL.
      *.. Jsto entry exists
          jsto_exists = yx.
        ELSE.
          CLEAR c_flg_error.
        ENDIF.
      
        SELECT SINGLE * FROM jest WHERE objnr = objnr_imp
                                    AND stat  = stk_ero.
        IF sy-subrc IS INITIAL.
      *.. initial jest entry exists
          jest_exists = yx.
        ELSE.
          CLEAR c_flg_error.
        ENDIF.
      
      ENDFORM.                    "CHECK_STATUS_EXISTS
      
      ************************************************************************
      * repair_status_object: repairs the status object
      *  -> objnr_imp: Object number to be repaired
      *  -> obtyp_imp: Object type of the object to be repaired
      *  -> order_imp: For reporting purpose only
      *  -> testmode_imp: For reporting purpose only
      *  -> jsto_exists: tells if jsto already exists
      *  -> jest_exists: tells if jest already exists
      ************************************************************************
      
      FORM repair_status_object USING objnr_imp LIKE jsto-objnr
                                      obtyp_imp LIKE jsto-obtyp
                                      order_imp LIKE caufv-aufnr
                                      testmode_imp
                                      jsto_exists
                                      jest_exists.
      
      * 1. status object does completely not exist
        IF     jsto_exists IS INITIAL AND
               jest_exists IS INITIAL.
      *.. Create status object completely
          CALL FUNCTION 'STATUS_OBJECT_CREATE'
            EXPORTING
              objnr = objnr_imp
              obtyp = obtyp_imp.
      *.. report to user
          PERFORM write_success USING obtyp_imp
                                      objnr_imp
                                      order_imp
                                      testmode_imp.
        ENDIF.
      
      * 2. no entry in jsto but in jest
        IF     jsto_exists IS INITIAL AND
           NOT jest_exists IS INITIAL.
      *.. only create an entry in jsto
          CLEAR jsto_tab.
          jsto_tab-objnr = objnr_imp.
          jsto_tab-obtyp = obtyp_imp.
          APPEND jsto_tab.
      *.. report to user
          PERFORM write_success USING obtyp_imp
                                      objnr_imp
                                      order_imp
                                      testmode_imp.
        ENDIF.
      
      * 3. no entry in jest but in jsto
        IF NOT jsto_exists IS INITIAL AND
               jest_exists IS INITIAL.
      *.. only set initial status for object in table jest
          CALL FUNCTION 'STATUS_CHANGE_INTERN'
            EXPORTING
              objnr  = objnr_imp
            TABLES
              status = init_tab.
      *.. report to user
          PERFORM write_success USING obtyp_imp
                                      objnr_imp
                                      order_imp
                                      testmode_imp.
        ENDIF.
      
      * 4. both exist -> nothing to be done
      
      ENDFORM.                    "REPAIR_STATUS_OBJECT
      
      ************************************************************************
      * log routine
      ************************************************************************
      FORM write_success USING obtyp_imp LIKE jsto-obtyp
                               objnr_imp LIKE jsto-objnr
                               order_imp LIKE caufv-aufnr
                               testmode_imp.
      
        DATA: object(10).
      
        CASE obtyp_imp.
          WHEN 'NPH'.
            object = 'network'.
          WHEN 'ORH' OR 'ORB' OR 'ORI'.
            object = 'order'.
          WHEN 'OSF'.
            object = 'sequence'.
          WHEN 'OVG' OR 'NPV' OR 'OVB'.
            object = 'operation'.
          WHEN 'OKP'.
            object = 'component'.
          WHEN 'NVO'.
            object = 'activity'.
          WHEN OTHERS.
            object = 'unknown'.
        ENDCASE.
      
        WRITE: / 'Status object'(t06),                            "#EC *
                 objnr_imp,                                       "#EC *
                 'for'(t07),                                      "#EC *
                 object,                                          "#EC *
                 'of order'(t08),                                 "#EC *
                 order_imp.                                       "#EC *
        IF testmode_imp IS INITIAL.
          WRITE: 'succesfully created.'(t09).                     "#EC *
        ELSE.
          WRITE: 'does not exist.'(t10).                          "#EC *
        ENDIF.
      ENDFORM.                    "WRITE_SUCCESS
      
      *&---------------------------------------------------------------------*
      *&      Form  BUILD_OBJECT_NUMBER_HEADER
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->P_CAUFV_AUFNR  text
      *      -->P_PREFIX_HEADER  text
      *      <--P_CAUFV_OBJNR  text
      *----------------------------------------------------------------------*
      FORM build_object_number_header USING    i_aufnr LIKE caufvd-aufnr
                                               i_prefix_header
                                      CHANGING e_objnr LIKE caufvd-objnr.
      
      * initializations
        CLEAR e_objnr.
        e_objnr = prefix_header.
        e_objnr+2 = i_aufnr.
      
      * check if onr00 entry exists
        SELECT SINGLE * FROM onr00 WHERE objnr = e_objnr.
        IF NOT sy-subrc IS INITIAL.
      *   onr00 entry does not exist -> create onr00 entry
          CLEAR e_objnr.
          IF i_prefix_header = 'OR'.
      *     production or process order
            CALL FUNCTION 'OBJECT_NUMBER_GET_OR'
              EXPORTING
                aufnr = i_aufnr
              IMPORTING
                objnr = e_objnr.
          ELSEIF i_prefix_header = 'NP'.
      *     network orders
            CALL FUNCTION 'OBJECT_NUMBER_GET_NP'
              EXPORTING
                aufnr = i_aufnr
              IMPORTING
                objnr = e_objnr.
          ENDIF.
        ENDIF.
      
      ENDFORM.                    " BUILD_OBJECT_NUMBER_HEADER
      
      *&---------------------------------------------------------------------*
      *&      Form  BUILD_OBJECT_NUMBER_SEQUENCE
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->P_AFFL_TAB_AUFPL  text
      *      -->P_AFFL_TAB_APLZL  text
      *      <--P_AFFL_TAB_OBJNR  text
      *----------------------------------------------------------------------*
      FORM build_object_number_sequence USING    i_aufpl LIKE affl-aufpl
                                                 i_aplzl LIKE affl-aplzl
                                        CHANGING e_objnr.
      
      * initializations
        CLEAR e_objnr.
        e_objnr = 'OS'.
        e_objnr+2  = i_aufpl.
        e_objnr+12 = i_aplzl.
      
      * check if onr00 entry exists
        SELECT SINGLE * FROM onr00 WHERE objnr = e_objnr.
        IF NOT sy-subrc IS INITIAL.
      *   onr00 entry does not exist -> create onr00 entry
          CLEAR e_objnr.
          CALL FUNCTION 'OBJECT_NUMBER_GET_OS'
            EXPORTING
              aplzl = i_aplzl
              aufpl = i_aufpl
            IMPORTING
              objnr = e_objnr.
        ENDIF.
      
      ENDFORM.                    " BUILD_OBJECT_NUMBER_SEQUENCE
      
      *&---------------------------------------------------------------------*
      *&      Form  OBJECT_NUMBER_BUILD_OPER
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->P_AFVC_TAB_AUFPL  text
      *      -->P_AFVC_TAB_APLZL  text
      *      -->P_PREFIX_OPER  text
      *      <--P_AFVC_TAB_OBJNR  text
      *----------------------------------------------------------------------*
      FORM object_number_build_oper USING    i_aufpl LIKE afvc-aufpl
                                             i_aplzl LIKE afvc-aplzl
                                             i_prefix_oper
                                    CHANGING e_objnr LIKE afvc-objnr.
      
      * initializations
        CLEAR e_objnr.
        e_objnr    = i_prefix_oper.
        e_objnr+2  = i_aufpl.
        e_objnr+12 = i_aplzl.
      
      * check if onr00 entry exists
        SELECT SINGLE * FROM onr00 WHERE objnr = e_objnr.
        IF NOT sy-subrc IS INITIAL.
      *   onr00 entry does not exist -> create onr00 entry
          CLEAR e_objnr.
          IF i_prefix_oper = 'OV'.
      *     production or process orders
            CALL FUNCTION 'OBJECT_NUMBER_GET_OV'
              EXPORTING
                aplzl = i_aplzl
                aufpl = i_aufpl
              IMPORTING
                objnr = e_objnr.
          ELSEIF i_prefix_oper = 'NV'.
      *     network orders
            CALL FUNCTION 'OBJECT_NUMBER_GET_NV'
              EXPORTING
                aplzl = i_aplzl
                aufpl = i_aufpl
              IMPORTING
                objnr = e_objnr.
          ENDIF.
        ENDIF.
      ENDFORM.                    " OBJECT_NUMBER_BUILD_OPER
      
      *&---------------------------------------------------------------------*
      *&      Form  OBJECT_NUMBER_BUILD_COMP
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->P_RESB_TAB_RSNUM  text
      *      -->P_RESB_TAB_RSPOS  text
      *      -->P_RESB_TAB_RSART  text
      *      <--P_RESB_TAB_OBJNR  text
      *----------------------------------------------------------------------*
      FORM object_number_build_comp USING    i_rsnum LIKE resb-rsnum
                                             i_rspos LIKE resb-rspos
                                             i_rsart LIKE resb-rsart
                                    CHANGING e_objnr LIKE resb-objnr.
      
      * initializations
        CLEAR e_objnr.
        e_objnr    = 'OK'.
        e_objnr+2  = i_rsnum.
        e_objnr+12 = i_rspos.
        e_objnr+16 = i_rsart..
      
      * check if onr00 entry exists
        SELECT SINGLE * FROM onr00 WHERE objnr = e_objnr.
        IF NOT sy-subrc IS INITIAL.
      *   onr00 entry does not exist -> create onr00 entry
          CLEAR e_objnr.
          CALL FUNCTION 'OBJECT_NUMBER_GET_OK'
            EXPORTING
              rsart = i_rsart
              rsnum = i_rsnum
              rspos = i_rspos
            IMPORTING
              objnr = e_objnr.
        ENDIF.
      
      ENDFORM.                    " OBJECT_NUMBER_BUILD_COMP
      
      *&---------------------------------------------------------------------*
      *&      Form  object_number_build_prt
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *      -->P_AFFH_TAB_AUFPL  text
      *      -->P_AFFH_TAB_PZLFH  text
      *      -->P_PREFIX_PRT  text
      *      <--P_AFFH_TAB_OBJNR  text
      *----------------------------------------------------------------------*
      FORM object_number_build_prt USING    i_aufpl
                                            i_pzlfh
                                            i_prefix_prt
                                   CHANGING e_objnr.
      
      * initializations
        CLEAR e_objnr.
        e_objnr    = i_prefix_prt.
        e_objnr+2  = i_aufpl.
        e_objnr+12 = i_pzlfh.
      
      * check if onr00 entry exists
        SELECT SINGLE * FROM onr00 WHERE objnr = e_objnr.
        IF NOT sy-subrc IS INITIAL.
      *   onr00 entry does not exist -> create onr00 entry
          CLEAR e_objnr.
          CALL FUNCTION 'OBJECT_NUMBER_GET_OF'
            EXPORTING
              aufpl = i_aufpl
              pzlfh = i_pzlfh
            IMPORTING
              objnr = e_objnr.
        ENDIF.
      
      ENDFORM.                    " object_number_build_prt
      
      *&--------------------------------------------------------------------*
      *&      Form  check_network_head
      *&--------------------------------------------------------------------*
      *       When setting activities to status CRTD, network may not be
      *       REL ==> set network to PREL.
      *---------------------------------------------------------------------*
      *      -->I_OBJNR    text
      *---------------------------------------------------------------------*
      FORM check_network_head USING i_aufpl LIKE afvc-aufpl
                                    i_testmode.
      
        STATICS: sv_aufpl LIKE afvc-aufpl.
      
        DATA: lt_stat  LIKE jstat OCCURS 0 WITH HEADER LINE,
              lv_objnr LIKE resb-objnr.
      
      * Process only once for each network
        IF sv_aufpl <> i_aufpl.
          REFRESH lt_stat.
          sv_aufpl = i_aufpl.
          SELECT SINGLE objnr FROM caufv INTO lv_objnr
                 WHERE aufpl = i_aufpl.
          CHECK sy-subrc IS INITIAL.
      
      *   check wether network is released
          CALL FUNCTION 'STATUS_CHECK'
            EXPORTING
              objnr             = lv_objnr
              status            = 'I0002'
            EXCEPTIONS
              object_not_found  = 1
              status_not_active = 2
              OTHERS            = 3.
          IF sy-subrc IS INITIAL.
      *     set REL to inactive
            lt_stat-stat = 'I0002'.
            lt_stat-inact = 'X'.
            APPEND lt_stat.
      *     set PREL to active
            lt_stat-stat = 'I0042'.
            lt_stat-inact = ' '.
            APPEND lt_stat.
          ENDIF.
      
          IF NOT i_testmode IS INITIAL.
            WRITE: / 'REL Network'(t11),                          "#EC *
                     lv_objnr+2(12),                              "#EC *
                     'can be reset to PREL'(t12).                 "#EC *
            WRITE:   'due to new activity status CRTD'(t13).      "#EC *
          ELSE.
            WRITE: / 'REL Network'(t11),                          "#EC *
                     lv_objnr+2(12),                              "#EC *
                     'is reset to PREL'(t14).                     "#EC *
            WRITE:   'due to new activity status CRTD'(t13).      "#EC *
            CALL FUNCTION 'STATUS_CHANGE_INTERN'
              EXPORTING
                objnr  = lv_objnr
              TABLES
                status = lt_stat.
          ENDIF.
        ENDIF.
      
      ENDFORM.                    "check_network_head
      *>>>> END OF INSERTION <<<<<<
      ...
      *&--------------------------------------------------------------------*