cancel
Showing results for 
Search instead for 
Did you mean: 

Is there anyway to add a nested object, Agentry-smp3.0

Former Member
0 Kudos

Hello Gurus,

I have two objects: PurchaseOrders and PurchaseItems. 1 PurchaseOrder has more than 1 PurchaseItems. In my Java code, I create a Item array in PurchaseOrder object to keep the PurchaseItems.

Now I want to add a PurchaseOrder in SAP and created a transaction to do so.

What should I do to add the PurchaseItems into the created PurchaseOrder? Do I have to create another transaction for it?

Any suggestion is highly appreciated. Thank you very much.

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

You will probably have to use multiple transactions if you want to send back only one PO object with lines.

  1. You will need create an Add transaction (with no update steps) to create the PO header object on the mobile device.
  2. Create add transactions (again with no update steps) to add the lines to the PO object on the mobile device
  3. When you are done and ready to send the object to the backend create an Edit transaction on the PO header object that will have properties for all the necessary PO header fields and a collection field that will be populated from the PO lines sub collection on the PO object.
  4. The Edit transaction will have the Update steps to send the PO object / lines to the backend system.  During your update steps you will need to loop over the lines sub-collection and add them one by one to the PO after the header is created in the backend.

I recommend using the ATE to confirm the transaction properties / sub-collection creation prior to being sent to the Agentry server for processing.

Good Luck!

--Bill

Former Member
0 Kudos

Hello Bill,

Thank you for your answer. Can you tell me more detail? It is my first time to add a new nested collection.

What I have created are

1. Transaction to add PO header: Done

2. Transaction to add PO Items: Done

3. Transaction to edit PO header and items: Done. The JavaBackend CreateSteplet is associate with this transaction.

What's about the actions? Do I have to create 3 action steps (or actions-i dont know) for 3 transactions, or just only need 1 action step for Edit Transaction?

I created Action steps as follows

POCreate:

     Transaction: POCreate

     Screenset: POCreate

     Target Object: None

ItemCreate:

     Transaction: ItemCreate

     Screenset: ItemCreate

     Target Object: None

POEdit:

     Transaction: POEdit

     Screenset: none

     TargetObject: none

I create 3 buttons to execute 3 above actions. 1 for POCreate, 1 for ItemCreate and another for POEdit.

Please help to verify if what I have done is correct.

    

Thank you very much.

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

You should always have a target object on your actions.  This makes them easier to read/understand and catches logic errors when you try to pass the wrong target to an action upon publish.  Your Action targets should be:

POCreate: MainObject - This is the object that holds the PO collection you are adding to

ItemCreate - PO - This is the object that holds the Items collection you are adding to

POEdit - PO - This is the object you are editing

Also, you should be running your POEdit transaction as part of your ItemCreate action.  Every time you add an item, you need to re-run the POEdit so that new item is bundled up and sent to the backend with the PO.  Make sure you have transaction merging turned on for the POEdit transaction so only one edit actually gets processed and passed up.  You should use the ATE and inspect your transactions to make sure this is working properly.  You want the edits to merge with the POCreate as well, so set them to merge with "any transaction".  In the transaction browser on the ATE, you should only ever see 1 transaction at a time for each PO.  If you see both a create and an edit, or multiple edits for the same PO, then you don't have the merging working correctly.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Thanks so much Jason...

i Dont really understand. In the java backend java bapi code, i loop over the transaction.item collection, then populate them into item array collection in PO object. is this possible to rerun the POedit every toime we add an item in my case? I thoghut the edit transaction should only run after we add all of the items onto device. Please help me explain it. Thank you vey much.

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

That was my point.  You only want the backend code to run once for each PO.  You can accomplish that with transaction merging on the client as I described.  You can run the Edit over and over again as long as the edit transactions are merging together.  That way, only one update step will run, passing up the PO and all the items you added only one time.  You could run the edit only after you add all items, but how would you trigger this?  How do you know when all items have been added?  Easier to just use merging and not worry about it.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Thank you for your help.

Now I face the issue: PurchaseOrderEdit Transaction property 1 missing target (":>PONumber" property) when I create a new Item and click save (circle green button)

Below are what I have done with the Agentry application. Please help me figure it out. Thank you very much.

Transactions:

1. Add new PO: NewPurchaseOrder transaction

2. Add new Item: AddPurchaseItem transaction

3. Edit PO: EditNewPO

Actions:

1. AddPurchaseOrder action

2. AddPurchaseItem action: invoke addItem transaction and editPo transaction

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

The EditPO transaction step does not need a target.  The parent action already points to the PurchaseOrder, so that is what will be used.  Try that first but I don't see that causing the error you received.  Does the EditNewPO transaction work otherwise?  Add a new button to test it on the purchase order list that runs your EditNewPO against the selected PurchaseOrder object.  Does it work or do you get the same error?  If you get an error, something is wrong with the transaction properties in EditNewPO.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

1. I removed the target of EditPO transaction step, but it shows the same error.

2. I edited EditNewPO as you suggested and tested it. Yes, the transaction works.

Something wrong might happen to the flow, I guess. Could you please help me check it. Thank you very much.

First, I add a new PurchaseOrder by clicking CreatePO button in the PurchaseOrder list.

Second, I click the newly PO to view detail screen with Item list screen.

Third, I choose Item List screen, and add new Item by clicking create New button. And click save. Then it shows the error.

Note: I dont create any screenset for editPO transaction and in EditPo transaction, I add all properties of PO, included PurchaseItemCollection. ( I am not sure if it is correct)

Former Member
0 Kudos

Hello,

I dont receive any error now but I still cant add the new PO with its Items to SAP. I check the log and it doesnt show any error. Please help me


2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PONumber = LOCAL_101 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PO_NUMBER=LOCAL_101 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.CompanyCode = 1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::COMP_CODE=1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseDocType = NB |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::DOC_TYPE=NB |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.ReleaseIndicator = R |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PO_REL_IND=R |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.ReleaseStatus = X |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::REL_STATUS=X |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.CreatedBy = HNGU3 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::CREATED_BY=HNGU3 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.VendorAccountNumber = 0000002000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::VENDOR=0000002000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseOrganization = 1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PURCH_ORG=1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseOrgGroup = 000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PUR_GROUP=000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.Currency = EUR |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::CURRENCY=EUR |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.POItemID = LOCAL_POITEM:1 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.POItemID = LOCAL_POITEM:1 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.PONumber = LOCAL_101 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.POItem = LOCAL_POITEM:1 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.Material = 2038 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.Plant = 1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::begin |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getString::Property: transaction.PurchaseItemCollection.0.Unit = EA |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::MATERIAL=2038 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PLANT=1000 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::QUANTITY=0 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::PO_UNIT=EA |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###FetchBAPI_Java_Class::NET_PRICE=0.0 |

2014 07 06 15:35:03#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###execute::::HNGU3::before BAPI execute: ZBAPI_CH_DOPURCHASEORDER_CRT |

2014 07 06 15:35:04#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###execute::::HNGU3::after BAPI execute: ZBAPI_CH_DOPURCHASEORDER_CRT |

2014 07 06 15:35:04#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getClientDeviceLanguage::begin |

2014 07 06 15:35:04#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###User::getClientDeviceLanguage::Property: <<user.client.Language>> = en |

2014 07 06 15:35:04#+0700#INFO#System.out##anonymous#Agentry Runtime Worker Thread###Steplet::doSteplet() |

2014 07 06 15:35:04#+0700#INFO#System.out##anonymous#Thread-1339###Reset timer. |

The Bapi wrapper I call in Java Steplet is ZBAPI_CH_DOPURCHASEORDER_CRT

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

How did you resolve the client-side error?  It seems like your line items are getting passed up because transaction.PurchaseItemCollection is showing up for the 1st line.  Do you mean that the line items are not saving to SAP?  If that is the case, then you need to debug your java code and make sure that you are populating the BAPI table with the PO Item Lines transaction data before saving.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

i solved client side error by adding the apply action step into add item step. I dont know if it is correct but temporarily, the client side error disappear.

the add item step:

createItem

apply

editPO

apply.

no, it didnt add anything, PO and Items. Do u mean that there is something wrong with the order of sending the PO and items?

now, i have to update the PO. We can add new items to the PO, or edit the existing items of the PO. Do u have any solutin for it. Thank you very much.

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

No, I mean there is something wrong with your java that actually populates the BAPI tables and posts the data to SAP.  Get a hold of older Syclo java for WM or SM to see how bundled data is posted there with parent objects and sub-collections.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Jason,

The problem is finally solved and now I can add PO and its Items. Thank you so much for your support.

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

PH,

Please remember to mark the question answered.

Thanks,

--Bill

jason_latko
Advisor
Advisor
0 Kudos

PH Ngu,

Please explain how you corrected the problem, and mark this thread as answered so others can benefit.  Thanks!

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hello,

The Bapi was incorrectly configured. That's why we could not add anything but the did show no error.

We fixed the Bapi and resolved the issue then.

Thanks

Answers (0)