cancel
Showing results for 
Search instead for 
Did you mean: 

How to fill depended Z-Table, created by Rapid Application Tool, with initial data?

Former Member
0 Kudos

Hello gurus,

I created a component ZBOOKING with RAD Tool and will fill booking detail table with initial data during a creation of new booking objekt.

My Booking component looks like on the picture below. It was created with Rapid Application Tool and is based on one ZBOOKING Table with was created in CRM Backend and one “Booking details” Table with was created with Rapid Application.

My Question is how should I populate initial Template-Data to this dependent “booking details” Table wenn I will create a new booking object.

Web UI of ZBooking component

Component structure of ZBooking

I have tried to do sample implementation in do_init_context method of ZACL_CLASS00000C_IMPL class to fill ZBOOKING_DETAILS with some data.

method DO_INIT_CONTEXT.

CALL METHOD SUPER->DO_INIT_CONTEXT.

DATA: lr_col TYPE REF TO if_bol_bo_col,
lr_valuenode
TYPE REF TO  cl_bsp_wd_value_node,
lr_template 
TYPE REF TO  ZBOOKING_DETAIL.


CREATE DATA lr_template.


CREATE OBJECT lr_valuenode
EXPORTING
IV_DATA_REF
= lr_template.

if lr_valuenode is BOUND.

lr_valuenode
->SET_PROPERTY_AS_STRING(
iv_attr_name
= 'ZZVISITDATE' "#EC NOTEXT
iv_value    
= '01.01.2014'
).
ENDIF.

CREATE OBJECT lr_col TYPE cl_crm_bol_bo_col.

lr_col
->ADD(
exporting
iv_entity
= lr_entity
IV_SET_FOCUS
= ABAP_TRUE
).

me
->TYPED_CONTEXT->ZBOOKING_DETAIL->SET_COLLECTION( lr_col ).
endmethod.

After this implementation the initial data is displayed in “Booking details”.

However if I press an Edit-List-button (Assignment block) I get an error “CUST Operation”.

May be I should fill this depented table ZBOOKING_DETAILS without cl_bsp_wd_value_node?

Where should I implement logic if I want to fill initial data just during creation of booking object and not every

time when the booking object is called or initialized?

Regards Dmitry

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Check this class methods"CL_AXT_TABLES_API". I guess you will find some method to create the data in the child. Also I suggest if you have created some Badi Implementation check that also.

Thanks,

Sunny Sahu

dharmakasi
Active Contributor
0 Kudos

Hi Dimitry,

Generally when you develop view from rapid application system will generate the all required code. As per the screen shots you are getting the error from the Edit list button event, did you check code in event of EDIT List button? If its possible share the code in edit button event.

Best Regards,

Dharmakasi.

Former Member
0 Kudos

Hi Dharmakasi,

Thanks a lot for your answer.

I want to set initial data (like template data) to booking_detail table if a new booking object is created.

In standard all data fields are empty.

I did not change anything in EDIT event. It's standard one generated from rapid application wizard.

deepika_chandrasekar
Active Contributor
0 Kudos

HI,

Take the collection_wrapper entity of the detail context node by using

lr_leading_entity ?= me->typed_context->ZBOOKING_DETAIL->collection_wrapper->get_current( ).

lr_leading_entity->SET_PROPERTY_AS_STRING(

                       iv_attr_name = 'ZZVISITDATE' "#EC NOTEXT

                       iv_value     = '01.01.2014'

                       ).

This should be enough. No need to add it in collection again

Regards,

Deepika.

Former Member
0 Kudos

Hi,

I have tried this solution but without success.

1. If my ZBOOKING_DETAIL is not exist, I can't my lr_leding_entity will be INITIAL.

How can I create a new ZBOOKING_DETAIL Object?

If I tried code below, i get null reference error.

lr_leading_entity->create_related_entity(
                 iv_relation_name = 'ZAET_CA_ATAB000000' ).



2. SET_PROPERTY for bol_entity is not working for me es well. I don't see any changes in my ZBOOKING_DETAIL Table after that.

lr_leading_entity->SET_PROPERTY_AS_STRING(

                       iv_attr_name = 'ZZVISITDATE' "#EC NOTEXT

                       iv_value     = '01.01.2014'

                       ).


3. If I don't add in the collection again, than nothing happens.

If I add new changed collection, then I see new added rows, but without values, because set_property is not working properly for my object. However when I click on edit list button, I will get my old rows in the table. It seems that a new collection is not set in my root object collection properly.

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

DATA: lo_bol_core TYPE REF TO cl_crm_bol_core,

      lt_params TYPE crmt_name_value_pair_tab,

      lo_bol_col TYPE REF TO if_bol_bo_col.


    lo_bol_core = cl_crm_bol_core=>get_instance( ).

    lo_bol_col = lo_bol_core->root_create( iv_object_name = 'ZAET_CA_ATAB000000'

                                     iv_create_param = lt_params

                                     iv_number = 1 ).

    lr_leading_entity lo_bol_col->get_first( ).

Like this you can create root entity.

Regards,

Deepika

dharmakasi
Active Contributor
0 Kudos

Hi Dimitri,

1. Yes your are right, if your parent object is empty you can not create the child object from it.

    

Your requirment is that when you create a entry in root object default template you want to add for the child object right?

I hope there is a relation between these 2 nodes 'ZAET_CA_HOTELBOOKING' and ZAET_CA_ATAB000000

Suppose you are root object is 'ZAET_CA_HOTELBOOKING' will get entry when you add data in first assignement block 'Hotel Booking'  while saving this data create a relation with child relation name ZAET_CA_ATAB000000 and set the date field or any other key field.

Add this code in start of save event of the first assignment block.

If you add code in do_init_context method you have to set the date using core modification, otherwise data will not be updated with your added data.

Best Regards,

Dharmakasi.

Former Member
0 Kudos

Hi  Dharmakasi,

exactly... just a question how can I implement object creation and relation to another parent object?

I tried to do it with root_create() but get an error with wrong access parameter.

Do you know what is the best way to create an object and related it to another object?

Regards,

Dmitry

mrkarthi
Participant
0 Kudos

Hi Dmitry,

Check if the below link could be useful to you.

Regards,

Karthi M R.

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

You need to use class cl_crm_bol_core instead of cl_bsp_wd_value_node class.

When you create rapid application it will create separate root object under AXT_CA compoent set

In your rapid application component go to 'BOL MODEL BROWSER' and check the root object for your rapid application.

Regards,

Deepika.

Former Member
0 Kudos

Hi Deepika,

thank you for your Answer.

Could you please provide me an example in code how can I use cl_crm_bol_core class in this case?

How can I create initial objects and populate to ZBOOKING_DETAIL  Object?

core = cl_crm_bol_core=>get_instance( ).
core->start_up( 'AXT_CA' ).

........

........

........

Regards,

Dmitry.

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

In DO_INIT_CONTEXT you need to use cl_crm_bol_entity instead of cl_bsp_wd_value_node

lr_valuenode TYPE REF TO  cl_crm_bol_entity,

Regards,

Deepika.

Former Member
0 Kudos

Hi,

how should I change code below to aplly it for cl_crm_bol_entity object?


and exactly how to create an initial bol_entity based on ZBOOKINGDETAILS?

*CREATE OBJECT lr_valuenode
*EXPORTING
*  IV_DATA_REF = lr_template.
*
*if lr_valuenode is BOUND.
*
*lr_valuenode->SET_PROPERTY_AS_STRING(
*                      iv_attr_name = 'ZZVISITDATE' "#EC NOTEXT
*                      iv_value     = '01.01.2014'
*                      ).
*ENDIF.


Thanks

Dmitry

Former Member
0 Kudos

ZBOOKING_DETAIL

deepika_chandrasekar
Active Contributor
0 Kudos

Hi,

When you click new button that time itself new entity will get created.

Check the context node collection wrapper..

You should use.

lr_det ?= me->typed_context->detail context node name->collection_wrapper->get_current( ).

If collection is not there you need to create it from root using create_related_entity method.

Regards,

Deepika

Former Member
0 Kudos

Hi,

I get an error "Dereferencing of the NULL reference" during created_related_entity.

If you see on the picture below I think that I use right relation name for my zbooking_detail table.

method DO_INIT_CONTEXT.

CALL METHOD SUPER->DO_INIT_CONTEXT.


data :   lr_leading_entity  TYPE REF TO cl_crm_bol_entity,
            lr_col TYPE REF TO if_bol_bo_col.
           

           lr_leading_entity->create_related_entity(

                  iv_relation_name = 'ZAET_CA_ATAB000000' ).

           lr_leading_entity->SET_PROPERTY_AS_STRING(
                       iv_attr_name = 'ZZVISITDATE' "#EC NOTEXT
                       iv_value     = '01.01.2014'
                       ).

lr_col->ADD(
   exporting
     iv_entity = lr_leading_entity
     IV_SET_FOCUS = ABAP_TRUE
     ).

me->TYPED_CONTEXT->ZBOOKING_DETAIL->SET_COLLECTION( lr_col ).

endmethod.

Many Thanks & Regards,
Dmitry