Functionality This function module can be used to delete an attachment. Theattachment is placed in the trash, if required, and can be retrievedfrom there before the trash is next emptied. Whether this is the sharedtrash or private trash depends on the folders in which the attachmentwas deleted. Import parameters ATTACHMENT_ID ID of the attachment to be deleted. This is the connection between theattachment and the document it belongs to. PUT_IN_TRASH If this flag is set ('X'), the attachment to be deleted is placed inthe trash. If the attachment is deleted in the inbox, outbox,resubmission folder or private folders, it is moved to the privatetrash of the active user. If the attachment was removed in the sharedfolders, it is moved to the shared trash. The attachment can beretrieved from the trash before it is next emptied. Exceptions ATTACHMENT_NOT_EXIST The specified attachment does not exist. An incorrect ID was probablypassed or the attachment involved has been deleted. OPERATION_NO_AUTHORIZATION It was not possible to delete the attachment specified. This may bebecause it is another user's private attachment or it is an attachmentin a shared folder for which the active user does not have a changeauthorization. It is also not generally possible to delete attachmentsfor a document which has already been sent. PARAMETER_ERROR An invalid combination of parameter values was passed to the functionmodule. X_ERROR An internal error or database inconsistency occurred. ENQUEUE_ERROR A lock involved in the delete operation could not be set. Processing isprobably being carried out by another user. Example Deletion of attachments for all documents in the private root folder.The deleted attachments are placed in the private trash. The ID of theprivate root folder is determined via the function moduleSO_USER_READ_API1, the contents of the private root folder read usingSO_FOLDER_READ_API1, and the list of attachments for the documentsdetermined provided via SO_DOCUMENT_READ_API1. DATA: FOL_CONT LIKE SOFOLENTI1 OCCURS 10 WITH HEADER LINE. DATA: ATTLIST LIKE SOATTLSTI1 OCCURS 5 WITH HEADER LINE. DATA: USER_DATA LIKE SOUDATAI1. DATA: TAB_LINES LIKE SY-TABIX. CALL FUNCTION 'SO_USER_READ_API1' EXPORTING 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-PRIVATFOL TABLES FOLDER_CONTENT = FOL_CONT EXCEPTIONS OTHERS = 1. IF SY-SUBRC <> 0. WRITE: / 'Private root folder could not be read !'. EXIT. ENDIF. LOOP AT FOL_CONT WHERE OBJ_TYPE = 'RAW' OR OBJ_TYPE = 'SCR'. CALL FUNCTION 'SO_DOCUMENT_READ_API1' EXPORTING DOCUMENT_ID = FOL_CONT-DOC_ID TABLES ATTACHMENT_LIST = ATTLIST EXCEPTIONS OTHERS = 1. IF SY-SUBRC <> 0. WRITE: / 'The document', FOL_CONT-OBJ_DESCR, 'could not be read !'. CONTINUE. ENDIF. DESCRIBE TABLE ATTLIST LINES TAB_LINES. IF TAB_LINES = 0. WRITE: / 'The document', FOL_CONT-OBJ_DESCR, 'does not have any attachments !'. CONTINUE. ENDIF. LOOP AT ATTLIST. CALL FUNCTION 'SO_ATTACHMENT_DELETE_API1' EXPORTING ATTACHMENT_ID = ATTLIST-ATTACH_ID PUT_IN_TRASH = 'X' EXCEPTIONS OTHERS = 1. IF SY-SUBRC <> 0. WRITE: / 'Attachment', ATTLIST-ATT_DESCR, 'of document', FOL_CONT-OBJ_DESCR, 'could not be deleted !'. ELSE. WRITE: / 'Attachment', ATTLIST-ATT_DESCR, 'of document', FOL_CONT-OBJ_DESCR, 'was deleted !'. ENDIF. ENDLOOP. ENDLOOP. Further information Information on calling the function modules SO_USER_READ_API1,SO_FOLDER_READ_API1 and SO_DOCUMENT_READ_API1 can be found in thedocumentation of the respective function modules. |