$PBExportHeader$f_sc_array.srf
global type f_sc_array from function_object
end type

forward prototypes
global subroutine f_sc_array (string arg_scstr)
end prototypes

global subroutine f_sc_array (string arg_scstr);Long ll_cnt
String ls_scstr
Long ll_scid
Long local_scid[]

ls_scstr = arg_scstr

IF Trim(arg_scstr) = '' THEN
	local_scid[1] = 0
ELSE	
	IF sys_power_issuper OR arg_scstr = '0' THEN		
		DECLARE cur_sc CURSOR FOR
			SELECT u_scdef.scID
			FROM u_scdef
			order by u_scdef.scid desc;
			
		OPEN cur_sc;
		
		FETCH cur_sc INTO :ll_scid;
		DO WHILE sqlca.SQLCode = 0
			ll_cnt++
			local_scid[ll_cnt] = ll_scid
			FETCH cur_sc INTO :ll_scid;
		LOOP
		
		CLOSE cur_sc;
	ELSE
		DO WHILE Len(ls_scstr) <> 1
			ls_scstr = Replace( ls_scstr, 1, 1, '' )
			ll_scid = Long(Left(ls_scstr,Pos(ls_scstr,',',1) - 1))
			ll_cnt++
			local_scid[ll_cnt] = ll_scid
			
			ls_scstr = Replace ( ls_scstr, 1, Pos(ls_scstr,',',1) - 1, '' )
		LOOP
	END IF
END IF

sys_user_scid = local_scid



end subroutine

