Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

CRM_DATAEXCHG_BADI - Field not saving in CRMD_ORDERADM_H Table

$
0
0

Hi All,

 

I am facing an issue where the Posting Date from crmd_orderadmh table is clearing out for some of the Contract somewhere in the system during processing of the contract (Reason for this is unknown and probably it is clearing out in ISU System and root cause is being worked upon ).

So as a work around I am trying to fill the posting date in the BDOC. I am filling up the posting date from the 'creation date' of the contract by below code.

After the code fix I can see that the BUS_TRANS_MSG contains the posting date but it is not updating the CRMD_ORDERADM_H Table finally. I have written the code in BADI CRM_DATAEXCHG_BADI in method CRM_DATAEXCH_AFTER_MBDOC_FILL. I am not a middleware guy and have been suggested to write the code in this BADI.

 

Can anybody please help me out why the field is not getting updated into the table. Is the method correctly choosen. A quick help will be appriciated.

 

 


    DATA : lv_posting_date TYPE crmt_posting_date,
           lv_crm_guid     TYPE crmt_object_guid,
           ls_orderadm_h   TYPE bad_orderadm_h_mess,
           lv_created_at   TYPE comt_created_at_usr.
    TYPES :BEGIN OF lty_crmd_orderadm,
             guid         TYPE crmt_object_guid,
             posting_date TYPE crmt_posting_date,
             created_at   TYPE comt_created_at_usr,
           END OF lty_crmd_orderadm.

    CONSTANTS : lc_0 TYPE crmt_posting_date VALUE '00000000'.

    DATA : lt_ty_crmd_orderadm TYPE STANDARD TABLE OF lty_crmd_orderadm,
           ls_ty_crmd_orderadm TYPE lty_crmd_orderadm.

    CHECK ct_message_ext-orderadm_h[] IS NOT INITIAL.

    SELECT  guid created_at posting_date FROM crmd_orderadm_h INTO TABLE lt_ty_crmd_orderadm FOR ALL

ENTRIES IN ct_message_ext-orderadm_h
      WHERE guid EQ ct_message_ext-orderadm_h-orderadm_h_guid.
    IF sy-subrc  = 0.
      SORT lt_ty_crmd_orderadm BY guid.
    ENDIF.

    FIELD-SYMBOLS: <fs_orderadm_h>  TYPE bad_orderadm_h_mess.

    LOOP AT ct_message_ext-orderadm_h ASSIGNING <fs_orderadm_h>.
      IF <fs_orderadm_h>-posting_date EQ space OR <fs_orderadm_h>-posting_date EQ lc_0 .
        lv_crm_guid = <fs_orderadm_h>-orderadm_h_guid.

        READ TABLE lt_ty_crmd_orderadm INTO ls_ty_crmd_orderadm WITH KEY guid = lv_crm_guid BINARY SEARCH. "binary search
        IF sy-subrc = 0.
          lv_created_at = ls_ty_crmd_orderadm-created_at.
          CALL FUNCTION 'ADDR_CONVERT_TIMESTAMP_TO_DATE'
            EXPORTING
              iv_timestamp = lv_created_at
            IMPORTING
              ev_date      = lv_posting_date.

          <fs_orderadm_h>-posting_date = lv_posting_date.
        ENDIF.
      ENDIF.
    ENDLOOP.

 

Many Thanks,


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>