on 2015 Dec 17 8:34 AM
Dear Gurus,
I want to create the the corrective action / Questions with features of Notifications.
Can i use the BADI PLM_AUDIT_ACT_LINK, method CREATE_OBJECT. and business object BUS2078.
Please help me with code / process to achieve the solution.
Regards
Naveen
HI All,
The following code will be helpful if you wanted to implement BADI PLM_AUDIT_ACT_LINK.
In Method GET_CREATE_MENU write following code:-
DATA ls_function LIKE LINE OF et_functions.
DATA ls_object TYPE sibflporb.
DATA l_guid TYPE cgpl_guid16.
DATA lt_links TYPE obl_t_link.
CONSTANTS: con_objtyp_action TYPE swo_objtyp VALUE 'BUS20370',
con_catid_busobject TYPE sibfcatid VALUE 'BO',
CO_OBJTYP_NOTIFICATION TYPE SWO_OBJTYP VALUE 'BUS2078',
CO_NOTIFICATION_CREATE TYPE SY-UCOMM VALUE 'QNOTIF_CREATE',
con_reltype TYPE oblreltype VALUE 'PLM_ACTOBJ'.
* con_objtyp_action TYPE swo_objtyp VALUE 'BUS20370',
* con_catid_busobject TYPE sibfcatid VALUE 'BO'.
*Fill key of the object corretive action
CALL METHOD ir_object->get_guid
IMPORTING
ex_guid = l_guid.
MOVE l_guid TO ls_object-instid.
MOVE con_objtyp_action TO ls_object-typeid.
MOVE con_catid_busobject TO ls_object-catid.
* check whether some object links already exist
TRY.
CALL METHOD cl_binary_relation=>read_links_of_binrel
EXPORTING
is_object = ls_object
ip_relation = con_reltype
IMPORTING
et_links = lt_links.
CATCH cx_obl_parameter_error .
CATCH cx_obl_internal_error .
CATCH cx_obl_model_error .
ENDTRY.
* disable creation of notification if a notification is already linked
READ TABLE lt_links WITH KEY typeid_b = co_objtyp_notification
TRANSPORTING NO FIELDS.
IF sy-subrc IS INITIAL.
MOVE 'X' TO ls_function-disabled.
ELSE.
* ls_function-disabled = i_disabled.
ENDIF.
* append function to create notification
ls_function-fcode = co_notification_create.
ls_function-text = 'NOTIFICATION CREATE'(001).
* ls_function-ACCEL = 'X'.
* ls_function-HIDDEN = 'X'.
* ls_function-FTYPE = 'T'.
* ls_function-FTYPE = 'N'.
APPEND ls_function TO et_functions.
In Method CREATE_OBJECT write following code....
DATA ls_info TYPE swotrm.
DATA ls_return TYPE swotreturn.
DATA lv_object TYPE swo_objhnd.
DATA l_qmart(2) TYPE c VALUE 'Q1'. "'Q1'.
DATA lt_container TYPE TABLE OF swcont.
DATA l_sender TYPE tbdls-logsys.
DATA l_external_id TYPE cgpl_extid.
DATA l_refobjkey TYPE swo_typeid.
DATA ls_objid TYPE swotobjid.
DATA l_msg TYPE c.
DATA lt_longtext TYPE TABLE OF tline.
DATA ls_longtext LIKE LINE OF lt_longtext.
CONSTANTS cv_reltype TYPE binreltyp VALUE 'VONA'. "Precessor-Successor
CONSTANTS :cv_method TYPE swotrm-method VALUE 'CREATESINGLECONTAINERDIALOG',
CO_NOTIFICATION_CREATE TYPE SY-UCOMM VALUE 'QNOTIF_CREATE',
CO_DESTINATION TYPE CHAR40 VALUE 'NONE',
CO_OBJTYP_NOTIFICATION TYPE SWO_OBJTYP VALUE 'BUS2078',
CON_OBJTYP_ACTION TYPE SWO_OBJTYP VALUE 'BUS20370',
CON_CATID_BUSOBJECT TYPE SIBFCATID VALUE 'BO'.
* CO_NOTIFICATION_DISPLAY TYPE SY-UCOMM VALUE 'QNOTIF_DISPLAY'.
CASE im_ucomm.
WHEN co_notification_create.
* Check whether notification already was created
IF NOT im_object->has_outline_children( ) IS INITIAL.
RAISE aborted_by_user.
ENDIF.
* Check whether method is available
CALL FUNCTION 'SWO_QUERY_METHOD' DESTINATION co_destination
EXPORTING
method = cv_method
objtype = co_objtyp_notification
IMPORTING
info = ls_info
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
MESSAGE e202(plm_audit) INTO l_msg.
CALL METHOD cl_cgpl_application_log=>message_add
EXPORTING
im_msgty = sy-msgty
im_msgid = sy-msgid
im_msgno = sy-msgno.
RAISE failed.
ENDIF.
* Initiate Business Object
CALL FUNCTION 'SWO_CREATE' DESTINATION co_destination
EXPORTING
objtype = co_objtyp_notification
IMPORTING
object = lv_object
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
RAISE failed.
ENDIF.
* Fill container: Notification Type
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = 'NotificationType' "#EC NOTEXT
field = l_qmart
TABLES
container = lt_container
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* Fill container: Sender = own logical system
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = l_sender
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = 'Sender' "#EC NOTEXT
field = l_sender
TABLES
container = lt_container
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* Fill container: Object corrective action
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = 'RefObjType' "#EC NOTEXT
field = con_objtyp_action
TABLES
container = lt_container
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* Fill container: Key of corrective action
CALL METHOD im_object->get_external_id
RECEIVING
re_external_id = l_external_id.
MOVE l_external_id TO l_refobjkey.
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = 'RefObjKey' "#EC NOTEXT
field = l_refobjkey
TABLES
container = lt_container
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* Fill relation type
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = 'RelType' "#EC NOTEXT
field = cv_reltype
TABLES
container = lt_container
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* Fill long text, take description of the corrective action
CALL METHOD im_object->get_longtext
EXPORTING
im_language = sy-langu
im_text_id = 'DESC' "#EC NOTEXT
IMPORTING
ex_lines = lt_longtext
EXCEPTIONS
OTHERS = 0.
IF NOT lt_longtext[] IS INITIAL.
CALL FUNCTION 'SWC_TABLE_SET'
EXPORTING
element = 'NotificationHeaderLongtext' "#EC NOTEXT
TABLES
container = lt_container
table = lt_longtext
EXCEPTIONS
type_conflict = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
ENDIF.
* Call method of Business Objekt
CALL FUNCTION 'SWO_INVOKE' DESTINATION co_destination
EXPORTING
object = lv_object
verb = cv_method
persistent = 'X'
IMPORTING
return = ls_return
TABLES
container = lt_container
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
RAISE failed.
ENDIF.
* Objectkey
CALL FUNCTION 'SWO_OBJECT_ID_GET' DESTINATION co_destination
EXPORTING
object = lv_object
IMPORTING
return = ls_return
objid = ls_objid
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_objid-objkey IS INITIAL.
RAISE failed.
ENDIF.
MOVE-CORRESPONDING ls_objid TO ex_borident.
* Release business object
CALL FUNCTION 'SWO_FREE' DESTINATION co_destination
EXPORTING
object = lv_object
EXCEPTIONS
communication_failure = 1
system_failure = 2.
WHEN OTHERS.
RAISE not_supported.
ENDCASE.
IN Method GET_DISPLAY_PROPERTIES write following code:-
MOVE icon_report TO e_icon.
MOVE text-001 TO e_tooltip.
MOVE text-001 TO e_description.
WRITE is_link-objkey_b TO e_extern_identification.
SHIFT e_extern_identification LEFT DELETING LEADING '0'.
In Method GET_CONTEXT_MENU write following code
DATA ls_function LIKE LINE OF ex_functions.
CONSTANTS: co_notification_edit TYPE sy-ucomm VALUE 'QNOTIF_EDIT',
co_notification_disp TYPE sy-ucomm VALUE 'QNOTIF_DISPLAY'.
ls_function-fcode = co_notification_edit.
ls_function-text = 'Change quality notification'(002).
APPEND ls_function TO ex_functions.
CLEAR: ls_function.
ls_function-fcode = co_notification_disp.
ls_function-text = 'Display quality notification'(002).
* ls_function-disabled = ''.
APPEND ls_function TO ex_functions.
In Method EXCECUTE_FUNCTION write following code:-
DATA lv_method TYPE swotrm-method VALUE 'EDIT'.
DATA lv_method_disp TYPE swotrm-method VALUE 'DISPLAY'.
DATA ls_info TYPE swotrm.
DATA ls_return TYPE swotreturn.
DATA lv_object TYPE swo_objhnd.
DATA l_objkey TYPE swotobjid-objkey.
CONSTANTS: co_notification_edit TYPE sy-ucomm VALUE 'QNOTIF_EDIT',
co_notification_disp TYPE sy-ucomm VALUE 'QNOTIF_DISPLAY',
co_destination TYPE char40 VALUE 'NONE',
co_objtyp_notification TYPE swo_objtyp VALUE 'BUS2078'.
* Take key
MOVE is_link-objkey_b TO l_objkey.
CASE im_fcode.
WHEN co_notification_edit.
* Check whether method is available
CALL FUNCTION 'SWO_QUERY_METHOD' DESTINATION co_destination
EXPORTING
method = lv_method
objtype = co_objtyp_notification
IMPORTING
info = ls_info
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Initiate Business Object
CALL FUNCTION 'SWO_CREATE' DESTINATION co_destination
EXPORTING
objtype = co_objtyp_notification
objkey = l_objkey
IMPORTING
object = lv_object
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Call method of Business Objekt
CALL FUNCTION 'SWO_INVOKE' DESTINATION co_destination
EXPORTING
object = lv_object
verb = lv_method
persistent = 'X'
IMPORTING
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Business Objekt freigeben
CALL FUNCTION 'SWO_FREE' DESTINATION co_destination
EXPORTING
object = lv_object
EXCEPTIONS
communication_failure = 1
system_failure = 2.
WHEN co_notification_disp.
* Check whether method is available
CALL FUNCTION 'SWO_QUERY_METHOD' DESTINATION co_destination
EXPORTING
method = lv_method_disp
objtype = co_objtyp_notification
IMPORTING
info = ls_info
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Initiate Business Object
CALL FUNCTION 'SWO_CREATE' DESTINATION co_destination
EXPORTING
objtype = co_objtyp_notification
objkey = l_objkey
IMPORTING
object = lv_object
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Call method of Business Objekt
CALL FUNCTION 'SWO_INVOKE' DESTINATION co_destination
EXPORTING
object = lv_object
verb = lv_method_disp
persistent = 'X'
IMPORTING
return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0
OR ls_return-code NE 0.
EXIT.
ENDIF.
* Business Objekt freigeben
CALL FUNCTION 'SWO_FREE' DESTINATION co_destination
EXPORTING
object = lv_object
EXCEPTIONS
communication_failure = 1
system_failure = 2.
WHEN OTHERS.
RAISE action_not_supported.
ENDCASE.
Regards
Subhaskar Reddy.L
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
106 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.