on 05-15-2018 11:03 PM
Hi, I created a UDF that links purchase order to sales order. I was able to do so, however, I’d like to be able to show the docnum of the purchase order. With the UDF, it shows the row number and not the docnum. Can you pls give me suggestions on how to make this possible? I’m guessing creating another UDF (formatted search) to populate the PO docnum from the linked UDF. Am I correct?
using sap b1 9.2
Hi Pia,
The available fields depend on the chosen table. A document is always registered in two tables, one contains the header data, like DocNum, and the other contains the row data, like LineNum.
So you need to connect the UDF, or a new UDF, to the table that contains the DocNum field. You can turn on System information from the View menu, and hover the mouse arrow over the DocNum field, to find out which table you need (it will be displayed in the information field at the bottom of the left of the B1 client).
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Johan for the reply. I think I understand the concept, but not sure how to apply it. The table I want to connect my new UDF to, is it the lookup table found in my linked UDF (which is just a lookup table and does not have a name, when I hover the mouse arrow over) or the actual PO window. I'll attach a screenshot for your reference.salesorderscreenshot.jpg
How would I write the FMS query for my udf?
Hi Pia,
You would have to hover the mouse over the required field in the PO window (see screenshot).
Please note that this works for almost all fields in the B1 client, and can be very handy when you need to write a query, for example for a report, or formatted search.
Now the items in a sales order can technically come from multiple Purchase Orders, so your UDF should indeed be no the row level of the Sales Order. If you would like to link the Sales Order row to Purchase Order row, you would have to create two UDFs on the row level of the Sales Order. One UDF would be linked to the OPOR table to get the DocNum, and the other would show the row number (LineNum).
Regards,
Johan
SELECT T0.DocNum
FROM dbo.OPOR T0
WHERE T0.U_PO<br>
Hi Johan, here's what I came up with for my FMS query on my other UDF, but not having much luck (sorry, fairly new to sap and sql). Also, we are keeping the PO link on the header and not at row level (assigning one PO will do). Thanks so much for your help!
U_PO - udf linked to Purchase Order (shows linenum)
U_PONum - udf to get DocNum (need help with FMS query)
Hi Pia,
That was exactly what I meant, thank you. To make the U_PO field as efficient as possible, we need to try and narrow down the list of POs as much as possible. So a couple more questions please:
Regards,
Johan
Hi Johan,
I appreciate the help!
Thanks,
Pia
Hi Pia,
Allright, the process is reasonably straightforward. Please do the following (in a test database first, to make sure that it works as expected):
SELECT T0.[DocNum]
, T0.[DocDate]
, T0.[CardCode]
, T0.[CardName]
, (select count(*) from POR1 where DocEntry = T0.DocEntry) AS [Nr of Rows in PO]
FROM OPOR T0
/* The number -4 determines how many
days old POs will be shown.
Change this number to get more or
less days worth of POs */
WHERE T0.[DocDate] BETWEEN cast(floor(cast(DATEADD(DAY, -4, GETDATE()) as float)) as datetime)
/* The number 0 determines how many
days into the future POs will be shown.
Change this number to get more or less days worth of POs */
AND cast(floor(cast(DATEADD(DAY, 0, GETDATE()) as float)) as datetime)
/* Please note that the first number (-4)
cannot be larger than the second number (0) */
6. Save the query (I recommend creating a separate category named 'Formatted Searches')
7. Open the Sales Order form
8. Click in the new User Defined field (PO), and press ALT + SHIFT + F2 on your keyboard
9. Choose the Search in Existing User-Defined Values according to Saved Query option.
10. Press the Open Saved Query button, select the new query you just saved, and press the OK button
11. Create a new Sales Order
12. Click the user defined field, and press SHIFT+F2
13. Choose the relevant purchase order, and Bob's your uncle.
Please note that I do not know if you will see the yellow drill down button with the user defined field.
Regards,
Johan
That worked Johan! Exactly what I was looking for, it also eliminated creating additional UDF's. Thank you so much! I appreciate the helpful tips as well. Will mark this solved and closed.
Cheers!
Pia
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.