cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a task automatically in a qm notification during saving

Former Member
0 Kudos

Hello,

I'm looking for a way to create a special task in a quality notification when someone enters a certain partner role.

This partner role is optional, but once it is registered there should be an open task for him..

I tried it with exit EXIT_SAPMIWO0_020.

If the partner role is registered and the particular task does not exist, the new task is added via "call function 'BAPI_QUALNOT_ADD_DATA' ".

The problem is that this time, 'BAPI_QUALNOT_ADD_DATA' explicitly requires the following:

"Note: The changes to the message data is available only after the successful passage of the function blocks BAPI_QUALNOT_SAVE and BAPI_TRANSACTION_COMMIT in the database."

When I use the two blocks in the Exit all other changes in the notofication is ignored.

What am I doing wrong? Or is there another solution?

Thanks for any guidance.
l-j

Accepted Solutions (1)

Accepted Solutions (1)

jogeswararao_kavala
Active Contributor
0 Kudos

Hello Andrea,

I have tested the code given below to be pit in include ZXQQMU20 (same exit you are trying EXIT_SAPMIWO0_020). What it does at the Save event of Notification is: It adds a special task, when the user modifies the PARVW field of an existing task to a value 'Person Responsible (VW)'  in the Tasks tab. . You can apply this to your requirement by modifying it suitably.

IF I_VIQMEL-QMART EQ 'Q1'.
   FIELD-SYMBOLS: <FS_QMSM> TYPE ANY.
   DATA: BEGIN OF I_QMSM OCCURS 10.
           INCLUDE STRUCTURE VIQMSM .
   DATA:END OF I_QMSM.

   DATA: BEGIN OF IT_QMSM OCCURS 10.
           INCLUDE STRUCTURE BAPI2080_NOTTASKI .
   DATA:END OF IT_QMSM.
   DATA:WA_QMSM LIKE IT_QMSM.

   ASSIGN ('(SAPLIQS0)IVIQMSM[]') TO <FS_QMSM>.
   I_QMSM[] = <FS_QMSM>.

   LOOP AT I_QMSM.
     IF I_QMSM-PARVW = 'VW'.

       WA_QMSM-TASK_SORT_NO =  '0001'.
       WA_QMSM-TASK_TEXT =  'Test for Auto-inclusion of Taks'.
       APPEND WA_QMSM TO IT_QMSM.

       CALL FUNCTION 'BAPI_ALM_NOTIF_DATA_ADD'
         EXPORTING
           NUMBER    = I_VIQMEL-QMNUM
         TABLES
           NOTIFTASK = IT_QMSM.

       CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE'
         EXPORTING
           NUMBER = I_VIQMEL-QMNUM.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
           WAIT = ''.
     ENDIF.
   ENDLOOP.
ENDIF.

Hope this helps

KJogeswaraRao

Answers (1)

Answers (1)

Ayoub_Habchi
Contributor
0 Kudos

Hello I-j,

In the exit, try to maintain directly the table  T_VIQMSM without calling the ADD_DATA Badi or the other blocks.

Let me know if this works.

Regards,

Ayoub.

Former Member
0 Kudos

I have already tried this, but the task has not been saved.

e_change = 'X'.

TASK_new_LINE-qmnum = I_VIQMEL-QMNUM.

TASK_NEW_LINE-mnkat = '2'.

TASK_NEW_LINE-matxt = 'Test Teamleader Task'.

TASK_NEW_LINE-mngrp = 'QM-G1'.

TASK_NEW_LINE-mnver = '000001'.

TASK_NEW_LINE-mncod = '0200'.

TASK_NEW_LINE-manum = '99'.

TASK_NEW_LINE-qsmnum = '1'.

*TASK_NEW_LINE-objnr = 'QA0002002700210099'.

TASK_NEW_LINE-parvw = 'VU'.

TASK_NEW_LINE-parnr = PARTNER_TAB2-PARNR.

APPEND TASK_NEW_line to T_viqmsm.

???

Ayoub_Habchi
Contributor
0 Kudos

Hi,

Is this all the code you put in the exit?

Try also to refer item ID with complete number (including leading zeros)

Regards,

Ayoub.