Hi Experts,
Error:
This situation occurs when breaking the current LUW,
in the same hand as the systems tries to carry its object status into DB.
This syntom is very common with inapropiate use of COMMIT WORK, that breakes the current LUW,
while not even all standard steps have been finished.
Prevention:
To avoid this situation, be aware of any use of Commit Works into customer Enhancements.
I do strongly recomend to avoid any use of commit works into customers enchancements.
Solution:
If you are experiencing the same error, and still need to repair the broken HU objekts,
then you will have run the attached PROGRAM, to solve the problem
Execution:
Inform your HU ( EXIDV )
1st Step: Create Status
2nd Step: Repair Status
3rd Step: Renew Status
*----------------------------------------------------------------------*
* Peter A. Stocklen
* Mail at not_a_real@email.id
*
* < Handling Unit Status Create, Delete, Renew, Repair >
*----------------------------------------------------------------------*
REPORT zpeter_hu.
TABLES vekp. "Handling Unit - Header Table
TABLES tvty. "Packaging Material Types
TABLES husstat. "
PARAMETERS: p_exidv TYPE vekp-exidv OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME NO INTERVALS.
PARAMETER: p_check RADIOBUTTON GROUP g1 DEFAULT 'X', "Check Status For Modif
p_create RADIOBUTTON GROUP g1, "Create Status Object - Step 1
p_repair RADIOBUTTON GROUP g1, "Repair Status Object - Step 2
p_delete RADIOBUTTON GROUP g1, "Delete Status Object
p_nwstat RADIOBUTTON GROUP g1, "Renew Status ( HU STATUS ) - Step 3
p_refrsh RADIOBUTTON GROUP g1. "Refresh ( Memory )
SELECTION-SCREEN END OF BLOCK b2.
DATA v_objnr TYPE jsto-objnr. "Object number
START-OF-SELECTION.
CLEAR vekp.
* Handling Unit - Header Table
SELECT SINGLE * FROM vekp
WHERE exidv EQ p_exidv.
IF sy-subrc NE space.
MESSAGE s088(st) WITH 'HU doesnt exist'(m01)
DISPLAY LIKE 'E'.
ELSE.
CLEAR v_objnr.
v_objnr = 'HU'.
v_objnr+2 = vekp-venum.
* Select single auf TVTY
CALL FUNCTION 'TVTY_SINGLE_READ'
EXPORTING
tvty_traty = vekp-vhart
IMPORTING
wtvty = tvty
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc EQ space.
CASE 'X'.
WHEN p_check.
** Carry Out Status Changes for an Activity
* CALL FUNCTION 'STATUS_CHANGE_FOR_ACTIVITY'
* EXPORTING
* check_only = ''
* client = sy-mandt
* objnr = v_objnr
* vrgng = 'HU16'
* EXCEPTIONS
* activity_not_allowed = 1
* object_not_found = 2
* status_inconsistent = 3
* status_not_allowed = 4
* wrong_input = 5
* warning_occured = 6
* OTHERS = 7.
*
* IF sy-subrc EQ space.
*
* MESSAGE s088(st) WITH 'HU is OK'(m09)
* DISPLAY LIKE 'S'.
*
* ELSE.
*
* CASE sy-subrc.
* WHEN 1.
* MESSAGE s088(st) WITH 'HU activity not allowed'(m11)
* DISPLAY LIKE 'E'.
* WHEN 2.
* MESSAGE s088(st) WITH 'HU object not found'(m12)
* DISPLAY LIKE 'E'.
* WHEN 3.
* MESSAGE s088(st) WITH 'HU status inconsistent'(m13)
* DISPLAY LIKE 'E'.
* WHEN 4.
* MESSAGE s088(st) WITH 'HU status not allowed'(m14)
* DISPLAY LIKE 'E'.
* WHEN 5.
* MESSAGE s088(st) WITH 'HU has wrong input'(m15)
* DISPLAY LIKE 'E'.
* WHEN 6.
* MESSAGE s088(st) WITH 'HU warning occured'(m16)
* DISPLAY LIKE 'W'.
*
* WHEN OTHERS.
* MESSAGE s088(st) WITH 'HU Inconsistent'(m10)
* DISPLAY LIKE 'S'.
* ENDCASE.
*
* ENDIF.
* Displays List of Influences on Transactions for Transaction and Object
CALL FUNCTION 'STATUS_ACTIVITY_ANALYZER'
EXPORTING
activity = 'HU16'
client = sy-mandt
objnr = v_objnr
EXCEPTIONS
activity_not_valid = 1
object_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE s088(st) WITH 'Status Activity Not Found or Not Valid'
DISPLAY LIKE 'E'.
ENDIF.
WHEN p_create.
* Create Status Object
CALL FUNCTION 'STATUS_OBJECT_CREATE'
EXPORTING
client = sy-mandt
objnr = v_objnr
obtyp = 'HUM'
stsma = tvty-stsma
EXCEPTIONS
obtyp_invalid = 1
status_object_already_exists = 2
stsma_invalid = 3
stsma_obtyp_invalid = 4
OTHERS = 5.
IF sy-subrc EQ space.
COMMIT WORK AND WAIT.
MESSAGE s088(st) WITH 'HU Status Created'(m07)
DISPLAY LIKE 'S'.
ELSE.
MESSAGE s088(st) WITH 'HU Create Error'(m08)
DISPLAY LIKE 'E'.
ENDIF.
WHEN p_repair.
* fehlendes Statusobjekt aus Änderungsbelegen rekonstruieren
CALL FUNCTION 'STATUS_OBJECT_REPAIR'
EXPORTING
client = sy-mandt
objnr = v_objnr
obtyp = 'HUM'
stsma = tvty-stsma
test_mode = space
EXCEPTIONS
obtyp_invalid = 1
stsma_invalid = 2
stsma_obtyp_invalid = 3
status_object_exists = 4
OTHERS = 5.
CASE sy-subrc.
WHEN 0.
COMMIT WORK.
MESSAGE s088(st) WITH 'HU Status Succesfully Repaired'(m02)
DISPLAY LIKE 'S'.
WHEN 4.
MESSAGE s088(st) WITH 'HU ja está OK!'(m04)
DISPLAY LIKE 'S'.
WHEN OTHERS.
MESSAGE s088(st) WITH 'HU Repair Error'(m03)
DISPLAY LIKE 'E'.
ENDCASE.
WHEN p_delete.
* Delete Status Object (in Dialog, DB Change ON COMMIT in Update Task)
CALL FUNCTION 'STATUS_OBJECT_DELETE'
EXPORTING
client = sy-mandt
objnr = v_objnr.
COMMIT WORK.
MESSAGE s088(st) WITH 'Deletion Executed'(m06)
DISPLAY LIKE 'S'.
WHEN p_nwstat.
TYPE-POOLS vses.
DATA t_hustatus TYPE vses_t_hustatus.
DATA t_hustobj TYPE vses_t_hustobj.
DATA w_hustatus TYPE LINE OF vses_t_hustatus.
DATA w_hustobj TYPE LINE OF vses_t_hustobj.
PERFORM zf_delete_object USING v_objnr.
PERFORM zf_delete_status USING v_objnr.
CALL FUNCTION 'HU_STATUS_UPDATE'
EXPORTING
it_hustatus = t_hustatus
it_hustobj = t_hustobj.
COMMIT WORK.
REFRESH t_hustobj.
REFRESH t_hustatus.
PERFORM zf_insert_object USING v_objnr tvty-stsma.
PERFORM zf_insert_status USING v_objnr 'E0002' ' ' tvty-stsma.
PERFORM zf_insert_status USING v_objnr 'I0001' 'X' tvty-stsma.
PERFORM zf_insert_status USING v_objnr 'I0511' ' ' tvty-stsma.
PERFORM zf_insert_status USING v_objnr 'I0512' ' ' tvty-stsma.
CALL FUNCTION 'HU_STATUS_UPDATE'
EXPORTING
it_hustatus = t_hustatus
it_hustobj = t_hustobj.
COMMIT WORK AND WAIT.
WRITE: 'Status Atual da HU:'.
SKIP.
SELECT * FROM husstat
WHERE objnr EQ v_objnr.
WRITE:/ husstat.
ENDSELECT.
WHEN p_refrsh.
* Reset Internal Status Management Buffer
CALL FUNCTION 'STATUS_BUFFER_REFRESH'
EXPORTING
i_free = 'X'.
MESSAGE s088(st) WITH 'Buffer Refresh Executed'
DISPLAY LIKE 'S'.
WHEN OTHERS.
* Do Nothing
ENDCASE.
ELSE.
MESSAGE s088(st) WITH 'Status Profile is Missing'(m05)
DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form ZF_INSERT_STATUS
*&---------------------------------------------------------------------*
FORM zf_insert_status USING iv_objnr
iv_stat
iv_inact
iv_stsma.
CLEAR w_hustatus.
w_hustatus-mandt = sy-mandt.
w_hustatus-objnr = iv_objnr.
w_hustatus-mod = 'I'.
w_hustatus-stat = iv_stat.
w_hustatus-inact = iv_inact.
w_hustatus-stsma = iv_stsma.
APPEND w_hustatus TO t_hustatus.
ENDFORM. " ZF_INSERT_STATUS
*&---------------------------------------------------------------------*
*& Form ZF_DELETE_STATUS
*&---------------------------------------------------------------------*
FORM zf_delete_status USING iv_objnr.
SELECT * FROM husstat
WHERE objnr EQ iv_objnr.
CLEAR w_hustatus.
w_hustatus-mandt = sy-mandt.
w_hustatus-objnr = iv_objnr.
w_hustatus-stat = husstat-stat.
w_hustatus-mod = 'D'.
APPEND w_hustatus TO t_hustatus.
ENDSELECT.
ENDFORM. " ZF_DELETE_STATUS
*&---------------------------------------------------------------------*
*& Form ZF_INSERT_OBJECT
*&---------------------------------------------------------------------*
FORM zf_insert_object USING iv_objnr iv_stsma.
CLEAR w_hustobj.
w_hustobj-objnr = iv_objnr.
w_hustobj-obtyp = 'HUM'.
w_hustobj-stsma = iv_stsma.
w_hustobj-mod = 'I'.
APPEND w_hustobj TO t_hustobj.
ENDFORM. " ZF_INSERT_OBJECT
*&---------------------------------------------------------------------*
*& Form ZF_DELETE_OBJECT
*&---------------------------------------------------------------------*
FORM zf_delete_object USING iv_objnr.
CLEAR w_hustobj.
w_hustobj-objnr = iv_objnr.
w_hustobj-mod = 'D'.
APPEND w_hustobj TO t_hustobj.
ENDFORM. "zf_delete_object
Message was edited by: Matthew Billingham - removed real email id.