cancel
Showing results for 
Search instead for 
Did you mean: 

Swapping Values in the Collection - Agentry

Former Member
0 Kudos

Hello Experts,

We have a requirement on swapping the values in collection, sequence value to be swapped between another record if the new sequence value is already existing for that record. This swapping should happen at agentry level without transmitting.

For Eg:

WO1

    TEST1_F(Operation1)

      MP1       ZSORT =11

      MP2       ZSORT =12

      MP3       ZSORT =13

      MP4       ZSORT =14

      MP5       ZSORT =21

      MP6       ZSORT =22

Now if technician updates the sequence of MP1 as ZSORT =13 à As per the requirement without transmitting, MP1 should get updated value ZSORT=13 and MP3 should be updated ZSORT=11.

We have created an action to edit the value of sequence now we want to search the changed value in the collection and swap.

How this can be achieved in Agentry?

  Please suggest

Regards,

Abhishek Wajge

Accepted Solutions (1)

Accepted Solutions (1)

jason_latko
Advisor
Advisor
0 Kudos

Abhishek,

Assume you are in an Action that edits a WO record.  The user changes the ZSORT, so now we need to check to see if another record already has that ZSORT and swap them.

Create two new string properties in the main object: TempZSORT and TempWO.  Write the current record's ZSORT and WOid to these properties with a new transaction that edits the MainObject.  Apply this change.

Now create a sub-action called UpdateNewWorkorder that searches for the other record, that has an execute rule on it that also looks to see if another record exists that matches.  Place this sub-action step directly after the Apply from the original edit (or add?) transaction.  The execute rule looks like this: ExecuteZsortSwap

TYPE

     MainObject -> Workorders Collection -> First Object Where SearchWOs rule is True

SearchWOs rule looks like this:

AND

     EQSTR

          Workorder Object -> ZSORT

          MainObject -> TempZSORT

     NOT

          EQSTR

               Workorder Object -> WOid

               MainObject -> TempWOid

The above will find the first WO that matches the ZSORT and is not the original record, if one exists.  The execute rule ensures that if there is not a matching record, the sub-action will not execute.  TYPE acts as a WHERE EXISTS Boolean check.  If the target path under the TYPE exists, then TYPE will return TRUE, else FALSE.

In the new sub-action, you will run a new transaction called WorkorderEditUpdateZsortNew

This transaction edits a Workorder object and has one property: ZSORT

Initial Value will be from another object property.  Point to this target:

MainObject -> Workorders Collection -> First Object Where SearchWOs rule is True -> Zsort property

The above will again find the matching record and pull the ZSort from it.

Apply this transaction.  Now we have completed one end of the swap.

Create another sub-action step called UpdateOldWorkorder in the original action, after the first.  Again use the execute rule ExecuteZsortSwap.

Now set the target of that sub-action to that record:

MainObject -> Workorders Collection -> First Object Where SearchWOs rule is True

In the new sub-action, you will run a new transaction called WorkorderEditUpdateZsortOld

This transaction edits a Workorder object and has one property: ZSORT

Initial Value will be from another object:  Then point to MainObject -> TempZSORT

Apply this transaction, and you are done.  The values are now swapped!

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Thanks Jason. It helped, swapping is working now.

Regards,

Abhishek

Answers (0)