You are on page 1of 12

Purpose

This page shows how to find out the outbound mail information with their linked service ticket no in ERMS.

Overview
In ERMS we can easily find out the inbound mails and out outbound mails Information but its difficult to find out
the outbound mail with their linking service ticket no information.
This wiki will help how to find out the outbound mails with their linking service ticket numbers before that I will
explain what are the tables which is used in ERMS.

Detailed Explanation about ERMS tables


CRMD_ERMS_HEADER : This will gives Header Details information.
This table will give's the information about mails like From mail address,TO mail address, Creation Date, Changed Date,
Status, Work Item ID, Employee responsible etc..
each and every mail will attached with there corresponding service ticket.
CRMD_ERMS_E21O : link email to one order.
This table will gives the information about the Linkage from E-Mail to one order object. Here every mail id have there own id
that is CON_ID and linked GUID. This GUID will gives the service ticket no.
CRMD_ERMS_CONTNT : Get subject of the mail.
This table will give's the E-Mail subject information based on CON_ID.
CRMD_ERMS_EVENTT : This will gives the E-Mail event text.
This table will give's Email event text which is like replied, rejected,process, new etc..

CRMD_ERMS_STATUS : E-Mail status.


This table will give's E-Mail Status Description based on Status_id.
SOOD,SOST,SOES this table are helpful to find out the outbound mail info with there linked service ticket number.

SOOD: SAPoffice: Object definition.


This table will give's the email information like Created Date, Created Time,Description based on OWNTP = 'USR'.
SOST : SAPoffice: Status log table.
This table will gives the Status log details.
SOOS : Send process.
This table will gives the TO,CC and BCC mails information.
SOES : This will gives the outbound From mail address , outbound To mail address and Status.
If we observe standard ERMS Process For each service ticket under there is inbound and outbound mails. This mails are
having their own ids that is CON_ID.

if we want to know the service ticket no for the replied mail id we have a function module.
In that function module we have to pass CON_ID and object type = SOFM then will get guid for the corresponding linked
service ticket.
Pass that GUID into crmd_order_read or crmd_orderadm_h you will get service ticket no.

lv_root-objkey = lv_conid.
lv_root-objtype = 'SOFM'.

* Get the persisted doc flows


CALL FUNCTION 'SREL_GET_NEXT_RELATIONS'

EXPORTING
object
= lv_root
max_hops
=1
TABLES
links
= lt_bor
EXCEPTIONS
internal_error = 1
no_logsys
=2
OTHERS
= 3.
IF sy-subrc <> 0.
RETURN.
ENDIF.
READ TABLE lt_bor INTO ls_bor INDEX 1.
IF sy-subrc = 0.
lv_guid = ls_bor-objkey_a.
APPEND lv_guid TO it_header_guid.

CALL FUNCTION 'CRM_ORDER_READ'


EXPORTING
it_header_guid
= it_header_guid[]
IMPORTING
et_orderadm_h
= it_orderadm_h[]
CHANGING
cv_log_handle
= lv_log_handle
EXCEPTIONS
document_not_found = 1
error_occurred
=2
document_locked
=3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
OTHERS
= 7.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

READ TABLE it_orderadm_h INTO wa_orderadm_h WITH KEY process_type = 'ZSRT'.


IF sy-subrc <> 0.
wa_data-service_tkt = wa_orderadm_h-object_id.
ENDIF.
ENDIF.
Actual Requirement :
I have designed one BSP Component which is like search and result and custom model too.
Step by step procedure to achieve this requirement.
1)

Create one custom model.

2)

create search/result bsp component.

3)

Attach model to that component.

4)

Create search and result view.

Here we have so many blogs which is already explained how to create custom model and search/result bsp component.
So that I havent explain procedure to create model or search/result view.
Creating Custom Search/result view link..
http://scn.sap.com/docs/DOC-26564
http://scn.sap.com/community/crm/webclient-ui-framework/blog/2012/05/29/custom-component-based-on-custom-genilcomponent
Creating Custom Model..
http://scn.sap.com/community/crm/webclient-ui-framework/blog/2012/05/28/custom-genil-object-model-an-overview
ZCRM_ERMS_SRVO this is my structure which is I have used in my model.

This is the my Custom Model class ZCL_CRM_ERMS_SRVO.

Redefine the method IF_GENIL_APPL_INTLAY~GET_DYNAMIC_QUERY_RESULT and write the logic.

*****************************************************
* Declaring select-options
*
*****************************************************
TYPES : BEGIN OF t_selopttab,
sign TYPE crmsignran,
option TYPE crmoptran,
low TYPE symsgv,
high TYPE symsgv,
END OF t_selopttab.

DATA : it_sel_objdes
TYPE STANDARD TABLE OF t_selopttab,
it_sel_crdate
TYPE STANDARD TABLE OF t_selopttab,
it_sel_emaifrom TYPE STANDARD TABLE OF t_selopttab,

it_sel_emailto
wa_sel
wa_param
lr_entity
lr_attr_props
v_key
lv_conid

TYPE STANDARD TABLE OF t_selopttab,


TYPE t_selopttab,
TYPE genilt_selection_parameter,
TYPE REF TO if_genil_cont_root_object,
TYPE REF TO if_genil_obj_attr_properties,
TYPE string,
TYPE string.

DATA : it_data TYPE STANDARD TABLE OF zcrm_erms_srvo,


wa_data TYPE zcrm_erms_srvo,
it_srvkt TYPE STANDARD TABLE OF zcrm_srvtkt_emp,
wa_srvkt TYPE zcrm_srvtkt_emp.

DATA : lv_root
TYPE borident,
lt_bor
TYPE crmt_ic_irec_links,
ls_bor
TYPE relgraphlk,
lv_guid
TYPE swo_typeid,
it_header_guid TYPE crmt_object_guid_tab,
it_orderadm_h TYPE crmt_orderadm_h_wrkt,
wa_orderadm_h TYPE crmt_orderadm_h_wrk,
lv_log_handle TYPE balloghndl.

*****************************************************
*
DECLARE THE TYPES
*
*****************************************************

TYPES : BEGIN OF t_sood,


objtp TYPE sood-objtp,
objyr TYPE sood-objyr,
objno TYPE sood-objno,
objdes TYPE sood-objdes,
crdat TYPE sood-crdat,
crtim TYPE sood-crtim,
END OF t_sood,
BEGIN OF t_sost,
rectp TYPE sost-rectp,
recyr TYPE sost-recyr,
recno TYPE sost-recno,
objtp TYPE sost-objtp,
objyr TYPE sost-objyr,
objno TYPE sost-objno,
msgid TYPE sost-msgid,
END OF t_sost.

TYPES : BEGIN OF t_soes,


rectp TYPE soes-rectp,
recyr TYPE soes-recyr,
recno TYPE soes-recno,

msgid TYPE soes-msgid,


msgv1 TYPE soes-msgv1,
msgv2 TYPE soes-msgv2,
msgv4 TYPE soes-msgv4,
status TYPE soes-status,
END OF t_soes.

DATA : lv_msgid TYPE symsgid,


lv_langu TYPE char2 VALUE 'EN',
lv_msgno TYPE char3,
lv_msgv1 TYPE string,
lv_msgv2 TYPE string,
lv_msgv4 TYPE string,
lv_message TYPE string.

DATA : gt_sood TYPE STANDARD TABLE OF t_sood,


gs_sood TYPE t_sood,
gt_sost TYPE STANDARD TABLE OF t_sost,
gs_sost TYPE t_sost,
gt_soes TYPE STANDARD TABLE OF t_soes,
gs_soes TYPE t_soes.

*****************************************************
* Search Qurey and Selection Screen inputs
*****************************************************

IF iv_query_name = 'SEARCH_SRVO'.

LOOP AT it_selection_parameters INTO wa_param.


CASE wa_param-attr_name.
WHEN 'DESCRIPTION'.
MOVE-CORRESPONDING wa_param TO wa_sel.
REPLACE ALL OCCURRENCES OF '*' IN wa_sel WITH '%'.
APPEND wa_sel TO it_sel_objdes.
WHEN 'FROM_DATE'.
MOVE-CORRESPONDING wa_param TO wa_sel.
APPEND wa_sel TO it_sel_crdate.
WHEN 'EMAIL_FROM'.
MOVE-CORRESPONDING wa_param TO wa_sel.
APPEND wa_sel TO it_sel_emaifrom.

WHEN 'EMAIL_TO'.
TRANSLATE wa_param-low TO LOWER CASE.

TRANSLATE wa_param-high TO LOWER CASE.


MOVE-CORRESPONDING wa_param TO wa_sel.

APPEND wa_sel TO it_sel_emailto.


ENDCASE.
CLEAR : wa_param,wa_sel.
ENDLOOP.

* <---data fetching logic based on selection screen inputs--->

SELECT objtp objyr objno objdes crdat crtim INTO CORRESPONDING FIELDS OF TABLE gt_sood FROM sood
WHERE crdat IN it_sel_crdate
AND owntp = 'USR'.

IF gt_sood[] IS NOT INITIAL.

SELECT rectp recyr recno objtp objyr objno msgid FROM sost INTO CORRESPONDING FIELDS OF TABLE
gt_sost
FOR ALL ENTRIES IN gt_sood WHERE objtp = gt_sood-objtp
AND objyr = gt_sood-objyr
AND objno = gt_sood-objno
AND msgid = 'SO'.
IF gt_sost[] IS NOT INITIAL.
SELECT rectp recyr recno msgid msgv1 msgv2 msgv4 status FROM soes INTO CORRESPONDING FIELDS
OF TABLE gt_soes FOR ALL ENTRIES IN gt_sost
WHERE rectp = gt_sost-rectp
AND recyr = gt_sost-recyr
AND recno = gt_sost-recno
AND msgv1 IN it_sel_emailto
AND msgv2 IN it_sel_emaifrom.
ENDIF.
ENDIF.

LOOP AT gt_soes INTO gs_soes.

READ TABLE gt_sost INTO gs_sost WITH KEY rectp = gs_soes-rectp


recyr = gs_soes-recyr
recno = gs_soes-recno.
IF sy-subrc = 0.

READ TABLE gt_sood INTO gs_sood WITH KEY objtp = gs_sost-objtp

objyr = gs_sost-objyr
objno = gs_sost-objno.
IF sy-subrc = 0.

wa_data-objtp = gs_sood-objtp.
wa_data-objyr = gs_sood-objyr.
wa_data-objno = gs_sood-objno.
wa_data-description = gs_sood-objdes.
wa_data-from_date = gs_sood-crdat.
wa_data-send_time = gs_sood-crtim.

wa_data-email_from = gs_soes-msgv2.
wa_data-email_to = gs_soes-msgv1.

lv_msgid = gs_soes-msgid.
lv_msgno = gs_soes-status.
lv_msgv1 = gs_soes-msgv1.
lv_msgv2 = gs_soes-msgv2.
lv_msgv4 = gs_soes-msgv4.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'


EXPORTING
input = lv_msgno
IMPORTING
output = lv_msgno.

CALL FUNCTION 'FORMAT_MESSAGE'


EXPORTING
id
= lv_msgid
lang
= 'EN'
no
= lv_msgno
v1
= lv_msgv1
v2
= lv_msgv2
*
V3
= lv_MSGV3
v4
= lv_msgv4
IMPORTING
msg
= lv_message
*
EXCEPTIONS
*
NOT_FOUND
=1
*
OTHERS
=2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

wa_data-status = lv_message.

CLEAR : lv_msgid,lv_msgno,lv_msgv1,lv_msgv2,lv_msgv4.

CONCATENATE gs_sood-objtp gs_sood-objyr gs_sood-objno INTO lv_conid.


wa_data-conid = lv_conid.

SHIFT lv_conid BY 17 PLACES RIGHT.

lv_root-objkey = lv_conid.
lv_root-objtype = 'SOFM'.

* Get the persisted doc flows


CALL FUNCTION 'SREL_GET_NEXT_RELATIONS'
EXPORTING
object
= lv_root
max_hops
=1
TABLES
links
= lt_bor
EXCEPTIONS
internal_error = 1
no_logsys
=2
OTHERS
= 3.
IF sy-subrc <> 0.
RETURN.
ENDIF.

READ TABLE lt_bor INTO ls_bor INDEX 1.


IF sy-subrc = 0.
lv_guid = ls_bor-objkey_a.

APPEND lv_guid TO it_header_guid.

CALL FUNCTION 'CRM_ORDER_READ'


EXPORTING
it_header_guid
= it_header_guid[]
IMPORTING
et_orderadm_h
= it_orderadm_h[]
CHANGING
cv_log_handle
= lv_log_handle
EXCEPTIONS
document_not_found = 1

error_occurred
=2
document_locked
=3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
OTHERS
= 7.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

READ TABLE it_orderadm_h INTO wa_orderadm_h WITH KEY process_type = 'ZSRT'.

wa_data-service_tkt = wa_orderadm_h-object_id.
ENDIF.

APPEND wa_data TO it_data.


ENDIF.
ENDIF.
CLEAR : wa_data,lv_conid,lv_guid,it_header_guid,wa_orderadm_h,it_orderadm_h,lt_bor,lv_root,lv_log_handle.
CLEAR : gs_soes,gs_sood.
ENDLOOP.

*populating data into result

LOOP AT it_data INTO wa_data.

TRY.
CALL METHOD iv_root_list->add_object
EXPORTING
iv_object_name = 'RESULT_SRVO'
is_object_key = wa_data
RECEIVING
rv_result
= lr_entity.

CATCH cx_crm_genil_duplicate_rel .
CATCH cx_crm_genil_model_error .
ENDTRY.

CALL METHOD lr_entity->set_attributes


EXPORTING
is_attributes = wa_data.

CLEAR : wa_data.
ENDLOOP.

ENDIF.

this is the final output here we can come to know sent mails based on creating date.

Related Content
http://scn.sap.com/thread/1340812
http://scn.sap.com/thread/3181618

Related Documents
E-MAIL INBOUND CONFIGURATION- ALM: Incident Management#MAILINBOUNDCONFIGURATIONALM:IncidentManagement-3SAPBusinessWorkflowandCommunicationSettings
How to set up Threading in ERMS

You might also like