The End Goal:
To get a list of unique product numbers (ITMMASTER.ITMREF) that were ordered through a specific supplier (PORDERQ.BPSNUM) and display it in a product selection window.
Example:
Product # | Supplier # |
10005 | 0021 |
10006 | 0021 |
The Setup:
So basically I have the POH2 screen with a custom action (ZSELITM2) on the selection action for the ITMREF field. When the magnifying glass icon is clicked it opens a window that should contain the end goal as stated above.
The Problem:
Since I am linking into the PORDERQ table to receive the suppliers that we ordered that product through I am getting a product line for each purchase order.
Example:
Product # | Supplier # |
10005 | 0021 |
10005 | 0021 |
10006 | 0021 |
10006 | 0021 |
Using the code below as reference how can I limit/filter the results to distinct values?
The Code:
$ACTION
Case ACTION
When "SEL_TABLE" : Gosub SEL_TABLE
When Default
Endcase
Return
$SEL_TABLE
Case TABLE
When "ZSELITM2" : Gosub S_ZSELITM2
Endcase
Return
#########################################################################
$S_ZSELITM2
Local File ITMMASTER[ITM], PORDERQ[POQ]
Local Char WZBPSNUM: WZBPSNUM= PARAM(1)
Link [POQ] With [ITM]ITM0 =[POQ]ITMREF AS [LNK]
Default File [LNK]
SIZCOL = 400
SIZLIG = 150
If WZBPSNUM<>""
CRITERE = "BPSNUM='"+WZBPSNUM+"'"
Endif
TIT(0) = "Select Product"
NBCOL = 2
TIT(1) = "Test" : COL(1) = "ITMREF"
TIT(2) = "BP" : COL(2) = "BPSNUM"
Return
I did find a work around by creating a view with the data modeled as I want and then just pulled it in using some other code, but I would love to know how to accomplish this programmatically using 4GL.