cancel
Showing results for 
Search instead for 
Did you mean: 

Access value of attribute of other context node in same view

Former Member
0 Kudos

Hi,

In do_prepare_output of IMPL class i'm trying to read one attribute value of different context node in same view.

BT126H_APPT/ApptDetails, i want to read the time value in context node BTDATE and pass it to do_prepare_output method of IMPL class to do some validation.

I have created one instance public type attribute (gv_stime) and set the value in set_time method and then call that attribute in the do_prepare_output with below code

lv_stime = me->ztyped_context->zbtdate->gv_stime.

but im getting an error: You attempted to use a 'NULL' object reference.

Could you pls let me know what is wrong.

Regards,

Shobhit

Accepted Solutions (1)

Accepted Solutions (1)

amarnath_kathi
Active Contributor
0 Kudos

When you comment out that line, could you see gv_stime being set up with a value?

Edited by: Amar Nath on Oct 22, 2010 11:36 AM

Former Member
0 Kudos

Yes,

In the setter method of that attribute the value has been filled in gv_stime.

Regards,

Shobhit

amarnath_kathi
Active Contributor
0 Kudos

Is the context node BTDATE or ZBTDATE? In the code,

lv_stime = me->ztyped_context->zbtdate->gv_stime.

you mentioned it ZBTDATE.

Former Member
0 Kudos

Context node is BTDate, zbtdate is an attribute which refers to z-CN class of BTDate.

amarnath_kathi
Active Contributor
0 Kudos

Try lv_stime = me->ztyped_context->btdate->gv_stime.

In the IMPL class attributes, look for ztyped_context, it refers to typed context, it in turn contains btdate which inturn contains gv_stime. Check this flow. The code should follow this.

Former Member
0 Kudos

gv_stime is the custom attribute which i created after enhancing the BTDate CN class, the attribute BTdate will refer to standard class where gv_stime is not available, hence i created a zbtdate class which will point towards Z-CN class of BTDate and it has the attriute gv_stime. But still im not able to fetch the value.

My only requirement is that i want theStart Date/time & End Date/time values of the Activity which im creaing in my do_prepare_output method of IMPL class to do some validation before it is getting saved.

Regards,

Shobhit

sumit_mittal2
Active Contributor
0 Kudos

Hi Shobhit,

Activity start date/end date can be obtained directly by reading the bol relation, you don't have to create z-class and fetch the data from there..

In do_prepare_output, you will get activity entity(BtadminH), check if the activity entity is bound read the related entities using below relation.

btadminh->btdateset->BTdate entity via "BTDate_T_ACTActPln" bol relation.

Timestamp From/Timestamp To field will have date values.

Cheers,

Sumit Mittal

Former Member
0 Kudos

Hi Sumit,

I know this thing but the problem was that the timestamp value is showing different then what is filled in the UI, may be because of timezone difference of the server and user.

Hence i thought to use the same value of date/time which get stored in the setter method of that attribute in the BTDate context node.

Regards,

Shobhit

sumit_mittal2
Active Contributor
0 Kudos

Hi Shobit,

true, there are some additional conversion done inside the setter method..

you can get those value using global cuco..

1. To Get/set the variable in ic session to avoid the static variable..

lr_bdc type ref to if_crm_ui_data_context.

lr_bdc = cl_crm_ui_data_context_srv=>get_instance( me ).

check lr_bdc is bound.

Using SET_DATA_ATTRIBUTE set the attribute value and using GET_DATA_ATTRIBUTE get the attribute valueu2026get_attribute, set_attribute

  • read current BuAg if exist

lr_buag ?= lr_bdc->GET_DATA_ATTRIBUTE( 'CURRENTBUAG' ).

Any entity which is registered in the spro->crm->ui framework->Technical Role Definition->Define Global Data Context Parameters

2. Another way is to raise a event from setter method, which will have the importing parameters as date values..

RAISE EVENT date_values EXPORTING value1 = 'from_date' value2 = 'to_date'.

Specify "date_values" as event in context node(BTDATE ) "events" parameter.

Now specify the handler class for your event in view impl. class, best place is to define it in do_init_context method redefine method and specify handler like this.

set HANDLER on_date_values for typed_context->BTDATE for all instances.

Create "on_date_values " method in view impl class and specify this method as event handler method(by clicking on event button, next to source code in the class )

provide the detail of even handler method for eg. even handler for " your context node(btdate)/date_values(event). declaring importing parameters.

Now on_date_values method of the impl. class will have your dates values, what you have assigned in the setter method, provided you are doing all the steps correctly

Let me know if you face any issue.

Cheers,

Sumit Mittal

Former Member
0 Kudos

Thanks Sumit,

Full points to you I have used the 1st approach which is quite less painful.

Also i have used some unused parameter like CURRENTDISPUTE, is this ok? if i create new parameter then the ext. object name should be BTOrder only ?

Hope you will enjoy in your new company.

Regards,

Shobhit

sumit_mittal2
Active Contributor
0 Kudos

Thanks shobhit and ya enjoying at new place but quite hectic though..

Anyways regarding unused parameters it's tough to comment as i am not aware of those, let me know the requirement then would be able to comment on this.

BTorder is the one order root entity, which is generic entity for all the one order objects.. there are multiple extensions to one order objects for eg. activity/opportunity etc. if you want to create new field for eg. in activity you can use btadminh/activityh as extn. object which will add new field in activity,

Incase if you use btorder it will be added as part of btorder and accessible across all the one order objects which might not be the case in your requirement.

Cheers,

Sumit Mittal

Answers (0)