SAP Function SO_DOCUMENT_SET_STATUS_API1 - SAPoffice: Set various statuses using RFC

Parameter Reference Type Length Default Optional Text
DOCUMENT_ID SOFOLENTI1-DOC_ID C 46 ID of document for which status is to be changed
STATUS SOOS-ACINP C 4 'READ' X New status

Exception Text
DOCUMENT_NOT_EXIST Specified document does not exist
ENQUEUE_ERROR Required locks could not be set
OPERATION_NO_AUTHORIZATION No authorization to change status
PARAMETER_ERROR Invalid combination of parameter values
X_ERROR Internal error or database inconsistency

Functionality
This function module allows a document status to be set. The specifiedfolder entry can be set to 'Viewed', 'In process', and 'Done'.
A distinction needs to be made here between the document and its folderentries. The document itself only exists once in the database. It isused as a template for the folder entries and can be referenced usingits object ID. The document can have any number of folder entries. Theycontain the contents and attributes of the document as well as someadditional attributes referring to the folder entry. These include thesender priority and expiration date of the folder entry. Folder entriesare the result of resubmissions, links, sending and creating a newdocument.

Import parameters
DOCUMENT_ID
ID of the folder entry of the document to be changed. It is theconnection between the document and the folder in which it is located.
STATUS
Default = 'READ'.
New status of the document.
The following values are allowed:
'READ' : sets the document to 'Viewed'
'INPR' : sets the document to 'In process'
'ACCO' : sets the document to 'Done'
The statuses 'INPR' and 'ACCO' are only allowed if the documentrequires action (status = 'TAAC'). As soon as the document has beenacted upon, the status cannot be reset to 'In process'.

Exceptions
DOCUMENT_NOT_EXIST
The specified folder entry does not exist. An incorrect ID was probablypassed or the relevant folder entry deleted.
OPERATION_NO_AUTHORIZATION
The folder entry could not be changed. This may be because the folderentry is located in the private area of another user.
PARAMETER_ERROR
An invalid combination of parameter values was passed to the functionmodule. A non-existent status may have been specified or one whichcannot be used.
X_ERROR
An internal error or a database inconsisteny occurred.
ENQUEUE_ERROR
The folder entry or the folder in which it is located could not belocked. It is probably being processed by another user.

Example
All documents in the inbox of the active user which require action areset to 'Done'. To determine and read the inbox, the function modulesSO_USER_READ_API1 and SO_FOLDER_READ_API1 are used.
DATA: FOL_CONT LIKE SOFOLENTI1 OCCURS 10 WITH HEADER LINE.
DATA: USER_DATA LIKE SOUDATAI1.
CALL FUNCTION 'SO_USER_READ_API1'
IMPORTING
USER_DATA = USER_DATA
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
WRITE: / 'User data could not be read !'.
EXIT.
ENDIF.
CALL FUNCTION 'SO_FOLDER_READ_API1'
EXPORTING
FOLDER_ID = USER_DATA-INBOXFOL
TABLES
FOLDER_CONTENT = FOL_CONT
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
WRITE: / 'Inbox could not be read !'.
EXIT
ENDIF.
LOOP AT FOL_CONT WHERE TO_DO_STAT = 'TAAC'.
CALL FUNCTION 'SO_DOCUMENT_SET_STATUS_API1'
EXPORTING
DOCUMENT_ID = FOL_CONT-DOC_ID
STATUS = 'ACCO'
EXCEPTIONS
OTHERS = 1.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Document', FOL_CONT-OBJ_DESCR,
'set to "Done" !'.
WHEN OTHERS.
WRITE: / 'Document', FOL_CONT-OBJ_DESCR,
'could not be set to "Done" !'.
ENDCASE.
ENDLOOP.

Further information
Information on calling the function modules SO_USER_READ_API1 andSO_FOLDER_READ_API1 can be found in the documentation of the respectivefunction module.