Creating a Dynamic Selection Window in Sage X3

By | January 20, 2012

Suppose we need to create a screen comprising a selection text which will dynamically fetch the data from different tables in Sage X3.
Let us proceed with an example as stated below:

The screenshot shown below consists of an option named “Then by” which comprises four different selection options. Each time this option changes, the “From” and “To” selection lookup should have the respective selection data.
For e.g. whenever the Vendor Number is selected the “From” and “To” text should display the Vendor Numbers, whereas, if the option is selected as Nature of Deduction Code the selection window should have Nature of Deduction in “From” and “To” columns.

To achieve this we have created an action code for that respective field as follows:
Path: Development>Process>Action.


Thus, action code is created by the name DOCTYPSEL which consists of CNSDOCSEL as its Standard Process file and DOCTYPSEL as its Action Identifier

Standard Process file consists of the following code:

The SEL_TABLE is the action triggered when we select the data from any table, i.e. when, any user right clicks on the respective text field where selection event is present.

$ACTION
When “DOCTYPSEL”:
Case ACTION
When “SEL_TABLE”: Gosub SEL_TABLE
Endcase
Endcase
Return

As seen in the code above, the action intern calls the procedure SEL_TABLE
program:

$SEL_TABLE
Case TABLE
When “DOCTYPSEL”: Gosub S_SELPIA
Endcase
Return

The above code calls a subprogram by name S_SELPIA.

$S_SELPIA
Local Decimal WTYP           : WTYP = Val (PARAM (1))
Local Char     WNUM (GLONVCR): WNUM = VALEUR
TIT (0)  = mess(18,100,1)
CRITERE = “1=1”
Case [M] VCRTYPSEL
When 1:
If!clalev([F:BPS]) : Local File BPSUPPLIER  [BPS] : End if
Default File [BPS]GSELFAC = 1
OBJET   = “BPS”
Filter [F: BPS]CRITERE = “BPSTYP=1”
When 2:
……………………
Endcase
SENS    = 1
VALEUR = WNUM
DEFPAG = 1
Return
As seen in the above code, the program works on different case statements for each selected parameter.

The following screenshot will give us a better understanding:


Thus, whenever the Vendor Number field is selected, the Selection window would display Vendor Numbers. similarly, if the Nature of Deduction is selected, it would thus select the Nature of Deduction data in Sage X3 [as seen in the above image].