动态生成唯一主键

这几天在做动态生成TR,看到标准程序根据source和target生成TR ID,永远是唯一的,突然我想到了以前的一个问题,如何处理dummy号的问题?之前的开发者用的是number range,如果主键可以是32位char,就可以用类似的方法做:

  DATA: l_data   TYPE rstran_s_hash,
        l_hash   TYPE rstranid,
        l_s_tran TYPE rstran,
        l_t_tran TYPE TABLE OF rstran,
        l_s_key  TYPE rstran_s_hash.

  l_data-sourcetype    = i_s_source-tlogo.
  l_data-sourcesubtype = i_s_source-subtype.
  l_data-sourcename    = i_s_source-objnm.
  l_data-targettype    = i_s_target-tlogo.
  l_data-targetsubtype = i_s_target-subtype.
  l_data-targetname    = i_s_target-objnm.

  TRY.
      CALL METHOD cl_rsmds_hash_utilities=>to_hash_c32
        EXPORTING
          i_data     = l_data
        RECEIVING
          r_hash_c32 = r_tranid.

    CATCH cx_rsmds_input_invalid_type.
      MESSAGE x000(rstran).                                 "#EC *
    CATCH cx_rsmds_input_invalid.
      MESSAGE x000(rstran).                                 "#EC *
  ENDTRY.

你可能感兴趣的:(BW,ABAP,ABAP)