Compile function Location_Services(@Service, @Params) /*********************************************************************************************************************** Name : Location_Services Description : Handler program for all Location services. Notes : Application errors should be logged using the Error Services module. There are a few methodological assumptions built into way errors are managed which are important to understand in order to properly work with Error Services: - The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger this will appear backwards since the originating procedure always appears at the bottom of the list and the current routine appears at the top of the list. We are using this orientation because it is common to refer to the process of calling other procedures as 'drilling down'. - The reason for defining the orientation of the call stack is because Error_Services allows for multiple error conditions to be appended to an original error. In most cases this will happen when a procedure at the bottom of the stack generates an error condition and then returns to its calling procedure. This higher level procedure can optionally add more information relevant to itself. This continues as the call stack 'bubbles' its way back to the top to where the originating procedure is waiting. - Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus) preserve their error state until explicitly cleared. This can hinder the normal execution of code since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists. Our philosophy is that error conditions should automatically be cleared before a new procedure is executed to avoid this problem. However, the nature of Basic+ does not make this easy to automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our philosophy then it should include a call into the 'Clear' service request at the top of the program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.) - Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any error conditions that were set before. Parameters : Service [in] -- Name of the service being requested Param1-10 [in/out] -- Additional request parameter holders Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure Metadata : History : (Date, Initials, Notes) 11/02/20 djs Original programmer. ***********************************************************************************************************************/ #pragma precomp SRP_PreCompiler $Insert SERVICE_SETUP $Insert LOGICAL $Insert LOCATION_EQUATES $Insert RLIST_EQUATES Declare function Error_Services Declare subroutine Btree.Extract, Error_Services, RList GoToService Return Response or "" //----------------------------------------------------------------------------- // SERVICES //----------------------------------------------------------------------------- Service GetLocationCassInfo(WONo, Locations) ErrorMessage = '' If ( (WONo NE '') and (Locations NE '') ) then OPEN 'DICT.WO_MAT' TO DictVar THEN SearchString = 'WO_NO':@VM:WONo:@FM:'CURR_LOCATION':@VM:Locations:@FM Flag = '' WOMatKeys = '' Btree.Extract(SearchString, 'WO_MAT', DictVar, WOMatKeys, '', Flag) If Flag EQ 0 then Locations = '' LocCnts = '' LocCassNos = '' LOOP WOMatKey = WOMatKeys[1,@VM] UNTIL WOMatKey = '' OR WOMatKeys = '' CurrLoc = XLATE('WO_MAT',WOMatKey,'CURR_LOCATION','X') If CurrLoc NE '' then CassNo = FIELD(WOMatKey,'*',2,1) LOCATE CurrLoc IN Locations USING @VM SETTING Pos THEN LocCnts<1,Pos> = LocCnts<1,Pos> +1 LocCassNos<1,Pos> = LocCassNos<1,Pos>:',':CassNo END ELSE Locations = INSERT(Locations,1,Pos,0,CurrLoc) LocCnts = INSERT(LocCnts,1,Pos,0,1) LocCassNos = INSERT(LocCassNos,1,Pos,0,CassNo) END end WOMatKeys[1,COL2()] = '' REPEAT Response = Locations:@FM:LocCnts:@FM:LocCassNos end else ErrorMessage = 'Error in service ':Service:'. Btree.Extract call failed.' end end else ErrorMessage = 'Error in service ':Service:'. Failed to open DICT.WO_MAT.' end end else ErrorMessage = 'Error in service ':Service:'. Null WONo or Locations variable passed in.' end If ErrorMessage NE '' then Error_Services('Add', ErrorMessage) end service Service GetLocationCassInfoRlist(WONo, Locations) ErrorMessage = '' If ( (WONo NE '') and (Locations NE '') ) then * OPEN 'DICT.WO_MAT' TO DictVar THEN Query = 'SELECT WO_MAT ' For each Loc in Locations using @VM setting vPos If vPos EQ 1 then Query := 'WITH WO_NO EQ ':Quote(WONo):' AND WITH CURR_LOCATION EQ ':Quote(Loc) end else Query := ' OR WITH WO_NO EQ ':Quote(WONo):' AND WITH CURR_LOCATION EQ ':Quote(Loc) end Next Loc GoSub ClearCursors Rlist(Query, TARGET_ACTIVELIST$, '', '', '') Locations = '' LocCnts = '' LocCassNos = '' EOF = False$ LOOP Readnext WOMatKey else EOF = True$ Until EOF CurrLoc = XLATE('WO_MAT',WOMatKey,'CURR_LOCATION','X') If CurrLoc NE '' then CassNo = FIELD(WOMatKey,'*',2,1) LOCATE CurrLoc IN Locations USING @VM SETTING Pos THEN LocCnts<1,Pos> = LocCnts<1,Pos> +1 LocCassNos<1,Pos> = LocCassNos<1,Pos>:',':CassNo END ELSE Locations = INSERT(Locations,1,Pos,0,CurrLoc) LocCnts = INSERT(LocCnts,1,Pos,0,1) LocCassNos = INSERT(LocCassNos,1,Pos,0,CassNo) END end REPEAT Response = Locations:@FM:LocCnts:@FM:LocCassNos end else ErrorMessage = 'Error in service ':Service:'. Null WONo or Locations variable passed in.' end If ErrorMessage NE '' then Error_Services('Add', ErrorMessage) end service ClearCursors: For counter = 0 to 8 ClearSelect counter Next counter return