COMPILE ROUTINE FIX_SEC_GROUPS(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, obj_Shipment,RList, Btree.Extract
DECLARE FUNCTION Get_Status, Set_Printer

$INSERT LSL_USERS_EQUATES
$INSERT SEC_GROUPS_EQUATES


DEBUG

OPEN 'SEC_GROUPS' TO FileIn ELSE
	GOTO Bail
END

OPEN 'DICT.SEC_GROUPS' TO DictVar ELSE
	GOTO Bail
END

DEBUG


SELECT FileIn

Done = 0

LOOP

READNEXT SecGroupID ELSE Done = 1
UNTIL Done
	READ SecGroupRec FROM FileIn,SecGroupID THEN
		UserIDs = XLATE('SEC_GROUPS',SecGroupID,'LSL_USER','X')
		
		UserCnt = COUNT(UserIDs,@VM) + (UserIDs NE '')
		FOR I = 1 TO UserCnt
			UserID = UserIDs<1,I>
			IF XLATE('LSL_USERS',UserID,LSL_USERS_ACTIVE$,'X') THEN
				SecGroupRec<SEC_GROUPS_USER$,-1> = UserID
			END
		NEXT I
		
		
		
		WRITE SecGroupRec ON FileIn,SecGroupID THEN
			Send_Dyn(SecGroupID:' New: ':SecGroupRec<SEC_GROUPS_USER$>)
			Send_Dyn(SecGroupID:' Org: ':UserIDs)
			Send_Dyn(' ')
		END
	END
REPEAT






GOTO Bail

SearchString  = "WO_CUST_NO":@VM:"6775":@VM:"6593":@VM:"408":@VM:"7076":@VM:"7053":@VM:"6874":@VM:"7055":@FM
SearchString := 'SHIP_DT':@VM:'>9/28/2011':@FM
 


Option = ''
Flag = ''

Btree.Extract(SearchString,'SEC_GROUPS',DictVar, ShipNos, Option, Flag)

IF Get_Status(errCode) THEN
	DEBUG
	GOTO Bail
END


ShipCnt = COUNT(ShipNos,@VM) + (ShipNos NE '')


FOR I = 1 TO ShipCnt
	ShipNo = ShipNos<1,I>

	READ ShipRec FROM FileIn,ShipNo THEN
				
		ShipDt		= OCONV(ShipRec<SEC_GROUPS_SHIP_DT$>,'D4/')
		SendDtm		= OCONV(ShipRec<SEC_GROUPS_SEND_DTM$>,'DT4/^S')
		WOCustNo	= XLATE('SEC_GROUPS',ShipNo,'WO_CUST_NO','X')
	
		IF SendDtm = '' THEN
			obj_Shipment('SendTechnical',ShipNo)
			
			Send_Dyn(I:' ':ShipNo:' ':WOCustNo:' ':ShipDt:' ':SendDtm)
		END
			
	
	END
NEXT I



* * * * * * *
Bail:
* * * * * * *

RETURN
