COMPILE FUNCTION obj_Vendor_Code(Method,Parms)
/*
	Methods Vendor Code conversions
    
	09/02/2011 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    SemiToEpi		;* Converts SemiStd Vendor code to EpiMesa vendor code
    EpiToSemi		;* Converts EpiMesa vendor code to SemiStd vendor code
   
*/


DECLARE FUNCTION Get_Status, Msg, Set_FSMsg
DECLARE FUNCTION Utility
DECLARE SUBROUTINE  Set_Status, Msg, Btree.Extract, ErrMsg

$INSERT MSG_EQUATES
$INSERT LABELS
$INSERT SEMI_VEND_CODE_EQUATES


ErrTitle = 'Error in Stored Procedure "obj_Vendor_Code"'
ErrorMsg = ''

IF NOT(ASSIGNED(Method))	THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms))		THEN Parms = ''

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

Result = ''


BEGIN CASE
	CASE Method = 'SemiToEpi'		; GOSUB SemiToEpi
	CASE Method = 'EpiToSemi'		; GOSUB EpiToSemi
	
	CASE 1
		ErrorMsg = 'Unknown Method ':Method:' passed to object routine.'

END CASE

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

RETURN Result



* * * * * * *
SemiToEpi:
* * * * * * *

SemiStdCode = Parms[1,@RM]

Result = XLATE('SEMI_VEND_CODE',SemiStdCode,SEMI_VEND_CODE_EPI_VEND_CD$,'X')

RETURN


* * * * * * *
EpiToSemi:
* * * * * * *

MesaCode = Parms[1,@RM]

Table = 'SEMI_VEND_CODE'
OPEN "DICT ":Table TO DictVar ELSE
	ErrMsg('Unable to Open DICT.SEMI_VEND_CODE for Btree.Extract')
	RETURN
END

Search = 'EPI_VEND_CD':@VM:MesaCode

Result = ''
Option = ''
Flag = ''
Ans = ''
Btree.Extract(Search, Table, DictVar, Result, Option, Flag)

RETURN



