1. Pepe Cuenca
  2. PowerBuilder
  3. Tuesday, 3 September 2019 08:38 AM UTC

Good Morning everyone, I need to understand something...

I have to send data to an external webservice , which wsdl file is

https://snfl.qdecalidad.com/snfl/webserviceAgroxSNFL/ws.apps

I've created a webservice proxy and I can see everything without a problem.

I have to use the function loadtableagreements, which needs a wsagroxagreement datatype. I think this object is like an structure of strings. 

I declare a variable called ls_cuerpo_contratos of the wsagroxagreements datatype. Then, from a datastore, i begin to fill the object strings, but crashes with null object reference. Do I have to initialize the structure, or the strings inside?

I paste here my code, I need to understand what i am doing wrong.

 

Thanks in advance, as always

 

 

decimal lc_filas_royal, i , contador
string resultado_contrato, resultado_valor, resultado_royal
long ll_filas_contratos

SoapConnection conn // Definimos conexión SOAP
webserviceagroxsnflcontrollerservice proxy_obj // Declaramos proxy
long rVal

conn = create SoapConnection //Creamos instancia de la conexión


rVal = Conn.CreateInstance(proxy_obj, &
"webserviceagroxsnflcontrollerservice")

try

//DECLARACION DE LA DW Y DE LAS VARIABLES DE CONTRATOS

ids_agreements = create u_ds
ids_agreements.DataObject = "d_snfl_listado_var"
ids_agreements.SetTransObject(sqlca)

ids_agreements.Retrieve( )


string ls_cempr_agree, ls_dempr_agree, ls_agree_agree, ls_ctn_agree, ls_datesig_agree, ls_cpropie_agree, ls_dpropie_agree,ls_cpais_agree, ls_linea_agree, ls_dpais_agree
string ls_cvaried_agree, ls_pbr_agree, ls_working_agree, ls_breeder_agree, ls_buds_agree, ls_plants_agree, ls_hectareas_agree, ls_year_plant_agree, ls_codmov_agree, ls_year_usa_agree, ls_year_act_agree, ls_movingday_agree
wsagroxagreements ls_cuerpo_contratos[]


ll_filas_contratos = ids_agreements.Rowcount( )


sle_lineas_contratos.text = string(ll_filas_contratos)

for i = 1 to ll_filas_contratos


ls_cempr_agree= trim(ids_agreements.Object.snflemplic_cempr[i])
ls_dempr_agree = trim(ids_agreements.Object.snflemplic_dempr[i])
ls_agree_agree = trim(ids_agreements.Object.snflagreement_agree[i])
ls_ctn_agree = trim(ids_agreements.Object.snflagreement_ctn[i])
ls_datesig_agree = trim(string(ids_agreements.Object.snflagreement_datesig[i]))
ls_cpropie_agree = trim(string(ids_agreements.Object.snflagreement_cpropie[i]))
ls_dpropie_agree = trim(ids_agreements.Object.snflgrower_dpropie[i])
ls_cpais_agree = trim(string(ids_agreements.Object.snflgrower_cpais[i]))
ls_dpais_agree = trim(string(ids_agreements.Object.gpaises_dpais[i]))
ls_linea_agree = trim(string(ids_agreements.Object.snfldata_linea[i]))
ls_cvaried_agree = trim(string (ids_agreements.Object.snfldata_cvaried[i]))
ls_pbr_agree = trim(string(ids_agreements.Object.snflvariety_breeder[i])) 
ls_working_agree = trim(string(ids_agreements.Object.snflvariety_working[i]))
ls_breeder_agree = trim(string(ids_agreements.Object.snflvariety_pbr[i]))
ls_buds_agree = trim(string(ids_agreements.Object.snfldata_buds[i]))
ls_plants_agree = trim(string(ids_agreements.Object.snfldata_plants[i]))
ls_hectareas_agree = trim(string(ids_agreements.Object.snfldata_hectareas[i]))
ls_year_plant_agree = trim(string(ids_agreements.Object.snfldata_year_plant[i]))
ls_codmov_agree = trim(string(ids_agreements.Object.snfldata_codmov[i]))
ls_year_usa_agree =trim(string(ids_agreements.Object.snfldata_year_usa[i]))
ls_year_act_agree =trim(string(ids_agreements.Object.snfldata_year_act[i]))
ls_movingday_agree =trim(string(ids_agreements.Object.snfldata_moving_day[i]))

 

 

ls_cuerpo_contratos[i].cempr = ls_cempr_agree THIS IS THE FIRST ERROR
ls_cuerpo_contratos[i].dempr = ls_dempr_agree
ls_cuerpo_contratos[i].agree = ls_agree_agree
ls_cuerpo_contratos[i].ctn = ls_ctn_agree
ls_cuerpo_contratos[i].datesig = ls_datesig_agree
ls_cuerpo_contratos[i].cpropie = ls_cpropie_agree
ls_cuerpo_contratos[i].dpropie = ls_dpropie_agree
ls_cuerpo_contratos[i].cpais = ls_cpais_agree
ls_cuerpo_contratos[i].dpais = ls_dpais_agree
ls_cuerpo_contratos[i].linea = ls_linea_agree
ls_cuerpo_contratos[i].cvaried = ls_cvaried_agree
ls_cuerpo_contratos[i].pbr = ls_pbr_agree
ls_cuerpo_contratos[i].working = ls_working_agree
ls_cuerpo_contratos[i].breeder = ls_breeder_agree
ls_cuerpo_contratos[i].buds = ls_buds_agree
ls_cuerpo_contratos[i].plants = ls_plants_agree
ls_cuerpo_contratos[i].hectareas = ls_hectareas_agree
ls_cuerpo_contratos[i].year_plant = ls_year_plant_agree
ls_cuerpo_contratos[i].codmov = ls_codmov_agree
ls_cuerpo_contratos[i].year_usa = ls_year_usa_agree
ls_cuerpo_contratos[i].year_act= ls_year_act_agree
ls_cuerpo_contratos[i].movingday = ls_movingday_agree


sle_generados.text = string(i)


next

Kevin Ridley Accepted Answer Pending Moderation
  1. Tuesday, 1 October 2019 18:36 PM UTC
  2. PowerBuilder
  3. # 1

Pepe,

 Try something like this.  I simplified populating the object to use static values, but this works for me:

 

Integer li_loop
wsagroxagreements lpx_agreements[], lpx_agreements_null[]

FOR li_loop = 1 TO 5
   lpx_agreements[li_loop] = CREATE wsagroxagreements
   lpx_agreements[li_loop].agree = "Value1"
   lpx_agreements[li_loop].breeder = "Value2"
   lpx_agreements[li_loop].buds = "Value3"
   lpx_agreements[li_loop].cempr = "Value4"
NEXT

FOR li_loop = 1 TO 5
   IF IsValid(lpx_agreements[li_loop]) THEN
      DESTROY lpx_agreements[li_loop]
   END IF
NEXT

lpx_agreements = lpx_agreements_null

return 1

 

Good luck I think you are close, hopefully this gets you over the hump,

Kevin

Comment
  1. Kevin Ridley
  2. Tuesday, 1 October 2019 21:06 PM UTC
Oh and congrats on becoming a dad, that's awesome!
  1. Helpful
  1. Kevin Ridley
  2. Wednesday, 2 October 2019 11:28 AM UTC
Forgot to mention, but obviously you make your web service call after the first loop. The second loop is just to cleanup objects and really belongs in a FINALLY block of a TRY/CATCH.
  1. Helpful
There are no comments made yet.
Pepe Cuenca Accepted Answer Pending Moderation
  1. Monday, 30 September 2019 14:41 PM UTC
  2. PowerBuilder
  3. # 2

Hi again guys, I'm back here, I bacame a dad last month and it's been quite difficult continuing work. 

I've created an structure with the same fields as wsagroxagreements structure, and it works. 

The problem is that the function loadtableagreements needs a wagroxagreements datatype. 

 

I paste my actual code here. Thank you again everyone.

 

decimal lc_filas_royal, i , contador
string resultado_contrato, resultado_valor, resultado_royal
long ll_filas_contratos, ll_constructor

SoapConnection conn // Definimos conexión SOAP
webserviceagroxsnflcontrollerservice proxy_obj // Declaramos proxy
long rVal

conn = create SoapConnection //Creamos instancia de la conexión


rVal = Conn.CreateInstance(proxy_obj, &
"webserviceagroxsnflcontrollerservice")

//DECLARACION DE LA DW Y DE LAS VARIABLES DE CONTRATOS

ids_agreements = create u_ds
ids_agreements.DataObject = "d_snfl_listado_var"
ids_agreements.SetTransObject(sqlca)

ids_agreements.Retrieve( )

string ls_cempr_agree, ls_dempr_agree, ls_agree_agree, ls_ctn_agree, ls_datesig_agree, ls_cpropie_agree, ls_dpropie_agree,ls_cpais_agree, ls_linea_agree, ls_dpais_agree
string ls_cvaried_agree, ls_pbr_agree, ls_working_agree, ls_breeder_agree, ls_buds_agree, ls_plants_agree, ls_hectareas_agree, ls_year_plant_agree, ls_codmov_agree, ls_year_usa_agree, ls_year_act_agree, ls_movingday_agree
wsagroxagreements ls_cuerpo_contratos[]


str_contratos le_estructura_agree[]



ll_filas_contratos = ids_agreements.Rowcount( )


for i = 1 to ll_filas_contratos


ls_cempr_agree= trim(ids_agreements.Object.snflemplic_cempr[i])
ls_dempr_agree = trim(ids_agreements.Object.snflemplic_dempr[i])
ls_agree_agree = trim(ids_agreements.Object.snflagreement_agree[i])
ls_ctn_agree = trim(ids_agreements.Object.snflagreement_ctn[i])
ls_datesig_agree = trim(string(ids_agreements.Object.snflagreement_datesig[i]))
ls_cpropie_agree = trim(string(ids_agreements.Object.snflagreement_cpropie[i]))
ls_dpropie_agree = trim(ids_agreements.Object.snflgrower_dpropie[i])
ls_cpais_agree = trim(string(ids_agreements.Object.snflgrower_cpais[i]))
ls_dpais_agree = trim(string(ids_agreements.Object.gpaises_dpais[i]))
ls_linea_agree = trim(string(ids_agreements.Object.snfldata_linea[i]))
ls_cvaried_agree = trim(string (ids_agreements.Object.snfldata_cvaried[i]))
ls_pbr_agree = trim(string(ids_agreements.Object.snflvariety_breeder[i])) //ES POSIBLE QUE EN LA DW, ELS CAMPS PBR I BREEDER ESTIGUEN CAMBIATS??????
ls_working_agree = trim(string(ids_agreements.Object.snflvariety_working[i]))
ls_breeder_agree = trim(string(ids_agreements.Object.snflvariety_pbr[i])) //ES POSIBLE QUE EN LA DW, ELS CAMPS PBR I BREEDER ESTIGUEN CAMBIATS??????
ls_buds_agree = trim(string(ids_agreements.Object.snfldata_buds[i]))
ls_plants_agree = trim(string(ids_agreements.Object.snfldata_plants[i]))
ls_hectareas_agree = trim(string(ids_agreements.Object.snfldata_hectareas[i]))
ls_year_plant_agree = trim(string(ids_agreements.Object.snfldata_year_plant[i]))
ls_codmov_agree = trim(string(ids_agreements.Object.snfldata_codmov[i]))
ls_year_usa_agree =trim(string(ids_agreements.Object.snfldata_year_usa[i]))
ls_year_act_agree =trim(string(ids_agreements.Object.snfldata_year_act[i]))
ls_movingday_agree =trim(string(ids_agreements.Object.snfldata_moving_day[i]))

le_estructura_agree[i].cempr = ls_cempr_agree
le_estructura_agree[i].dempr = ls_dempr_agree
le_estructura_agree[i].agree = ls_agree_agree
le_estructura_agree[i].ctn = ls_ctn_agree
le_estructura_agree[i].datesig = ls_datesig_agree
le_estructura_agree[i].cpropie = ls_cpropie_agree
le_estructura_agree[i].dpropie = ls_dpropie_agree
le_estructura_agree[i].cpais = ls_cpais_agree
le_estructura_agree[i].dpais = ls_dpais_agree
le_estructura_agree[i].linea = ls_linea_agree
le_estructura_agree[i].cvaried = ls_cvaried_agree
le_estructura_agree[i].pbr = ls_pbr_agree
le_estructura_agree[i].working = ls_working_agree
le_estructura_agree[i].breeder = ls_breeder_agree
le_estructura_agree[i].buds = ls_buds_agree
le_estructura_agree[i].plants = ls_plants_agree
le_estructura_agree[i].hectareas = ls_hectareas_agree
le_estructura_agree[i].year_plant = ls_year_plant_agree
le_estructura_agree[i].codmov = ls_codmov_agree
le_estructura_agree[i].year_usa = ls_year_usa_agree
le_estructura_agree[i].year_act= ls_year_act_agree
le_estructura_agree[i].movingday = ls_movingday_agree

// ls_cuerpo_contratos[i].cempr = ls_cempr_agree
// ls_cuerpo_contratos[i].dempr = ls_dempr_agree
// ls_cuerpo_contratos[i].agree = ls_agree_agree
// ls_cuerpo_contratos[i].ctn = ls_ctn_agree
// ls_cuerpo_contratos[i].datesig = ls_datesig_agree
// ls_cuerpo_contratos[i].cpropie = ls_cpropie_agree
// ls_cuerpo_contratos[i].dpropie = ls_dpropie_agree
// ls_cuerpo_contratos[i].cpais = ls_cpais_agree
// ls_cuerpo_contratos[i].dpais = ls_dpais_agree
// ls_cuerpo_contratos[i].linea = ls_linea_agree
// ls_cuerpo_contratos[i].cvaried = ls_cvaried_agree
// ls_cuerpo_contratos[i].pbr = ls_pbr_agree
// ls_cuerpo_contratos[i].working = ls_working_agree
// ls_cuerpo_contratos[i].breeder = ls_breeder_agree
// ls_cuerpo_contratos[i].buds = ls_buds_agree
// ls_cuerpo_contratos[i].plants = ls_plants_agree
// ls_cuerpo_contratos[i].hectareas = ls_hectareas_agree
// ls_cuerpo_contratos[i].year_plant = ls_year_plant_agree
// ls_cuerpo_contratos[i].codmov = ls_codmov_agree
// ls_cuerpo_contratos[i].year_usa = ls_year_usa_agree
// ls_cuerpo_contratos[i].year_act= ls_year_act_agree
// ls_cuerpo_contratos[i].movingday = ls_movingday_agree
//

sle_generados.text = string(i)


next
proxy_obj.loadtableagreements("d6a5ef292a3cc08a00434c0582965eac",le_estructura_agree[],TRUE)

 

 

Comment
  1. Miguel Leeuwe
  2. Monday, 30 September 2019 16:04 PM UTC
Congrats !!!
  1. Helpful
There are no comments made yet.
Pepe Cuenca Accepted Answer Pending Moderation
  1. Wednesday, 4 September 2019 06:45 AM UTC
  2. PowerBuilder
  3. # 3

Hi Chris, 

I've uploaded the Object to the thread

Attachments (1)
Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 4 September 2019 14:30 PM UTC
Thanks! The .SRU file extension already tells me its a "Structure". Structure's are "auto-instantiated" - so *NO* Create() is required. Thus your code "ls_cuerpo_contratos[i].cempr = ls_cempr_agree" should work no matter is it's NULL, Empty or an actual String value.

My thought now is that the field "snflemplic_cempr[i]" in the DWO might be corrupted in some other way leading to an invalid situation within "ls_cempr_agree "

My suggestions now would be to ...

1) Add a TRY..CATCH around this block of code.

2) Check the "Exception" object for the real error before the App crashes.

3) Also, use the IDE "debugger" to step through your code & data

  1. Helpful
  1. Kevin Ridley
  2. Tuesday, 1 October 2019 18:05 PM UTC
.sru is for user objects, .srs is for structures.
  1. Helpful
There are no comments made yet.
Pepe Cuenca Accepted Answer Pending Moderation
  1. Tuesday, 3 September 2019 17:35 PM UTC
  2. PowerBuilder
  3. # 4

Hi Chris, 

I've added a creation statement:

ls_cuerpo_contratos[ll_filas_contratos] = create wsagroxagreements

But the error is still there. I think that what is null is the variables inside the object (cempr,dempr...), but I don't know how to access them...

 

Thank you very much again, Pepe. 

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 3 September 2019 18:06 PM UTC
Hi Pepe;

Can you export the "wsagroxagreements" object's source and then attach it to this thread?

Regards ... Chris

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 3 September 2019 15:07 PM UTC
  2. PowerBuilder
  3. # 5

Hi Pepe;

  If "ls_cuerpo_contratos" is a structure ... NO. If "ls_cuerpo_contratos" is a User Object then a YES for instatiation (ie: CREATE).

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.