SAP Function SO_NEW_DOCUMENT_SEND_API1 - SAPoffice: Send new document

Parameter Reference Type Length Default Optional Text
COMMIT_WORK SONV-FLAG C 1 SPACE X An explicit commit work is to occur at end
DOCUMENT_DATA SODOCCHGI1 u 152 Attributes of new document
DOCUMENT_TYPE SOODK-OBJTP C 3 'RAW' X Document type
PUT_IN_OUTBOX SONV-FLAG C 1 SPACE X Flag: Move document to outbox after send

Parameter Reference Type Length Text
NEW_OBJECT_ID SOFOLENTI1-OBJECT_ID C 17 ID of created object (not document)
SENT_TO_ALL SONV-FLAG C 1 Flag: Document sent to all

Parameter Reference Length Optional Text
CONTENTS_HEX SOLIX 255 X Document contents (binary)
OBJECT_CONTENT SOLISTI1 255 X Document Content
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
RECEIVERS SOMLRECI1 1367 Document recipients with send attributes

Exception Text
DOCUMENT_NOT_SENT Document not sent to any recipients
DOCUMENT_TYPE_NOT_EXIST Unknown object type
ENQUEUE_ERROR Required locks could not be set
OPERATION_NO_AUTHORIZATION No authorization to send/create
PARAMETER_ERROR Invalid combination of parameter values
TOO_MANY_RECEIVERS Too many recipients, no authorization
X_ERROR Internal error or database inconsistency

Functionality
This function module enables you to send a new document, which has notyet been created, internally and externally. During the send processthe document is created, along with the attributes and content that areto be transferred.

Import parameters
DOCUMENT_TYPE
Default = 'RAW'.
Document class. All classes are possible except for folders ('FOL') anddistributions lists ('DLI').
PUT_IN_OUTBOX
Default = ' '.
If this flag is activated ('X'), the newly created document is alsoplaced in the outbox of the active user when it is sent.
DOCUMENT_DATA
This structure must contain the attributes of the document to be sent.

  • OBJ_NAME

  • Name of document.
    • OBJ_DESCR

    • Title (short description) of document.
      • OBJ_LANGU

      • Language of document.
        • OBJ_SORT

        • Sort field of document. You can search for this term using attributesearch.
          • OBJ_EXPDAT

          • Expiry date of document. The document itself cannot expire, but eachtime the document is entered in a folder, this date is used as thedefault for the expiry date of the entry (field EXPIRY_DAT).
            • SENSITIVTY

            • Document sensitivity.
              A private document can have the following levels of sensitivity:
              'O' : Standard, normal sensitivity
              'F' : Functional, can be forwarded functionally
              'P' : Confidential, not visible to substitutes
              For documents in shared folders, only sensitivity level 'O' ispermitted.
              • OBJ_PRIO

              • Recipient priority. The document itself does not have a priority level,but each time the document is entered in a folder, this value is usedas the default for recipient priority for the entry (field PRIORITY).
                • NO_CHANGE

                • If this flag is activated ('X'), documents in shared folders can onlybe changed by the author. The author can change documents in privatefolders after they have been sent.
                  • PRIORITY

                  • Recipient priority for the folder entry. This value gives the priority,which was assigned to the document by the owner, after receipt.
                    • EXPIRY_DAT

                    • Expiry date of the folder entry. When the expiry date has been reachedor passed, the entry is placed in private trash and can be retrievedfrom there if needed, up until the next time the trash is emptied. Anew folder entry is initially given the expiry date of the documentfrom field OBJ_EXPDT.
                      • PROC_TYPE

                      • If this field does not contain the default value (default is ' '), thedocument can be processed.
                        The following entries are permitted:
                        'D' : Dialog module
                        'F' : Function module
                        'R' : Report
                        'S' : Report with transfer of values to global memory
                        'T' : Transaction
                        'U' : Transaction with transfer of values to global memory
                        • PROC_NAME

                        • Processing element. You must enter the name of the dialog module,function module, report or transaction in accordance with the entry inthe field PROC_TYPE.
                          • PROC_SYST

                          • Name of sytem in which the document is to be processed. If no system isspecified or '*' is entered, processing is possible in all systems.
                            • PROC_CLINT

                            • Client in which the document is to be processed. If no client isspecified or '*' is entered, processing is possible in all clients.
                              • SKIP_SCREN

                              • If this flag is activated ('X'), the first screen is skipped duringprocessing.
                                • TO_DO_OUT

                                • If this flag is activated ('X'), the document cannot be processed fromthe SAPoffice interface. You must use the API function moduleSO_DOCUMENT_SET_STATUS_API1.
                                  • FREE_DEL

                                  • If this flag is activated ('X'), you can delete the document fromexternal folders using the API.
                                    • DOC_SIZE

                                    • Size of the document in bytes. For PC documents, the size of therelevant file should be entered, for RAW and SCR documents the size isthe "length of the last line" + "number of other lines multiplied by255".

                                      Export parameters
                                      NEW_OBJECT_ID
                                      Object ID of the document created during the send process.
                                      SENT_TO_ALL
                                      If this flag is activated ('X'), the document was sent to all specifiedrecipients or, in the case of external forwarding, the correspondingsend requests were delivered to the subsystem. If sending or deliveryfailed in one or more cases, the flag is not activated.

                                      Table parameters
                                      OBJECT_HEADER
                                      This table must contain the document class-relevant data. For example,SAPscript documents store information here about forms and styles,Excel list viewer documents store, amongst other things, the number ofrows and columns and PC documents store their original file names.

                                      • LINE

                                      • Requires class-relevant document information line by line.
                                        OBJECT_CONTENT
                                        This table must contain the actual content of the document.
                                        • LINE

                                        • Requires the content of the document line by line.
                                          OBJECT_PARA
                                          This table is used only by documents that are to be processed. It mustcontain the SET/GET parameter that is transferred 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 value of the parameter in NAME.
                                                • HIGH

                                                • This field is not used.
                                                  OBJECT_PARB
                                                  This table is only used by documents to which a particular processingtype is assigned. The meaning of the table depends on the processingtype. If the processing element is a report, or transaction withtransfer of values to the global memory, the table content isinterpreted as the quantity of parameters with the relevant values andexported to the memory ID taken from the first row. If the processingelement is a function module or a dialog module, the table istransferred to this as table parameter MSGDIAL.
                                                  • NAME

                                                  • If the processing element is a report or a transaction with transfer ofvalues to the global memory, the field of the first row of the tablemust contain the name of the memory ID used for the export. The fieldsof the other rows accommodate the parameter names. If the processingelement is a function module or a dialog module, the fields mustcontain values corresponding to the use of the module.
                                                    • VALUE

                                                    • If the processing element is a report or a transaction with transfer ofvalues to the global memory, the field for the first row of the tablemust remain empty. The fields for the other rows accommodate the valuesbelonging to the parameters in NAME. If the processing element is afunction or dialog module, the fields must contain values correspondingto the use of the modules.
                                                      RECEIVERS
                                                      This table must contain the document recipients.
                                                      • RECEIVER

                                                      • Name of recipient.
                                                        The following entry categories are possible:
                                                        SAP user name of the recipient
                                                        SAPoffice name of the recipient
                                                        Shared distribution list
                                                        Fax number in the form of structure SADRFD
                                                        Internet address in the form of structure SADRUD
                                                        Remote SAP name in the form of structure SADR7D
                                                        X.400 address in the form of structure SADR8D
                                                        • ADR_TYPE

                                                        • Type of RECEIVER entry.
                                                          The following values are permitted:
                                                          'B' : SAP user name
                                                          ' ' : SAPoffice name
                                                          'C' : Shared distribution list
                                                          'F' : Fax number
                                                          'U' : Internet address
                                                          'R ' : Remote SAP name
                                                          'X' : X.400 address
                                                          • REC_ID

                                                          • If the recipient is a SAPoffice user, the user ID, instead of therecipient name in RECEIVER, can be entered in this field.
                                                            • REPLY_DOC

                                                            • If there is a value in this field, the document is a reply to thefolder entry identified by the specified ID. A correspondence historyis automatically created/continued.
                                                              • REC_DATE

                                                              • The date on which the document is to reach the recipient. This datecannot be guaranteed for external recipients as it depends on connectedproducts.
                                                                • PROXY_ID

                                                                • If automatic forwarding is active in the recipient's system, this fieldcontains the SAP user ID or the address ID of the external address towhich the document was ultimately sent.
                                                                  • RETRN_CODE

                                                                  • When the recipient has received the document, the function moduleenters the value '0' in this field. If the document is not successfullyreceived, a value unequal to '0' is entered in the field.
                                                                    • EXPRESS

                                                                    • If this flag is activated ('X'), the document is sent with theattribute 'express'. If the recipient is a SAPoffice user who is loggedon, he or she receive a message immediately, saying that he or she hasreceived an express mail.
                                                                      • COPY

                                                                      • If this flag is activated ('X'), the document is sent with theattribute 'copy'.
                                                                        • BLIND_COPY

                                                                        • If this flag is activated ('X'), the document is sent with theattribute 'secret copy'. If the recipient is a SAPoffice user, he orshe can neither print nor forward the document.
                                                                          • NO_FORWARD

                                                                          • If this flag is activated ('X') and the recipient is a SAPoffice user,he or she cannot forward the document.
                                                                            • NO_PRINT

                                                                            • If this flag is activated ('X') and the recipient is a SAPoffice user,he or she cannot print the document.
                                                                              • TO_ANSWER

                                                                              • If this flag is activated ('X') and the recipient is a SAPoffice user,the user must reply to the document before he or she can delete it fromhis or her inbox.
                                                                                • TO_DO_EXPL

                                                                                • If this flag is activated ('X') and the recipient is a SAPoffice user,the user must process the document before he or she can delete it fromhis or her inbox.
                                                                                  • TO_DO_GRP

                                                                                  • If this field contains a value between '1' and '9', a SAPoffice user inthe recipient group indicated by this number must process the documentbefore the recipients can delete it from their inboxes. If the value'0' is entered, the document does not need to be processed.
                                                                                    • COM_TYPE

                                                                                    • Communication method used to send the document. This field is onlyrelevant if the recipient is an address number, that is, if thedocument is sent externally via address management. If the field isempty, the standard communication type specified in address managementis used.
                                                                                      The following values are permitted:
                                                                                      'INT' : Send via Internet
                                                                                      'FAX' : Send as a fax
                                                                                      'X40' : Send via X.400
                                                                                      'RML' : Send in another SAP system
                                                                                      • LFDNR

                                                                                      • Current number from address management. This field is only relevant ifthe recipient is an address number, that is, if the document is sentvia address management. If the field is empty, the default currentnumber in address management is used.
                                                                                        • FAX

                                                                                        • This field is not used.
                                                                                          • COUNTRY

                                                                                          • This field is not used.
                                                                                            • SPOOL_ID

                                                                                            • This field is not used.
                                                                                              • NOTIF_DEL

                                                                                              • If this flag is activated ('X'), the sender receives confirmation whenthe recipient receives the document. He or she also receives a messageif the document could not be delivered. This flag should only beactivated for external sending, since internal sending is synchronous.Confirmation is only supported by a small number of mail systems,however. For example: X.400 and SAP SAP.
                                                                                                • NOTIF_READ

                                                                                                • If this flag is activated ('X'), the sender is notified as soon as therecipient has read the document. This flag should only be activated forexternal sending, since internal sending is synchronous. Readnotification is only supported by a small number of mail systems,however. For example: X.400 and SAP SAP.
                                                                                                  • NOTIF_NDEL

                                                                                                  • If this flag is activated ('X'), the recipient receives a message ifthe document could not be delivered to the recipient. This flag shouldonly be activated for external sending, since internal sending issynchronous. The message is only supported by a small number of mailsystems, however. For example: X.400 and SAP SAP.
                                                                                                    • SAP_BODY

                                                                                                    • If this flag is activated ('X'), SAP specific data is transferred tothe document in an external body part when sending via X.400. This flagshould only be activated if the target system is an SAP System.

                                                                                                      Exceptions
                                                                                                      TOO_MANY_RECEIVERS
                                                                                                      Too many recipients were specified. The active user does not haveauthorization to send to this number of recipients.
                                                                                                      DOCUMENT_NOT_SENT
                                                                                                      The document could not be sent. It was not delivered to any of thespecified recipients.
                                                                                                      DOCUMENT_TYPE_NOT_EXIST
                                                                                                      The document class specified does not exist or is not permitted.
                                                                                                      OPERATION_NO_AUTHORIZATION
                                                                                                      The document was not allowed to be sent because one of the requiredauthorizations did not exist.
                                                                                                      PARAMETER_ERROR
                                                                                                      The combination of parameter values transferred to the function modulewas not a permitted combination.
                                                                                                      X_ERROR
                                                                                                      Am internal error or a database inconsistency has occurred.
                                                                                                      ENQUEUE_ERROR
                                                                                                      A lock required for the send process could not be set. It is probablethat another user is processing.

                                                                                                      Example
                                                                                                      Sending a confidential RAW document to an internal user and an Internetaddress. The new document is also placed in the sender's outbox.
                                                                                                      DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
                                                                                                      DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
                                                                                                      DATA: DOC_CHNG LIKE SODOCCHGI1.
                                                                                                      DATA: ENTRIES LIKE SY-TABIX.
                                                                                                      DATA: NAME(15).
                                                                                                      * Fill the document
                                                                                                      DOC_CHNG-OBJ_NAME = 'URGENT'.
                                                                                                      DOC_CHNG-OBJ_DESCR = 'Read at once !'.
                                                                                                      DOC_CHNG-SENSITIVTY = 'P'.
                                                                                                      OBJCONT = 'Hey guys, time for lunch !!!'.
                                                                                                      APPEND OBJCONT.
                                                                                                      OBJCONT = 'Lets get going !'.
                                                                                                      APPEND OBJCONT.
                                                                                                      DESCRIBE TABLE OBJCONT LINES ENTRIES.
                                                                                                      READ TABLE OBJCONT INDEX ENTRIES.
                                                                                                      DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
                                                                                                      * Fill the receiver list
                                                                                                      CLEAR RECLIST.
                                                                                                      RECLIST-RECEIVER = SY-UNAME. " replace with <(><<)>login name>
                                                                                                      RECLIST-REC_TYPE = 'B'.
                                                                                                      RECLIST-EXPRESS = 'X'.
                                                                                                      APPEND RECLIST.
                                                                                                      CLEAR RECLIST.
                                                                                                      RECLIST-RECEIVER = 'ned.neighbour@next.door.com'.
                                                                                                      RECLIST-REC_TYPE = 'U'.
                                                                                                      APPEND RECLIST.
                                                                                                      * Send the document
                                                                                                      CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                                                                                                      EXPORTING
                                                                                                      DOCUMENT_TYPE = 'RAW'
                                                                                                      DOCUMENT_DATA = DOC_CHNG
                                                                                                      PUT_IN_OUTBOX = 'X'
                                                                                                      TABLES
                                                                                                      OBJECT_CONTENT = OBJCONT
                                                                                                      RECEIVERS = RECLIST
                                                                                                      EXCEPTIONS
                                                                                                      TOO_MANY_RECEIVERS = 1
                                                                                                      DOCUMENT_NOT_SENT = 2
                                                                                                      OPERATION_NO_AUTHORIZATION = 4
                                                                                                      OTHERS = 99.
                                                                                                      CASE SY-SUBRC.
                                                                                                      WHEN 0.
                                                                                                      LOOP AT RECLIST.
                                                                                                      IF RECLIST-RECEIVER = SPACE.
                                                                                                      NAME = RECLIST-REC_ID.
                                                                                                      ELSE.
                                                                                                      NAME = RECLIST-RECEIVER.
                                                                                                      ENDIF.
                                                                                                      IF RECLIST-RETRN_CODE = 0.
                                                                                                      WRITE: / NAME, ': succesfully sent'.
                                                                                                      ELSE.
                                                                                                      WRITE: / NAME, ': error occured'.
                                                                                                      ENDIF.
                                                                                                      ENDLOOP.
                                                                                                      WHEN 1.
                                                                                                      WRITE: / 'Too many receivers specified !'.
                                                                                                      WHEN 2.
                                                                                                      WRITE: / 'No receiver got the document !'.
                                                                                                      WHEN 4.
                                                                                                      WRITE: / 'Missing send authority !'.
                                                                                                      WHEN OTHERS.
                                                                                                      WRITE: / 'Unexpected error occurred !'.
                                                                                                      ENDCASE.

                                                                                                      Notes
                                                                                                      To send an existing document, you must use the function moduleSO_OLD_DOCUMENT_SEND_API1.
                                                                                                      If the active user is still to be able to process the document after ithas been sent, it must be moved to the outbox when sent using the flagPUT_IN_OUTBOX. You can use the function module SO_FOLDER_READ_API1 toread the contents of the outbox and the object ID to find the documentsent.
                                                                                                      It is not possible to use a user address name as the recipient sincethis may not be unique. To get around this problem, you can use thefunction module SO_NAME_CONVERT_API1. This provides a hit list inresponse to a specified name, for which a dialog is constructed with achoice of required values.