SAP Function SO_DOCUMENT_INSERT_API1 - SAPoffice: Create new office document using RFC

Parameter Reference Type Length Default Optional Text
DOCUMENT_DATA SODOCCHGI1 u 152 Document attributes (general header)
DOCUMENT_TYPE SOODK-OBJTP C 3 Document Class
FOLDER_ID SOOBJINFI1-OBJECT_ID C 17 ID of folder in which document is to be created

Parameter Reference Type Length Text
DOCUMENT_INFO SOFOLENTI1 u 770 Complete attributes of document

Parameter Reference Length Optional Text
CONTENTS_HEX SOLIX 255 X Document contents (binary)
OBJECT_CONTENT SOLISTI1 255 X Document contents (text)
OBJECT_HEADER SOLISTI1 255 X Header data for document (spec.header)
OBJECT_PARA SOPARAI1 92 X SET/GET parameter for processing
OBJECT_PARB SOPARBI1 285 X Fields and values for processing

Exception Text
DOCUMENT_TYPE_NOT_EXIST Document type does not exist
ENQUEUE_ERROR Required locks could not be set
FOLDER_NOT_EXIST Specified folder does not exist
OPERATION_NO_AUTHORIZATION No authorization to create document
PARAMETER_ERROR Invalid combination of parameter values
X_ERROR Internal error or database inconsistency

Functionality
This function module allows a new document to be created in a specifiedfolder.
A distinction must be made here between the document and its folderentries. The document itself only exists once in the database. Itserves 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 related to the folder entry. These include thesender priority and the expiration date of the entry. Folder entriesare the result of resubmissions, links, sending and creating a newdocument.

Import parameters
FOLDER_ID
Object ID of the folder in which the document is to be created.
DOCUMENT_TYPE
Type of document. Distribution lists ('DLI') and folders ('FOL') cannotbe created using this function module.
DOCUMENT_DATA
This structure must contain the attributes of the document to becreated. Values in the fields of the attributes belonging to thedocument affect each future folder entry while entries in theentry-related fields only affect the folder entry generatedautomatically when the document is created.

  • OBJ_NAME

  • Name of the document.
    • OBJ_DESCR

    • Title (short description) of the document.
      • OBJ_LANGU

      • Language of the document.
        • OBJ_SORT

        • Sort field of the document. This term can be searched for in theattribute search.
          • OBJ_EXPDAT

          • Expiration date of the document. The document itself cannot expire,however this date is used for the expiration date of the entry (fieldEXPIRY_DAT) for each new folder entry of the document.
            • SENSITIVTY

            • Sensitivity of the document:
              A private document can have the following sensitivity:
              'O' : standard, normal sensitivity
              'F' : functional, can only be forwarded functionally
              'P' : confidential, not visible to substitute
              Only the sensitivity 'O' is allowed for documents in the sharedfolders.
              • OBJ_PRIO

              • Recipient priority. The document itself does not have a priority,however this value is used for the recipent priority of the entry(field PRIORITY) for each new folder entry of the document.
                • NO_CHANGE

                • If this flag is set ('X'), the document can only be changed by theauthor in the case of shared folder entries. In the case of privatefolder entries, the author can also make changes after the document hasbeen sent.
                  • PRIORITY

                  • Recipient priority of the folder entry. This value represents theimportance assigned to the entry by the owner after it has beenreceived.
                    • EXPIRY_DAT

                    • Expiration date of the folder entry. When the expiration date has beenreached or exceeded, the entry is placed in the private trash and canbe retrieved from there if necessary before the trash is next emptied.A new folder entry is initially provided with the expiration date ofthe document from the field OBJ_EXPDAT.
                      • PROC_TYPE

                      • If this field is not initial (not ' '), the document can be processed.
                        The following entries are allowed:
                        'D' : dialog module
                        'F' : function module
                        'R' : report
                        'S' : report with value transfer to global memory
                        'T' : transaction
                        'U' : transaction with value transfer to global memory
                        • PROC_NAME

                        • Processing element. Depending on the entry in the field PROC_TYPE, thename of the dialog module, function module, report, or transaction mustbe specified.
                          • PROC_SYST

                          • Name of the system in which the document is to be processed. If nosystem is specified or the value '*', processing can be carried out inany system.
                            • PROC_CLINT

                            • Client in which the document is to be processed. If no client isspecified or the value '*', processing can be carried out in anyclient.
                              • SKIP_SCREN

                              • If this flag is set ('X'), the first screen is skipped in theprocessing.
                                • TO_DO_OUT

                                • If this flag is set ('X'), the document cannot be acted upon from theSAPoffice interface. Processing must be carried out outside SAPofficevia the API function module SO_DOCUMENT_SET_STATUS_API1.
                                  • FREE_DEL

                                  • If this flag is set ('X'), the document can also be deleted in otherfolders via the API.
                                    • DOC_SIZE

                                    • Size of the document in bytes. In the case of PC documents, the size ofthe respective file should be entered here, in the case of RAW and SCRdocuments, the size is calculated from the "length of the last line" +"number of remaining lines multiplied by 255".

                                      Export parameters
                                      DOCUMENT_INFO
                                      This structure contains the attributes of the document after it hasbeen created.

                                      • DOC_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.
                                        • OBJECT_ID

                                        • Object ID of the document.
                                          • OBJ_TYPE

                                          • Type of document.
                                            • OBJ_NAME

                                            • Name of document.
                                              • OBJ_DESCR

                                              • Title (short description) of document.
                                                • OBJ_LANGU

                                                • Language of document.
                                                  • OBJ_SORT

                                                  • Sort field of the document. This term can be searched for in theattribute search.
                                                    • CREATOR_ID

                                                    • SAPoffice ID of the creator of the document.
                                                      • CREAT_NAME

                                                      • SAPoffice name of the creator of the document. The SAPoffice name isunique client-wide.
                                                        • CREAT_FNAM

                                                        • Full name of the creator of the document from the address management.
                                                          • CREAT_DATE

                                                          • Date document was created.
                                                            • CREAT_TIME

                                                            • Time document was created.
                                                              • CHANGE_ID

                                                              • SAPoffice ID of person who last changed the document.
                                                                • CHANG_NAME

                                                                • SAPoffice name of person who last changed the document. The SAPofficename is unique client-wide.
                                                                  • CHANG_FNAM

                                                                  • Full name of the person who last changed the document from the addressmanagement.
                                                                    • CHANG_DATE

                                                                    • Date of last change.
                                                                      • CHANG_TIME

                                                                      • Time of last change.
                                                                        • OWNER_ID

                                                                        • SAPoffice ID of the owner of the document.
                                                                          • OWNER_NAM

                                                                          • SAPoffice name of the owner of the document. The SAPoffice name isunique client-wide.
                                                                            • OWNER_FNAM

                                                                            • Full name of the owner of the document from the address management.
                                                                              • LAST_ACCES

                                                                              • Date document was created/changed. Contains the latest of the twovalues.
                                                                                • OBJ_EXPDAT

                                                                                • Expiration date of the document. The document itself cannot expire,however this date is used for the expiration date of the entry (fieldEXPIRY_DAT) for each new folder entry of the document.
                                                                                  • SENSITIVTY

                                                                                  • Sensitivity of the document.
                                                                                    A private document can have the following sensitivity:
                                                                                    'O' : standard, normal sensitivity
                                                                                    'F' : functional, can be forwarded functionally
                                                                                    'P' : confidential, not visible to substitute
                                                                                    Only the sensitivity 'O' is allowed for documents in the sharedfolders.
                                                                                    • OBJ_PRIO

                                                                                    • Recipient priority. The document itself does not have a priority,however this value is used for the recipient priority of the entry(field PRIORITY) for each new folder entry of the document.
                                                                                      • NO_CHANGE

                                                                                      • If this flag is set ('X'), the document can only be changed by theauthor in the case of shared folder entries. In the case of privatefolder entries, the author can also make changes after the document hasbeen sent.
                                                                                        • PRIORITY

                                                                                        • Recipient priority of the folder entry. This value represents theimportance assigned to the entry by the owner after it has beenreceived.
                                                                                          • HISTORY

                                                                                          • If this flag is set ('X'), the document has a correspondence history.
                                                                                            • RESUB

                                                                                            • If this field is not initial (not ' '), the folder entry is aresubmitted document.
                                                                                              • RESUB_DATE

                                                                                              • Date of the resubmission.
                                                                                                • SENDER_ID

                                                                                                • If the document was sent internally, this field contains the SAPofficeID of the sender, if it was received from an external source, theaddress ID of the sender is entered.
                                                                                                  • SEND_NAM

                                                                                                  • If the document was sent internally, this field contains the SAPofficename of the sender, if it was received from an external source, thename of the address ID of the sender is entered.
                                                                                                    • SEND_FNAM

                                                                                                    • If the document was sent internally, this field contains the full nameof the sender from the address management. In the case of documentsreceived externally, a description of the address of the sender, whichshould be as precise as possible, is inserted.
                                                                                                      • SEND_DATE

                                                                                                      • Date of the send operation.
                                                                                                        • SEND_TIME

                                                                                                        • Time of the send operation.
                                                                                                          • FORWARD_ID

                                                                                                          • SAPoffice ID of the forwarder of the document.
                                                                                                            • FORW_NAM

                                                                                                            • SAPoffice name of the forwarder of the document. The SAPoffice name isunique client-wide.
                                                                                                              • FORW_FNAM

                                                                                                              • Full name of the forwarder of the document from the address management.
                                                                                                                • FORW_DATE

                                                                                                                • Forwarding date.
                                                                                                                  • FORW_TIME

                                                                                                                  • Forwarding time.
                                                                                                                    • REC_ID

                                                                                                                    • If the document was sent internally, this field contains the SAPofficeID of the recipient, if it was sent externally, the address ID of therecipient is entered.
                                                                                                                      • REC_NAM

                                                                                                                      • If the document was sent internally, this field contains the SAPofficename of the recipient, if it was sent externally, the name of theaddress ID of the recipient is entered.
                                                                                                                        • REC_FNAM

                                                                                                                        • If the document was sent internally, this field contains the full nameof the recipient from the address management. In the case of documentssent externally, a description of the address of the recipient isentered.
                                                                                                                          • REC_DATE

                                                                                                                          • Date document was received.
                                                                                                                            • REC_TIME

                                                                                                                            • Time document was received.
                                                                                                                              • EXPRESS

                                                                                                                              • If this flag is set ('X'), the document was received with the attribute'express'.
                                                                                                                                • COPY

                                                                                                                                • If this flag is set ('X'), the document was received with the attribute'copy'.
                                                                                                                                  • BLIND_COPY

                                                                                                                                  • If this flag is set ('X'), the document was received with the attribute'blind copy'. As a result, it cannot be printed nor forwarded.
                                                                                                                                    • NO_FORWARD

                                                                                                                                    • If this flag is set ('X'), the document cannot be forwarded by therecipient.
                                                                                                                                      • NO_PRINT

                                                                                                                                      • If this flag is set ('X'), the document cannot be printed by therecipient.
                                                                                                                                        • TO_ANSWER

                                                                                                                                        • If this flag is set ('X'), the recipient must reply to the documentbefore the relevant folder entry can be removed from the inbox.
                                                                                                                                          • TO_DO_EXPL

                                                                                                                                          • If this flag is set ('X'), the recipient must take action on thedocument before the relevant folder entry can be removed from theinbox.
                                                                                                                                            • TO_DO_GRP

                                                                                                                                            • If this field has a value between '1' and '9', one user from therecipient group formed by this number must take action on the documentbefore the relevant folder entry can be removed from the one of theinboxes involved. If the value '0' is entered, no action is required.
                                                                                                                                              • C_TO_DO

                                                                                                                                              • Number of recipients who must take action on the document.
                                                                                                                                                • C_IN_PROC

                                                                                                                                                • Number of recipients who have accessed the document for processing.
                                                                                                                                                  • C_DONE

                                                                                                                                                  • Number of recipients who have taken action on the document.
                                                                                                                                                    • C_EXPRESS

                                                                                                                                                    • Number of recipients who have received the document with the 'express'attribute.
                                                                                                                                                      • C_COPY

                                                                                                                                                      • Number of recipients who have received the document with the attribute'copy'.
                                                                                                                                                        • C_BLIND_CP

                                                                                                                                                        • Number of recipients who have received the document with the attribute'blind copy'.
                                                                                                                                                          • C_TO_REPLY

                                                                                                                                                          • Number of recipients who must reply to the document.
                                                                                                                                                            • C_ANSWERED

                                                                                                                                                            • Number of recipients who have replied to the document.
                                                                                                                                                              • C_READ

                                                                                                                                                              • Number of recipients who have viewed the document.
                                                                                                                                                                • C_RECEIVER

                                                                                                                                                                • Number of persons who have received the document visibly to allrecipients. To obtain the complete number of recipients, the number ofblind copies in C_BLIND_CP must be added to this number.
                                                                                                                                                                  • PROC_TYPE

                                                                                                                                                                  • If this field is not initial (not ' '), the document can be processed.
                                                                                                                                                                    The following values are possible:
                                                                                                                                                                    'D' : dialog module
                                                                                                                                                                    'F' : function module
                                                                                                                                                                    'R' : report
                                                                                                                                                                    'S' : report with value transfer to global memory
                                                                                                                                                                    'T' : transaction
                                                                                                                                                                    'U' : transaction with value transfer to global memory
                                                                                                                                                                    • PROC_NAME

                                                                                                                                                                    • Processing element. Depending on the entry in the field PROC_TYPE, thename of the dialog module, function module, report, or transaction isspecified.
                                                                                                                                                                      • PROC_SYST

                                                                                                                                                                      • Name of the system in which the document is to be processed. If nosystem is specified or the value '*', processing can be carried out inany system.
                                                                                                                                                                        • PROC_CLINT

                                                                                                                                                                        • Client in which the document is to be processed. If no client isspecified or the value '*', processing can be carried out in anyclient.
                                                                                                                                                                          • SKIP_SCREN

                                                                                                                                                                          • If this flag is set ('X'), the first screen is skipped in theprocessing.
                                                                                                                                                                            • TO_DO_OUT

                                                                                                                                                                            • If this flag is set ('X'), the document cannot be acted upon from theSAPoffice interface. Processing must be carried out from SAPoffice viathe API function module SO_DOCUMENT_SET_STATUS_API1.
                                                                                                                                                                              • FREE_DEL

                                                                                                                                                                              • If this flag is set ('X'), the document can also be deleted in otherfolders via the API.
                                                                                                                                                                                • READ

                                                                                                                                                                                • If the folder entry is a received document and this flag is set ('X'),it has already been read.
                                                                                                                                                                                  • READ_DATE

                                                                                                                                                                                  • Date when the document was read.
                                                                                                                                                                                    • READ_TIME

                                                                                                                                                                                    • Time when the document was read.
                                                                                                                                                                                      • TO_DO_STAT

                                                                                                                                                                                      • Status of the folder entry regarding action to be taken.
                                                                                                                                                                                        The following values are possible:
                                                                                                                                                                                        'TAAC' : Still ToDo
                                                                                                                                                                                        'INPR' : In process
                                                                                                                                                                                        'ACCO' : Done
                                                                                                                                                                                        • STILL_TODO

                                                                                                                                                                                        • If this flag is set ('X'), the folder entry still needs to be actedupon.
                                                                                                                                                                                          • REPLY_SENT

                                                                                                                                                                                          • If this flag is set ('X'), the folder entry has already been repliedto.
                                                                                                                                                                                            • RESUB_READ

                                                                                                                                                                                            • If this flag is set ('X'), the folder entry is a viewed resubmitteddocument.
                                                                                                                                                                                              • EXPIRY_DAT

                                                                                                                                                                                              • Expiration date of the folder entry. When the expiration date has beenreached or exceeded, the entry is placed in the private trash and canbe retrieved from there if necessary before the trash is next emptied.A new folder entry is initially provided with the expiration date ofthe document from the field OBJ_EXPDAT.
                                                                                                                                                                                                • DOC_SIZE

                                                                                                                                                                                                • Size of the document in bytes.

                                                                                                                                                                                                  Table parameters
                                                                                                                                                                                                  OBJECT_HEADER
                                                                                                                                                                                                  This table must contain the data dependent on the document type. Forexample, SAPscript documents have information on the layout set andstyle, Excel list viewer documents the number of lines and columns, andPC documents their original file names.

                                                                                                                                                                                                  • LINE

                                                                                                                                                                                                  • Requires the type-dependent information of the document by the line.
                                                                                                                                                                                                    OBJECT_CONTENT
                                                                                                                                                                                                    This table must contain the actual contents of the document.
                                                                                                                                                                                                    • LINE

                                                                                                                                                                                                    • Requires the contents of the document by the line.
                                                                                                                                                                                                      OBJECT_PARA
                                                                                                                                                                                                      This table is only used by documents which are to be processed. It mustcontain the SET/GET parameters which are passed to the processingelement.
                                                                                                                                                                                                      • NAME

                                                                                                                                                                                                      • Name of the SET/GET parameter. Only the first three characters areused.
                                                                                                                                                                                                        • OPTION

                                                                                                                                                                                                        • This field is not used.
                                                                                                                                                                                                          • LOW

                                                                                                                                                                                                          • Requires the relevant value of the parameter in NAME.
                                                                                                                                                                                                            • HIGH

                                                                                                                                                                                                            • This field is not used.
                                                                                                                                                                                                              OBJECT_PARB
                                                                                                                                                                                                              This table is only used by documents which have been assigned aparticular processing type. Depending on this, they have a differentmeaning. If the processing element is a report or transaction withvalue transfer to the global memory, the table contents are interpretedas a set of parameters with related values and exported to the memoryID derived from the first line. If the processing element is a functionor dialog module, the table is passed to it as the table parameterMSGDIAL.
                                                                                                                                                                                                              • NAME

                                                                                                                                                                                                              • If the processing element is a report or transaction with valuetransfer to the global memory, the field of the first table line mustcontain the name of the memory ID used for the export. The fields ofthe other lines are used to contain the names of the parameters. If theprocessing element is a function or dialog module, the fields must beassigned values appropriately according to the use.
                                                                                                                                                                                                                • VALUE

                                                                                                                                                                                                                • If the processing element is a report or transaction with valuetransfer to the global memory, the field of the first table line mustremain blank. The fields of the other lines are used to contain thevalues for the parameters in NAME. If the processing element is afunction or dialog module, the fields must be assigned valuesappropriately according to the use.

                                                                                                                                                                                                                  Exceptions
                                                                                                                                                                                                                  FOLDER_NOT_EXIST
                                                                                                                                                                                                                  The specified folder does not exist. An incorrect ID was probablytransferred or the relevant folder deleted.
                                                                                                                                                                                                                  DOCUMENT_TYPE_NOT_EXIST
                                                                                                                                                                                                                  The specified document type does not exist or is not allowed.
                                                                                                                                                                                                                  OPERATION_NO_AUTHORIZATION
                                                                                                                                                                                                                  The specified document could not be created. This may be because it wasto be created in the private area of another user or in a shared folderfor which the active user does not have a create authorization.
                                                                                                                                                                                                                  PARAMETER_ERROR
                                                                                                                                                                                                                  An invalid combination of parameter values was passed to the functionmodule. This may be because an invalid value was passed as thepriority, sensitivitiy, or processing parameter. In some areas (inbox,resubmissions, trash) it is also not possible to create documents.
                                                                                                                                                                                                                  ENQUEUE_ERROR
                                                                                                                                                                                                                  The specified folder could not be locked. Processing is probably beingcarried out by another user.

                                                                                                                                                                                                                  Example
                                                                                                                                                                                                                  A private document is created in the outbox of the active user. The IDof the outbox is determined via the function module SO_USER_READ_API1.
                                                                                                                                                                                                                  DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
                                                                                                                                                                                                                  DATA: USER_DATA LIKE SOUDATAI1.
                                                                                                                                                                                                                  DATA: DOC_CHNG LIKE SODOCCHGI1.
                                                                                                                                                                                                                  DATA: ENTRIES LIKE SY-TABIX.
                                                                                                                                                                                                                  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.
                                                                                                                                                                                                                  DOC_CHNG-OBJ_NAME = 'PRIVAT'.
                                                                                                                                                                                                                  DOC_CHNG-OBJ_DESCR = 'My private document'.
                                                                                                                                                                                                                  DOC_CHNG-LANGU = SY_LANGU.
                                                                                                                                                                                                                  DOC_CHNG-SENSITIVTY = 'P'.
                                                                                                                                                                                                                  OBJCONT = 'All created myself !'.
                                                                                                                                                                                                                  APPEND OBJCONT.
                                                                                                                                                                                                                  OBJCONT = 'No one else has access to it !'.
                                                                                                                                                                                                                  APPEND OBJCONT.
                                                                                                                                                                                                                  DESCRIBE TABLE OBJCONT LINES ENTRIES.
                                                                                                                                                                                                                  READ TABLE OBJCONT INDEX ENTRIES.
                                                                                                                                                                                                                  DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
                                                                                                                                                                                                                  CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'
                                                                                                                                                                                                                  EXPORTING
                                                                                                                                                                                                                  FOLDER_ID = USER_DATA-OUTBOXFOL
                                                                                                                                                                                                                  DOCUMENT_TYPE = 'RAW'
                                                                                                                                                                                                                  DOCUMENT_DATA = DOC_CHNG
                                                                                                                                                                                                                  TABLES
                                                                                                                                                                                                                  OBJECT_CONTENT = OBJCONT
                                                                                                                                                                                                                  EXCEPTIONS
                                                                                                                                                                                                                  OTHERS = 1.
                                                                                                                                                                                                                  CASE SY-SUBRC.
                                                                                                                                                                                                                  WHEN 0.
                                                                                                                                                                                                                  WRITE: / 'Document created !'.
                                                                                                                                                                                                                  WHEN 1.
                                                                                                                                                                                                                  WRITE: / 'Error creating document !'.
                                                                                                                                                                                                                  ENDCASE.

                                                                                                                                                                                                                  Notes
                                                                                                                                                                                                                  To create folders or distribution lists, the function modulesSO_FOLDER_INSERT_API1 or SO_DLI_INSERT_API1 are used.

                                                                                                                                                                                                                  Further information
                                                                                                                                                                                                                  Informatiaon on calling the function module SO_USER_READ_API1 can befound in the documentation of this function module.