scough
24th January 2011, 22:56
Looking for advice on where to start with using 4GL in product configuration constraints.
I currently do not program in 4GL but I think it shouldn't be that hard to write a function that looks up part numbers from a table filtered by arguments in the function call.
Anyone have any simple examples so I can get started?
Thanks
mark_h
24th January 2011, 23:01
This is the correct forum for questions around coding. Search this forums for sample scripts and sql - you should find a lot of threads around coding. Plus there is help attached to this forum - for LN, but a lot of it can be applied to 4c4.
EdHubbard
25th January 2011, 11:41
example 1: Calling a Baan dll tc.mcs.dll9988c (maintained in ttadv2131m000)
!#pragma used dll otcmcsdll9988c
!table ttipcf500
!table ttccom010
!import("tipcf500.cuno", tipcf500.cuno)
!if (tcmcs.dll9988c.read.customer.master(tipcf500.cuno) ) then
! [custname] = tccom010.cuno(3;4)
!endif
this reads the customer account number and then places part of it in a feature
You don't have to use a dll as you could write the sql in the constraint (the dll function is shown below).
function extern domain tcbool
tcmcs.dll9988c.read.customer.master(
domain tccuno pcuno
)
{
select tccom010.cuno,
tccom010.nama,
tccom010.ccty,
tccom010.ccur,
tccom010.cbrn,
tccom010.crat
from tccom010
where tccom010._index1 = {:pcuno}
as set with 1 rows
selectdo
return ( true )
endselect
return ( false )
}
scough
25th January 2011, 18:40
Thanks for the replies... this will get me started!
scough
31st January 2011, 19:44
The syntax for what I am trying to do does not appear to be as easy to find as I had hoped.
I am trying to add a part number to the BOM based on three parameters:
P1 (has 8 options)
P2 (has 2 options)
P2 (has 2 options)
I have a custom table tipcf900 having 4 fields (P1,P2,P3,PartNumber)
Given the current number of options there will be 32 rows in the table. Can anyone provide and example how how I can pull the PartNumber from this table and place it in the BOM?
Oh and if possible I would rather it not use an external dll at this point. I would like to use those later when I am more versed in programming 4GL.
The three parameters to be used in the SQL statement will come from user data entered into product feature fields ( i used Px here for simplicity. The product features are not really named Px)
mark_h
31st January 2011, 22:59
Assuming the unique key index on this table is p1,p2 and p3. Which means you get a unique part number for the query.
select tipcf900.*
from tipcf900
where tipcf900._index1 = {:p1,:p2,:p3}
selectdo
endselect
Without really knowing more it is too hard to really write a good query.
scough
1st February 2011, 18:16
Hmm.. I thought I posted a reply but its not showing so I will try again.
There are some nuances to the select statment that I need to know as you have shown in that example.
However, I am hoping someone my have a full example of how they query a table using parameter's pulled from user entered data into product feature fields and then use the results of that query to put the partnumber on the bill of materials.
mark_h
1st February 2011, 18:36
Can't help with PCF since we don't us it. You might try searching this forum for some of the PCF tables to see if there are any examples.
EdHubbard
1st February 2011, 23:11
placed above Mark's example code, it would be something like:
string p1 global
string p2 global
string p3 global
(assuming p1 to p3 are strings)
p1 = [feature1]
p2 = [feature2]
p3 = [feature3]
the square brackets refer in the constraint code to a name of a feature.
scough
2nd February 2011, 01:18
Ok... now given a set of parameters, the sql would return on of the 32 partnumbers from the table.
Do I access that returned partnumber in the following way: tipcf900.PartNumber
Now, this is where I am a little confused. The Generic BOM lists all of the 32 different part numbers, each having the ability to have its own constraint.
I am not sure where I need to create the substitution constraint. I would assume when I know where to create it, I would use "Item Code" and I would assign item_data = tipcf900.PartNumber
Is this correct?
EdHubbard
2nd February 2011, 11:10
So in your Generic BOM you have 32 items.
Against each one you can have the same constraint ID as it is having to go through the same process.
In the Validation section of that constraint ID, you will need to get validate = true for the actual item that you want.
So you could put validate = true after the selectdo and then add 2 lines below:
selectempty
validate = false
and then endselect
The effect of this is to only validate the item component that you need.
scough
2nd February 2011, 15:49
Ok thanks!