Skip to Content

Purpose: Measuring document mail and Notification, if you have put entry from your Measurement Limit.

Application: This process implementation will help to prevent your measure problem occurred for any Equipments.

Step1: Firstly maintain your E-mail id in Equipment master through TC- IE02.

Step2: Maintain your measuring Point data with Measurement Range Limits by IK02.

Step3: Please maintain your all settings (TC- SCOT) from your SAP Server to Email Server by Basis Consultant.

Step4: Please put measuring point entry beyond from measurement limit and save document.

Step5: Check your mail status from TC: SOST/SBWP.

Step6: Please find program which is applied by Technical Consultant but firstly prepare to FS logic with field and table details.

*BREAK-POINT.
DATA: I_BAPI2080_NOTHDRI TYPE STANDARD TABLE OF BAPI2080_NOTHDRI WITH HEADER LINE.
DATA: I_BAPI2080_NOTHDRI2 TYPE STANDARD TABLE OF BAPI2080_NOTHDRE WITH HEADER LINE.
DATA: I_BAPIRET2 TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.

DATA: I_BAPIRET21 TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.

DATA: I_BAPI2080_NOTHDRE TYPE STANDARD TABLE OF BAPI2080_NOTHDRE WITH HEADER LINE.
DATA: I_BAPI2080_NOTFULLTXTI TYPE STANDARD TABLE OF BAPI2080_NOTFULLTXTI WITH HEADER LINE.
DATA: IT_DYNPREAD TYPE STANDARD TABLE OF DYNPREAD,
WA_DYNPREAD
LIKE LINE OF IT_DYNPREAD .

DATA: EQNO(18) TYPE C,
OBNO
(22) TYPE C,
**      MINR TYPE f,”ltp,” DECIMALS 16,
**      MAXR TYPE f,”ltP,” DECIMALS 16,
MINR
(10) TYPE P,” DECIMALS 14,
MAXR
(10) TYPE P,” DECIMALS 14,
DESC
(25) TYPE C.

DATA: MESG TYPE STRING,
NDESC
TYPE STRING,
edesc
type string,
UNIT(3) TYPE C,
FACT
TYPE F.

*****************************************************************************
*                   Data Declaration For E-Mail                             *
*****************************************************************************
DATA:   W_CNT                  TYPE I,
LD_FORMAT
(4)           TYPE C ,“so_obj_tp ,
LD_ATTDESCRIPTION
(40TYPE C ,
LD_ATTFILENAME        
TYPE SO_OBJ_DES ,
V_NAME                
TYPE STRING,
GD_ATTACHMENT_DESC
(22) TYPE C,
GD_CNT                
TYPE I,
GD_SENT_ALL
(1)         TYPE C,
GD_DOC_DATA           
LIKE SODOCCHGI1,
GD_ERROR              
TYPE SYSUBRC.
DATA:   IT_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
IT_CONTENTS
LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_RECEIVERS
LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
IT_ATTACHMENT
LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_MESSAGE
TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0 WITH HEADER LINE.
*************************************************************************************
**data imrg-point type char12.

* create field symbol
FIELDSYMBOLS: <STATUS>,
<TEMP>
.

* Assign value of variable from calling prog to field symbol
ASSIGN (‘(SAPLIMR0)IMRG-POINT’) TO <STATUS>.
ASSIGN (‘(SAPLIMR0)RIMR0-READC’) TO <TEMP>.

SELECT SINGLE  MPOBJ MRMIN MRMAX PTTXT MRNGU FROM IMPTT INTO (OBNO, MINR, MAXR, DESC, UNIT)
WHERE POINT = <STATUS>.

***CALL FUNCTION ‘MC_UNIT_CONVERSION’
***  EXPORTING
****   MATNR                      = ‘ ‘
***    NACH_MEINS                 = UNIT
***    VON_MEINS                  = ‘Pa’
*** IMPORTING
***   UMREF                      = FACT
*** EXCEPTIONS
***   CONVERSION_NOT_FOUND       = 1
***   MATERIAL_NOT_FOUND         = 2
***   NACH_MEINS_MISSING         = 3
***   OVERFLOW                   = 4
***   VON_MEINS_MISSING          = 5
***   OTHERS                     = 6
***          .
***IF SY-SUBRC <> 0.
**** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
****         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
***ENDIF.
DATA: ILOAN TYPE ILOAILOAN,
ADNO
TYPE ILOAADRNR,
EMAIL
TYPE ADR6SMTP_ADDR.

SELECT SINGLE EQUNR  FROM EQUI INTO EQNO WHERE OBJNR = OBNO.
SELECT SINGLE EQKTX FROM EQKT INTO EDESC WHERE EQUNR EQ EQNO AND SPRAS EQ ‘EN’.

SELECT SINGLE ILOAN FROM EQUZ INTO ILOAN WHERE EQUNR EQ EQNO.
SELECT SINGLE ADRNR FROM ILOA INTO ADNO WHERE ILOAN EQ ILOAN.
SELECT SINGLE SMTP_ADDR FROM ADR6 INTO EMAIL WHERE ADDRNUMBER = ADNO.

CONCATENATE ‘Measuring Point’ DESC ‘Notification’ INTO NDESC SEPARATED BY SPACE.

IF ( ( <TEMP> < MINR ) OR ( <TEMP> > MAXR ) ).
* create header data
I_BAPI2080_NOTHDRI
REFOBJECTKEY = SYUNAME.“‘PJAREF’.
I_BAPI2080_NOTHDRI
EQUIPMENT    = EQNO.“‘10000030’.
I_BAPI2080_NOTHDRI
REPORTEDBY   = SYUNAME.“‘PJAREP’.
I_BAPI2080_NOTHDRI
SHORT_TEXT   = NDESC.“‘PJA Short Test from BAPI’.
I_BAPI2080_NOTHDRI
PRIORITY     = ‘1’.

* create header long text
I_BAPI2080_NOTFULLTXTI
OBJTYPE    = ‘QMEL’.
I_BAPI2080_NOTFULLTXTI
FORMAT_COL = ‘U1’.
I_BAPI2080_NOTFULLTXTI
TEXT_LINE  = ‘Long text 1’.
APPEND I_BAPI2080_NOTFULLTXTI.
I_BAPI2080_NOTFULLTXTI
OBJTYPE    = ‘QMEL’.
I_BAPI2080_NOTFULLTXTI
FORMAT_COL = ‘U1’.
I_BAPI2080_NOTFULLTXTI
TEXT_LINE  = ‘Long text 2’.
APPEND I_BAPI2080_NOTFULLTXTI.

CALL FUNCTION ‘BAPI_ALM_NOTIF_CREATE’
EXPORTING
*   EXTERNAL_NUMBER          =
NOTIF_TYPE              
= ‘M1’
NOTIFHEADER             
= I_BAPI2080_NOTHDRI
*   TASK_DETERMINATION       = ‘ ‘
*   SENDER                   =
*   ORDERID                  =
IMPORTING
NOTIFHEADER_EXPORT      
= I_BAPI2080_NOTHDRE
TABLES
*   NOTITEM                  =
*   NOTIFCAUS                =
*   NOTIFACTV                =
*   NOTIFTASK                =
*   NOTIFPARTNR              =
*    longtexts                = i_bapi2080_notfulltxti
*   KEY_RELATIONSHIPS        =
RETURN                   = I_BAPIRET2.

CALL FUNCTION ‘ALM_PM_MAINTNOT_PUTINPROGRESS’
EXPORTING
NUMBER             = I_BAPI2080_NOTHDRENOTIF_NO
*     LANGU              = SY-LANGU
*     LANGUISO           =
*     TESTRUN            = ‘ ‘
*   IMPORTING
*     SYSTEMSTATUS       =
*     USERSTATUS         =
*   TABLES
*     RETURN             =
.
IF SYSUBRC = 0.

CALL FUNCTION ‘BAPI_ALM_NOTIF_SAVE’
EXPORTING
NUMBER            = I_BAPI2080_NOTHDRENOTIF_NO
IMPORTING
NOTIFHEADER      
= I_BAPI2080_NOTHDRI2
* TABLES
*   RETURN            =
.
ENDIF.
if sysubrc = 0.

PERFORM STATUS_UPDATE IN PROGRAM SAPLBSVA.

*  CALL FUNCTION ‘STATUS_UPDATE_TASK_TRIGGER’.

CONCATENATE ‘Measurement Limit Out of Range.                Notification ‘ I_BAPI2080_NOTHDRI2NOTIF_NO ‘Created.’ INTO MESG SEPARATED BY SPACE.

MESSAGE MESG TYPE ‘I’.

*  Code for mail added by Sachin Singhal on 19.12.2012**********************************************
data: mail_text TYPE string.
CONCATENATE ndesc I_BAPI2080_NOTHDRI2NOTIF_NO ‘Created on’ edesc INTO mail_text SEPARATED BY SPACE.

IF eMAIL IS NOT INITIAL.

CONSTANTS:
*    gc_subject TYPE so_obj_des VALUE ‘ABAP Email with CL_BCS’,
gc_raw    
TYPE char03 VALUE ‘RAW’.

DATA:
gc_subject
TYPE so_obj_des,
gv_mlrec        
TYPE so_obj_nam,
gv_sent_to_all  
TYPE os_boolean,
gv_email        
TYPE adr6smtp_addr,
gv_subject      
TYPE so_obj_des,
gv_text         
TYPE bcsy_text,
gr_send_request 
TYPE REF TO cl_bcs,
gr_bcs_exception
TYPE REF TO cx_bcs,
gr_recipient    
TYPE REF TO if_recipient_bcs,
gr_sender       
TYPE REF TO cl_sapuser_bcs,
gr_document     
TYPE REF TO cl_document_bcs.

TRY.
gc_subject
= ndesc.
“Create send request
gr_send_request
= cl_bcs=>create_persistent( ).
“Email FROM…
gr_sender
= cl_sapuser_bcs=>create( syuname ).
“Add sender to send request
CALL METHOD gr_send_request->set_sender
EXPORTING
i_sender
= gr_sender.

“Email TO…
gv_email
= email.
gr_recipient
= cl_cam_address_bcs=>create_internet_address( gv_email ).
“Add recipient to send request
CALL METHOD gr_send_request->add_recipient
EXPORTING
i_recipient
= gr_recipient
i_express  
= ‘X’.

“Email BODY
APPEND MAIL_TEXT TO gv_text.
gr_document
= cl_document_bcs=>create_document(
i_type   
= gc_raw
i_text   
= gv_text
i_length 
= ’12’
i_subject
= gc_subject ).
“Add document to send request
CALL METHOD gr_send_request->set_document( gr_document ).

“Send email
CALL METHOD gr_send_request->send(
EXPORTING
i_with_error_screen
= ‘X’
RECEIVING
result             
= gv_sent_to_all ).
**      IF gv_sent_to_all = ‘X’.
**        WRITE ‘Email sent!’.
**      ENDIF.

“Commit to send email
*      COMMIT WORK.

“Exception handling
CATCH cx_bcs INTO gr_bcs_exception.
WRITE:
‘Error!’,
‘Error type:’,
gr_bcs_exception
->error_type.
ENDTRY.

IF SYSUBRC <> 0.
MESSAGE ID SYMSGID TYPE ‘S’ NUMBER SYMSGNO
WITH SYMSGV1.
ELSE.
CL_OS_TRANSACTION_END_NOTIFIER
=>RAISE_COMMIT_REQUESTED( ).
CALL FUNCTION ‘DB_COMMIT’.
CL_OS_TRANSACTION_END_NOTIFIER
=>RAISE_COMMIT_FINISHED( ).
*      MESSAGE ID ‘ZHR’ TYPE ‘S’ NUMBER ‘002’ WITH WA_DISPLAY-PERNR.
ENDIF.

endif.
endif.
ENDIF.

Best Regards,

Akhilesh Singh


To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply