Finally i have a solution, i created a SIM to complete this requierement
Thanks MIke for your guide.
Josue R.
/////////////////////////////////////////// VARIABLES GLOBALES /////////////////////////////////////////
Var SqlStr : A2056 = ""
Var SqlStr1 : A2056 = ""
Var tc_obj_num : N10 = 1
Var tc_nombre : A15 = "Dolares"
Var Tipo_Cambio : $10 = 0
Var hODBCDLL : N12 = 0
event print_trailer: Hap_Hr
var cnt : n3
var mi_mlvl [ @numdtlt ] : n1
var mi_slvl [ @numdtlt ] : n1
var mi_obj[ @numdtlt ] : n5
var mi_cnt : n3 = 0
VAR Concatena_TC : A50 //Concatena Texto y Numero del Tipo de Cambio
if @cknum = 0
exitwitherror "Begin a check and try again"
endif
for cnt = 1 to @numdtlt
if @dtl_type[ cnt ] = "T"
mi_cnt = mi_cnt + 1
// mi_obj[ mi_cnt ] = @dtl_objnum[ cnt ]
// mi_mlvl[ mi_cnt ] = @dtl_mlvl[ cnt ]
// mi_slvl[ mi_cnt ] = @dtl_slvl[ cnt ]
if @dtl_objnum[ cnt ] = 21
// infomessage "Esta Orden Contiene", @Dtl_Ttl[cnt], "Dolares"
call Procesa_Consulta_Tipo_Cambio
FORMAT Concatena_TC AS " Tipo de Cambio : ", Tipo_Cambio
//@header[1]=Tipo_Cambio
@trailer[1]=" "
@trailer[2]="********************************"
@trailer[3]="Corresponsal Cambiario : HSBC "
@trailer[4]=" C O M P R A E N U S D "
@trailer[5]=Concatena_TC
@trailer[6]="********************************"
@trailer[7]=" "
break
//@dtl_objnum[ cnt ]
endif
//infomessage "Tender number", @dtl_objnum[ cnt ]
//waitforenter
endif
endfor
endevent
Sub Procesa_Consulta_Tipo_Cambio
SqlStr = ""
/// Crea sentencia SQl para recuperar ventas x cajero ////////
Format SqlStr as "SELECT conversion_rate FROM micros.currency_def "
Format SqlStr as SqlStr, "WHERE obj_num = ", tc_obj_num
Call Load_ODBC_DLL
Call ConnectDB
DLLCALL_CDECL hODBCDLL, sqlGetRecordSet(SqlStr)
SqlStr1 = ""
DLLCALL_CDECL hODBCDLL, sqlGetLastErrorString(Ref SqlStr1)
IF (SqlStr1 <> "")
Call UnloadDLL
Window 12,78
display 1,1, mid(Trim(sqlstr1), 1,75)
display 2,1, mid(Trim(sqlstr1), 76,75)
display 3,1, mid(Trim(sqlstr1), 151,75)
display 4,1, mid(Trim(sqlstr1), 226,75)
display 5,1, mid(Trim(sqlstr1), 301,75)
waitforenter
windowclose
ExitWithError "Error: ", SqlStr1
ENDIF
SqlStr1 = ""
DLLCALL_CDECL hODBCDLL, sqlGetFirst(Ref SqlStr1)
IF SqlStr1 = ""
// venta = 0
//WaitForenter "No tiene Datos"
ELSE
IF Len(Trim(SqlStr1)) > 0 Then
// Waitforenter sqlstr1
// Split SqlStr1, ";", Emp_last_name,Emp_First_name
Tipo_Cambio = SqlStr1
// WaitForenter sqlstr1
ENDIF
ENDIF
EndSub
//////////////////////// CARGA LIBRERIAS PARA ODBCCONECTA A BD MICROS
Sub Load_ODBC_DLL
IF hODBCDLL = 0
IF @WSTYPE = 3
DLLLoad hODBCDLL, "\cf\micros\bin\MDSSysUtilsProxy.dll"
ELSE
DLLLoad hODBCDLL, "..\bin\MDSSysUtilsProxy.dll"
ENDIF
ENDIF
IF hODBCDLL = 0
ExitWithError "No se Puede Cargar DLL (MDSSysUtilsProxy.DLL)"
ENDIF
EndSub
//////////////////////// CONECTA A BD MICROS ////////////////////////////////////////////////////////
Sub ConnectDB
Var Status : N1
DLLCALL_CDECL hODBCDLL, sqlIsConnectionOpen(Ref Status)
// IF Status = 0
DLLCALL_CDECL hODBCDLL, sqlInitConnection("micros","ODBC;UID=dba;PWD=micros", "")
// ELSE
// InfoMessage "ODBC", "Base de Datos Conectada(...)"
// ENDIF
Endsub