Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
robynhosby
Active Participant

Hello!

SolMan 7.1 brought us long awaited functionality to reassign Change Documents to a different project.  This was great! However, if more than one Change Document is assigned to the Request for Change, the Change Document loses its link to the Request for Change that approved the Change Document ... the source information and traceability is lost.

This blog contains a simple solution to retain this information in the Change Document until a standard solution is provided in SolMan.

Standard Functionality before change

After process Change Project Assignment...

In the Details assignment block, the Related Request for Change field is blank because it is disconnected from the approval RfC.

In the Related Transaction assignment block, the RfC is no longer linked.

The standard messages at the top are retained in the standard under the Application Log assignment block, so no custom solution is needed to retain that...

Requirement

Our requirement was include the RfC number that approved the Change Document in the Change Document's log for traceability and future reference.

Solution

Hopefully, SolMan 7.2 will provide a standard solution to include the approval RfC in the CD's log or another standard field. Until then, I created an enhancement..... 

I created a new structure (called Zabc_CHARM_DOC_FLOW in the below code) and a table type for that new structure (called Zabc_CHARM_DOC_FLOW_TAB)

<code>

    RAISE tl_task_group_not_lock.

  ENDIF.

"""""""""""""""""$"$\SE:(1) Class CL_AI_CRM_ACTION_UTILITY, Method REASSIGN_CHANGE, End                                                                                       A

*$*$-Start: (1)---------------------------------------------------------------------------------$*$*


ENHANCEMENT 1  Zabc_CHARM_MESSAGE_LOG.    "active version

*******************************************************************************

* Created: 11/13/2015 Robyn Osby

* Usage  : When Changing project assignment, the original Change Request that

*          contained the approval is not logged on the reassigned Change Document.

*          Write the source CR to the textbox log in the CD.

* Note   : If needed in testing, this logic will read new and existing ChaRM texts:

*               data lt_texts type COMT_TEXT_TEXTDATA_T.

*               clear lt_texts. refresh lt_texts.

*               CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'

*                 EXPORTING

*                   iv_header_guid = mv_crm_doc_guid

*                 IMPORTING

*                   et_alltexts    = lt_texts.

*

********************************************************************************

data: ls_PROCESS_type TYPE CRMT_PROCESS_TYPE_DB.

data: lt_docflow      TYPE Zabc_CHARM_DOC_FLOW_TAB,

     ls_docflow      type Zabc_CHARM_DOC_FLOW.

data: ls_APP_MESSAGE  type BALMI.

data: lt_text3        type CRMT_TEXT_COMT,

      ls_text3        type CRMT_TEXT_COM,

      ls_lines3       type line of COMT_TEXT_LINES_T,

      ls_field_names  type CRMT_INPUT_FIELD_NAMES,

      lt_input_field  TYPE  CRMT_INPUT_FIELD_TAB,

      ls_input_field  type CRMT_INPUT_FIELD.


data: lt_objects_to_save TYPE  CRMT_OBJECT_GUID_TAB,

      ls_objects_to_save TYPE  CRMT_OBJECT_GUID,

      lt_saved_objects TYPE  CRMT_RETURN_OBJECTS,

      lt_objects_not_saved TYPE  CRMT_OBJECT_GUID_TAB,

      gt_nocheck_before_save TYPE  CRMT_OBJECT_GUID_TAB.


constants:  lc_object TYPE COMT_TEXT_TEXTOBJECT value 'CRM_ORDERH',

            lc_tdid   type TDID value 'CD03', "general note textbox

            lc_RFC    type CRMT_PROCESS_TYPE_DB value 'ZMCR'.

*-------------------------------------------------------------------------------

* 1) Process only for CDs

    SELECT SINGLE PROCESS_TYPE INTO ls_PROCESS_TYPE

            FROM crmd_orderadm_h

            WHERE guid = mv_crm_doc_guid.

    if sy-subrc = 0.

      case ls_PROCESS_TYPE.

        when 'ZMAD'

        or 'ZMMJ'

        or 'ZMMI'

        or 'ZMTM'. "CDs that can reassign project?


* 2) Read Change Request number that created this Change document.

*    If first project reassignment, the Change Request will be in the document

*    flow. Read that CR #.  CR # will not be found if it after 1st reassignment.

          CALL METHOD Zabc_CHARM=>READ_DOC_FLOW

            EXPORTING

              PI_GUID         = mv_crm_doc_guid

              PI_PROCESS_TYPE = ls_PROCESS_TYPE

            IMPORTING

              PO_DOCFLOW      = lt_docflow.


         sort LT_DOCFLOW by process_type.

           read table LT_DOCFLOW into ls_docflow with key process_type = lc_RFC

                                                 binary search.

           if sy-subrc = 0. "RfC found?


* 3) Populate message

             ls_APP_MESSAGE-MSGTY = 'I'.

             ls_APP_MESSAGE-MSGID = 'ZCHARM'.

             ls_APP_MESSAGE-MSGNO = '027'. "Original Change Request &1 contains approvals.

             ls_APP_MESSAGE-MSGV1 = ls_docflow-Object_ID.

             clear: ls_APP_MESSAGE-MSGV2, ls_APP_MESSAGE-MSGV3, ls_APP_MESSAGE-MSGV4.


* 4) Store message for screen dialog (top of ChaRM)

             append ls_APP_MESSAGE to et_APP_MESSAGE.


* 5) Update textbox with message so it is retained on save

             clear: ls_text3, lt_text3, ls_field_names.

             refresh: lt_text3.

             ls_text3-REF_GUID = mv_crm_doc_guid. "charm guid

             ls_text3-REF_KIND = 'A'.

             ls_text3-TEXT_OBJECT = lc_object.

             ls_text3-TDID     = lc_tdid.

             ls_text3-TDSPRAS  = 'E'.

             ls_text3-MODE     = 'A'. "text creation

            ls_lines3-TDFORMAT = '*'.

             message id ls_APP_MESSAGE-MSGID type ls_APP_MESSAGE-MSGTY

                                             number ls_APP_MESSAGE-MSGNO

                     inTO ls_lines3-TDLINE

                     with ls_APP_MESSAGE-MSGV1 ls_APP_MESSAGE-MSGV2

                          ls_APP_MESSAGE-MSGV3 ls_APP_MESSAGE-MSGV4.

             append ls_lines3 to ls_text3-lines.

             append ls_text3 to lt_text3.


             clear ls_input_field.

             ls_input_field-REF_GUID = mv_crm_doc_guid. "charm guid

             ls_input_field-REF_KIND = 'A'.

             ls_input_field-OBJECTNAME = 'TEXTS'.

             concatenate lc_tdid 'E' into ls_input_field-LOGICAL_KEY.

             ls_field_names-FIELDNAME = 'LINES'.

             append ls_field_names to ls_input_field-FIELD_NAMES.

             append ls_input_field to lt_input_field.


* 5a) Update textbox

             CALL FUNCTION 'CRM_ORDER_MAINTAIN'

              EXPORTING

                it_text                       = lt_text3

              CHANGING

                ct_input_fields               = lt_input_field

              EXCEPTIONS

                OTHERS                        = 99.


             IF sy-subrc IS INITIAL.


* 5b) Save ChaRM with new textbox

               ls_objects_to_save = mv_crm_doc_guid. "charm guid

               append ls_objects_to_save to lt_objects_to_save.

               append ls_objects_to_save to gt_nocheck_before_save.


               CALL FUNCTION 'CRM_ORDER_SAVE'

                 EXPORTING

                   it_objects_to_save   = lt_objects_to_save

*                  iv_update_task_local = true

                 IMPORTING

                   et_saved_objects     = lt_saved_objects

                   et_objects_not_saved = lt_objects_not_saved

                 CHANGING

                   ct_nocheck_before_save = gt_nocheck_before_save

                 EXCEPTIONS

                   OTHERS               = 0.


               COMMIT WORK.

             endif.


          endif. "RfC found?


      when others.


      endcase.

    endif.


ENDENHANCEMENT.

*$*$-End:   (1)---------------------------------------------------------------------------------$*$*


ENDMETHOD.                    "create_request

<code>

Class Zabc_CHARM method READ_DOC FLOW

Class Zabc_CHARM method READ_DOC_FLOW is used for other doc flow logic in other areas so it has extra logic. It contains:

method READ_DOC_FLOW.

*********************************************************************************

* Created: 9/30/2015 Robyn Osby

* Usage  : Read the preceding and following ChaRM documents within the document flow.

*********************************************************************************

  data: ls_DOCFLOW type zabc_charm_doc_flow.

  data: zz_ls_prior_doc_guid   type CRMT_OBJECT_GUID,

           zz_ls_next_doc_guid    type CRMT_OBJECT_GUID.

  data: zz_lz_guid             type CRMT_OBJECT_GUID, "next doc's guid

           zz_l_guid              TYPE  CRMT_OBJECT_GUID_TAB.

  data: zz_lz_doc_flow         TYPE line of cRMT_DOC_FLOW_WRKT,

           zz_lz_doc_flow_db      type line of CRMT_DOC_FLOW_DB_WRKT.

  data: zz_iz_doc_flow         TYPE cRMT_DOC_FLOW_WRKT,

           zz_li_DOC_FLOW_DB_WRKT type CRMT_DOC_FLOW_DB_WRKT.

  DATA: zz_LI_REQTD_OBJS       TYPE  CRMT_OBJECT_NAME_TAB.

  data: zz_lz_orderadm_h_wrk TYPE  CRMT_ORDERADM_H_WRK,

        zz_lz_process_type   TYPE  CRMT_PROCESS_TYPE,

        zz_l_doc_linked      TYPE  CRMT_OBJECT_ID,

        zz_lz_object_type    TYPE  SWO_OBJTYP.

  DATA: zz_L_CV_LOG_HANDLE TYPE  BALLOGHNDL.

*--------------------------------------------------------------------------------------

* 1) Read the document flow

  CLEAR: zz_LI_REQTD_OBJS, zz_L_GUID, zz_iz_doc_flow,

         zz_lS_prior_doc_guid, zz_lS_next_doc_guid.

  REFRESH: zz_LI_REQTD_OBJS, ZZ_L_GUID, zz_iz_doc_flow.

  APPEND 'DOC_FLOW' TO zz_LI_REQTD_OBJS.

  APPEND pi_guid TO zz_L_GUID.

  CALL FUNCTION 'CRM_ORDER_READ_OW'

    EXPORTING

      IT_HEADER_GUID       = zz_L_GUID

      IT_REQUESTED_OBJECTS = zz_LI_REQTD_OBJS

    IMPORTING

      ET_DOC_FLOW          = zz_iz_doc_flow

    CHANGING

      CV_LOG_HANDLE        = zz_L_CV_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.

  ENDIF.

* 2) Read preceding document (e.g. CR for CDs documents reported).

  loop at zz_iz_doc_flow into zz_lz_doc_flow.

    zz_Lz_GUID = zz_lz_doc_flow-OBJKEY_a. "for PRECEDING docs

    CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'

      EXPORTING

        iv_orderadm_h_guid     = zz_Lz_GUID

      IMPORTING

        es_orderadm_h_wrk      = zz_lz_orderadm_h_wrk

        ev_process_type        = zz_lz_process_type

        ev_object_id           = zz_l_doc_linked

        ev_object_type         = zz_lz_object_type

      EXCEPTIONS

        admin_header_not_found = 1

        OTHERS                 = 2.

    if sy-subrc = 0.

      ls_DOCFLOW-process_type = zz_lz_orderadm_h_wrk-process_type.

      ls_DOCFLOW-OBJECT_ID    = zz_l_doc_linked.

      ls_DOCFLOW-guid         = zz_ls_next_doc_guid     = zz_Lz_GUID.

      append ls_DOCFLOW to PO_DOCFLOW.

    endif.

* 3) Read FOLLOWING documents

    zz_Lz_GUID = zz_lz_doc_flow-OBJKEY_B. "for FOLLOWING doc

    CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'

      EXPORTING

        iv_orderadm_h_guid     = zz_Lz_GUID

      IMPORTING

        es_orderadm_h_wrk      = zz_lz_orderadm_h_wrk

        ev_process_type        = zz_lz_process_type

        ev_object_id           = zz_l_doc_linked

        ev_object_type         = zz_lz_object_type

      EXCEPTIONS

        admin_header_not_found = 1

        OTHERS                 = 2.

    if sy-subrc = 0.

      case pi_PROCESS_TYPE. "doc currently being processed

        when 'SDCR' or 'ZMCR'. "7.0 and 7.1 CRs? Then find CDs linked

          ls_DOCFLOW-process_type = zz_lz_orderadm_h_wrk-process_type.

          ls_DOCFLOW-OBJECT_ID    = zz_l_doc_linked.

          ls_DOCFLOW-guid         = zz_ls_next_doc_guid     = zz_Lz_GUID.

          append ls_DOCFLOW to PO_DOCFLOW.

        when others. "currently on a CD?

          ls_DOCFLOW-process_type = zz_lz_orderadm_h_wrk-process_type.

          ls_DOCFLOW-OBJECT_ID    = zz_l_doc_linked.

          ls_DOCFLOW-guid         = zz_ls_next_doc_guid     = zz_Lz_GUID.

          append ls_DOCFLOW to PO_DOCFLOW.

      endcase.

    endif.

  endloop.

* 4) Compress and filter out current ChaRM

  delete PO_DOCFLOW where process_type = pi_process_type.

  sort PO_DOCFLOW by guid.

  delete adjacent duplicates from PO_DOCFLOW.

endmethod.


Results

The standard messages are still displayed at the top of the UI. The Related Request for Change field is still cleared (when more than CD is linked to the source RfC).


But now, the messages at the top of the UI and the Text log (under General Note) now contain the RfC that contains the approvals...


Hopefully, SolMan will contain this enhancement as a standard in a upcoming release. Until then, I hope my solution will be of help to your project!


Cheers!


Labels in this area