We can use SAP standard program 'RC1_IDOC_SET_STATUS' to change idoc status simply but if we'd like to change IDoc status 51 to another one like 68, we'd better create a custom program which contains a logic to delete related work item(s).
1. We can get related WI ID from table SWW_CONTOB by using idoc number as key
2. Can use FM SWW_WI_DELETE to delete the WI
3. Use FM IDOC_STATUS_WRITE_TO_DATABASE to append status to IDoc