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

forward prototypes
global function integer f_open_win (long arg_scid, string arg_code)
end prototypes

global function integer f_open_win (long arg_scid, string arg_code);s_edit_index_tran s_tran
s_tran.work_mode = 0
s_tran.arg_pkid = 0
s_tran.arg_string_code = arg_code
s_tran.c_long = arg_scid
s_tran.d_long = 2
s_tran.if_retrieve_all = local_retrieve_all

String ls_scname,ls_sccode
String ls_space
Int li_spacenum
String ls_d_string
Boolean if_f

SELECT scname,sccode
	INTO :ls_scname,:ls_sccode
	FROM u_scdef
	Where scid = :arg_scid;
IF sqlca.SQLCode <> 0 OR IsNull(ls_scname) THEN ls_scname = ''

li_spacenum = 50 - Len(Trim(ls_scname)) - 2 - Len(String(arg_scid))
ls_space = Fill(' ',li_spacenum)

ls_d_string = ls_scname+ls_space+'['+String(arg_scid)+']'


s_tran.d_string = ls_d_string

String ls_billcode,ls_win1,ls_win2

ls_billcode = Mid(Trim(arg_code),Len(ls_sccode) + 1,2)

SELECT win1,win2
	INTO :ls_win1,:ls_win2
	FROM u_billcode
	Where firststr = :ls_billcode;
IF sqlca.SQLCode <> 0 THEN
	if_f = FALSE
ELSE
	if_f = TRUE
END IF

IF NOT if_f THEN
	SELECT win1,win2
		INTO :ls_win1,:ls_win2
		FROM u_billcode
		Where oldfirststr = :ls_billcode;
	IF sqlca.SQLCode <> 0 THEN
		if_f = FALSE
	ELSE
		if_f = TRUE
	END IF
END IF

IF if_f THEN
	window openwin
	OpenWithParm(openwin,s_tran,ls_win1)
END IF


RETURN 1
end function

