Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAdI for PM notifications

former_member189629
Active Contributor
0 Kudos

Hi All,

I have a requirement to send notification tests (QMEL-QMTXT) as an email to the top managers whenever a Notification is created, either manually (using IW21) or pre-scheduled notifications. Whenever a new notification gets saved, it must go as an external email (non-SAP) to the top managers' ids.

I found the following BAdIs for that object:

IQS0_STATUS_MAINTAIN Control of Changeability of User Status

IWO1_SUBSCREEN_0170 Display Additional Data on Object Screen 0170 PhysicalSample

IWOC_LIST_TUNING Performance Tuning for Lists in PM/CS

IWOC_OBJECTINFO_CHNG Changes to Data of Object Info Screen

NOTIF_AUTHORITY_01 Additional Authorization Checks for the Notification

WOC_FL_DETERMINE Determine Date for Determining Installation Loc. Equi.

1) Which would be the right one to use.?

OR

2) Is there a better/another method to meet the requirement.

Useful answers will be gratefully rewarded

Karthik

Message was edited by:

Karthik

4 REPLIES 4

former_member181962
Active Contributor
0 Kudos

A better way would be to configure an output type which is attached to a print program, which in turn will send mails.

Configuration of output type is done in NACE transaction.

Regards,

Ravi

0 Kudos

Thanks Ravi!

I must check out the possibility of adding an output type. What the functional consultant wanted is, as a user hits the "SAVE" button on creating a notification or a pre-scheduled notification is due on time, an email should be sent to the top managers as they would hardly be logged on to SAP.

0 Kudos

Hi Karthik

U can use BADI or user exit for the purpose. Please find out which is the BADI or Exit that ios getting triggered at the time of document save operation. following are some of the enhancements that are related to PM notification -

IWO10026 , IWO10027 , IWOC0001 , IWOC0002 , IWOC0003 , IWOC0004

Once u have chosen the right BADI / Userexit , than u can us the following peice of code as reference to send the required data as an external mail to the desired recepient.

But the most important point to note in this regards is that, the SMTP port must be configured in the server for flushing the mail out of SAP system to the target Id through the mail server. this configuration is done in transaction SCOT

Refer the following code for sending external mails -

<b>&----


*& Report ZMK_TEST_MAIL *

*& *

&----


*& *

*& *

&----


REPORT ZMK_TEST_MAIL .

parameters: mail_id like ZTARGET_MAIL_ID-MAIL_ID.

parameters: messeg like solisti1.

parameters: subject like sodocchgi1-obj_descr.

data : tab_lines type i.

DATA: objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.

DATA: objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: reclist1 LIKE somlreci1 OCCURS 500 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 500 WITH HEADER LINE.

DATA: itab LIKE somlreci1 OCCURS 50 WITH HEADER LINE."RKU 220802

DATA: doc_chng LIKE sodocchgi1.

CLEAR objtxt.

move 'This is a test mail , on receipt pls make an acknowlegement to' to objtxt.

APPEND objtxt.

clear objtxt.

move ' the following mail id <abcn@xyz.com>' to objtxt.

append objtxt.

MOVE ' ' TO objtxt.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

  • creation of the entry for the compressed document

CLEAR objpack.

objpack-transf_bin = ''.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

APPEND objpack.

doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).

move subject to doc_chng-obj_descr.

doc_chng-obj_prio = 1.

  • recipient Details

CLEAR reclist1.

CLEAR reclist.

REFRESH reclist1.

REFRESH reclist.

reclist1-rec_type = 'U'.

reclist1-com_type = 'INT'.

reclist1-receiver = mail_id.

APPEND reclist1 TO reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

  • object_header = objhead

  • contents_bin = objbin

contents_txt = objtxt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

if sy-subrc = 0.

submit rsconn01 using selection-set 'SAP&CONNECTINT' and return.

endif</b>

hope this helps u .....

Regards

Mukundhan

0 Kudos

hi,

You should use FM 'IWOC_POST_NOTIFICATION'.

In This FM use implicit enhancement  ZI_SND_MAIL_NOTIF_CRT.