`
jgtang82
  • 浏览: 409937 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

生成 Solution Manager Key 的 ABAP 程序(转)

    博客分类:
  • ABAP
阅读更多

安装 SAP ECC5/6 的时候,必须要输入一个 Solution Manager Key,这个号一般需要通过 SAP 提供的 Solution Manager 服务器来生成,但是很多时候我们不想安装这个庞大的系统(15G 左右)。用下面这个小小的 ABAP 程序,我们就可以快速生成 Solution Manager Key 了。

REPORT  ZSLMKEY.

types: begin of dswpclientkey,
         INSTNO type num10,
         DBID(3),
         BUNDLE_ID(8),
         SERVICE_KEY(40),
       end of dswpclientkey.
*data: dswpclientkey_w type standard table of dswpclientkey.
DATA: P_VALUE(10),
      P_INSTNO(10).

PARAMETERS: P_SID(3),
             P_SYSNO(2),
             P_SERVER(15).

START-OF-SELECTION.
  PERFORM GET_SP_VALUE USING P_SID
                             P_SYSNO
                             P_SERVER
                             P_INSTNO
                    CHANGING P_VALUE.

END-OF-SELECTION.
  WRITE P_VALUE.
*&---------------------------------------------------------------------*
*&      Form  get_sp_value
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PF_SID  text
*      -->P_PF_SYSNO  text
*      -->P_PF_SERVER  text
*      <--P_PF_VALUE  text
*----------------------------------------------------------------------*
FORM get_sp_value USING    P_PF_SID
                           P_PF_SYSNO
                           P_PF_SERVER
                           P_PF_INSTNO
                  CHANGING P_PF_VALUE.

  CONSTANTS: lc_part_len TYPE i VALUE 5,
             lc_pw_len   TYPE i VALUE 10,
             lc_allowed_chars(38) TYPE c VALUE
             '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_'.

  data: lf_string(20)        type c,
        lf_key               type i,
        ls_key               type dswpclientkey,
        lf_part(lc_part_len) type c,
        lf_finalf(lc_pw_len) type c,
        lf_finalx            type xstring,
        lf_xbuffer           type xstring,
        lf_opf(10)           type c,
        lf_langu             like sy-langu,
        lf_subrc             like sy-subrc,
        lf_len               type i,
        lo_conv_to_x         TYPE REF TO cl_abap_conv_out_ce.

  clear: lf_string, lf_finalx, lf_opf.

  concatenate p_pf_sid p_pf_sysno p_pf_server into lf_string.

* Large letters only
  translate lf_string to upper case.

  lf_langu = sy-langu.
  SET LOCALE LANGUAGE 'E'.
  lo_conv_to_x = cl_abap_conv_out_ce=>create( encoding = '1100' ).
  lf_len = STRLEN( lf_string ).

  IF lf_string(lf_len) CN lc_allowed_chars.
  else.

* Fold the input string to a lc_part_len long string
    WHILE lf_len > 0.
      lf_part = lf_string(lc_part_len).
      SHIFT lf_string BY lc_part_len PLACES.
      lf_len = STRLEN( lf_string ).
      CALL METHOD lo_conv_to_x->reset.
      CALL METHOD lo_conv_to_x->write( data = lf_part n = -1 ).
      lf_xbuffer = lo_conv_to_x->get_buffer( ).
      lf_finalx = lf_finalx BIT-XOR lf_xbuffer.
    ENDWHILE.

    lf_key = 12.

    PERFORM scramble USING      lf_finalx
                                lf_key
                                lc_part_len
                       CHANGING lf_finalf
                                lf_subrc.

    if not lf_finalf is initial.
      p_pf_value = lf_finalf.
      ls_key-dbid        = p_pf_sid.
      ls_key-instno      = p_pf_instno.
      ls_key-bundle_id   = 'SM_KEY'.
      ls_key-service_key = lf_finalf.
      if not p_pf_instno is initial.
*        insert dswpclientkey_w from ls_key.
        if sy-subrc <> 0.
*          update dswpclientkey_w from ls_key.
        endif.
      endif.
    else.
      clear p_pf_value.
    endif.
  endif.
ENDFORM.                    " get_sp_value
*&---------------------------------------------------------------------*
*&      Form  scramble
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LF_FINALX  text
*      -->P_LF_KEY  text
*      -->P_LC_PART_LEN  text
*      <--P_LF_finalf  text
*      <--P_LF_SUBRC  text
*----------------------------------------------------------------------*
FORM scramble USING    iv_xstring TYPE xstring
                       iv_key TYPE i
                       iv_src_len TYPE i
              CHANGING lf_finalf
                       lf_subrc LIKE sy-subrc.

  CONSTANTS: lc_max_len    TYPE i VALUE 20,
             lc_mask(4)    TYPE x VALUE '0000003F',
             lc_random(64) TYPE x VALUE
                      'F0ED53B83244F1F876C67959FD4F13A2' &
                      'C15195EC5483C234774943A27DE26596' &
                      '5E5398789A17A33CD383A8B829FBDCA5' &
                      '55D702778413ACDDF9B83116610E6DFA'.

  DATA: lv_key_index(4)  TYPE x,
        lv_rand_index(4) TYPE x,
        lv_xkey(4)       TYPE x,
        lv_xkey_shl_1(4) TYPE x,
        lv_xkey_shr_5(4) TYPE x,
        lv_scramble_byte TYPE x,
        lv_dest(lc_max_len) TYPE x,
        lv_index         TYPE i,
        lv_len           TYPE i.

  CLEAR lf_subrc.

  IF iv_src_len EQ 0. EXIT. ENDIF.
  lv_len = XSTRLEN( iv_xstring ).
  IF iv_src_len GT lc_max_len OR
     iv_src_len GT lv_len.
    lf_subrc = 2.
    EXIT.
  ENDIF.

  lv_xkey       = iv_key.
  lv_xkey_shl_1 = iv_key * 2.
  lv_xkey_shr_5 = iv_key DIV 32.
  lv_rand_index = lv_xkey BIT-XOR lv_xkey_shr_5 BIT-XOR lv_xkey_shl_1.
  lv_rand_index = lv_rand_index BIT-AND lc_mask.

  lv_index = 0.
  DO iv_src_len TIMES.
    CATCH SYSTEM-EXCEPTIONS compute_int_times_overflow = 1.
      lv_key_index = ( iv_key * lv_index * lv_index ) - lv_index.
    ENDCATCH.
    IF sy-subrc <> 0.
      lf_subrc = 1.
      EXIT.
    ENDIF.
    lv_scramble_byte = lc_random+lv_rand_index(1) BIT-XOR
                       lv_key_index+3(1).
    lv_dest+lv_index(1) = iv_xstring+lv_index(1) BIT-XOR
                          lv_scramble_byte.
    lv_index = lv_index + 1.
    lv_rand_index = lv_rand_index + 1.
    lv_rand_index = lv_rand_index BIT-AND lc_mask.
  ENDDO.
  IF lf_subrc <> 0.
    EXIT.
  ENDIF.

  WRITE lv_dest(iv_src_len) TO lf_finalf.

ENDFORM.                    " scramble

分享到:
评论
1 楼 blueoxygen 2007-12-27  
good!

相关推荐

    SAP 生成Solution Manager Key的ABAP程序

    如果有SAP系统,在安装新的系统是可以使用该ABAP程式生成Solution Manager Key,本人测试可用,仅供大家学习交流,请勿用于商业用途

    Solution Manager Key 的 ABAP 程序

    根据给定的信息,本文将详细解释“生成Solution Manager Key的ABAP程序”的相关内容,包括Solution Manager Key的作用、生成Solution Manager Key的背景需求以及具体的ABAP程序实现细节。 ### Solution Manager Key...

    solumation manager key生成代码

    根据提供的文件信息,我们可以深入探讨SAP系统中的Solution Manager Key(SLM Key)生成代码的知识点。这将涉及ABAP编程语言以及SAP系统中特定的功能实现方式。 ### SLM Key概念 在SAP系统中,SLM Key是用于识别和...

    计算SolutionMangerKey程序

    根据提供的文件信息,我们可以推断出这是一段ABAP编程代码,主要功能是计算Solution Manager Key(SMK),即一种用于验证SAP Solution Manager合法性的密钥。此报告(Report ZSLMKEY)的主要目的是根据输入参数计算...

    SAP PO/PI教程 Process Orchestration The Comprehensive Guide

    7.2.3 SAP PI Central Monitoring with SAP Solution Manager 7.2.4 Message Retention 7.2.5 User-Defined Message Search 7.3 Troubleshooting 7.3.1 Configuring Log and Traces 7.3.2 Using the Log Viewer...

    SAP R3 联机事务码速查手册

    SAP solution Manager4.0服务器版本安装,安装盘6张DVD,配Oracle 10g,MS- SQL2005或IBM的DB6数据库 6, ECC6 安装或虚拟机,安装盘8张DVD,配Oracle 10g,MS-SQL2005或IBM的DB6数据库 7, BW7(BI)安装和虚拟机,...

    SD销售组织与单别对应关系设置

    SAP solution Manager4.0服务器版本安装,安装盘6张DVD,配Oracle 10g,MS- SQL2005或IBM的DB6数据库 6, ECC6 安装或虚拟机,安装盘8张DVD,配Oracle 10g,MS-SQL2005或IBM的DB6数据库 7, BW7(BI)安装和虚拟机,...

    SAP ECC6 安装笔记

    6. **输入Solution Manager Key**,点击继续按钮。 7. **安装完成**:整个安装过程大约需要10个小时。 #### 四、后续配置与注意事项 - **中文设定**:通过修改Instance Profile和运行`RSCPINST`来设置语言。 - **...

Global site tag (gtag.js) - Google Analytics