Register Login

SO_ NEW_ DOCUMENT_ SEND_API1 Example Reports

Updated May 18, 2018

Some examples of the use of SO_NEW_DOCUMENT_SEND_API1


REPORT YHRPHI02.
*---------------------------------------------------------------------*
* Test for send mail *
* Philippe.c *
*---------------------------------------------------------------------*
PARAMETERS: TEXT(10).
DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1,
ENTRIES LIKE SY-TABIX.

DATA: BEGIN OF OBJECT_PARA OCCURS 2.
INCLUDE STRUCTURE SOPARAI1.
DATA: END OF OBJECT_PARA.

PERFORM MAIL_ONLY.
*erform mail_call_transaction.
*erform mail_call_report.
*---------------------------------------------------------------------*
* FORM MAIL_ONLY *

*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM MAIL_ONLY.
* fill the document
DOC_CHNG-OBJ_NAME = 'URGENT'.
DOC_CHNG-OBJ_DESCR = 'Test SAP MAPI'.
DOC_CHNG-SENSITIVTY = 'P'.
DOC_CHNG-PROC_SYST = 'TST'.
DOC_CHNG-PROC_CLINT = '010'.

* message
OBJCONT = 'Ex changement des tapes'.
APPEND OBJCONT.
OBJCONT = 'demain !!!'.
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
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = ' '.
RECLIST-RECEIVER = 'CHC'.
APPEND RECLIST.
* reclist-receiver = 'CHC'.
* 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.
ENDFORM.
*---------------------------------------------------------------------*
* FORM MAIL_CALL_TRANSACTION *

*---------------------------------------------------------------------*
FORM MAIL_CALL_TRANSACTION.
* fill the document
DOC_CHNG-OBJ_NAME = 'URGENT'.
DOC_CHNG-OBJ_DESCR = 'Read at once !'.
DOC_CHNG-SENSITIVTY = 'P'.
DOC_CHNG-PROC_TYPE = 'T'.
DOC_CHNG-PROC_NAME = 'PA30'.
DOC_CHNG-PROC_SYST = SY-SYSID.
DOC_CHNG-PROC_CLINT = SY-MANDT.

OBJECT_PARA-NAME = 'PER'.
OBJECT_PARA-LOW = '00008515'.
APPEND OBJECT_PARA.

OBJCONT = 'Please, Check this person !!!'.
APPEND OBJCONT.
OBJCONT = 'Is it correct !'.
APPEND OBJCONT.
OBJCONT = TEXT.
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
RECLIST-EXPRESS = 'X'.
RECLIST-RECEIVER = 'EXT04'.
RECLIST-REC_TYPE = ' '.
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
OBJECT_PARA = OBJECT_PARA
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-RETRN_CODE = 0.
* write: / reclist-receiver, ': Message sended'.
ELSE.
* write: / reclist-receiver, ': Message not sended'.
ENDIF.
ENDLOOP.
WHEN 1.

WRITE: / 'too_many_receivers !'.
WHEN 2.
WRITE: / 'document_not_sent !'.
WHEN 4.
WRITE: / 'operation_no_authorization !'.
WHEN OTHERS.
WRITE: / 'Error unknown !'.
ENDCASE.
ENDFORM.
*---------------------------------------------------------------------*
* FORM MAIL_CALL_REPORT *
*---------------------------------------------------------------------*
FORM MAIL_CALL_REPORT.
INCLUDE .
OBJCONT = ' Please, check the log. '.
APPEND OBJCONT.
CONCATENATE ICON_EXECUTE_OBJECT
'Choose ''Execute'' to display the log of the TA'
INTO OBJCONT SEPARATED BY SPACE.
APPEND OBJCONT.
DOC_CHNG-OBJ_NAME = 'URGENT'.
DOC_CHNG-OBJ_DESCR = TEXT.
DOC_CHNG-SENSITIVTY = 'P'.
DOC_CHNG-PROC_SYST = SY-SYSID.

DOC_CHNG-PROC_CLINT = SY-MANDT.
DESCRIBE TABLE OBJCONT LINES ENTRIES.
READ TABLE OBJCONT INDEX ENTRIES.
DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
DOC_CHNG-PROC_TYPE = 'R'.
OBJECT_PARA-NAME = 'KOR'.
OBJECT_PARA-LOW = 'DEVK901000'.
APPEND OBJECT_PARA.
DOC_CHNG-PROC_NAME = 'YHIMPOR4'.
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = 'X'.
RECLIST-RECEIVER = 'PHILIPPEC'.
APPEND RECLIST.
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = 'X'.
RECLIST-RECEIVER = 'PHIL'.
APPEND RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_TYPE = 'RAW'
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ' '
TABLES
OBJECT_CONTENT = OBJCONT
OBJECT_PARA = OBJECT_PARA
RECEIVERS = RECLIST.
ENDFORM.


×