Ansicht
Dokumentation

SO_ATTACHMENT_DELETE_API1 - SAPoffice: Delete attachment using RFC

SO_ATTACHMENT_DELETE_API1 - SAPoffice: Delete attachment using RFC

BAL_S_LOG - Application Log: Log header data   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module can be used to delete an attachment. The attachment is placed in the trash, if required, and can be retrieved from there before the trash is next emptied. Whether this is the shared trash or private trash depends on the folders in which the attachment was deleted.

Import parameters

ATTACHMENT_ID
ID of the attachment to be deleted. This is the connection between the attachment and the document it belongs to.
PUT_IN_TRASH
If this flag is set ('X'), the attachment to be deleted is placed in the trash. If the attachment is deleted in the inbox, outbox, resubmission folder or private folders, it is moved to the private trash of the active user. If the attachment was removed in the shared folders, it is moved to the shared trash. The attachment can be retrieved from the trash before it is next emptied.

Exceptions

ATTACHMENT_NOT_EXIST
The specified attachment does not exist. An incorrect ID was probably passed or the attachment involved has been deleted.
OPERATION_NO_AUTHORIZATION
It was not possible to delete the attachment specified. This may be because it is another user's private attachment or it is an attachment in a shared folder for which the active user does not have a change authorization. It is also not generally possible to delete attachments for a document which has already been sent.
PARAMETER_ERROR
An invalid combination of parameter values was passed to the function module.
X_ERROR
An internal error or database inconsistency occurred.
ENQUEUE_ERROR
A lock involved in the delete operation could not be set. Processing is probably 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 the private root folder is determined via the function module SO_USER_READ_API1, the contents of the private root folder read using SO_FOLDER_READ_API1, and the list of attachments for the documents determined 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.

Notes

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 the documentation of the respective function modules.





Parameters

ATTACHMENT_ID
PUT_IN_TRASH

Exceptions

ATTACHMENT_NOT_EXIST
ENQUEUE_ERROR
OPERATION_NO_AUTHORIZATION
PARAMETER_ERROR
X_ERROR

Function Group

SOI1

Vendor Master (General Section)   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 6120 Date: 20240523 Time: 110125     sap01-206 ( 79 ms )