Conditional IS_IN_DB

19 views
Skip to first unread message

Carl Petersen

unread,
Jun 19, 2017, 4:09:10 PM6/19/17
to web2py-users
Hello,

I have a screen that updates a code cross-reference table which contains a code-type field.  That code-type field has a master table.  What I want to do is validate the cross referenced codes in the code cross reference table against various master tables depending on the value of the code-type field.  For instance:

This is the code cross-reference:




Values:

code_type source_system_id source_code                 target_code target_source_system_id code_type_id source_system_dwid target_system_dwid id
TM                 V                         UPS 3 DAY SELECT 3DS                 PS                                         8                 (null)                         (null)                         797
TM                 V                         UPS NEXT DAY AIR NDA         PS                                         8                 (null)                         (null)                         798
DT                 V                         COD - COLLECT         Collect         MG                                         9                 (null)                         (null)                         799
DT                 V                         COLLECT                 Collect         MG                                         9                 (null)                         (null)                         800

This is the code type table:


Values:


code_type code_description          id

ML                 UNKNOWN                   1

PT                 Payment Terms           2

CT                 Country                           3

PC                 Profit Center                   4

DP                 Department                   5

SL                 Ship Location                   6

SM                 GP Ship Method           7

TM                 Transport Mode           8

DT                 Delivery Terms           9

TC                 Transport Carrier         10

PlantCust Plants to Customers 12

II                 Ignore Inventory Plant 13

MC                 Shipping Country         11


What I would like is for the source and target code fields to be validated against different master tables based on the value of the code-type field.  For instance, if the code-type were "CT", I'd like the source and target codes validated against the country code master, but if the code-type field were "PC", then I'd like the source and target codes validated against the GL Profit Center table (ie... IS_IN_DB()).


Thanks,


Carl


Reply all
Reply to author
Forward
0 new messages