Skip to Content
0
Former Member
Jun 26, 2008 at 05:42 PM

SWC - Mails retained in SCOT

236 Views

Hi Everybody!

I have a custom function module (see below) that was working fine in SAP R/3 Release 4.6B. After a technical upgrade to ECC 6.0 the function still works but all messages generated are retained in SCOT and should be "Pushed" manually.

Is there any atribbute that should be set in this release that was not necessary to do in 4.6B?

Thanks in advance.

Regards,

Mariana

FUNCTION Z_MAIL_SEND_MESSAGE.

*"----


""Interfase local

*" IMPORTING

*" REFERENCE(P_AUTOR) LIKE SOXNA-FULLNAME

*" REFERENCE(P_TYPEID) TYPE SO_ESCAPE DEFAULT 'U'

*" REFERENCE(P_TITULO) TYPE SO_TEXT255

*" REFERENCE(P_DOCUMENTPRIORITY) TYPE CHAR1 DEFAULT '1'

*" REFERENCE(P_DOCUMENTSENSITIVITY) TYPE CHAR1 DEFAULT 'C'

*" REFERENCE(P_DOCUMENTTYPE) TYPE SO_OBJ_TP DEFAULT 'RAW'

*" TABLES

*" TB_DEST STRUCTURE ZMAILDEST

*" TB_TEXT STRUCTURE SOLI OPTIONAL

*" TB_ATTACH TYPE ZMAIL_TT_ATTACHS OPTIONAL

*" EXCEPTIONS

*" ERROR_CREATE_OBJECT

*" ERROR_CREATE_MESSAGE

*" ERROR_INSERT_ATTACH

*" NO_DEST

*"----


DATA: L_RECIPIENT TYPE SWC_OBJECT,

L_MESSAGE TYPE SWC_OBJECT,

L_OBJKEY LIKE SWOTOBJID-OBJKEY,

L_NAME LIKE ST_MAIL-NAME.

DATA: WA_ITEM LIKE SOLI.

SWC_CONTAINER LT_CONTAINER.

IF TB_DEST[] IS INITIAL.

RAISE NO_DEST.

ENDIF.

  • Create empty object

SWC_CREATE_OBJECT L_MESSAGE 'MESSAGE' SPACE.

IF SY-SUBRC <> 0.

RAISE ERROR_CREATE_OBJECT.

ENDIF.

  • Complete attributes for Message Object

SWC_SET_ELEMENT LT_CONTAINER 'DOCUMENTTITLE' P_TITULO.

SWC_SET_ELEMENT LT_CONTAINER 'DOCUMENTLANGU' SY-LANGU.

SWC_SET_ELEMENT LT_CONTAINER 'DOCUMENTPRIORITY' P_DOCUMENTPRIORITY.

SWC_SET_ELEMENT LT_CONTAINER 'DOCUMENTSENSITIVITY'

P_DOCUMENTSENSITIVITY.

SWC_SET_ELEMENT LT_CONTAINER 'NO_DIALOG' 'X'.

SWC_SET_ELEMENT LT_CONTAINER 'DOCUMENTTYPE' P_DOCUMENTTYPE.

SWC_SET_TABLE LT_CONTAINER 'DocumentContent' TB_TEXT.

SWC_CALL_METHOD L_MESSAGE 'Create' LT_CONTAINER.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING ERROR_CREATE_MESSAGE.

ENDIF.

  • Create sender address

PERFORM GET_SENDER_ADDR USING P_AUTOR L_NAME.

SWC_CLEAR_CONTAINER LT_CONTAINER.

SWC_CREATE_OBJECT L_RECIPIENT 'RECIPIENT' SPACE.

SWC_SET_ELEMENT LT_CONTAINER 'AddressString' L_NAME.

SWC_SET_ELEMENT LT_CONTAINER 'TypeId' P_TYPEID.

SWC_SET_ELEMENT LT_CONTAINER 'CommunicationType' 'MAIL'.

SWC_CALL_METHOD L_RECIPIENT 'CreateAddress' LT_CONTAINER.

  • Add sender to message object

SWC_CLEAR_CONTAINER LT_CONTAINER.

SWC_SET_ELEMENT LT_CONTAINER 'Sender' L_RECIPIENT.

SWC_CALL_METHOD L_MESSAGE 'SetNextSender' LT_CONTAINER.

SWC_FREE_OBJECT L_RECIPIENT.

  • remember object

SWC_GET_OBJECT_KEY L_MESSAGE L_OBJKEY.

  • Create destination addresses

LOOP AT TB_DEST.

SWC_CLEAR_CONTAINER LT_CONTAINER.

SWC_CREATE_OBJECT L_RECIPIENT 'RECIPIENT' SPACE.

SWC_SET_ELEMENT LT_CONTAINER 'AddressString' TB_DEST-MAIL.

SWC_SET_ELEMENT LT_CONTAINER 'TypeId' TB_DEST-TYPEID.

SWC_SET_ELEMENT LT_CONTAINER 'CommunicationType' 'MAIL'.

SWC_CALL_METHOD L_RECIPIENT 'CreateAddress' LT_CONTAINER.

SWC_CLEAR_CONTAINER LT_CONTAINER.

SWC_SET_ELEMENT LT_CONTAINER 'NewRecipient' L_RECIPIENT.

SWC_CALL_METHOD L_MESSAGE 'AddCopyOfRecipient' LT_CONTAINER.

SWC_FREE_OBJECT L_RECIPIENT.

ENDLOOP.

SWC_CALL_METHOD L_MESSAGE 'Save' LT_CONTAINER.

  • SWC_CLEAR_CONTAINER LT_CONTAINER.

  • Add attachments to message...

LOOP AT TB_ATTACH.

PERFORM INSERT_ATTACHMENTS TABLES LT_CONTAINER USING TB_ATTACH.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING ERROR_INSERT_ATTACH.

ENDIF.

  • SWC_CLEAR_CONTAINER LT_CONTAINER.

  • SWC_SET_ELEMENT LT_CONTAINER 'ATTACHMENT' TB_ATTACH-ITEM.

  • SWC_SET_ELEMENT LT_CONTAINER 'ATTACHMENTTITLE' TB_ATTACH-OBJDES.

  • SWC_SET_ELEMENT LT_CONTAINER 'AttachmentType' TB_ATTACH-TYPE.

*

  • SWC_CALL_METHOD L_MESSAGE 'Attach' LT_CONTAINER.

ENDLOOP.

SWC_CLEAR_CONTAINER LT_CONTAINER.

  • Send message

SWC_CALL_METHOD L_MESSAGE 'Submit' LT_CONTAINER.

ENDFUNCTION.