Skip to Content
Technical Articles
Author's profile photo Dharmesh Kumar

How to create a follow up (Subsequent Notification) in PM

Prerequisite:

You have a PM notification under which you want to create a child (subsequent or follow up) notification.

 

Overview:

I wanted to create a subsequent PM notification under a parent notification and could not found any concrete solution for the same which inspired me to write this blog to help fellow developers who are facing a similar problem.

I tried using FM ‘QM06_FM_TASK_CREATE_QM_NOTIFIC’ but it was expecting way too many parameters and even after writing the code it didn’t work as expected so I switched to ‘IQS4_CREATE_NOTIFICATION’ which was much easier to code and worked like a charm.

The code I have written is wrapped in an RFC as I had to call it in an OData service as the integration had to be done from a Fiori application.

 

Steps:

Create a function module as below:

 

And paste this code in source code:

FUNCTION zpm_create_subsequent_notif.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(REF_NOTIFICATION) TYPE  QMNUM OPTIONAL
*"     VALUE(FUNC_LOCATION) TYPE  TPLNR OPTIONAL
*"     VALUE(NOTIF_DESCRIPTION) TYPE  QMTXT OPTIONAL
*"     VALUE(LONG_TEXT) TYPE  STRING OPTIONAL
*"     VALUE(PRIORITY) TYPE  PRIOK OPTIONAL
*"     VALUE(REPORTED_BY) TYPE  QMNAM OPTIONAL
*"  EXPORTING
*"     VALUE(SUB_NOTIF) TYPE  QMNUM
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2
*"----------------------------------------------------------------------
  IF ref_notification IS INITIAL.
    RETURN.
  ENDIF.

  DATA: ls_riqs5 TYPE riqs5.
  DATA: lt_inlines TYPE TABLE OF rfc_tline.
  DATA: ls_viqmel_out TYPE viqmel.
  DATA: ls_viqmel_out1 TYPE viqmel.
  DATA: lt_return TYPE TABLE OF bapiret2.
  DATA: lt_return1 TYPE TABLE OF bapiret2.

  SELECT SINGLE * FROM viqmel INTO @DATA(ls_viqmel) WHERE qmnum = @ref_notification.
  IF sy-subrc = 0.
    MOVE-CORRESPONDING ls_viqmel TO ls_riqs5.
    ls_riqs5-qwrnum = ref_notification.
    ls_riqs5-tplnr = func_location.
    ls_riqs5-qmtxt = notif_description.
    ls_riqs5-priok = priority.
    IF reported_by IS NOT INITIAL.
      ls_riqs5-qmnam = reported_by.
    ELSE.
      ls_riqs5-qmnam = sy-uname.
    ENDIF.
    ls_riqs5-qmdat = sy-datum.
    ls_riqs5-mzeit = sy-uzeit.
  ENDIF.

  SPLIT long_text AT '<BR/>' INTO TABLE DATA(lt_ltext).
  IF lt_ltext IS NOT INITIAL.
    LOOP AT lt_ltext INTO DATA(ls_ltext).
      APPEND INITIAL LINE TO lt_inlines ASSIGNING FIELD-SYMBOL(<fs_inlines>).
      <fs_inlines>-refobjtyp = 'QMEL'.
      <fs_inlines>-tdformat = '>X'.
      CONCATENATE '* ' ls_ltext INTO <fs_inlines>-tdline RESPECTING BLANKS.
      CONDENSE <fs_inlines>-tdline.
    ENDLOOP.
  ENDIF.


  CALL FUNCTION 'IQS4_CREATE_NOTIFICATION'
    EXPORTING
      i_riqs5     = ls_riqs5
      i_commit    = 'X'
    IMPORTING
      e_viqmel    = ls_viqmel_out
    TABLES
      i_inlines_t = lt_inlines
      return      = lt_return.
  READ TABLE lt_return WITH KEY type = 'E' TRANSPORTING NO FIELDS.
  IF sy-subrc = 0.
    APPEND LINES OF lt_return TO return.
    RETURN.
  ELSE.
    CALL FUNCTION 'IQS4_SAVE_NOTIFICATION'
      EXPORTING
        i_qmnum  = ls_viqmel_out-qmnum
        i_commit = 'X'
      IMPORTING
        e_viqmel = ls_viqmel_out1
      TABLES
        return   = lt_return1.
    READ TABLE lt_return1 WITH KEY type = 'E' TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
      APPEND LINES OF lt_return TO return.
      RETURN.
    ELSE.
      sub_notif = ls_viqmel_out-qmnum.
    ENDIF.
  ENDIF.
ENDFUNCTION.

 

Input Parameters:

 

Output Parameter:

 

Check the linkage in IW23:

 

Conclusion:

If you follow the above steps, you should be able to create a subsequent notification of a parent notification. If you want you can separate the code and put in a user exit or program as per your requirement.

I hope this post will be helpful to you.

 

Regards,

Dharmesh

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.