how to give option to write comments about rejection in case Approver rejects the workitem?

Sue Keohan keohan at ll.mit.edu
Mon Nov 21 22:17:15 EST 2005


Hi Yogesh,

How about a nice little popup, in your dialog approval task. I've used 
it many times. Some sample code here...
FUNCTION z_invoice_approval.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(INVOICE) LIKE RBKP-BELNR
*" EXPORTING
*" REFERENCE(RESULT) LIKE OFIWA-OKCOD
*" REFERENCE(APPROVE_OR_REJECT) LIKE SYST-INDEX
*" TABLES
*" REJECTION_REASON STRUCTURE ZWF_TEXT
*" EXCEPTIONS
*" INVOICE_NOT_FOUND
*"----------------------------------------------------------------------
* This function module will display key information to approvers,
* and also allow them to approve, reject, or display the Invoice.

DATA: objkey LIKE sweinstcou-objkey.
DATA: event_container TYPE STANDARD TABLE OF swcont
WITH HEADER LINE.

DATA: vendornumber LIKE lfa1-lifnr.

approve_or_reject = 0.
* get the Invoice info from RBKP
SELECT SINGLE *
FROM rbkp
WHERE belnr = invoice.

* get Purchase Order Number

* now get the vendor name



* now, get the status information to be displayed
* REFRESH: i_wbs.

result = 'CANC'.
approve_or_reject = 99.
rejection_text[] = rejection_reason[].
* g_wi_id = wi_id.
CALL SCREEN 9001 STARTING AT 1 1.

result = action.


CASE result.
WHEN 'APRV'.
approve_or_reject = 0.
* add new option, 'Approve with Comments' - 3/25/04 - SRK
when 'APRVCMMNT'.
approve_or_reject = 0.
* 03/31/04 - append any new lines to rejection reason - SRK
append lines of rejection_text to rejection_reason.
* rejection_reason[] = rejection_text[].
WHEN 'REJ'.
rejection_reason[] = rejection_text[].
approve_or_reject = 1.
WHEN OTHERS.
approve_or_reject = 99.
ENDCASE.


ENDFUNCTION.
And here is the dialog stuff...


MODULE user_command_9001 INPUT.
action = okcode.

CASE okcode.
WHEN 'APRV' OR 'REJ' or
'APRVCMMNT'.
* 03/25/04 - SRK - add capture of text for 'Approve with Comments'
if okcode = 'APRVCMMNT'.
CONCATENATE 'Approval reason for Invoice'(t04)
rbkp-belnr INTO title_str
SEPARATED BY space.
descr1 = 'Enter your reason for Approval'(t05).
CONCATENATE 'TC Invoice:'(t06) rbkp-belnr INTO descr2
SEPARATED BY space.
DO.
CALL FUNCTION 'Z_WFCOM_GET_USER_TEXT'
EXPORTING
title = title_str
descr1 = descr1
descr2 = descr2
TABLES
rejection_text = rejection_text
EXCEPTIONS
user_cancel = 1
OTHERS = 2.

CASE sy-subrc.
WHEN 0.
LOOP AT rejection_text.
IF rejection_text IS INITIAL.
DELETE rejection_text.
ENDIF.
ENDLOOP.
LOOP AT rejection_text.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
MESSAGE i090(zwf).
CLEAR okcode.
CONTINUE.
ENDIF.
EXIT.
WHEN 1.
EXIT.
WHEN 2.
REFRESH: rejection_text.
ENDCASE.
ENDDO.
IF sy-subrc = 1.
EXIT.
ENDIF.
ENDIF.

IF okcode = 'REJ'.
CONCATENATE 'Rejection reason for Invoice'(t04)
rbkp-belnr INTO title_str
SEPARATED BY space.
descr1 = 'Enter your reason for rejection'(t05).
CONCATENATE 'TC Invoice:'(t06) rbkp-belnr INTO descr2
SEPARATED BY space.
DO.
CALL FUNCTION 'Z_WFCOM_GET_USER_TEXT'
EXPORTING
title = title_str
descr1 = descr1
descr2 = descr2
TABLES
rejection_text = rejection_text
EXCEPTIONS
user_cancel = 1
OTHERS = 2.

CASE sy-subrc.
WHEN 0.
LOOP AT rejection_text.
IF rejection_text IS INITIAL.
DELETE rejection_text.
ENDIF.
ENDLOOP.
LOOP AT rejection_text.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
MESSAGE i090(zwf).
CLEAR okcode.
CONTINUE.
ENDIF.
EXIT.
WHEN 1.
EXIT.
WHEN 2.
REFRESH: rejection_text.
ENDCASE.
ENDDO.
IF sy-subrc = 1.
EXIT.
ENDIF.
ENDIF.
LEAVE TO SCREEN 0.
WHEN 'DISP'.
* SET PARAMETER ID 'VL' FIELD likp-vbeln.
SET PARAMETER ID 'RBN' FIELD rbkp-belnr.
SET PARAMETER ID 'GJR' FIELD rbkp-gjahr.
SET PARAMETER ID 'CHG' FIELD ' '.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.

CLEAR okcode.

ENDMODULE. " user_command_9001 INPUT
*&---------------------------------------------------------------------*
*& Module exit_9002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit_9002 INPUT.
action = okcode.
CASE okcode.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR okcode.

ENDMODULE. " exit_9002 INPUT
*&---------------------------------------------------------------------*
*& Module user_command_9002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9002 INPUT.
action = okcode.

CASE okcode.
WHEN 'ATT'.

CALL FUNCTION 'SWL_WI_NOTE_CREATE'
EXPORTING
wi_id = g_wi_id
* WORKITEM =
* NOTE =
* I_SUPPRESS_ENQUEUE = ' '
* DO_COMMIT = 'X'
* CHANGING
* WI_HEADER =
* SWLC_WORKITEM =
EXCEPTIONS
error_setting_note_exist_flag = 1
error_note_creation = 2
error_container_update = 3
container_does_not_exist = 4
error_in_wi_enqueue = 5
illegal_wi_state = 6
wi_header_read_failed = 7
object_creation_failed = 8
method_calling_failed = 9
wi_buffer_refresh_failed = 10
user_has_cancelled = 11
OTHERS = 12.
CASE sy-subrc.
WHEN 11.
okcode = 'CANC'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
LEAVE TO SCREEN 0.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.

CLEAR okcode.


ENDMODULE. " user_command_9002 INPUT
*&---------------------------------------------------------------------*
*& Module EXIT_9003 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit_9003 INPUT.
* The OKCODE for CANC is type 'E', so any processing of CANC occurs
* in this block, not in the user_command_9003
action = okcode.
CASE okcode.
WHEN 'CANC'.
*** Destroy the controls before leaving. It's pointless to
*** capture exceptions here, because if this fails, the program will
*** short dump while going back to the selection screen anyway.
CALL METHOD: cc_editor->free,
rr_container->free.
REFRESH t_rejection_reason.
CLEAR t_rejection_reason.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR okcode.

ENDMODULE. " EXIT_9003 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9003 INPUT.
action = okcode.
* user can select to display or change the invoice, end the workflow
CASE okcode.
WHEN 'DISP'.
* SET PARAMETER ID 'VL' FIELD likp-vbeln.
SET PARAMETER ID 'RBN' FIELD rbkp-belnr.
SET PARAMETER ID 'GJR' FIELD rbkp-gjahr.
SET PARAMETER ID 'CHG' FIELD ' '.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
CALL METHOD: cc_editor->free,
rr_container->free.

WHEN 'CHNG'.
SET PARAMETER ID 'RBN' FIELD rbkp-belnr.
SET PARAMETER ID 'GJR' FIELD rbkp-gjahr.
SET PARAMETER ID 'CHG' FIELD 'X'.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
CALL METHOD: cc_editor->free,
rr_container->free.
WHEN 'END'.
*** Destroy the controls before leaving. It's pointless to
*** capture exceptions here, because if this fails, the program will
*** short dump while going back to the selection screen anyway.
CALL METHOD: cc_editor->free,
rr_container->free.
REFRESH t_rejection_reason.
CLEAR t_rejection_reason.
LEAVE TO SCREEN 0.
ENDCASE.

CLEAR okcode.
ENDMODULE. " USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
*& Module exit_9004 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module exit_9004 input.
* The OKCODE for CANC is type 'E', so any processing of CANC occurs
* in this block, not in the user_command_9004
action = okcode.
CASE okcode.
WHEN 'CANC'.
*** Destroy the controls before leaving. It's pointless to
*** capture exceptions here, because if this fails, the program will
*** short dump while going back to the selection screen anyway.
CALL METHOD: cc_editor->free,
rr_container->free.
REFRESH t_rejection_reason.
CLEAR t_rejection_reason.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR okcode.

endmodule. " exit_9004 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9004 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9004 input.
action = okcode.
* user can select to display or change the invoice, end the workflow
CASE okcode.
WHEN 'DISP'.
* SET PARAMETER ID 'VL' FIELD likp-vbeln.
SET PARAMETER ID 'RBN' FIELD rbkp-belnr.
SET PARAMETER ID 'GJR' FIELD rbkp-gjahr.
SET PARAMETER ID 'CHG' FIELD ' '.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
CALL METHOD: cc_editor->free,
rr_container->free.

WHEN 'CHNG'.
SET PARAMETER ID 'RBN' FIELD rbkp-belnr.
SET PARAMETER ID 'GJR' FIELD rbkp-gjahr.
SET PARAMETER ID 'CHG' FIELD 'X'.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
CALL METHOD: cc_editor->free,
rr_container->free.
WHEN 'END'.
*** Destroy the controls before leaving. It's pointless to
*** capture exceptions here, because if this fails, the program will
*** short dump while going back to the selection screen anyway.
CALL METHOD: cc_editor->free,
rr_container->free.
REFRESH t_rejection_reason.
CLEAR t_rejection_reason.
LEAVE TO SCREEN 0.
ENDCASE.

CLEAR okcode.

endmodule. " USER_COMMAND_9004 INPUT

Yogesh Chopra wrote:

> Thanks for your reply Edwin. There is some thing different happening 
> in SAP standard transaction FV60. Please Note every body.
>
> In Transaction FV60, I experienced that change event will only 
> initiate when Document is changed from Complete to NON-Complete
>
> Complete event will only initiate when document is changed from 
> Non-Complete to Complete.
>
> In any other circumstances we have to customize the event to occur.
>
> In my case I am doing changes in a complete document and saving it as 
> a complete that’s why no event was captured. I have created a user 
> exit and initiate a change event. Now it is working fine.
>
> Can any one give suggestion that, in case Approver wants to reject the 
> Invoice he /she may want to write the reason of rejection? How I will 
> accomplish this in my task. That is when a user click on the workitem 
> and press reject option then he/she should have option to write 
> his/her comments in that task
>
> Is there any way to accomplish this?
>
> Thanks and Best Regards
>
> Yogesh Chopra
>
> Yogesh.Chopra at axonglobal.com <mailto:Yogesh.Chopra at axonglobal.com>
>
> -----Original Message-----
> *From:* Edwin Mukusha [mailto:emukusha at nebraska.edu]
> *Sent**:* Tuesday, November 22, 2005 12:37 AM
> *To:* SAP Workflow Users' Group
> *Cc:* SAP-WUG at mit.edu; sap-wug-bounces at mit.edu
> *Subject:* Re: can any one suggest me for this ? "Wait for event"
>
>
> Hello Yogesh,
>
> Maybe, try using change object BELEGV instead. When dealing with 
> change documents keep an eye in the entries made in the table CDHDR to 
> make sure you are affecting the right document, and also keep a track 
> of what happens to your events via the event log (transaction SWEL) as 
> you go along.
>
> I am wondering why you specified the CREATED event in the case of a 
> change in the SWEC transaction. I would think that you want the event 
> CHANGED in such a case.
>
> Lastly make sure that your fork has 3 branches and needs 1 for 
> completion so that you accomplish the 'dissapearing act' (if you 
> haven't already done so).
>
> good luck,
>
> Edwin
>
>
>
> 	
>
> *"Yogesh Chopra" <Yogesh.Chopra at axonglobal.com>*
> Sent by: sap-wug-bounces at mit.edu
>
> 11/18/2005 09:03 PM
> Please respond to "SAP Workflow Users' Group"
>
> 	
>
>
> To: <SAP-WUG at mit.edu>
> cc:
> Subject: can any one suggest me for this ? "Wait for event"
>
>
>
>
> Hello! Every body
>
> There is one problem I am facing at the time of wait for event 
> generation.
>
> I have created my own customize ZFIPP and delegated it to FIPP. 
> Workflow start event is “ CREATE”. I am getting right workitem in my 
> SAP INBOX when I create COMPLETE PARK INVOICE document through FV60. I 
> have put fork with three braches in workflow. My requirement is, when 
> a user makes a change in parked document the new workflow should 
> overwrite the previous workflow item which is pending in approver 
> inbox for action. When a user delete the parked document then workflow 
> item should automatically be disappeared from approver INBOX.
>
> What customizing I should check to make change document work. I have 
> already made an entry in through SWEC
>
> BELEGR FIPP CREATED on change radio button is checked.
>
> What else I need to do. So that when a user make a change in parked 
> document, it should overwrite the previous pending workitem in 
> Approver inbox.
>
> I have wait for event in one of the branch in FORK where is am using 
> waiting change even to occur and after that I have user one activinty 
> where I am user RESET RELEASE FLAG function module. But this flag is 
> not reset when I am changing the document. It means that wait for 
> change event is not working properly.
>
> Please give any suggestions.
>
> Thanks and Best Regards
>
> Yogesh Chopra
>
>
>
>
>
> The content of this email is confidential and for the
> addressee only. If you are not the addressee of this
> email (or responsible for the delivery of this message
> to such person) you may not copy, forward, disclose
> or otherwise use it or any part of it in any form
> whatsoever. If you have received this email in error
> please email the sender by replying to this message
> and delete this message thereafter.
>
> Opinions, conclusions and other information in this
> message that do not relate to the official business
> of our Company shall be understood as neither
> given nor endorsed by it.
>
>
>
>
>
> The content of this email is confidential and for the
> addressee only. If you are not the addressee of this
> email (or responsible for the delivery of this message
> to such person) you may not copy, forward, disclose
> or otherwise use it or any part of it in any form
> whatsoever. If you have received this email in error
> please email the sender by replying to this message
> and delete this message thereafter.
>
> Opinions, conclusions and other information in this
> message that do not relate to the official business
> of our Company shall be understood as neither
> given nor endorsed by it.
>
>
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>
>
>
>
>
>
>
> The content of this email is confidential and for the
> addressee only. If you are not the addressee of this
> email (or responsible for the delivery of this message
> to such person) you may not copy, forward, disclose
> or otherwise use it or any part of it in any form
> whatsoever. If you have received this email in error
> please email the sender by replying to this message
> and delete this message thereafter.
>
> Opinions, conclusions and other information in this
> message that do not relate to the official business
> of our Company shall be understood as neither
> given nor endorsed by it.
>
>------------------------------------------------------------------------
>
>_______________________________________________
>SAP-WUG mailing list
>SAP-WUG at mit.edu
>http://mailman.mit.edu/mailman/listinfo/sap-wug
>  
>


More information about the SAP-WUG mailing list