cancel
Showing results for 
Search instead for 
Did you mean: 

How to update value nodes attrib values in BOL to make it sortable?

Former Member
0 Kudos

Hi all,

I have a requirement to add custom fields in an assignment block. i added it through value nodes and populated values for those fields in do_prepare using BOL set_property nd updated BOL using core_modify().

But the values are not updated in BOL after modify() so that i got dump during sort. So i populated values dynamically in get_XX of the attrib that i added.

Here is the link for the previous process i did.

http://scn.sap.com/thread/3534963

Now the issue is when i set the value dynamically to the web ui i could not sort the custom field in the web ui since BOL doesn't contain the data for custom fields. So again i am supposed to look the way in which i can update BOL with the values instead of doing it dynamically.

Plz help me out on this concern.

Regards,

Karthik

Accepted Solutions (0)

Answers (2)

Answers (2)

dharmakasi
Active Contributor
0 Kudos

Hi Karthik,

You can set the filter option for your value attributes by using configurator class.

Please do the below steps and share results with us,

First step: You might be using the <chtmlb:configTable> tag in your .htm page right?, there will be a standard class linked with this tag.

Open that class in se24 and create an ehnacment for the method get_column_definitions

Second step: Write a if statement to trigger only for your table view id using the parameter in method

p_tableview_id. Once this is satisfied then you can add below code within the if statement as shown below.

Loop at P_COLUMN_DEFINITIONS into ls_column
WHERE COLUMNNAME = 'DOC_DESC'   " you can give your custom attribute column name

                    
OR    COLUMNNAME = 'DOC_ID'

ls_column-sort = 'X'.

modify p_column_definitions from ls_column index sy-tabix  transporting sort.

endloop.

   GT_COLUMN_DEFINITIONS[] = P_COLUMN_DEFINITIONS[].

Option 2:

Instead of creating ehnacement spot in standard method you can do this

"you can copy standard chtmlb tag into custom tag then you can use this in your .htm page. You have to modify the same method in your custom class".

I will suggest first create enhancement spot in standard method " GET_COLUMN_DEFINTION"

and check the results if it works you can implement option 2.

Thanks,

Dharmakasi.

Former Member
0 Kudos

Hi Dharma,

I could get the standard class associated with the tag.

How will i be able to get the class name?

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi Karthik,

From .htm page if you double click on that tag, system will navigate to one screen there you can find the class name.

Regards,

Dharmakasi.

Former Member
0 Kudos

Hi Dharma,

Tiz method is fr dynamic population that i did through  get_XX() or through do_prepare?

Now i populated value through get_xx() nd commented old codes in do_prepare.

Regards,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi,

What ever i suggested will work for value node attributes, Please try that solution surely it will work for you.

Regards,

Dharmakasi.

Former Member
0 Kudos


Hi dharma,

I have few doubts.

I need to enhance the get_column_definitions in Element handler class right?..

But in ma case its IF method. prefixed with ifXXXXXXXXX-get_column_definitions.

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi Karthik,

Yeah that method only you have to do, its interface method. I just given method name alone.

Best Regards,
Dharmakasi.

Former Member
0 Kudos

Hi,

Can you plz say the enhancement creation steps ?.

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi,

There are already some threads with details, Please refer to the below thread, at the end of the method write logic which i have give earlier. Let me know if you need further more clarifications.

Best Regards,

Dharmakasi.

Former Member
0 Kudos

HI,

ENHANCEMENT 1  ZCUSTOMSORT.    "inactive version

IF p_tableview_id eq ''. 

  Loop at P_COLUMN_DEFINITIONS into ls_column

    WHERE COLUMNNAME = 'Z_DUEDATE'

    OR    COLUMNNAME = 'Z_EMPLOYEERESPONSIBLE'

    OR    COLUMNNAME = 'Z_RESPONSIBLEGROUP'.

   

    ls_column-sort = 'X'.

    modify p_column_definitions from ls_column index sy-tabix  transporting sort.

  endloop.

   GT_COLUMN_DEFINITIONS[] = P_COLUMN_DEFINITIONS[].

ENDIF.

ENDENHANCEMENT.

is the enhancement code. but i get error ls_column  is nt definded. enhancement is present efore data declaration of the method.

ls_column is declared in the standard method method itself down the enhancement.

If i declare again then i get GT_COLUMN_DEFINITIONS[] nt declared.

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi Karthik,

You have to create enhancement at just before end method line, if you scroll down you can one see enhancement option. Once creation is done select the enhancement and activate it.

Best Regards,

Dharmakasi.

Former Member
0 Kudos

Hi ,

Yes. I got it. One more doubt. How to get table view id p_tableview_id.

Will i be able to get it in webui?.

In degugging i get many id's.

Thanks,

Karthik

Former Member
0 Kudos

hi,

one more error like before when i place enhancement at last.

GT_COLUMN_DEFINITIONS[] is nt defined.

i can see gt_column_description in standard code like

if gt_column_description []not initial.

Is tat GT_COLUMN_DEFINITIONS[] or gt_column_description[]?

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi Karthick,

It is supposed to be GT_COLUMN_DESCRIPTION only but no need of assign table to GT_COLUMN_DESCRIPTION this value.

Just add the loop code alone,

Loop at P_COLUMN_DEFINITIONS into ls_column
WHERE COLUMNNAME = 'DOC_DESC'   " you can give your custom attribute column name

                    
OR    COLUMNNAME = 'DOC_ID'

ls_column-sort = 'X'.

modify p_column_definitions from ls_column index sy-tabix  transporting sort.

endloop.

For the table name, keep break point in that method and check the parameter p_tableviewid only.

Regardsm

Dharmakasi.

Former Member
0 Kudos

Hi,

I got the table id nd done the changes.  But no change during sort.

I can see ls_column-sort = 'X'. is set fr the custom fields during debugging.

But when i sort the custom field there is no change on the webui.

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi,

you have modified the p_column_definitions table right?

Can you share your table view screen shot with values?

Best Regards,

Dharmakasi.

Former Member
0 Kudos

Hi dharma,

below are the screen shot.

these are the fields in the assign block

one of the 3 custom fields

when ever i sort on trans or trans type or date its getting sorted nd custom fields also populates correspondingly.

when i sort on due date or emp res or res group assign block remains same after refresh.

thanks,

karthik

dharmakasi
Active Contributor
0 Kudos

Hi Kathik,

Why are you giving the p_tableview_id as 'XXXXX_Table'? You should give correct assignment block name.( i think it must be like business context ).

Best Regards,

Kasi.

Former Member
0 Kudos

Hi,

That is the corresponding tableview id value for buz context. In 1st screen shot u can see the value in variable window.

thanks,

karthik

Former Member
0 Kudos

Hi,

the sort value is 'X' before v change to 'x'.

while debugging i see before changing ls_column-sort to 'X' its already 'X'.

thanks

karthik

dharmakasi
Active Contributor
0 Kudos

Hi karthick,

I think we have to do changes in SORT event also, check how the standard fields sorting is working and try to implement same logic for custom fields as well.

Regards,
Dharmakasi.

Former Member
0 Kudos

Kasi,

Is there any other way to meet ma requirement instead of adding value attrib??

If so plz give suggession.

Thanks,

Karthik

dharmakasi
Active Contributor
0 Kudos

Hi Karthik,

Do you need only sort, if you provide filter option, will it do for you?

Otherwise you can add new fields in BTPARTNER context node using AET and use them in configuration.

Best Regards,
Dharmakasi.

VineetRai
Explorer
0 Kudos

Hi Karthik ,

         You have probably not locked the entity before calling the Set property . Just debug the set_property method a bit and you will see the place where the lock on the entity is checked.

Regards,

Vineet

Former Member
0 Kudos

Hi vineet,

i used that as well. You can visit this discusiion to get detail about the issue.

if  lr_entity_val->is_changeable( ) = abap_true.

lr_entity_val->set_property( iv_attr_name = 'Z_RESPONSIBLEGROUP' iv_value = lv_partner_descr ).
endif.

tiz is hw i coded.

http://scn.sap.com/thread/3534963

Thanks,

Karthik

VineetRai
Explorer
0 Kudos

Hi Karthik ,

       Let me summarize the issue here :

> You have some custom Z fields in an assignment block for which you need to show the values in UI

> You should be able to sort the assignment block entries based on these Z fields .

Let us understand what the different approaches /steps you have followed till now mean -

1. Coding the values in the GETTER methods ( GET_Z....)     : Any values that you return in this method are only for the UI layer display and are not persisted anywhere in the BOL . That's why these GET methods are called every time the page is reloaded . Since the values are not stored in the BOL layer , when you try to do a sort , the BOL frameowrk will only have blank values for these fields . This approach will not satisfy your requirement 2 .

2. Set the properties of the fields using SET_PROPERTY method -

     The Set property method pushes the value to the BOL layer . After setting the properties you should be able to sort the BOL collection based on the Z fields . You need to lock the entity before you can do a Set_property . You can do this in the DO_PREPARE_OUTPUT ()  ( or even in each of the getter methods ) .

3. Modify () - method is used to push the data from the BOL layer to the API layer ( via GENIL ) . In your case , since the Z fields are only present in the UI layer ( and not in DB ) , you do NOT need to call modify () in the DO_PREPARE_OUTPUT () .

So just call set property and set the values of the z fields . You should be able to sort on the z fields .

Regards,

Vineet

Former Member
0 Kudos

Hi vineet,

I have that at first with out using modify(). I am getting dump even now if i use set_property alone.

As i mention in ma last post attrib_ref is getting initialised. Thats why i have gone for modify(). But even after that there was no +ve result.

As you mentioned in Point 2 i have used lock () nd ischangable to check the lock status nd called set_property. But still no breakthrough.

*              if  lr_entity_val->lock( iv_reread = abap_true ) = if_genil_Boolean=>true.

*              lr_entity_val->set_property( iv_attr_name = 'Z_DUEDATE' iv_value = wl_appointment-date_to ).

*              ENDIF.

* I used above way of lock also

CALL METHOD lr_entity_val->switch_to_change_mode( ).

              if  lr_entity_val->is_changeable( ) = abap_true.

              lr_entity_val->set_property( iv_attr_name = 'Z_DUEDATE' iv_value = wl_appointment-date_to ).

              ENDIF.

Thanks,

Karthik

Former Member
0 Kudos

Vineet,

attrib_ref is getting initial after i use modify() in do_prepare output.

if i dun use modify() in do_prepare then during sort while debugging attrib_ref is initial. So till my knowledge i feel like modify function is done by framework if we dun use manually.

Here is the check for attrib_ref during sort.

      if iv_entity->my_manager_entry is not bound or iv_entity->container_proxy is not bound.

        raise exception type cx_bol_exception

          exporting

            textid = cx_bol_exception=>entity_already_freed.

      endif.

*here i get the dump since attribref is initial

Pardon me if ma understanding is wrong.

Regards,

Karthik


VineetRai
Explorer
0 Kudos

Hi Karthik ,

    When you call modify () then the data is pused to API layer and the data is re-read . This will wipe out the values of your Z fields as they are not present in the DB/API layer structures .

If the value of the Z attribute is initial at the time of sorting , it can only mean that the data has been refreshed after you filled the values. Check if there is any re-read happening after you set the values . Also add a built_table statement at the end of your do_prepare_output code .

Regards,

Vineet

Former Member
0 Kudos

Vineet,

If i use modify() not oly z feilds are initialised. Total attrib_ref is initialed.

If i use reread manualy() then it fetched data from API nd z fields are initial. If i use reread() attrib ref is nt initial only z fields are blank.

Below are the details fr ur understanding.

is_changable is true(lock)

web ui has the values

dump while sorting

if i use modify() without reread() in do_prepare

 

Attrib_ref when i use modify()

when i use reread() after modify() exception occurs and flow goes to catch block.

i used   typed_context->btdocflow->build_table( ). at the end of do_prepare

Regards,

Karthik