abaphanaslt

SAP SLT into HANA not updating date field


I would like to SLT data into our HANA Data warehouse. That is the easy part, I can move data that is a one to one match (type 1 table). But I would like to make it type 2 and preserve history. I have the following code in the transform, and it will not populate the update field.

*&---------------------------------------------------------------------*
*&  Include           ZAUSP_SLT_TRANSFORM
*&---------------------------------------------------------------------*


STATICS lv_syn_name TYPE tabname.

DATA con_name TYPE dbcon_name.

DATA lv_timestamp TYPE timestampl.

FIELD-SYMBOLS <lv_operation> TYPE any.


CONCATENATE _mt_id ':R:R' INTO con_name.

ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_AUSP> TO <lv_operation>.

IF sy-subrc = 0 AND
   <lv_operation> = 'D'.

  IF lv_syn_name IS INITIAL.
    CALL METHOD cl_iuuc_tab_ident_access=>get_ident
      EXPORTING
        iv_mt_id       = _mt_id
        iv_tabname     = _cobj_alias
        iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
        iv_ident_type  = cl_iuuc_tab_ident_access=>co_ident_synonym
      IMPORTING
        ev_full_name   = lv_syn_name.
    IF lv_syn_name IS INITIAL.
      allog_msg 'E' 'DMC_RT_MSG' '000'
      'Get Synonym Error' space space space 'IL '.
      RAISE stopped_by_rule.
    ENDIF.
  ENDIF.

  GET TIME STAMP FIELD lv_timestamp.

  UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
    SET ZDELETE_FLAG = 'X'
        ZUPD_DATETIME = lv_timestamp
    WHERE mandt  = <wa_s_AUSP>-mandt
      AND objek = <wa_s_AUSP>-objek
      AND atinn = <wa_s_AUSP>-atinn
      AND atzhl = <wa_s_AUSP>-atzhl
      AND mafid = <wa_s_AUSP>-mafid
      AND klart = <wa_s_AUSP>-klart
      AND adzhl = <wa_s_AUSP>-adzhl.


  IF sy-subrc <> 0.
    allog_msg 'E' 'DMC_RT_MSG' '000'
    'Update Error' space space space 'IL '.
    RAISE stopped_by_rule.
  ENDIF.

  skip_record.
ENDIF.

"Code for timestamp outside of delete.

 IF lv_syn_name IS INITIAL.
    CALL METHOD cl_iuuc_tab_ident_access=>get_ident
      EXPORTING
        iv_mt_id       = _mt_id
        iv_tabname     = _cobj_alias
        iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
        iv_ident_type  = cl_iuuc_tab_ident_access=>co_ident_synonym
      IMPORTING
        ev_full_name   = lv_syn_name.
    IF lv_syn_name IS INITIAL.
      allog_msg 'E' 'DMC_RT_MSG' '000'
      'Get Synonym Error' space space space 'IL '.
      RAISE stopped_by_rule.
    ENDIF.
  ENDIF.

  GET TIME STAMP FIELD lv_timestamp.

  UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
    SET   ZUPD_DATETIME = lv_timestamp          "slt_update is the name in your slt strucure!
    WHERE MANDT  = <wa_s_AUSP>-MANDT             "key_1 = pk of your table
    AND   OBJEK  = <wa_s_AUSP>-OBJEK
    AND   ATINN  = <wa_s_AUSP>-ATINN
    AND   ATZHL  = <wa_s_AUSP>-ATZHL
    AND   MAFID  = <wa_s_AUSP>-MAFID
    AND   KLART  = <wa_s_AUSP>-KLART
    AND   ADZHL  = <wa_s_AUSP>-ADZHL.

   IF sy-subrc <> 0.
    allog_msg 'E' 'DMC_RT_MSG' '000'
    'Update Error' space space space 'IL '.
    RAISE stopped_by_rule.
  ENDIF.

Why don't the time field get updated for all rows inserted into target? When I try and set a break point to debug during replication, I get the following error:

enter image description here

So I click one, and get the following for each one:

enter image description here

So I go to SE38 and try to activate each one individually:

enter image description here

I did not write the code in these additional programs, and do not understand how they relate to the INCLUDE I wrote. I am left thinking the INCLUDE transform I wrote is not being executed due to the background programs not being active?


Solution

  • The below code resolved my issue.

    STATICS lv_syn_name TYPE tabname.
    DATA con_name TYPE dbcon_name.
    DATA lv_timestamp TYPE timestampl.
    FIELD-SYMBOLS <lv_operation> TYPE any.
    
    FIELD-SYMBOLS: <lt_log_tab>       TYPE table,
                   <ls_log_tab>       TYPE any,
                   <lv_primary_key_1> TYPE any,
                   <lv_primary_key_2> TYPE any,
                   <lv_primary_key_3> TYPE any,
                   <lv_primary_key_4> TYPE any.
    *
    *
    *
    ** get operation flag
    ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_ausp> TO <lv_operation>.
    *
    *
    IF sy-subrc = 0 AND
       <lv_operation> = 'D'.
    *
    *
    **** replication mode and record was deleted
    
      IF lv_syn_name IS INITIAL.
    *   get synonym name in case of multi use active
        CALL METHOD cl_iuuc_tab_ident_access=>get_ident
          EXPORTING
            iv_mt_id       = _mt_id
            iv_tabname     = _cobj_alias
    *       iv_tabname     = 'AUSP'
            iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
            iv_ident_type  = cl_iuuc_tab_ident_access=>co_ident_synonym
          IMPORTING
            ev_full_name   = lv_syn_name.
        IF lv_syn_name IS INITIAL.
    *     set message
          allog_msg 'E' 'DMC_RT_MSG' '000'
          'Get Synonym Error' space space space 'IL '.
          RAISE stopped_by_rule.
        ENDIF.
      ENDIF.
    *
    *
    *
    **** set additional target fields
      GET TIME STAMP FIELD lv_timestamp.
      CONCATENATE _mt_id ':R:R' INTO con_name.
    
      UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
        SET deleted = 'X'
            delete_time = lv_timestamp
            WHERE mandt  = <wa_s_ausp>-mandt
            AND   objek  = <wa_s_ausp>-objek
            AND   atinn  = <wa_s_ausp>-atinn
            AND   atzhl  = <wa_s_ausp>-atzhl
            AND   mafid  = <wa_s_ausp>-mafid
            AND   klart  = <wa_s_ausp>-klart
            AND   adzhl  = <wa_s_ausp>-adzhl.
    
    
    
      IF sy-subrc <> 0.
        DATA(lc_subrc) = sy-subrc.
        DATA lc_ausp TYPE c LENGTH 100.
        CONCATENATE <wa_s_ausp>-mandt  <wa_s_ausp>-objek <wa_s_ausp>-atinn <wa_s_ausp>-atzhl <wa_s_ausp>-mafid <wa_s_ausp>-klart <wa_s_ausp>-adzhl
         INTO lc_ausp SEPARATED BY ','.
    *   set message
        allog_msg 'E' 'DMC_RT_MSG' '000'
         'Update Error' space space space 'IL '.
        allog_msg 'E' 'DMC_RT_MSG' '000'
        'Error Details:' lv_syn_name _cobj_alias lc_subrc 'IL '.
        allog_msg 'E' 'DMC_RT_MSG' '000'
       'Table Details:' lc_ausp space space 'IL '.
        RAISE stopped_by_rule.
      ENDIF.
    
    **** do not replicate delete
      skip_record.
    
    ELSEIF sy-subrc = 0 AND <lv_operation> = 'I'.
    
      GET TIME STAMP FIELD <wa_r_ausp>-insert_time.
    
    
    ELSEIF sy-subrc = 0 AND <lv_operation> = 'U'.
    
      GET TIME STAMP FIELD <wa_r_ausp>-update_time.
    
    
    ELSE.
    *Initial load branch
      GET TIME STAMP FIELD  <wa_r_ausp>-insert_time.
    
    ENDIF.