I need to read variant configurations from sales orders.
At the moment I use the BAPI BAPI_SALESORDER_GETDETAILBOS or BAPISDORDER_GETDETAILEDLIST.
But I need some more information.
For example:
I got a car and I need all single parts which are included in that car (all material numbers).
Is there a BAPI, RFC or internal function module to get those pieces of information?
We solved it. Will use BAPISDORDER_GETDETAILEDLIST for this purpose.
Related
The Django docs on aggregation give the following example for annotations:
for store in Store.objects.all():
store.min_price # Error! min_price not defined!
for store in Store.objects.annotate(min_price=Min('books__price')):
store.min_price # Fine
However, we only annotated a single field. We only know what the price of the cheapest book is, but not exactly which is the cheapest book. What if I wanted the result of the annotation be precisely that book, not just its price? (I'll call this function or class AggregateRelation)
for store in Store.objects.annotate(
cheapest_book=AggregateRelation('books__price', Min)
):
store.cheapest_book.price
store.cheapest_book.title
Is there a way to do this?
I checked up FilteredRelation but that's only useful for filtering. It does not truly retrieve the instances.
If (and only if) you are using PostgreSQL, then I think there's an answer using .distinct(fields)
Book.objects.order_by('store_id', 'price').distinct('store_id')
should get you the cheapest book for each store if I've understood the documentation (linked above) right. Adding select_related() should mean that you don't hit the DB again when you refer to book.store.whatever
If you don't have PostgreSQL I think you can use a SubQuery. The following is my attempt to follow the documentation:
from django.db.models import OuterRef, Subquery
cheapest = Book.objects.filter(store=OuterRef('pk')).order_by('price')
stores = Store.objects.annotate(cheapest_book_pk=Subquery(cheapest.values('pk')[:1]))
Something like this will get you a list of Store objects, each annotated with the pk of the cheapest book that it is selling.
Please tell me whether I've got this right!
I have a tracking number from Amazon that starts with TBA that I'd like to track via their API. I've seen their getPackageTrackingDetails endpoint but it takes an integer as input and I get an error when I try to use a TBA number on that endpoint. I know it is possible somehow, since AfterShip can do it (just enter a valid tracking number that starts with TBA). I cannot find in Amazon's docs how to do it and Amazon customer support doesn't know how to do it, either.
You have to distinguish between the packageNumber (which is an integer) and the trackingNumber (which is a string). When creating your shipment, you will get the packageNumber. With that number you can call getPackageTrackingDetails.
The Shipping-Api seems to be the right endpoint to use. See https://github.com/amzn/selling-partner-api-docs/blob/main/references/shipping-api/shipping.md#get-shippingv1trackingtrackingid
The getTrackingInformation operation accepts a tracking number as an input parameter.
Looking through the API documentation, there doesn't seem to be a good way to go from TBA number (if you can't just cut off those first three letters) to Package ID.
My order of operations on fixing this problem:
Chop the first three letters off the TBA variable you have, convert to integer, try it. Per Andrew Morton's comment.
What AfterShip may also be doing is going from the order ID. If the TBA is closely related to the order ID, the Amazon API will give you the information to go from Order ID -> Fulfillment Shipment -> Fulfillment Package -> Package ID. You could then use the Package ID to get your package information. So I'd look at Order ID's as well as Package ID's to see if you could convert one to another.
Given Stevish's comment, it's possible that the TBA can be cut off the TBA number and used as a package number if there is only one package in the order, but things get more complicated in other situations.
If you're working on a site that has the seller Order ID stored on your side, that seems to be the intent they have for getting it through the API.
I was wondering what the limits were on the number of metafields that an entity in Shopify could have. For instance, under a given namespace for a product object, could you have 1000 unique key value pairs? Is there a hard limit?
Please note I have consulted the documentation on Shopify's Metafield API page (http://api.shopify.com/metafield.html) but it only states the following limits:
The namespace has a maximum of 20 characters, and the key has a maximum of 30 characters.
Thanks for help!
There's no hard limit, but if you're storing that much info you might want to consider doing it locally as retrieving it will become a pain.
The most metafields that we've applied to any given element to date is 5434. We have a collection that currently contains that many metafields, and it seems to be working fine!
I wouldn't advise doing this, as it's a nightmare to find and remove any via Postman if manual intervention is required. But it's certainly possible!
If you had the following
MyNS.Key1 = 1
MyNS.Key2 = 2
...
MyNS.Key1000 = 1000
You should be able to access it like
products.metafields.MyNS[someKey]
So not too difficult to retrieve, or am i missing something else
Does anyone have any experience adding their own data to GapMinder, the really cool software that Hans Rosling uses in his TED talks? I have an array od objects in JSON that would be easy to show in moving bubbles. This would be really cool.
I can see that my Ubuntu box has what looks like data in /opt/Gapminder Desktop/share/assets/graphs/world, but I would need to figure out:
How to add a measure to a graph
How to add a data series
How to set the time range of the data
Identify the measures to follow at each time step
and so on.
Just for the record: if you want to use Gapminder with your own dataset, you have to convert your data in a format suitable to Gapminder. More specifically, looking in the assets/graphs/world, you will have to:
Edit the file overview.xml, which contains the tree structure of all the indicators (just copy/paste an entry and specify your own data);
Convert your data copying the structure of the xml files in that directory (this is the tricky part): you can specify some metadata in the preamble, and then specify your own data series, with something like:
<t1 m="i20,50.0,99.0,1992" d="90.0, ... ,50.0, ..."/> where i20 is the country id, which is followed by the minima and maxima of the series, and the year it refers to.
In my humble opinion, Gapminder is a great app but it definitely needs more work on integration with other datasets. Way better to use Google Motion Chart as you did, or MooGraph (site and doc), which is unfortunately not as great as Gapminder.
#Stefano
the information you provided is very valuable. Is somewhere available a detailed specification of the XML files containing the data?
Anyway, just to enrich your response, I also found that:
overview.xml file
The link between Nations and their IDs is in this file
The structure of the menus for the selection of the indicators is also in the same file (at the bottom) under the section <indicatorCategorization>
The structure of the datafile XML
For each line the year represents the first year of the serie, and then the values follow one per year, comma separated.
Grazie,
Max
I ended up using the google motion chart API. I ended up with this.
My java/groovy program receives table names and table fields from the user input, it queries the tables in SAP and returns its contents.
The user input may concern the tables CDPOS and CDHDR. After reading the SAP documentations and googling, I found these are tables storing change document logs. But I did not find any remote call functions that can be used in java to perform this kind of queries.
Then I used the deprecated RFC Function Module RFC_READ_TABLE and tried to build up customized queries only depending on this RFC. However, I found if the number of desired fields I passed to this RFC are more than 2, I always got the DATA_BUFFER_EXCEEDED error even if I limit the max rows.
I am not authorized to be an ABAP developer in the SAP system and can not add any FM to existing systems, so I can only write code to accomplish this requirement in JAVA.
Am I doing something wrong? Could you give me some hints on that issue?
DATA_BUFFER_EXCEEDED only happens if the total width of the fields you want to read exceeds the width of the DATA parameter, which may vary depending on the SAP release - 512 characters for current systems. It has nothing to do with the number of rows, but the size of a single dataset.
So the question is: What are the contents of the FIELDS parameter? If it's empty, this means "read all fields." CDHDR is 192 characters in width, so I'd assume that the problem is CDPOS which is 774 characters wide. The main issue would be the fields VALUE_OLD and VALUE_NEW, both 245 Characters.
Even if you don't get developer access, you should prod someone to get read-only dictionary access to be able to examine the structures in detail.
Shameless plug: RCER contains a wrapper class for RFC_READ_TABLE that takes care of field handling and ensures that the total width of the selected fields is below the limit imposed by the function module.
Also be aware that these tables can be HUGE in production environments - think billions of entries. You can easily bring your database to a grinding halt by performing excessive read operations on these tables.
PS: RFC_READ_TABLE is not released for customer use as per SAP note 382318, and the note 758278 recommends to create your own function module and provides a template with an improved logic.
Use BBP_RFC_READ_TABLE instead
There is a way around the DATA_BUFFER_EXCEED error. Although this function is not released for customer use as per SAP OSS note 382318, you can get around this issue with changes to the way you pass parameters to this function. Its not a single field that is causing your error, but if the row of data exceeds 512 bytes this error will be raised. CDPOS will have this issue for sure!
The work around if you know how to call the function using Jco and pass table parameters is to specify the exact fields you want returned. You then can keep your returned results under the 512 byte limit.
Using your example of table CDPOS, specify something like this and you should be good to go...(be careful, CDPOS can get massive! You should specify and pass a where clause!)
FIELDS = 'OBJECTCLAS'....
FIELDS = 'OBJECTID'
In Java it can be expressed as..
listParams.setValue(this.getpObjectclas(), "OBJECTCLAS");
By limiting the fields you are returning you can avoid this error.