cancel
Showing results for 
Search instead for 
Did you mean: 

Get ADR2(Telephone Numbers) data from memory before BP Save in the UI

0 Kudos

Hi ,

I need to get the cellphone/telephone number of the BP in memory before the BP is saved in the UI to send that BP an sms during registration. I implemented BADI BUPA_GENERAL_UPDATE and I already have the code to send smss built and works fine, so what I need is the cellphone number(TELNR_LONG) in memory. I have already tried function modules BUA_BUPA_ADR2_GET, BUR_BUPR_ADR2_GET, BUA_BUPA_MEMORY_ADDRESSES_GET, BUA_BUPA_MEMORY_ADDRESS_GET but they all return nothing and some just gives me short dumps, is there another BADI that I can implement for this that has ADR2 table as an import parameter? or any function module I can call?

Thanks.

Regards,

Wesley

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Kathirvel,

Thanks for your responce, I implemented the code as you said but I get a short dump in line:

lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).

and it doesnt explain the error in details.

We also ran the transaction GENIL_BOL_BROWSER to manually test your code logic test and it works fine from there. Is there something I could be doing wrong?

Regards,

Wesley

Former Member
0 Kudos

I tested the code here and it is working fine for me. Try with the below code:

check lr_entity is bound.
lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).

Additionally, please post the ST22 dump details.

Regards

Kathirvel

0 Kudos

Hi Kathirvel

The dump is as follows even though it is not that descriptive:

What happened?

Error in the ABAP Application Program

The current ABAP program "ZCL_IM__ESP_BG_UPDATE=========CP" had to be

terminated because it has

come across a statement that unfortunately cannot be executed.

What can you do?

Note down which actions and inputs caused the error.

To process the problem further, contact you SAP system

administrator.

Using Transaction ST22 for ABAP Dump Analysis, you can look

at and manage termination messages, and you can also

keep them for a long time.

Error analysis

During the COMMIT WORK statement, the following are executed:

- the routines registered with the statement PERFORM .. ON COMMIT,

- the registered methods for the events of the object services

and

- possibly the local update (SET UPDATE TASK LOCAL).

An exception was raised and caught. The normal sequence of the routines

was interrupted by this resulting in the program being continued before

the call of COMMIT WORK. As this can lead to inconsistencies, the

processing cannot be continued in the normal way.

Error analysis

During the COMMIT WORK statement, the following are executed:

- the routines registered with the statement PERFORM .. ON COMMIT,

- the registered methods for the events of the object services

and

- possibly the local update (SET UPDATE TASK LOCAL).

An exception was raised and caught. The normal sequence of the routines

was interrupted by this resulting in the program being continued before

the call of COMMIT WORK. As this can lead to inconsistencies, the

processing cannot be continued in the normal way.

43 DATA: str_lv_ard2 TYPE STANDARD TABLE OF adr2,

44 lv_adr2 TYPE adr2,

45 str_lv_recipient TYPE ad_telnrlg.

46 DATA: lv_fname TYPE bu_namep_f,

47 lv_lname TYPE bu_namep_l.

48

49 * endif.

50 DATA lr_dquery TYPE REF TO cl_crm_bol_dquery_service.

51 DATA lr_result TYPE REF TO if_bol_entity_col.

52 DATA lv_bu_partner_guid TYPE bu_partner_guid.

53 DATA lv_partner_guid TYPE string.

54 DATA lr_entity TYPE REF TO cl_crm_bol_entity.

55 DATA lv_telephone TYPE string.

56

57 READ TABLE it_changed_instances

58 INTO lv_bu_partner_guid INDEX 1.

59 CHECK sy-subrc EQ 0.

60 lv_partner_guid = lv_bu_partner_guid.

61

62 CLEAR: lr_dquery, lr_result.

63 lr_dquery = cl_crm_bol_dquery_service=>get_instance( 'BuilHeaderAdvancedSearch' ).

64 lr_dquery->add_selection_param( iv_attr_name = 'PARTNER_GUID'

65 iv_sign = 'I'

66 iv_option = 'EQ'

67 iv_low = lv_partner_guid ).

68 lr_result = lr_dquery->get_query_result( ).

69 IF lr_result IS BOUND.

70 lr_entity = lr_result->get_first( ).

71

72 * CHECK lr_entity IS BOUND.

>>>>> lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' )

74 lv_telephone = lr_entity->get_property_as_string( 'TELEPHONEMOB' ).

75 ENDIF.

Former Member
0 Kudos

Tested it a few times here and it works perfectly for me.

*    lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).
*    lv_telephone = lr_entity->get_property_as_string( 'TELEPHONETEL' ).
    DATA lx_crm_genil_error TYPE REF TO cx_crm_genil_model_error.
    DATA lv_exception TYPE string.
    TRY.
        CALL METHOD lr_entity->get_related_entity
          EXPORTING
            iv_relation_name = 'BuilStandardAddressRel'
          RECEIVING
            rv_result        = lr_entity.
        lv_telephone = lr_entity->get_property_as_string( 'TELEPHONETEL' ).
      CATCH cx_crm_genil_model_error INTO lx_crm_genil_error.
        CALL METHOD lx_crm_genil_error->if_message~get_text
          RECEIVING
            result = lv_exception.
    ENDTRY.

Try to replace the code and this will catch the exception into lv_exception. Please check if that gives some info. Otherwise please raise an OSS message. Unfortunately, I can't think of any other issue as this code is working fine.

Regards

Kathirvel

Answers (2)

Answers (2)

0 Kudos

Hi Kathirvel

Sorry for the late response, your code was not working initially because the BP didnt have an ID Number entered, but when the BP has an ID Number it worked perfectly. So in the code I check if the ID Number was entered before I use the code.

Thanks for your help, rewarded full points to you.

Regards,

Wesley

Former Member
0 Kudos

Please find a sample code to get the telephone number. You can adope the same for your requirement. Thanks.

METHOD if_ex_bupa_general_update~change_before_update.

  DATA lr_dquery          TYPE REF TO cl_crm_bol_dquery_service.
  DATA lr_result          TYPE REF TO if_bol_entity_col.
  DATA lv_bu_partner_guid TYPE bu_partner_guid.
  DATA lv_partner_guid    TYPE string.
  DATA lr_entity          TYPE REF TO cl_crm_bol_entity.
  DATA lv_telephone       TYPE string.

  READ TABLE it_changed_instances
       INTO lv_bu_partner_guid INDEX 1.
  CHECK sy-subrc EQ 0.
  lv_partner_guid = lv_bu_partner_guid.

  CLEAR: lr_dquery, lr_result.
  lr_dquery = cl_crm_bol_dquery_service=>get_instance( 'BuilHeaderAdvancedSearch' ).
  lr_dquery->add_selection_param( iv_attr_name = 'PARTNER_GUID'
                                  iv_sign      = 'I'
                                  iv_option    = 'EQ'
                                  iv_low       = lv_partner_guid ).
  lr_result = lr_dquery->get_query_result( ).
  IF lr_result IS BOUND.
    lr_entity = lr_result->get_first( ).
    lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).
    lv_telephone = lr_entity->get_property_as_string( 'TELEPHONETEL' ).
  ENDIF.

ENDMETHOD.                    "if_ex_bupa_general_update~change_before_update

Regards

Kathirvel