on 07-01-2014 7:38 AM
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.
You will probably have to use multiple transactions if you want to send back only one PO object with lines.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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.
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
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
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
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)
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
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
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.
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
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.