added LSL2 stored procedures
This commit is contained in:
142
LSL2/STPROC/IMPORT_NAMES.txt
Normal file
142
LSL2/STPROC/IMPORT_NAMES.txt
Normal file
@ -0,0 +1,142 @@
|
||||
compile function import_names()
|
||||
begin condition
|
||||
pre:
|
||||
post:
|
||||
end condition
|
||||
declare subroutine rlist
|
||||
declare function msg, fieldcount, send_info
|
||||
$insert logical
|
||||
$insert rlist_equates
|
||||
$insert names_equ
|
||||
open 'TNAMES' to TNames else
|
||||
void = msg( '', 'Unable to open Tnames...' )
|
||||
return 0
|
||||
end
|
||||
open 'NAMES' to Names else
|
||||
void = msg( '', 'Unable to open Names...' )
|
||||
return 0
|
||||
end
|
||||
rlist( 'SELECT TNAMES', target_activelist$, '', '', '' )
|
||||
NumKeys = @reccount
|
||||
Cnt = 0
|
||||
Eof = false$
|
||||
NotProcessedIds = ''
|
||||
loop
|
||||
readnext TNameId else Eof = true$
|
||||
until Eof
|
||||
read TNameRec from Tnames, TNameId else
|
||||
void = msg( '', 'Unable to read ':TNameId:' from Tnames' )
|
||||
return 0
|
||||
end
|
||||
if TNameRec<19> = 'CUSTOMER' or TNameRec<19> = 'VENDOR' and TNameRec<32> <> '' then
|
||||
* they are a customer or vendor and there is a customer or vendor no
|
||||
NameRec = ''
|
||||
ConvertPeriod = false$
|
||||
UlVal = TNameRec<39>
|
||||
gosub MakeUpperLower
|
||||
ConvertPeriod = true$
|
||||
NameRec<names_salutation$> = UlVal
|
||||
*
|
||||
UlVal = TNameRec<5>
|
||||
gosub MakeUpperLower
|
||||
NameRec<names_first$> = UlVal
|
||||
*
|
||||
UlVal = TNameRec<6>
|
||||
gosub MakeUpperLower
|
||||
NameRec<names_last$> = UlVal
|
||||
*
|
||||
UlVal = TNameRec<7>
|
||||
gosub MakeUpperLower
|
||||
NameRec<names_title$> = UlVal
|
||||
*
|
||||
Phones = ''
|
||||
PhoneType = ''
|
||||
if TNameRec<15> then
|
||||
Phones<1,-1> = TNameRec<15>
|
||||
PhoneType<1,-1> = 'Office'
|
||||
end
|
||||
if TNameRec<16> then
|
||||
Phones<1,-1> = TNameRec<16>
|
||||
PhoneType<1,-1> = 'Home'
|
||||
end
|
||||
if TNameRec<17> then
|
||||
Phones<1,-1> = TNameRec<17>
|
||||
PhoneType<1,-1> = 'Fax'
|
||||
end
|
||||
if TNameRec<18> then
|
||||
Phones<1,-1> = TNameRec<18>
|
||||
PhoneType<1,-1> = 'Modem'
|
||||
end
|
||||
NameRec<names_phone$> = Phones
|
||||
NameRec<names_phone_types$> = PhoneType
|
||||
*
|
||||
IPhones = ''
|
||||
IPhoneType = ''
|
||||
if TNameRec<36> then
|
||||
IPhones<1,-1> = TNameRec<36>
|
||||
IPhoneType<1,-1> = 'Office'
|
||||
end
|
||||
if TNameRec<38> then
|
||||
IPhones<1,-1> = TNameRec<38>
|
||||
IPhoneType<1,-1> = 'Fax'
|
||||
end
|
||||
NameRec<names_intl_phone$> = IPhones
|
||||
NameRec<names_intl_phone_types$> = IPhoneType
|
||||
*
|
||||
Comments = TNameRec<25>
|
||||
convert @tm to ' ' in Comments
|
||||
convert @vm to ' ' in Comments
|
||||
if TNameRec<11> then ;* put the mail stop in the comments
|
||||
Comments := ' Mail Stop# ':TNameRec<11>
|
||||
end
|
||||
NameRec<names_comments$> = Comments
|
||||
NameRec<names_co_id$> = TNameRec<32>
|
||||
NameRec<names_entry_id$> = TNameRec<31>
|
||||
NameRec<names_entry_date$> = TNameRec<2>
|
||||
write NameRec on Names, TNameId else
|
||||
void = msg( '', 'Unable to write ':TNameId:' on NAMES' )
|
||||
return 0
|
||||
end
|
||||
end else
|
||||
* they are not a customer or vendor or they do not have a customer or vendor number
|
||||
NotProcessedIds<-1> = TNameId
|
||||
end
|
||||
Cnt += 1
|
||||
Percent = oconv( iconv(Cnt/NumKeys, 'MD2'), 'MD0' ):'%'
|
||||
Void = send_info( Percent:' Complete importing names...')
|
||||
repeat
|
||||
if NotProcessedIds then
|
||||
open 'SYSLISTS' to ListsFile else
|
||||
Void = msg( '', 'Unable to open SYSLISTS file' )
|
||||
return 0
|
||||
end
|
||||
write NotProcessedIds on ListsFile, 'UNPROCESSED_NAMES' else
|
||||
Void = msg( '', 'Unable to write UNPROCESSED_NAMES on SYSLISTS file.' )
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 0
|
||||
|
||||
*===========================================================================*
|
||||
MakeUpperLower:
|
||||
convert ' ' to @fm in UlVal
|
||||
if ConvertPeriod then
|
||||
convert '.' to @fm in UlVal
|
||||
end
|
||||
Wcnt = fieldcount( UlVal, @fm )
|
||||
for i = 1 to Wcnt
|
||||
ThisWord = UlVal<i>
|
||||
if alpha( ThisWord[1,1] ) then
|
||||
if index( ThisWord, '&', 1 ) else
|
||||
FirstLetter = ThisWord[1,1]
|
||||
RestOfWord = ThisWord[2,999]
|
||||
convert @lower.case to @upper.case in FirstLetter
|
||||
convert @upper.case to @lower.case in RestOfWord
|
||||
UlVal<i> = FirstLetter:RestOfWord
|
||||
end
|
||||
end
|
||||
next i
|
||||
convert @fm to ' ' in UlVal
|
||||
return
|
||||
|
||||
*===========================================================================*
|
Reference in New Issue
Block a user