cancel
Showing results for 
Search instead for 
Did you mean: 

Send data from object to DataWindow

Former Member
0 Kudos

Hi,

I need to send data from an object (uo _) to a DataWindow control, click on the button Aceptar from object (uo_)

In the window I have a of_send function with this code, but does not work:

Integer  li_Row, ll_i, li_RowCount

li_Row = dw_detail.InsertRow(0)

iu_cst_dw_multifilter = CREATE u_cst_dw_multifilter

li_RowCount = iu_cst_dw_multifilter.dw_filter.RowCount()

FOR ll_i = 1 TO li_RowCount

  IF iu_cst_dw_multifilter.dw_filter.Object.item[ll_i] = '1' THEN

  dw_detail.Object.id_pro[li_Row] = iu_cst_dw_multifilter.dw_filter.Object.id_pro[ll_i]

  END IF

NEXT

Parent.CloseUserObject(iu_cst_dw_multifilter)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jorge;

  Since this seems to be a Visual User Object, you can not use the Create command. For visual UO's, you would instead use the OpenUserObject() or OpenUserObjectWithParm() method to instantiate the class.

   Only non-visual UO's would be instantiated via the Create. However, if that was the case - you would not use a CloseUserObject() command but instead, the Destroy command.

   If indeed you end up using the OpenUserObject() method - then your current use of the CloseUserObject() method is correct.

HTH

Regards ... Chris

Former Member
0 Kudos

Hi Chris.

Yes it is a UserObject Visual.

This code is in the button Agregar:

OpenUserObject(iu_cst_dw_multifilter)

Being open the UserObject Visual as pass data to DataWindow control of window?

1. Button Aceptar has this code:

iw_parent.DYNAMIC FUNCTION of_send()

of_send has this code now:

Integer  li_Row, ll_i, li_RowCount

li_Row = dw_filter.InsertRow(0)

u_cst_dw_multifilter      lu_cst_dw_multifilter

li_RowCount = lu_cst_dw_multifilter.dw_filter.RowCount()

FOR ll_i = 1 TO li_RowCount

  IF lu_cst_dw_multifilter.dw_filter.Object.item[ll_i] = '1' THEN

  dw_filter.Object.id_pro[li_Row] = lu_cst_dw_multifilter.dw_filter.Object.id_pro[ll_i]

  END IF

NEXT

RETURN 0

Error:

---------------------------

PowerBuilder application execution error (R0002)

---------------------------

Application terminated.

Error: Null object reference at line 7 in function of_send of object w_form_detail.

---------------------------

Aceptar  

---------------------------

Any idea, please

Former Member
0 Kudos

Hi Jorge;

  I am guessing that the command that is encountering the NULL Object error is the following ...

     li_RowCount = lu_cst_dw_multifilter.dw_filter.RowCount() .

I suspect that because you declare the UO as follows:

    u_cst_dw_multifilter lu_cst_dw_multifilter

Remember that this is just a C Pointer to an object and the pointer is initialized by the PB run-time as NULL. AFAICS, you do not need this declaration.

Since you open the UO & then save its address in the "iu_cst_dw_multifilter" instance variable in your original post, you might like to try ...

   li_RowCount = iu_cst_dw_multifilter.dw_filter.RowCount()

HTH

Regards ... Chris

Former Member
0 Kudos

Chris,

Instance:

u_cst_dw_multifilter.dw_filter   iu_cst_dw_multifilter.dw_filter


Modify:


li_RowCount = iu_cst_dw_multifilter.dw_filter.RowCount()

I have the same error.

Former Member
0 Kudos

   Ahhh OK ... now I see the issue (I think) - if the User Object was declared in the Window Painter and not instantiated at run time.

Therefore ...

1) Remove any OpenUserObject() or CloseUserObject() commands

2) In the Window Painter's "control" pane, take note of your UO's control name

2) In the "of_send ( )" method ... replace the DWFilter UO name with the Control Name from step#2 that you found.

Former Member
0 Kudos

The UserObject Visual is open at runtime.

Code in the window:

Code in the nvo:

Objects:

Former Member
0 Kudos

a) Looks like a PFC framework based application

b) So you have both visual and non-visual UO's for DW filtering classes

I would suggest stepping through your logic in the PB debugger and taking note of the pointers to both the Visual and Non-Visual UO's as your script progresses. Maybe you can see at what point the pointers to either of these UO's are either, not initialized properly, destroyed, NULLed out or reset - that would in turn cause the NULL Object error.

Former Member
0 Kudos

Chris,

It works without the nvo.

I wanted to encapsulate and reuse it the nvo n_cst_dwsrv_multifilter.

Former Member
0 Kudos

Good .. so now you need to follow (via the debugger) the NVUO logic in the associated PowerScipt's that process the NVUO. All the way from creation, use and then disposition to see if the NVUO is instantiated properly and the information passed to it is properly instantiated (up to your NULL error). That way, you should see the problem in the bug screen as you step through your code.

Former Member
0 Kudos

Chris Thanks from Peru!!

ricardojasso
Participant
0 Kudos

Jorge,

I see that your problem has been solved. I just have one small observation: If I understand your logic correctly the InsertRow(0) statement should be inside the [For Next] loop and inside the [If Then End If] statement.

FOR ll_i = 1 TO li_RowCount

     IF lu_cst_dw_multifilter.dw_filter.Object.item[ll_i] = '1' THEN

          li_Row = dw_filter.InsertRow(0)

          dw_filter.Object.id_pro[li_Row] = lu_cst_dw_multifilter.dw_filter.Object.id_pro[ll_i]

     END IF

NEXT

It seems to me you are trying to insert into the Detail DW all the selected items from the Filter DW. Then you should issue an InsertRow in the Detail DW each time a selected item has been encountered in the Filter DW. If I understand correctly your 'detail' DW will store the list of selected items from the multi filter user object.

Regards,

Ricardo

Former Member
0 Kudos

Ricardo Thanks!!

Answers (0)