1

我想将数据 SLT 到我们的 HANA 数据仓库中。这是最简单的部分,我可以移动一对一匹配的数据(类型 1 表)。但我想让它成为类型 2 并保留历史。我在转换中有以下代码,它不会填充更新字段。

*&---------------------------------------------------------------------*
*&  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.

为什么不为插入到目标中的所有行更新时间字段?当我尝试在复制期间设置断点进行调试时,我收到以下错误:

在此处输入图像描述

因此,我单击一个,然后为每个获取以下内容:

在此处输入图像描述

所以我去 SE38 并尝试单独激活每个:

在此处输入图像描述

我没有在这些附加程序中编写代码,也不明白它们与我编写的 INCLUDE 有何关系。我想我写的 INCLUDE 转换由于后台程序没有被激活而没有被执行?

4

1 回答 1

1

下面的代码解决了我的问题。

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.
于 2016-12-05T21:13:27.730 回答