Monday, 18 September 2023

Governance API

 Handling of several change request and entity data.

DATA :

      lr_crequest                 TYPE REF TO if_usmd_crequest_api,

      lr_gov_api                  TYPE REF TO if_usmd_gov_api,

      t_crequest_obj_list         TYPE   usmd_gov_api_t_ent_struc,

      lr_adpostal_detail_key_str  TYPE REF TO data,

      lr_adpostal_detail_key_tab  TYPE REF TO data,

      lr_adpostal_detail_data_str TYPE REF TO data,

      lr_adpostal_detail_data_tab TYPE REF TO data,

      w_crequest_obj_list         TYPE   usmd_gov_api_s_ent_struc,

      ls_crequest                 TYPE usmd_s_crequest.


    FIELD-SYMBOLS :

      <fs_t_adpostal_detail_key>  TYPE ANY TABLE,

      <fs_w_adpostal_detail_key>  TYPE any,

      <fs_t_adpostal_detail_data> TYPE INDEX TABLE,

      <fs_w_adpostal_detail_data> TYPE any.


    "Get API Instance:

    CALL METHOD cl_usmd_crequest_api=>get_instance

      EXPORTING

        iv_crequest          = im_cr_id

      IMPORTING

        re_inst_crequest_api = lr_crequest.


    "CR Request Details:

    CALL METHOD lr_crequest->read_crequest

      IMPORTING

        es_crequest = ls_crequest.


    ex_crequest = ls_crequest.


    "Get Instance of Model:

    lr_gov_api = cl_usmd_gov_api=>get_instance( iv_model_name = im_modelname ).


    "Get Object List:

    lr_gov_api->get_object_list( EXPORTING iv_crequest_id = im_cr_id

                                 IMPORTING et_object_list = t_crequest_obj_list ).


    "Check with Entity Type:

    READ TABLE t_crequest_obj_list INTO w_crequest_obj_list WITH KEY entity = im_entity.

    IF sy-subrc <> 0.

*      RETURN.

    ENDIF.


    CLEAR : lr_adpostal_detail_key_str,lr_adpostal_detail_key_tab.


    "Get KeyStr and KeyTab:

    lr_gov_api->create_data_reference( EXPORTING iv_entity_name = im_entity

                                                 iv_struct      = lr_gov_api->gc_struct_key

                                       IMPORTING er_structure   = lr_adpostal_detail_key_str

                                                 er_table       = lr_adpostal_detail_key_tab ).

    "Get AdPostal data:

    lr_gov_api->create_data_reference( EXPORTING iv_entity_name = im_entity

                                       iv_struct      = lr_gov_api->gc_struct_key_attr

                             IMPORTING er_structure   = lr_adpostal_detail_data_str

                                       er_table       = lr_adpostal_detail_data_tab ).


    ASSIGN lr_adpostal_detail_key_str->*  TO <fs_w_adpostal_detail_key>.

    ASSIGN lr_adpostal_detail_key_tab->*  TO <fs_t_adpostal_detail_key>.

    ASSIGN w_crequest_obj_list-r_struc->* TO <fs_w_adpostal_detail_key>.

    INSERT <fs_w_adpostal_detail_key> INTO TABLE <fs_t_adpostal_detail_key>.

    ASSIGN lr_adpostal_detail_data_str->*  TO <fs_w_adpostal_detail_data>.

    ASSIGN lr_adpostal_detail_data_tab->* TO <fs_t_adpostal_detail_data>.


    "AD_postal Detail Data:

    TRY.

        lr_gov_api->read_entity( EXPORTING iv_entity_name   = im_entity

                                           it_key           = <fs_t_adpostal_detail_key>

                                           iv_crequest_id   = im_cr_id

                                           if_active_data   = abap_false

                                 IMPORTING et_data          = <fs_t_adpostal_detail_data> ).


      CATCH cx_usmd_gov_api_core_error cx_usmd_gov_api.

*          EXIT.

    ENDTRY.

    IF <fs_t_adpostal_detail_data> IS NOT INITIAL.

      "Read Index 1.

      READ TABLE <fs_t_adpostal_detail_data> INDEX 1 INTO <fs_w_adpostal_detail_data>.

      CLEAR <fs_t_adpostal_detail_data>.

      IF sy-subrc EQ 0 .

        ex_cr_data = <fs_w_adpostal_detail_data>.

      ENDIF.

    ENDIF.


9 comments:

  1. Amazing Content with very useful information we are awaiting for your next blog.
    Digital Marketing

    ReplyDelete
  2. Amazing Content with very useful information we are awaiting for your next blog.
    Website Development

    ReplyDelete
  3. Amazing content with very useful information awaits your next blog.
    CLOUD BASED SOLUTIONS

    ReplyDelete
  4. Amazing content with very useful information awaits your next blog.
    Technology Solutions

    ReplyDelete
  5. Amazing content with very useful information awaits your next blog.
    IT Consulting

    ReplyDelete
  6. Amazing content with very useful information awaits your next blog.
    IT Security

    ReplyDelete
  7. Amazing content with very useful information awaits your next blog.
    IT Governance

    ReplyDelete
  8. Amazing content with very useful information awaits your next blog.
    IT Project Management

    ReplyDelete
  9. Amazing content with very useful information awaits your next blog.
    Grow Your Business

    ReplyDelete