Advance With Dialog on Asynchronous Task
Ramki Maley
rmaley at erpworkflow.com
Tue Jun 30 16:45:00 EDT 2015
Loren,
I think you are allowed to have a terminating event for a synchronous
task. That should take care of change outside workflow. You don't need
any hacks other than a synchronous edit method.
It is worth a try. Not a good practice to update SAP tables directly ;-) .
Cheers,
Ramki.
On 6/30/15, 3:24 PM, Bratzler, Loren wrote:
>
> Ramki,
>
> Even if I put the status check in the "Complete Execution" condition,
> there is still the chance that someone could change the document
> status to "complete" between the time it is entered and when the
> approver acts upon it. Once that status is changed to "complete", I
> would not be able to use that as a way to know that it is OK to
> advance to the next step.
>
> So now, I have come up with another hack that so far, appears to work
> for every scenario I can think of. It involves setting the status of
> the document back to "parked" before launching the MIR4 t-code. Then
> when we come back from MIR4, I check it again to see if the status has
> been changed to "complete":
>
> begin_method zedit changing container.
>
> DATA: lv_status TYPE rbkp-rbstat.
>
> SELECT SINGLE rbstat
> FROM rbkp
> INTO lv_status
> WHERE belnr = object-key-invoicedocnumber
> AND gjahr = object-key-fiscalyear.
>
> IF lv_status = 'B'.
> UPDATE rbkp
> SET rbstat = 'A'
> WHERE belnr = object-key-invoicedocnumber
> AND gjahr = object-key-fiscalyear.
> ENDIF.
>
> PERFORM edit IN PROGRAM rbus2081 TABLES container CHANGING swo_%invoke.
>
> SELECT SINGLE rbstat
> FROM rbkp
> INTO lv_status
> WHERE belnr = object-key-invoicedocnumber
> AND gjahr = object-key-fiscalyear.
>
> IF lv_status <> 'B'. /" Completed/
> exit_cancelled.
> ENDIF.
>
> end_method.
>
> Note that I could not figure out how to get the SWC_CALL_METHOD to
> work so I am using the PERFORM option instead. It seems to work fine.
>
> Loren Bratzler
>
> Norfolk Southern Corporation
>
> *From:*sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] *On
> Behalf Of *Ramki Maley
> *Sent:* Tuesday, June 30, 2015 1:34 PM
> *To:* SAP Workflow Users' Group
> *Subject:* [EXTERNAL] Re: Advance With Dialog on Asynchronous Task
>
> Hi Loren,
>
> A better option might be to test the status in the 'Complete
> Execution' Condition for the step. Not sure if that will break the
> dialog chain. you can easily test it.
>
> And for the other question, the answer is SWC_CALL_METHOD <Object>
> <Method> <Container>.
>
> Cheers,
> Ramki.
>
> On 6/30/15, 9:28 AM, Bratzler, Loren wrote:
>
> Hey Jocelyn, hope you are doing well!
>
> Thinking about what you said and what Ramki said, I found a hack
> for my custom method that appears to work where I check the status
> of the document after returning from the t-code call:
>
> begin_method zedit changing container.
>
> DATA: lv_status TYPE rbkp-rbstat.
>
> DATA: xwfla1 LIKE boole-boole VALUE 'X'. /"Note916729/
> SET PARAMETER ID 'RBN' FIELD object-key-invoicedocnumber.
> SET PARAMETER ID 'GJR' FIELD object-key-fiscalyear.
> SET PARAMETER ID 'CHG' FIELD 'X'.
> EXPORT xwfla1 TO MEMORY ID 'FIENJOYWF'. /"Note916729/
> CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
>
> SELECT SINGLE rbstat
> FROM rbkp
> INTO lv_status
> WHERE belnr = object-key-invoicedocnumber
> AND gjahr = object-key-fiscalyear.
>
> IF lv_status <> 'B'./" Completed/
> exit_cancelled.
> ENDIF.
>
> end_method.
>
> The obvious downside to this is if someone happens to change the
> document status to "completed" outside of workflow via the normal
> backend MIR4 screen. We do have an enhancement implementation on
> the MIR4 screen where I might be able to control the "save as
> complete" button to only be allowed by the workflow approver. If
> I can make that work, then this approach may work for us.
>
> One more question for anyone: This custom method, ZEDIT, is a
> copy of the standard method, EDIT. Is there a way to call the
> standard method from my custom method so that I don't have to
> duplicate the code being executed?
>
> Loren Bratzler
>
> Norfolk Southern Corporation
>
> *From:*sap-wug-bounces at mit.edu <mailto:sap-wug-bounces at mit.edu>
> [mailto:sap-wug-bounces at mit.edu] *On Behalf Of *Dart, Jocelyn
> *Sent:* Monday, June 29, 2015 4:54 PM
> *To:* SAP Workflow Users' Group
> *Subject:* [EXTERNAL] Re: Advance With Dialog on Asynchronous Task
>
> Hi Loren
>
> Ok so this is why that method was originally asynchronous as with
> a transaction the std way to find out if the work was done is to
> listen for a terminating event.
>
> So Catch-22.
>
> Maybe see if there is a BAPI that lets you do a synchronous call.
>
> Is creating your own alternative UI in SAPUI5 or WDA to control
> the edit a possible option?
>
> Rgds
>
> Jocelyn
>
>
> Sent from my iPhone with many apologies for the spelling, grammar
> and any other deficiencies
>
>
> On 30 Jun 2015, at 5:28 am, Bratzler, Loren
> <Loren.Bratzler at nscorp.com <mailto:Loren.Bratzler at nscorp.com>> wrote:
>
> I'm not sure how I am going to be able to tell from within the
> EDIT method if the document is "COMPLETE" or not. The method
> code is executing transaction MIR4 directly like this:
>
> begin_method edit changing container.
>
> DATA: xwfla1 LIKE boole-boole VALUE 'X'. "Note916729
> SET PARAMETER ID 'RBN' FIELD object-key-invoicedocnumber.
> SET PARAMETER ID 'GJR' FIELD object-key-fiscalyear.
> SET PARAMETER ID 'CHG' FIELD 'X'.
> EXPORT xwfla1 TO MEMORY ID 'FIENJOYWF'. "Note916729
> CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
>
> end_method.
>
> Loren
>
> *From:*sap-wug-bounces at mit.edu
> <mailto:sap-wug-bounces at mit.edu>
> [mailto:sap-wug-bounces at mit.edu] *On Behalf Of *Ramki Maley
> *Sent:* Thursday, June 25, 2015 6:02 PM
> *To:* SAP Workflow Users' Group
> *Subject:* [EXTERNAL] Re: Advance With Dialog on Asynchronous Task
>
> Loren,
>
> Instead of a terminating event for your custom EDIT method,
> Try issuing an EXIT_CANCELLED if the document is not
> 'COMPLETE'. This will keep the workitem from completing.
>
> Cheers,
> Ramki.
>
> On 6/25/15, 1:58 PM, Bratzler, Loren wrote:
>
> Hello Wuggers,
>
> Hope someone can help me here:
>
> I have a requirement in a workflow to have a two-part
> approval process for the Incoming Invoice (BUS2081)
> business object. The first part of the approval process
> is to have the approver open the document in Edit mode and
> review and make revisions to a restricted number of
> fields. Once their review is done, we want them to click
> "Save as Complete" and then automatically advance to the
> second part of the approval process where the user
> decision (approve or reject buttons) appear.
>
> For the first step of the process, I am using the standard
> EDIT method of the object and when I define my task for
> using this method, I assign the terminating event
> "COMPLETED" so that the task will only complete when the
> user clicks "Save as Complete".
>
> The problem is that the EDIT method for this object is
> asynchronous:
>
> <image001.png>
>
> So the "advance with dialog" option does not work to
> automatically advance to the user decision step where the
> approve/reject buttons will appear.
>
> I tried to create my own custom synchronous method in the
> object that was a copy of the standard method. I then
> created a new task to execute this new method and defined
> the same terminating event. However, the problem with
> that is when I insert the task into the workflow, there
> are two outcome paths. One path is for the terminating
> event I assigned but the other path is the normal
> "advance" path. This causes the workflow to advance to
> the user decision step when we don't want it to. We only
> want it to advance when they click "save as complete" and
> raise the COMPLETED event. With this configuration, the
> step advances when they click other options on the screen
> like "back", "exit" or "cancel".
>
> <image002.png>
>
> The workflow builder will not allow me to deactivate the
> "Step executed" outcome for the step:
>
> <image003.png>
>
> Error message that occurs when you try to deactivate this
> outcome:
>
> <image004.png>
>
> So I'm trying to figure out is there some way for me to
> get around these limitations?
>
> Loren Bratzler
>
> Norfolk Southern Corporation
>
>
>
>
>
>
> _______________________________________________
>
> SAP-WUG mailing list
>
> SAP-WUG at mit.edu <mailto:SAP-WUG at mit.edu>
>
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu <mailto:SAP-WUG at mit.edu>
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>
>
>
>
> _______________________________________________
>
> SAP-WUG mailing list
>
> SAP-WUG at mit.edu <mailto:SAP-WUG at mit.edu>
>
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>
>
>
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu
> http://mailman.mit.edu/mailman/listinfo/sap-wug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20150630/91e94caf/attachment-0001.htm
More information about the SAP-WUG
mailing list