Hi,
I am not good with tcl and need help to write a simple UPOC to do the following please:
I receive various file names from a source once daily and I need to update the database only if the file type is SMS Daily , TCHEADERÂ or CVENDOR . The rest can be killed.
The problem is, the contents of the file is received in a separate message that has no file names. The file names are in the message above but can be identified using certain format.
We receive files in Cloverleaf with the following (This is what I see in SMART DB):
This is what I see in the first line:
(1) Anything that has “Interface is Complete” needs to be killed and move onto the next message in the SMART DB
“2024-08-06 1640 Records Have been extracted as TCTERMS. Interface is Complete”
*************************************************************************
Then I need to look for any of the 3 file types which has the following format in the first line of the incoming file:
(2) SMS Daily – (tcl code to uniquely identify the files
file where the unique identifier is a combination of 4 elements, SQDMFGVENDORNBR which is first 6 digits, followed by SQDDISTVENDORNBR next 6 digits withoutany spaces and SQDCONTRACTNBR next 6 gigits and SQD-ITEM-REF-NBR last 7 digits)
SMS Daily Format -9383479383471176278274720AR-4205
******************************************************************************
(3) TCHEADER – The first 6 digits is the vendor #
KILL: First ” 2024-08-06 2042 Records Have been extracted as TCHEADER . Interface is Complete”
9577491175222025-09-302018-10-022018-10-02NNot
******************************************************************
(4) CVENDOR – The first 6 digits is the vendor #
KILL: First ” 2024-08-06 2042 Records Have been extracted as CVENDOR. Interface is Complete”
Format: 003938347000001UNIT 1, TESTTTT PARK SHEPCOTE LANE SHEFFIELD GB11 1 D11
**********************************************************************
This is what I started doing
proc trxID_Cat360Files_US { mh } {
set file_handle [open $filename r] ;# Get message
echo “hello, these are files from 360Catalogue”
# Read the first line
set first_line [gets $file_handle]
# Close the file
close $file_handle
# Extract the data elements using regular expressions
regexp {(\d{6})(\d{6})(\d{6})(\d{7})} $first_line match sqd
# Check if all elements were found
if {$match} {
# Construct the unique identifier
set IMS_SMS_DAILY_unique_identifier [string concat $sqdmfgvendornbr $sqddistvendornbr $sqdcontractnbr $sqditemrefnbr]
# Return the unique identifier
return $unique_identifier
echo IMS_SMS_DAILY = $IMS_SMS_DAILY_unique_identifier
set filenames
} else {
# If no match was found, return an empty string
return “”
}
set TRXID “trxID_Cat360Files_US”
}
I have added 3 attachments too of what I have done so far and the schema.