$PBExportHeader$f_get_dft_pf.srf global type f_get_dft_pf from function_object end type forward prototypes global function string f_get_dft_pf (long arg_mtrlid) end prototypes global function string f_get_dft_pf (long arg_mtrlid);String rst_pfcode Long cnt Long ll_dftwrkgrpid Select count(*) Into :cnt From u_mtrl_pf Where mtrlid = :arg_mtrlid And ifdft = 1; If sqlca.SQLCode <> 0 Then cnt = 0 If cnt = 1 Then Select pfcode Into :rst_pfcode From u_mtrl_pf Where mtrlid = :arg_mtrlid And ifdft = 1; Else Select dftwrkgrpid Into :ll_dftwrkgrpid From u_mtrldef Where mtrlid = :arg_mtrlid; If sqlca.SQLCode <> 0 Then ll_dftwrkgrpid = 0 Select top 1 u_mtrl_pf.pfcode Into :rst_pfcode From u_mtrl_pf Where u_mtrl_pf.mtrlid = :arg_mtrlid And u_mtrl_pf.ifdft = 1 And (u_mtrl_pf.wrkid = :ll_dftwrkgrpid or :ll_dftwrkgrpid = 0 ); End If If sqlca.SQLCode <> 0 Then rst_pfcode = '' Return rst_pfcode end function