I built an App with the Master Detail Template. Normaly you navigate between 2 entities. For example Storage Type (Master Page) and the belonging Quantity (Detail Page). My problem is, that the Storage Type depends on a Warehouse number, which is fix in my case. The navigation to the detail page needs 2 key ids. The Storage Type is given, but my Warehouse Number has the value "null" but should be "Y01". How do i manually assign the Warehouse Number in my code or better there do i find this parameter ?
RequestPayload
--batch_3d6f-76ed-a97a Content-Type: application/http Content-Transfer-Encoding: binary
GET LagertypSet(Lgnum=null,Lgtyp='D41') HTTP/1.1
sap-contextid-accept: header Accept: application/json Accept-Language: de-DE DataServiceVersion: 2.0 MaxDataServiceVersion: 2.0 x-csrf-token: Uae5fDde8SUoJexmuZEsug==
--batch_3d6f-76ed-a97a--
Kind Regards, Felix
Just as a little starting note: It is usually a good practice to not hard-code the warehouse number in your code, but to get it from a configuration table somewhere, either in your application, or better from the back-end (e.g. user-parameters?)
Anyway, the secret lies somewhere in the createKey method that is probably part of the code you generated? The createKey constructs the portion LagertypSet(Lgnum=null,Lgtyp='D41')
based on the parameters you pass and on the metamodel of your service. In your situation, this should look like:
var key = createKey("/LagertypeSet", {
Lgnum: somethingThatsNull,
Lgtyp: keyFromMaster
});
The Lgnum shouldn't be pointing to the variable that's null anymore, but to the variable that contains Y01
. E.g.:
var defaultWarehouse = "Y01";
var key = createKey("/LagertypeSet", {
Lgnum: defaultWarehouse,
Lgtyp: keyFromMaster
});
I hope with these pointers, you'll be able to improve your code. Good luck!