cancel
Showing results for 
Search instead for 
Did you mean: 

Enhanced comp new context node added; Attribute doesn't hold values entered

Former Member
0 Kudos

Hi

I enhanced the component, ICCMP_BTSHEAD. Added a new context node, with higher level BOL entity as BTADMINH.

the attribute Extenal reference (PO_NUMBER_SOLD), added on the configuration.

When user enters value in external reference field, on save the value disappears. the field doesn't hold the value.

I debugged the Set_PO_NUMBER_SOLD method of the attribute. Collection_ref>Data_ref>attribute list is intial. the PO_NUmber shows blank.

Kindly help me how to hold the field value.

Thanks!

I added below code in Do_validate_input method. It is reading the po_number_sold attribute. but not saving the attribute.

method DO_VALIDATE_INPUT.
CALL METHOD SUPER->DO_VALIDATE_INPUT
    .

*****-----------------------------------------------------------------------------------*
*   set external reference value
*    set entity to BTSALESSET as current
  DATA : lr_salesSet_coll        TYPE REF TO    if_bol_bo_col,
         lr_salesSet_entity      TYPE REF TO    cl_crm_bol_entity,
         lr_btSalesSet           TYPE REF TO    ZL_ICCMP_BT_BTSHEADER_CN00,
         lv_ext_ref              TYPE           STRING,
         lr_current_extRef       TYPE REF TO    if_bol_bo_property_access.

  TRY.

    CHECK me->ztyped_context->BTSalesSet IS BOUND.
*CHECK  me->typed_context->BTSalesSet IS BOUND.
    lr_salesSet_coll = me->ztyped_context->BTSalesSet->GET_COLLECTION_WRAPPER( ).
    lr_salesSet_entity ?= lr_salesSet_coll->GET_CURRENT( ).

    CHECK lr_salesSet_entity IS BOUND AND lr_salesSet_entity->ALIVE( ) EQ ABAP_TRUE.

    lr_current_extRef = lr_salesSet_coll->GET_CURRENT( ).

    TRY.
      CALL METHOD LR_CURRENT_EXTREF->GET_PROPERTY_AS_STRING
        EXPORTING
          IV_ATTR_NAME = 'PO_NUMBER_SOLD'
        RECEIVING
          RV_RESULT    = lv_ext_ref.
      IF lv_ext_ref IS NOT INITIAL.
        lr_salesSet_entity->switch_to_change_mode( ).

        TRY.
            CALL METHOD LR_CURRENT_EXTREF->SET_PROPERTY_AS_STRING
              EXPORTING
                IV_ATTR_NAME = 'PO_NUMBER_SOLD'
                IV_VALUE     = lv_ext_ref.
          CATCH CX_SY_CONVERSION_ERROR .
        ENDTRY.

        LR_CURRENT_EXTREF->set_properties( if_genil_obj_attr_properties=>changeable ).
        DATA: lv_attr_props       TYPE REF TO if_genil_obj_attr_properties.
        lv_attr_props->set_all_properties( if_genil_obj_attr_properties=>changeable ).

      ENDIF.
    ENDTRY.



  endtry.
endmethod.

Edited by: Ekta on Oct 12, 2011 12:16 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Go to the .ctxt class. inside that there will be method CREATE_XXX where XXX is the context node u created. inside this method there should be call to the on_new_focus method of ur custom context node class. i think in ur case you are using get_related_entity and not creating any entity in case there is no entity. you can do debugging and can see if there is any entity or not for ur newly added context node.See the bsp component and view like BPFS_HEAD/Details ..see the methods like CREATE_CONTEXT_NODES, create_builheader( ) and create_builstandardaddress( ) to understand how on_new_focus is called. your on_new_focus should be like builstandardaddress->on_new_focus method.

here builheader is like btadminh and builstandardaddress is like the context node u created.

let us know what u see in debugging ..

Edited by: asen2222 on Oct 12, 2011 12:30 PM

Former Member
0 Kudos

Hi

Thanks for the response...

method CREATE_BTSALESSET.
    DATA:
      model        TYPE REF TO if_bsp_model,
      coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
      entity       TYPE REF TO cl_crm_bol_entity,    "#EC *
      entity_col   TYPE REF TO if_bol_entity_col.    "#EC *

    model = owner->create_model(

        class_name     = 'ZL_ICCMP_BT_BTSHEADER_CN00'

        model_id       = 'BTSalesSet' ). "#EC NOTEXT
    BTSalesSet ?= model.
    CLEAR model.

* initial setting for depandant model node
    coll_wrapper =
      BTADMINH->get_collection_wrapper( ).
    TRY.
        entity ?= coll_wrapper->get_current( ).
      CATCH cx_sy_move_cast_error.
    ENDTRY.
    IF entity IS BOUND.
      BTSalesSet->on_new_focus(
                   focus_bo = entity ).
    ENDIF.

endmethod.

the above mentioned is the code for create_<mycontextNode>. In debugging, the entity is BTADMINH. Which is the higherlevel BOL entity.

When debugging reaches on_new_focus the entity changes to BTSalesSet. Which is the required one.

BUT!! when the debugging reaches back to Create_BTSalesSet method, the entity remains same as old and doesn't changes to new one BTSalesSet.

It is only in on_new_focus method, that entity changes to "BTSalesSet"

I think i explained fine...

As suggested by you i will see the other components, how on_new_focus is defined. Thanks in advance...

Will let you all posted..

Edited by: Ekta on Oct 12, 2011 12:51 PM

Former Member
0 Kudos

can u paste the code inside the method BTSalesSet->on_new_focus( focus_bo = entity ) ? inside the on_new_focus method it should create (if it is in changeable state) in case get_related_entity doesnot return anything...also let us know what happens inside that method after seeing in debugging.

Former Member
0 Kudos

Hi...

Please find the coe below, as it is in BTSetesSet->on_new_focus()

method ON_NEW_FOCUS.

    DATA: lv_collection TYPE REF TO if_bol_bo_col,
          entity        TYPE REF TO cl_crm_bol_entity.

*   get collection of dependent nodes
    entity ?= focus_bo.
    TRY.
        lv_collection = entity->get_related_entities(
               iv_relation_name = 'BTHeaderSalesSet' ).

        IF lv_collection IS NOT BOUND or lv_collection->size( ) = 0.
          IF entity->is_changeable( ) = ABAP_TRUE.
            TRY.
                entity = entity->create_related_entity(
                 iv_relation_name = 'BTHeaderSalesSet' ).
              CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel.
*               should never happen
            ENDTRY.
            IF entity IS BOUND.
              CREATE OBJECT lv_collection TYPE cl_crm_bol_bo_col.
                lv_collection->add( entity ).
*--------------------------------------------------------------------*
                lv_collection->find( iv_index = 1 ).
*--------------------------------------------------------------------*
            ENDIF.
          ENDIF.
        ENDIF.

      CATCH cx_crm_genil_model_error.
*       should never happen
        EXIT.
      CATCH cx_sy_ref_is_initial.
    ENDTRY.
*--------------------------------------------------------------------*
    me->collection_wrapper->set_collection( lv_collection ).
*--------------------------------------------------------------------*


endmethod.

Former Member
0 Kudos

Hi

In On_new_focus, the entity is changed to BTSalesSet. It is attached to the collection wrapper. But when it returns back to Create_BTSalesSet, the entity is again BTAdminH.

Kindly suggest

Thanks!

Former Member
0 Kudos

I think that is fine... this is simply local variable and parameter variable thing.... so u r saying that it is succesfully getting/creating entity BTSalesSet..right ?? if yes then context node creation is working fine..

please do test these steps and let us know ..

1. if u enter a value in the new field and press enter .. does it still showing the value u entered ?

2. when u save,put a breakpoint in the save method. in that method check the variable lr_ent where lr_ent is as below.. see if it has the value u entered or not

lr_ent ? = me->type_context->BTSALESSET->collection_wrapper->get_current( ).

3. do not use the ztyped_context, use the typed_context attribute..

Former Member
0 Kudos

Actually, there is no save method. i typed the code in DO_FINISH_INPUT.

if i use 'me->type_context->' then it gives me syntax error. and asks to use the ztype_context.. if i use typed_context then it doesn't recognize the context node BTSalesSet.

I debuged the code, the entity list blank. there is no value for po_number_sold, Please find the coe below.

Also!

I debugged the Set_po_number_sold method. it is reading the value entered in web ui and setting the attribute property. The standard code for set method is working fine.

Kindly suggest...

don't know where in the flow, the value is vanishing...

method DO_FINISH_INPUT.

  CHECK me->typed_context IS NOT INITIAL.
  CHECK me->typed_context->btadminh->collection_wrapper->get_current( ) IS NOT INITIAL.

  super->do_finish_input( EXPORTING global_event    = global_event
                                      global_messages = global_messages ).

*--------------------------------------------------------------------*
*   set external reference value
*    set entity to BTSALESSET as current
  DATA : lr_salesSet_coll        TYPE REF TO    if_bol_bo_col,
         lr_salesSet_entity      TYPE REF TO    cl_crm_bol_entity,
         lr_btSalesSet           TYPE REF TO    ZL_ICCMP_BT_BTSHEADER_CN00,
         lv_ext_ref              TYPE           STRING,
         lr_current_extRef       TYPE REF TO    if_bol_bo_property_access.

  TRY.

    CHECK me->ztyped_context->BTSALESSET IS BOUND.

    lr_salesSet_coll = me->ztyped_context->BTSALESSET->GET_COLLECTION_WRAPPER( ).
    lr_salesSet_entity ?= lr_salesSet_coll->GET_CURRENT( ).

    CHECK lr_salesSet_entity IS BOUND AND lr_salesSet_entity->ALIVE( ) EQ ABAP_TRUE.

    lr_current_extRef = lr_salesSet_coll->GET_CURRENT( ).

    TRY.
      CALL METHOD LR_CURRENT_EXTREF->GET_PROPERTY_AS_STRING
        EXPORTING
          IV_ATTR_NAME = 'PO_NUMBER_SOLD'
        RECEIVING
          RV_RESULT    = lv_ext_ref.
    ENDTRY.
  ENDTRY.
*--------------------------------------------------------------------*
endmethod.

Former Member
0 Kudos

ok... i forgot it is custom context node.. u have to use ztyped_context...

can u give me the answer for qs 1 i asked in my earlier post ?

also send us the steps u do after u add the value in the field ..

e.g : click save button or press enter and save ...

also u dont get any value here in the lv_ext_ref ?

CALL METHOD LR_CURRENT_EXTREF->GET_PROPERTY_AS_STRING

EXPORTING

IV_ATTR_NAME = 'PO_NUMBER_SOLD'

RECEIVING

RV_RESULT = lv_ext_ref.

Former Member
0 Kudos

Hi

When i enter value in the field added through new context node. Then that value vanishes from screen, after i press save.

In method DO_VALIDATE_INPUT method i get the value for po_number_sold, when debugging. using the mentioned method of get_property.

I tried same code in Do_prepare_output, after entering the value in the field. the entity list remains blank.

The value etered in the external_reference field (PO_number_sold) is not saved in backend. That is the reason the output_prepare method reads it blank.

Kindly suggest...

BTSalesSet is a relation entity to BTAdminH. Similarly BTActivityH is also relation entity to BTAdminH. As a standard component, BTActivityH is part of context nodes. And there is a field of Extenal_act_id. I included the field in the component configuration.

On entering the value in the External_act_id, the value is being saved in the screen as well as in the backend.

se16 table for the same is CRMD_ACTIVITY_H

It is become reallyv tricky... kindly suggest me..

Edited by: Ekta on Oct 13, 2011 9:11 AM

Former Member
0 Kudos

what i understood from ur posts

1. when u enter the value in the custom added field, it disappears from the webui field, after clicking enter or clicking save.

2. You can see ur context node and the value in the do_validate_input, that means it is set in your context node properly

3. you can't see it in the do_prepare_output means it is already lost.

my qs -- is ur context node entity blank in the do_prepare_output or the entity is present but the value of that field is blank ?

what is the save button method name ? I cannot find it in that component ICCMP_BTSHEAD.

My advice -- the reason might be some custom code somewhere between do_prepare_output and do_validate_input deleting the ur context node instance...

so u might have to debug and find out where it is deleting ur data..

Former Member
0 Kudos

Hi

Now i am trying to do with EEWB tool.

And it is working as well

it is saving in database table entries.

also i need to pass the values to the follow up documents.. so i think EEWB tool is better

Thanks!

will keep posted...

Answers (1)

Answers (1)

christy_landry
Explorer
0 Kudos

We had the same issue, and eventually linked this behavior to multiple implementations of BAdI BADI_LORD_DO_PAI. When there were two separate implementations filling structure ct_supply in methods FILL_SUPPLY_LIST and/or ADD_SUPPLY_LIST, one implementation would clobber the custom fields of the other, leading to disappearing CRM screen values after hitting enter and/or failure to update the fields in ECC.