I want to create a BAQ that includes the country name of the order’s destination. The ultimate goal is a sales report based on the AR invoice.
However, I ran into one difficulty. I need the destination country name. I found out that OrderRel_OTSCounrtyNum had the field values I wanted. But that field is just a number, and I need a Description.
I want to create a SQL that will fetch this CountryNum into Description.
Please help me. Thank you very much.
The information you need should be in the Country table. If you join that to your query then the Description field gives you the country name.
Sometimes the field help gives a bit of additional information to help locate the data you are looking for.
One other thing might be worth checking is that I think the OrderRel.OTSCountryNum field will only be populated if you are using One Time Ship-To addresses on the order. If you are using saved Ship To addresses I think you will need to look at another table for the address details.
Sorry, I didn’t tell you about my Phrase Build situation earlier.
I want to use InvcHead to represent one line per Invoice. Total amount and some additional information related to Total, etc…
When I connect OrderDtl, the lines increase as many as the number of Dtl.
So I’m looking for another way.
There is also the field OrderRel.OTSCountryNum but it only seems to be populated if you have entered a different OTS on the release compared with the OTS input into the order header.
Can you share a bit more information about your order/shipping/invoice process, particularly:
Do you ship your whole order to the same address, or can there be different addresses at line or release level?
Do you have multiple shipments per invoice? If so, do these all go to the same shipping address? If not, how will you decide which address to use in your report.
If you have a simple process where you have one shipment for the whole order to the same address, and then invoice the complete shipment, then I think there are only three places to look at the for the address, all at header level.
The ShipTo table if you have saved shipping addresses
The Customer table if the the order is shipped to the customers invoice address
The OrderHed table if you are using One Time Ship To’s
Sorry I’m a bit rusty on this, a few years ago we added custom address fields to our ShipHed table which automatically capture the address information for all our scenario’s, making it easy to report on, but harder for me to remember how we did it before.
We ship whole order to the same address.
We have multiple shipments per invoice, but these all go to the same shipping address.
In fact, my now retired colleague implemented exactly the country name I wanted.
The BAQ below is his. I don’t have contact with him, so I can’t ask him.
I hope this helps.
This is what everyone has been saying basically, but to put it all together:
If the order has a “one-time ship-to,” then the address info is on the OrderHed table
If the order has a ship-to selected, you need the ShipTo table for the data
If you have no ship-to selected and it is not a “one-time ship-to” … you actually do have a ship-to - its ID is "" [empty string].
a. (You can ignore this advice; it’s covered by #2.)
City is free text in 1 and 2
So is State/Province, ZIP, etc.
But Country is text in the ShipTo table and an integer in the OrderHed table.
a. Thus you need to join in the Country table for the sake of one-time ship-to.
This reminds me of another implied point - one that really seems like a bug (I know, it’s not):
The ship-to address can be changed at any time, so if you reprint an old invoice, it can lie to you about where the order was actually shipped to.
For that reason and just the headache of it all, why is the address info not just ALL stored in the order or pack slip etc.?
I can hear the rebuttal - because the code probably looks at the ship-to ID to see if it can combine multiple lines/orders on one one pack slip or if it needs to be split up. Also ship-to IDs can carry Tax Liability info.
I am not sure about the triggers that happen with OTS. I have not really dug in to see what happens when you use OTS with saving as a ST and OTS without saving.