mig28mx
2nd October 2013, 01:10
Hi,
I want to use API functions to fill a customized table using the maintenance session for it.
My code looks like the following:

error = false

stpapi.put.field("tfcmg9167m000", "tfcmg967.date", "27092013") | Fecha
stpapi.put.field("tfcmg9167m000", "tfcmg967.year", "2013") | Año
stpapi.put.field("tfcmg9167m000", "tfcmg967.fprd", "9") | P fiscal
stpapi.put.field("tfcmg9167m000", "tfcmg967.rprd", "9") | P listado
stpapi.put.field("tfcmg9167m000", "tfcmg967.vyer", "2013") | Año iva
stpapi.put.field("tfcmg9167m000", "tfcmg967.vprd", "9") | P iva
stpapi.put.field("tfcmg9167m000", "tfcmg967.ttyp", "180") | Tipo transaccion
stpapi.put.field("tfcmg9167m000", "tfcmg967.dsrn", "10") | Serie
stpapi.put.field("tfcmg9167m000", "tfcmg967.docn", str$(next.sec))
stpapi.put.field("tfcmg9167m000", "tfcmg967.info", "2013_180_00000004")
stpapi.put.field("tfcmg9167m000", "tfcmg967.emno", "4645") | Empleado
stpapi.put.field("tfcmg9167m000", "tfcmg967.amnt", "500") | Importe
stpapi.put.field("tfcmg9167m000", "tfcmg967.dscr", "informe gtos 1") | Descripcion informe
stpapi.put.field("tfcmg9167m000", "tfcmg967.ccur", "PES") | divisa
stpapi.put.field("tfcmg9167m000", "tfcmg967.tcur", "PES")
stpapi.put.field("tfcmg9167m000", "tfcmg967.ctra", "ASM029") | Codigo gasto
stpapi.put.field("tfcmg9167m000", "tfcmg967.dig1", "IC146") | dim1
stpapi.put.field("tfcmg9167m000", "tfcmg967.dig2", "155021") | dim2
stpapi.put.field("tfcmg9167m000", "tfcmg967.dig3", "39099") | dim3
stpapi.put.field("tfcmg9167m000", "tfcmg967.dig4", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.dig5", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.leac", "110110110101") | cuenta abono
stpapi.put.field("tfcmg9167m000", "tfcmg967.dim1", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.dim2", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.dim3", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.dim4", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.dim5", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.user", logname$)
stpapi.put.field("tfcmg9167m000", "tfcmg967.btno", "0")
stpapi.put.field("tfcmg9167m000", "tfcmg967.datc", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.anti", "0")
stpapi.put.field("tfcmg9167m000", "tfcmg967.rate", "1")
stpapi.put.field("tfcmg9167m000", "tfcmg967.pedi", "")
stpapi.put.field("tfcmg9167m000", "tfcmg967.anti", "0.0")

ret = stpapi.insert("tfcmg9167m000", true, mensaje)
if ret = 1 then
stpapi.get.field("tfcmg9167m000", "tfcmg967.info", info.nuevo)
mensaje = sprintf$("Se creó el informe de gastos %s", info.nuevo)
rprt_send()
tipo = 1
proce = 3
stpapi.end.session("tfcmg9167m000")
mensaje = ""

else
tipo = 2
proce = 3
ret = stpapi.recover("tfcmg9167m000", mensaje)
stpapi.end.session("tfcmg9167m000")
reg.erroneos = reg.erroneos + 1
error = true
endif
}


I´m filling all the fields of the table due to I can´t solve the error message: Value can´t be zero obtained on the sentence stpapi.insert

Any ideas about how to solve?

Thank you in advance.
Miguel.

mig28mx
2nd October 2013, 02:27
Hi,
After posting, I realized that I was missing the date translation.

Miguel.

mark_h
2nd October 2013, 04:28
Thanks for the follow up. This is the correct forum for AFS type posts.