SAP ABAP 代码修改自动比较对象版本一致

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

第一步找到SE38/SE37代码修改的出口
SMOD中查找
第二步实施增强
CMOD中添加增强并激活如下图
在这里插入图片描述
第三步添加代码
在这里插入图片描述

在这里插入图片描述
如上图两个双击添加并修改代码
ZXSEUU08中与 ZXSEUU01代码一致如下

*&---------------------------------------------------------------------*
*&  包含                ZXSEUU01
*&---------------------------------------------------------------------*
if  objectname <> 'ZXSEUU01'.
*  break jordan.
**  只要编辑就检查一下
*  CHECK sy-uname = 'JORDAN'.
  check operation eq 'MODIFY'.
  check sy-tcode = 'SE37'.
  data:lv_object type tadir-object.
  case sy-tcode.
    when 'SE38'.
      lv_object = 'PROG'.
    when 'SE37'.
      lv_object = 'FUNC'.
    when others.
  endcase.
  data ls_yabap_check_001 type yabap_check_001.
  select single * from yabap_check_001
    into ls_yabap_check_001 where bname eq sy-uname and object = '' and objname = ''.
  if sy-subrc is initial.
    if ls_yabap_check_001-datum is initial.
      exit.
    elseif ls_yabap_check_001-datum >= sy-datum.
      exit.
    endif.
  else.
    select single * from yabap_check_001
        into ls_yabap_check_001
       where bname eq sy-uname and object = lv_object
       and objname = objectname and datum = sy-datum
       and disregard = abap_true  "空为已激活
      .
    if sy-subrc is initial.
      exit.
    endif.
  endif.


  clear lw_yabap_check_002.
  perform get_version using objectname  lv_object changing lw_yabap_check_002.

  clear lw_yabap_check_002.
  data:lt_tfdir type table of tfdir,
       lw_tfdir type tfdir.

*** step1 获取主函数
  select single * from    tfdir
    into lw_tfdir where  funcname = objectname.
  check sy-subrc is initial.
  select * from    tfdir
    into table lt_tfdir where  pname = lw_tfdir-pname.
  if sy-subrc is  initial.
    loop at lt_tfdir assigning field-symbol(<fs_tfdir>).
*******      限制输出条目数以免返回的过数过大使人无法评估
      describe table lt_yabap_check_002 lines data(lv_lines).
      if lv_lines > 50.
        exit.
      endif.
*      IF lw_wbcrossi-include IS NOT INITIAL.  标准函数出口这个include是没有版本的
      if <fs_tfdir>-funcname is not initial.
        read table lt_yabap_check_002 with  key objname = <fs_tfdir>-funcname transporting no fields.
        if sy-subrc is initial.
****          已经在的情况焉那么不需要再列出来以免无限循环
          continue.
        endif.
        clear lw_yabap_check_002.
        lw_yabap_check_002-objname_link = objectname.
        perform get_version using <fs_tfdir>-funcname  lv_object changing lw_yabap_check_002.
      endif.
    endloop.
  endif.
****  step2 获取函数外的子例程
*************除了函数把其他的pefrorm子例程也查出来检查版本主要就是top与f01 f02这种
  data:lt_wbcrossi type table of wbcrossi,
       lw_wbcrossi type wbcrossi.

  data:lv_object_prog type tadir-object value 'PROG'.
  select * from wbcrossi
    into table lt_wbcrossi
    where otype = 'IC' and master = lw_tfdir-pname and include = lw_tfdir-pname .
  if sy-subrc is  initial.
    loop at lt_wbcrossi into lw_wbcrossi.
      describe table lt_yabap_check_002 lines lv_lines.
      if lv_lines > 50.
        exit.
      endif.
      if lw_wbcrossi-name is not initial.
        read table lt_yabap_check_002 with  key objname = lw_wbcrossi-name transporting no fields.
        if sy-subrc is initial.
****          已经在的情况焉那么不需要再列出来以免无限循环
          continue.
        endif.
        clear lw_yabap_check_002.
        lw_yabap_check_002-objname_link = lw_tfdir-pname.
        perform get_version using lw_wbcrossi-name  lv_object_prog  changing lw_yabap_check_002.
      endif.
    endloop.
  endif.
  gv_object = lv_object.
  gv_objectname = objectname.
  sort lt_yabap_check_002 by suggest descending.
  perform show_alv.
endif.

另外有表如下这个表主要是记录检查的日志
在这里插入图片描述
其他include如下
ZXSEUF01 获取对象相关
ZXSEUF02 alv显示相关
ZXSEUF03 代码比较相关
lsvrif18 标准代码的一些inculde 都在 ZXSEUZZZ中添加
ZXSEUTOP 变量定义及声明
放同一个include也没事

*----------------------------------------------------------------------*
***INCLUDE ZXSEUF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  GET_VERSION_LIST_REMOTE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_DIR_OBJTYPE  text
*      -->P_DIR_OBJNAME  text
*      <--P_NO_ENTRY  text
*----------------------------------------------------------------------*
form get_version_list_remote tables to_vrs_dir_vrs structure vrsd
                              using pi_objtype pi_objname pi_dir_destination
                              changing po_no_entry
                               .

  data: old_state type bool.

  refresh: vrs_dir_vrs, logvers_dir.

  perform check_vc_state_remote using pi_dir_destination changing old_state.

  if old_state = true.
    perform get_old_fashioned_versdir using pi_objtype pi_objname pi_dir_destination
                                      changing po_no_entry.
  else.
    call function 'SVRS_GET_VERSION_DIRECTORY_46'
      exporting
        destination            = pi_dir_destination
        objname                = pi_objname
        objtype                = pi_objtype
      tables
        version_list           = vrs_dir_vrs
        lversno_list           = logvers_dir
      exceptions
        no_entry               = 1
        system_failure         = 2
        communication_failure_ = 3.

    case sy-subrc.
      when 0.
        po_no_entry = false.
      when 1.
        po_no_entry = true.
      when 2.
*        'Fehler im Zielsytem'.
*        MESSAGE w123.
        leave.
      when 3.
*        'Keine Verbindung zum Zielsystem'.
*        MESSAGE w124.
        leave.
    endcase.
  endif.
  to_vrs_dir_vrs[] = vrs_dir_vrs[].
endform.                    " GET_VERSION_LIST_REMOTE


form check_vc_state_remote using pi_dir_destination changing po_old_state.

  data: head_entry like vrsd.

  perform get_vrsd_entry_remote
          using head_type head_objname head_versno pi_dir_destination
          changing head_entry po_old_state.

endform.                    "check_vc_state_remote

form get_vrsd_entry_remote using pi_objtype pi_objname pi_versno pi_dir_destination
                           changing vrsd_entry po_no_entry.

  call function 'GET_VRSD_ENTRY_46'
    exporting
      destination           = pi_dir_destination
      objname               = pi_objname
      objtype               = pi_objtype
      versno                = pi_versno
    importing
      vrsd_entry            = vrsd_entry
    exceptions
      no_entry_found        = 1
      system_failure        = 2
      communication_failure = 3.

  case sy-subrc.
    when 0.
      po_no_entry = false.
    when 1.
      po_no_entry = true.
    when 2.
*      'Fehler im Zielsytem'.
*      message w123.
      leave.
    when 3.
*       'Keine Verbindung zum Zielsystem'.
*      message w124.
      leave.
  endcase.

endform.                    "get_vrsd_entry_remote



form get_old_fashioned_versdir using pi_objtype pi_objname pi_dir_destination
                               changing po_no_entry.

  data: vrsd_entry like vrsd.

  data: object_not_found like bool.

  perform get_vrsd_entry_remote
          using pi_objtype pi_objname null_versno pi_dir_destination
          changing buffer0 po_no_entry.

  if po_no_entry = false.
    call function 'GET_VERSION_LIST_46'
      exporting
        destination           = pi_dir_destination
        objname               = pi_objname
        objtype               = pi_objtype
      tables
        version_list          = vrs_dir_vrs
      exceptions
        system_failure        = 1
        communication_failure = 2.

    case sy-subrc.
      when 1.
*        'Fehler im Zielsytem'.
*        message w123.
        leave.
      when 2.
*        'Keine Verbindung zum Zielsystem'.
*        message w124.
        leave.
    endcase.


    sort vrs_dir_vrs descending by versno.
    loop at vrs_dir_vrs.
      logvers_dir-versno = vrs_dir_vrs-versno.
      append logvers_dir.
    endloop.
    read table vrs_dir_vrs index 1.
    if vrs_dir_vrs-versmode = impt_mode.
*      Es gibt einen offenen Import, setze Flag zurück:
      vrs_dir_vrs-versmode  = corr_mode.
    endif.
    vrs_dir_vrs-versno = 0.
    modify vrs_dir_vrs index 1.
  endif.

  vrsd_entry = buffer0.
  perform add_active_version_remote using pi_dir_destination
          changing vrsd_entry object_not_found.

  if object_not_found = false.
    po_no_entry = false.
  endif.

*  Möglicherweise gibt es eine überarbeitete Version.
  perform add_modif_version_remote using pi_dir_destination
          changing vrsd_entry object_not_found.

  if object_not_found = false.
    po_no_entry = false.
  endif.

endform.

form add_active_version_remote  using pi_dir_destination changing vrsd_info structure vrsd
                                        po_not_found.

  data: object_not_found like vrsd-versmode.
  data: nplus1           like vrsd-versno.
  data: retcode          like bool.

  call function 'FIND_OBJECT_40'
    exporting
      destination           = pi_dir_destination
      objname               = vrsd_info-objname
      objtype               = vrsd_info-objtype
    importing
      object_not_found      = object_not_found
    exceptions
      system_failure        = 1
      communication_failure = 2.

  case sy-subrc.
    when 1.
*        'Fehler im Zielsytem'.
*      message w123.
      leave.
    when 2.
*        'Keine Verbindung zum Zielsystem'.
*      message w124.
      leave.
  endcase.                             " SY-SUBRC.

  if object_not_found = space.
    po_not_found = false.
  else.
    po_not_found = true.
  endif.

  clear: vrsd_info-korrnum, vrsd_info-author,
         vrsd_info-datum,   vrsd_info-zeit.

  if po_not_found = false.

    if vrsd_info-versmode = impt_mode.
*     Es gibt einen offenen Import, und einen Satz n+1 der
*     uns verschwiegen wurde. Er beschreibt die aktive Version
      nplus1 = vrsd_info-lastversno + 1.
      perform get_vrsd_entry_remote
              using vrsd_info-objtype vrsd_info-objname nplus1 pi_dir_destination
              changing vrsd_info retcode.
    else.
      perform get_korrinfo_remote using pi_dir_destination changing vrsd_info.
    endif.

    move-corresponding vrsd_info to vrs_dir_vrs.
    vrs_dir_vrs-versno    = null_versno.
    logvers_dir-versno    = acti_versno.
    insert vrs_dir_vrs index 1.
    insert logvers_dir index 1.
  endif.

endform.

form add_modif_version_remote using pi_dir_destination changing vrsd_info structure vrsd
                                       po_not_found.

  data: mod_dd_exists like vrsd-versmode.

  call function 'TEST_MOD_DD_40'
    exporting
      destination           = pi_dir_destination
      objname               = vrsd_info-objname
      objtype               = vrsd_info-objtype
    importing
      mod_dd_exists         = mod_dd_exists
    exceptions
      system_failure        = 1
      communication_failure = 2.

  case sy-subrc.
    when 1.
*       'Fehler im Zielsytem'.
*      message w123.
      leave.
    when 2.
*       'Keine Verbindung zum Zielsystem'.
*      message w124.
      leave.
  endcase.

  if mod_dd_exists <> space.
    po_not_found = false.
    perform get_korrinfo_remote using  pi_dir_destination changing vrsd_info.
    move-corresponding vrsd_info to vrs_dir_vrs.
    vrs_dir_vrs-versno    = modi_versno.
    logvers_dir-versno    = modi_versno.
    insert vrs_dir_vrs index 1.
    insert logvers_dir index 1.

  else.
    po_not_found = true.
  endif.

endform.                    "add_modif_version_remote


form get_korrinfo_remote using pi_dir_destination changing vrsd_info structure vrsd.

  call function 'GET_KORRNUM_AUTHOR_DATUM_40'
    exporting
      destination           = pi_dir_destination
      objname               = vrsd_info-objname
      objtype               = vrsd_info-objtype
    importing
      author                = vrsd_info-author
      datum                 = vrsd_info-datum
      korrnum               = vrsd_info-korrnum
      zeit                  = vrsd_info-zeit
    exceptions
      system_failure        = 1
      communication_failure = 2.

  case sy-subrc.
    when 1.
*       'Fehler im Zielsytem'.
*      message w123.
      leave.
    when 2.
*       'Keine Verbindung zum Zielsystem'.
*      message w124.
      leave.
  endcase.

  if vrsd_info-korrnum <> space.
*     Korrektur ist offen, Zeitstempel korrigieren:
    vrsd_info-datum = sy-datum.
    vrsd_info-zeit  = sy-uzeit.
  endif.

endform.
*&---------------------------------------------------------------------*
*&      Form  GET_VERSION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PROGRAM  text
*      <--P_LW_YABAP_CHECK_002  text
*----------------------------------------------------------------------*
form get_version  using    p_program p_object type tadir-object
                  changing pw_yabap_check_002 type ty_yabap_check_002_mix .

  data:lv_mtext_qas type string.
  data:lv_mtext_prd type string.
*  PROGRAM  Version management: Directory table
  data:ls_vrsd type vrsd.
**  取当前对象已经释放的请求里面最新的激活版本
  select single * from vrsd
    into ls_vrsd
    where objname = p_program
    and versno =  0
**    防止是第一次修改并没有释放的情况
    and korrnum is not null .
*     AND korrnum eq abap_false.
  if sy-subrc is initial.
    pw_yabap_check_002-dev = ls_vrsd.
  else.
    pw_yabap_check_002-objname = p_program.
    pw_yabap_check_002-crdate = sy-datum.
    pw_yabap_check_002-crtime = sy-uzeit.
    pw_yabap_check_002-objname = p_program.
*       REPOSRC 是报表的情况下,查这个表
    data:ls_reposrc type  reposrc.

*****    这里如果是函数的话需要改一下取数逻辑
    select single * from reposrc into ls_reposrc
       where progname = p_program.
    if sy-subrc is initial.
      pw_yabap_check_002-dev_author = ls_reposrc-cnam.
*      pw_yabap_check_002-dev_author = ls_reposrc-cnam.
      pw_yabap_check_002-dev_versno = ls_reposrc-vern.
    endif.
    pw_yabap_check_002-suggest = '无版本信息无法比较'.

    append pw_yabap_check_002 to lt_yabap_check_002.
    exit.
  endif.

*  TMSMCONF
***  检查本系统是有传输请求配置的
  data:ls_tmsmconf type tmsmconf.
  select single * from tmsmconf into ls_tmsmconf .
  check sy-subrc is initial.

***  TMSCSYS
**  查到本系统内的传输请求  这里可以区分 Q*与T*
  data:lt_tmscsys type table of tmscsys.
  select * from tmscsys into table lt_tmscsys
      where extsys <> 'X'
       or extsys is null
       and nfsgrp eq ls_tmsmconf-nfsgrp.
  check sy-subrc is initial.
***  检查是se38的程序
*  IF p_object = 'PROG'.
*******    排除SAP的程序 LYFG_TEST01F01
**       TRDIR
**    select
*    DATA:ls_tadir TYPE tadir.
*    SELECT SINGLE * FROM  tadir INTO ls_tadir
*         WHERE pgmid = 'R3TR'
*         AND object = p_object
*         AND obj_name = p_program.
*    CHECK sy-subrc IS INITIAL.
*  ENDIF.


*TMSADM@TPV.DOMAIN_DEV
*ZXF05U01
*REPS
* 函数模块 SVRS_DISPLAY_REMOTE_DIR
* * Lies die Versionsliste des REMOTE-Systems
  data: dir_objtype   like vrsd-objtype.
  data: dir_objname   like vrsd-objname.
  data: no_entry type bool.
  dir_objtype = ls_vrsd-objtype.
  dir_objname = ls_vrsd-objname.

************************************************************************
*   获取当前对象的测试环境的版本信息                                   *
************************************************************************
  data:    lt_vrs_dir_vrs_qas like table of vrsd ,
           lw_vrs_dir_vrs_qas type vrsd.
  dir_destination_qas = 'TMSADM@QA1.DOMAIN_DEV'.

* Prüfe, ob Objekt im Zielsystem existiert und Versionen hat
  data:  returncode_qas like sy-subrc,
         returncode_prd like sy-subrc.
  perform ck_check_remote_object
                using    dir_destination_qas dir_objname
                changing dir_objtype
                         returncode_qas.
  case returncode_qas.
    when 0 or 1.
    when 2.
*    'Fehler im Zielsystem'
      message id 'SB' type 'I' number 123 into lv_mtext_qas.
    when 3.
*     'Keine Verbindung zum Zielsystem oder fehlerhafte Kommunikation'
      message id 'SB' type 'I' number  124 into lv_mtext_qas.

    when 4.
*     'Das Objekt existiert nicht im Zielsystem'.
      message id 'SB' type 'I' number  131 into lv_mtext_qas.

  endcase.
  if returncode_qas eq 0 or returncode_qas eq 1.
    perform get_version_list_remote tables lt_vrs_dir_vrs_qas
                                    using dir_objtype dir_objname dir_destination_qas
                                    changing no_entry.
  else.
    lw_vrs_dir_vrs_qas-objname  = dir_objname.
    lw_vrs_dir_vrs_qas-objtype  = dir_objtype.
    append lw_vrs_dir_vrs_qas to lt_vrs_dir_vrs_qas.
  endif.

************************************************************************
*   获取当前对象的生产的版本信息                                       *
************************************************************************
  dir_destination_prd = 'TMSADM@TPV.DOMAIN_DEV'.
  perform ck_check_remote_object
                  using    dir_destination_prd dir_objname
                  changing dir_objtype
                           returncode_prd.
  case returncode_prd.
    when 0 or 1.
    when 2.
*    'Fehler im Zielsystem'
      message id 'SB' type 'I' number 123 into lv_mtext_prd.
    when 3.
*     'Keine Verbindung zum Zielsystem oder fehlerhafte Kommunikation'
      message id 'SB' type 'I' number  124 into lv_mtext_prd.

    when 4.
*     'Das Objekt existiert nicht im Zielsystem'.
      message id 'SB' type 'I' number  131 into lv_mtext_prd.

  endcase.

  if returncode_prd eq 0 or returncode_prd eq 1.
    data:    lt_vrs_dir_vrs_prd like table of vrsd ,lw_vrs_dir_vrs_prd type vrsd.

    perform get_version_list_remote tables lt_vrs_dir_vrs_prd
                                    using dir_objtype dir_objname dir_destination_prd
                                    changing no_entry.
  else.
    lw_vrs_dir_vrs_prd-objname  = dir_objname.
    lw_vrs_dir_vrs_prd-objtype  = dir_objtype.
    append lw_vrs_dir_vrs_prd to lt_vrs_dir_vrs_prd.
  endif.

  check no_entry ne true.
  if no_entry eq true.
    exit.
  endif.
  check no_entry ne true.
  pw_yabap_check_002-crdate = sy-datum.
  pw_yabap_check_002-crtime = sy-uzeit.
  pw_yabap_check_002-objname = p_program.
  pw_yabap_check_002-dev_versno = ls_vrsd-korrnum.
  if lt_vrs_dir_vrs_prd[] is not initial.
    read table lt_vrs_dir_vrs_prd index 1 into lw_vrs_dir_vrs_prd.
    if sy-subrc is initial.
      if lw_vrs_dir_vrs_prd-korrnum is initial.
        pw_yabap_check_002-dev_prd_compare = lv_mtext_prd.
      else.
        pw_yabap_check_002-prd_versno = lw_vrs_dir_vrs_prd-korrnum.
      endif.
      pw_yabap_check_002-prd = lw_vrs_dir_vrs_prd.
    endif.
  endif.
  if lt_vrs_dir_vrs_qas[] is not initial.
    read table lt_vrs_dir_vrs_qas index 1 into lw_vrs_dir_vrs_qas.
    if sy-subrc is initial.
      if lw_vrs_dir_vrs_qas-korrnum is initial.
        pw_yabap_check_002-dev_qas_compare = lv_mtext_qas.
      else.
        pw_yabap_check_002-qas_versno = lw_vrs_dir_vrs_qas-korrnum.
      endif.
      pw_yabap_check_002-qas = lw_vrs_dir_vrs_qas.
    endif.
  endif.
**DEV_AS4TEXT 请求描述 后面还要加开发人员

  if pw_yabap_check_002-dev_versno eq pw_yabap_check_002-qas_versno
    and pw_yabap_check_002-qas_versno eq pw_yabap_check_002-prd_versno
    and pw_yabap_check_002-dev_versno is not initial
    and pw_yabap_check_002-qas_versno is not initial
    and pw_yabap_check_002-prd_versno is not initial.

    pw_yabap_check_002-suggest = '放心修改。'(011).

  else.
*****    增加代码自动比较

    perform get_version_description using  pw_yabap_check_002.

    perform auto_compare_versions using  pw_yabap_check_002.

  endif.
  append pw_yabap_check_002 to lt_yabap_check_002.
endform.                    " GET_VERSION


form ck_check_remote_object using pi_logdest like rfcdes-rfcdest
                                  pi_objname like vrsd-objname
                            changing pi_objtype like vrsd-objtype
                                     retcode like sy-subrc.
************************************************************************
* FUNKTION:
* Prüft nach, ob das angegebene System mittels REMOTE-Function-Call
* angesprochen werden kann.
* ----------------------------------------------------------------------
* PARAMETER:
* PI_LOGDEST: Name der logischen Destination
*
* PI_OBJTYPE: Name des Objekts ('REPO', 'DYNP', ETC.)
*
* PI_OBJNAME: Name des Objekts
*
* RETCODE:    = 0 versions exist
*             = 1 active object exists
*             = 2/3 communication failures
*             = 4 object does not exist at all
*             = 5 object exists, but incompatible releases
************************************************************************
  data: object_not_found  like vrsd-versmode value ' '.

  data: vrsd_entry like vrsd.

  clear: retcode, object_not_found.

* Überprüfe, ob das Fremdsystem angesprochen werden kann und
* ob es dort Versionen dieses Objekts gibt.
  perform ck_check_remote_versions
          using pi_logdest pi_objname
          changing pi_objtype
                   retcode.

  if retcode = 1.
*   Keine Versionen im Fremdsystem gefunden. Prüfe, ob das Objekt
*   überhaupt im Zielsystem existiert.
    call function 'FIND_OBJECT_40'
      exporting
        destination           = pi_logdest
        objname               = pi_objname
        objtype               = pi_objtype
      importing
        object_not_found      = object_not_found
      exceptions
        system_failure        = 2
        communication_failure = 3.

    if sy-subrc <> 0.
      retcode = sy-subrc.
    else.
      if object_not_found <> space.
        retcode = 4.
      else.
        retcode = 1.
      endif.
    endif.

  elseif retcode = 0.
*   Versionen im Fremdsystem vorhanden, prüfen ob Vergleich
*   überhaupt möglich ist, oder nur Anzeige.
*   Bis jetzt gibt es bei fast allen Objekttypen Probleme
    if pi_objtype = 'DYNP' or
       pi_objtype = 'CUAD' or
       pi_objtype = 'TABD' or
       pi_objtype = 'VIED' or
       pi_objtype = 'MCID' or
       pi_objtype = 'MCOD' or
       pi_objtype = 'ENQD' or
       pi_objtype = 'TABT'.
*     Wir prüfen den Release-Stand anhand des Header Eintrages
      call function 'GET_VRSD_ENTRY_46'
        exporting
          destination           = pi_logdest
          objname               = head_objname
          objtype               = head_type
          versno                = head_versno
        importing
          vrsd_entry            = vrsd_entry
        exceptions
          no_entry_found        = 1
          system_failure        = 2
          communication_failure = 3.

      retcode = sy-subrc.
      if retcode = 1.
*       Wenn kein Header Eintrag vorhanden ist, dann handelt es
*       sich um einen älteren Releasestand (< 30A).
        retcode = 5.
      elseif retcode = 0.
*       Es gibt einen Header Eintrag, aber ist es ein richtiger?
        if vrsd_entry-rels < '30A '.                      "#EC PORTABLE
          retcode = 5.
        endif.
      endif.

    endif.

  endif.
endform.

form ck_check_remote_versions using pi_logdest like rfcdes-rfcdest
                                    pi_objname like vrsd-objname
                              changing pi_objtype like vrsd-objtype
                                       po_retcode like sy-subrc.
************************************************************************
* FUNKTION:
* Prüft nach, ob es in dem angegebenen System Versionen (in VRSD) des
* angegebenen Objektes gibt.
* ----------------------------------------------------------------------
* PARAMETER:
* PI_LOGDEST: Name der logischen Destination
*
* PI_OBJTYPE: Name des Objekts ('REPO', 'DYNP', ETC.)
*
* PI_OBJNAME: Name des Objekts
*
* PO_RETCODE: = 0 versions exist
*             = 1 no versions
*             = 2/3 communication failures
************************************************************************
  tables tfdir.
  data: versno like vrsd-versno value 0.
  data: iname  like vrsd-objname.
  data: iobjtype  like vrsd-objtype.


  data: vrsd_entry like vrsd.

  clear: po_retcode.

* Überprüfe, ob das Fremdsystem angesprochen werden kann und
* ob es dort Versionen dieses Objekts gibt.
  call function 'GET_VRSD_ENTRY_46'
    exporting
      destination           = pi_logdest
      objname               = pi_objname
      objtype               = pi_objtype
      versno                = versno
    importing
      vrsd_entry            = vrsd_entry
    exceptions
      no_entry_found        = 1
      system_failure        = 2
      communication_failure = 3.

  po_retcode = sy-subrc.
  if po_retcode <> 1.
    exit.
  endif.

  if pi_objtype = rept_type or pi_objtype = reps_type or
     pi_objtype = func_type.
*   Für einige Objekttypen werden noch alte LIMU REPOs gesucht,
*   in denen Versionen der ABAP-Source stehen könnten

    if pi_objtype = func_type.
*     wir brauchen zuerst den Include-Namen
      clear: iname.
      select single * from tfdir where funcname = pi_objname.
      iname(1)   = 'L'.
      iname+1(4) = tfdir-pname+4(4).   "'4' ist OK, da REPOs nicht mehr
      "versioniert werden.
      iname+5(1) = 'U'.
      iname+6(2) = tfdir-include.
*     Nun können wir die Versionen suchen
      iobjtype = repo_type.
      call function 'GET_VRSD_ENTRY_46'
        exporting
          destination           = pi_logdest
          objname               = iname
          objtype               = iobjtype
          versno                = versno
        importing
          vrsd_entry            = vrsd_entry
        exceptions
          no_entry_found        = 1
          system_failure        = 2
          communication_failure = 3.

      po_retcode = sy-subrc.

    elseif pi_objtype = reps_type.
      iobjtype = repo_type.
      call function 'GET_VRSD_ENTRY_46'
        exporting
          destination           = pi_logdest
          objname               = pi_objname
          objtype               = iobjtype
          versno                = versno
        importing
          vrsd_entry            = vrsd_entry
        exceptions
          no_entry_found        = 1
          system_failure        = 2
          communication_failure = 3.

      po_retcode = sy-subrc.

* Der Anzeigereport RSVRSTCO kann keine REPOs anzeigen
*    elseif pi_objtype = rept_type.
*      pi_objtype = repo_type.
*      call function 'GET_VRSD_ENTRY_40'
*         exporting
*              destination  = pi_logdest
*              objname      = pi_objname
*              objtype      = pi_objtype
*              versno       = versno
*         importing
*              vrsd_entry   = vrsd_entry
*         exceptions
*              no_entry_found        = 1
*              system_failure        = 2
*              communication_failure = 3.

*      po_retcode = sy-subrc.

    endif.
  endif.

endform.
*&---------------------------------------------------------------------*
*&      Form  GET_VERSION_DESCRIPTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PW_YABAP_CHECK_002  text
*----------------------------------------------------------------------*
form get_version_description  using    piw_yabap_check_002  type ty_yabap_check_002_mix.
  data:lw_e07t type e07t.
  if piw_yabap_check_002-dev_versno is not initial.
    select single as4text
      from e07t
      into piw_yabap_check_002-dev_as4text
     where trkorr eq piw_yabap_check_002-dev_versno.
    piw_yabap_check_002-dev_author = piw_yabap_check_002-dev-author.
  endif.

  if piw_yabap_check_002-qas_versno is not initial.
    select single as4text
      from e07t
      into piw_yabap_check_002-qas_as4text
     where trkorr eq piw_yabap_check_002-qas_versno.
    piw_yabap_check_002-qas_author = piw_yabap_check_002-qas-author.
  endif.

  if piw_yabap_check_002-prd_versno is not initial.
    select single as4text
      from e07t
      into piw_yabap_check_002-prd_as4text
     where trkorr eq piw_yabap_check_002-prd_versno.
    piw_yabap_check_002-prd_author = piw_yabap_check_002-prd-author.
  endif.
endform.                    " GET_VERSION_DESCRIPTION

form auto_compare_versions  using    piw_yabap_check_002  type ty_yabap_check_002_mix.
*代码参考SAPLSVRL / LSVRLF04
*FORM COMPARE_VERSIONS 与 	ZLOCAL_CL_SALV_BS_RUNTIME_INFO
**  这些版本的源没有区别。需要考虑多语言
*  data:lv_object like piw_yabap_check_002-objname,
*        ls_vrsd1 like piw_yabap_check_002-dev,
*        ls_vrsd2 like piw_yabap_check_002-qas,
*        lv_result like piw_yabap_check_002-DEV_QAS_COMPARE.


***  DEV_QAS_COMPARE
  if '对象在目标系统内不存在'(003) ne piw_yabap_check_002-dev_qas_compare.
    perform auto_compare_versions_sub using piw_yabap_check_002-objname piw_yabap_check_002-dev piw_yabap_check_002-qas changing piw_yabap_check_002-dev_qas_compare.
  endif.
***  DEV_PRD_COMPARE
  if '对象在目标系统内不存在'(003) ne piw_yabap_check_002-dev_prd_compare.
    perform auto_compare_versions_sub using piw_yabap_check_002-objname piw_yabap_check_002-dev piw_yabap_check_002-prd changing piw_yabap_check_002-dev_prd_compare.
  endif.
***  SUGGEST
  data:
    lv_string_no_diff type string,
    lv_string_no_exit type string.
  lv_string_no_diff = '这些版本的源没有区别。'(001).
  lv_string_no_exit = '对象在目标系统内不存在'(003).
  if piw_yabap_check_002-dev_qas_compare eq piw_yabap_check_002-dev_prd_compare and piw_yabap_check_002-dev_prd_compare eq lv_string_no_diff.
    piw_yabap_check_002-suggest = '放心修改。'(011).
  elseif piw_yabap_check_002-dev_qas_compare eq piw_yabap_check_002-dev_prd_compare and piw_yabap_check_002-dev_prd_compare eq   lv_string_no_exit.
    piw_yabap_check_002-suggest = '放心修改。'(011).
  elseif piw_yabap_check_002-dev_qas_compare eq  lv_string_no_diff and piw_yabap_check_002-dev_prd_compare eq   lv_string_no_exit.
    piw_yabap_check_002-suggest = '放心修改。'(011).
  else.
    piw_yabap_check_002-suggest = '请确认后再修改。'(012).
  endif.

endform.

form auto_compare_versions_sub  using pv_objname type  ty_yabap_check_002_mix-objname
                                  ps_vrsd1 type ty_yabap_check_002_mix-dev
                                  ps_vrsd2 type ty_yabap_check_002_mix-qas
                           changing pv_result type ty_yabap_check_002_mix-dev_qas_compare.

  check ps_vrsd2-korrnum is not initial.
  data: lt_sel_versions like vrsd occurs 0,
        lv_selnumber    type i,
        ls_vers_1       like vrsd,
        ls_vers_2       like vrsd,
        ls_infoline1a   like vrsinfolna,
        ls_infoline1b   like vrsinfolnb,
        ls_infoline2a   like vrsinfolna,
        ls_infoline2b   like vrsinfolnb,
        lv_objname1_l   like vrsd-objname,
        lv_objname2_l   like vrsd-objname.
***  DEV_QAS_COMPARE
  ls_infoline1a-objname =  	pv_objname.
  ls_infoline2a-objname =   pv_objname.

  move-corresponding  ps_vrsd1 to ls_infoline1b.
  move-corresponding  ps_vrsd1 to ls_vers_1.
  move-corresponding  ps_vrsd2 to ls_infoline2b.
  move-corresponding  ps_vrsd2 to ls_vers_2 .

  call function 'SVRS_SHORT2LONG_NAME'
    exporting
      objtype       = ls_vers_1-objtype
      objname_short = ls_vers_1-objname
    importing
      objname_long  = lv_objname1_l.

  call function 'SVRS_SHORT2LONG_NAME'
    exporting
      objtype       = ls_vers_2-objtype
      objname_short = ls_vers_2-objname
    importing
      objname_long  = lv_objname2_l.
  submit rsvrsrs3 and return
  with objname  = lv_objname1_l
  with objnam2  = lv_objname2_l
  with versno1  = ls_vers_1-versno
  with versno2  = ls_vers_2-versno
  with objtyp1  = ls_vers_1-objtype
  with objtyp2  = ls_vers_2-objtype
  with infoln1a = ls_infoline1a
  with infoln1b = ls_infoline1b
  with infoln2a = ls_infoline2a
  with infoln2b = ls_infoline2b
  exporting list to memory.
  data  begin of itab_list occurs 0.
          include structure abaplist.
  data  end of itab_list.
  data: begin of vlist occurs 0, "这个调用程序ALV输出的长度要根据实际长度来确认
          line type c length 300,
        end of vlist.
  call function 'LIST_FROM_MEMORY'
    tables
      listobject = itab_list
    exceptions
      not_found  = 4
      others     = 8.
  free memory .
  call function 'LIST_TO_ASCI'
    exporting
      list_index         = -1
    tables
      listasci           = vlist
      listobject         = itab_list
    exceptions
      empty_list         = 1
      list_index_invalid = 2
      others             = 3.
  if sy-subrc = 0 and vlist[] is not initial.
    describe table vlist[] lines data(lv_lines).
    read table vlist index lv_lines.
    pv_result =  vlist-line.
  endif.
endform.
*----------------------------------------------------------------------*
***INCLUDE ZXSEUF02.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  SHOW_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

****DEFINITION

class lcl_event_receiver definition.

  public section.
    methods:

      handle_double_click
                    for event double_click of cl_gui_alv_grid
        importing e_row e_column.

  private section.

endclass.

data: ok_code           like sy-ucomm,
      gt_sflight        type table of sflight,
      gt_sbook          type table of sbook,
      g_max             type i value 100,
      g_repid           like sy-repid,
      gs_layout         type lvc_s_layo,
      gt_fieldcat       type lvc_t_fcat with header line,
      cont_on_main      type scrfname value 'BCALVC_EVENT2_D100_C1',
      cont_on_dialog    type scrfname value 'BCALVC_EVENT2_D101_C1',
      grid1             type ref to cl_gui_alv_grid,
      grid2             type ref to cl_gui_alv_grid,
* references to custom container: neccessary to bind ALV Control
      custom_container1 type ref to cl_gui_custom_container,
      custom_container2 type ref to cl_gui_custom_container,
      event_receiver    type ref to lcl_event_receiver.
****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_event_receiver (Implementation)
*
* In this example, only event DOUBLE_CLICK is caught
*

class lcl_event_receiver implementation.

  method handle_double_click.
    data: ls_sflight like line of gt_sflight.

* § 4.The event DOUBLE_CLICK provides parameters for row and column
*   of the click. Use row parameter to select a line of the
*   corresponding internal table.

* read selected row from internal table gt_sflight
    read table gt_sflight index e_row-index into ls_sflight.

* § 5.Select data and call the second dynpro.

* select corresponding lines of table sbook
*    PERFORM select_table_sbook USING ls_sflight
*                               CHANGING gt_sbook.

* call dialog screen and display new alv control
    call screen 101 starting at 10 5.

  endmethod.                           "handle_double_click

endclass.

module pbo_0101 output.

* § 6.The first time dynpro 101 is called:
*   Create a second ALV Control for table SBOOK. This example
*   uses default lifetime (IMode), i.e, although you leave dynpro 101
*   the Control is still alive. This makes sense if it is expected
*   that the user wants to see different selections of table SBOOK
*   (the controls needs only be created once).
  set pf-status 'STANDARD'.
  if custom_container2 is initial.
* (the data from sbook is already selected)

* create a custom container control for our ALV Control
    create object custom_container2
      exporting
        container_name              = cont_on_dialog
      exceptions
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.
    if sy-subrc ne 0.
* add your handling, for example
      call function 'POPUP_TO_INFORM'
        exporting
          titel = g_repid
          txt2  = sy-subrc
          txt1  = 'The control could not be created'(510).
    endif.
* create an instance of alv control
    create object grid2
      exporting
        i_parent = custom_container2.
*
* change title
*
    gs_layout-grid_title = '对象版本差异提示'(101).
    gs_layout-cwidth_opt = abap_true.
*
* adjust field catalog
* to suppress the output of already displayed key fields of sflight
*
    perform mask_columns tables gt_fieldcat.

    call method grid2->set_table_for_first_display
      exporting
        is_layout       = gs_layout
      changing
        it_fieldcatalog = gt_fieldcat[]
        it_outtab       = lt_yabap_check_002[].

  else.
* § 7.The next time dynpro 101 is called you use method
*     'refresh_table_display' to display newly selected data
*     in the instance of ALV Control that 'belongs' to dynpro 101.
    call method grid2->set_frontend_fieldcatalog exporting it_fieldcatalog = gt_fieldcat[].
    call method grid2->set_frontend_layout exporting is_layout = gs_layout.
    call method grid2->refresh_table_display.

  endif.                               "IF grid2 IS INITIAL.


  call method cl_gui_control=>set_focus exporting control = grid2.
  call method cl_gui_cfw=>flush.

*  CREATE OBJECT event_receiver.
*  SET HANDLER event_receiver->handle_double_click FOR grid2.

  if sy-subrc ne 0.
* add your handling, for example
    call function 'POPUP_TO_INFORM'
      exporting
        titel = g_repid
        txt2  = sy-subrc
        txt1  = 'Error in FLush'(500).
  endif.

endmodule.                             " PBO_0101  OUTPUT
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
form mask_columns tables p_gt_fieldcat type lvc_t_fcat.


* Build the fieldcat according to DDIC structure SBOOK:
  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = 'YABAP_CHECK_002'
    changing
      ct_fieldcat      = p_gt_fieldcat[].

* suppress key fields CARRID, CONNID and FLDATE
*  LOOP AT p_gt_fieldcat.
*    IF p_gt_fieldcat-fieldname = 'CARRID'
*     OR p_gt_fieldcat-fieldname = 'CONNID'
*     OR p_gt_fieldcat-fieldname = 'FLDATE'.
*      p_gt_fieldcat-key_sel = 'X'.
*      p_gt_fieldcat-no_out = 'X'.
*      MODIFY p_gt_fieldcat.
** set left alignment for the two key fields left...
*    ELSEIF p_gt_fieldcat-fieldname = 'BOOKID'
*          OR p_gt_fieldcat-fieldname = 'CUSTOMID'.
*      p_gt_fieldcat-just = 'L'.
*      MODIFY p_gt_fieldcat.
*    ENDIF.
*  ENDLOOP.

endform.                               " MASK_COLUMNS
module pai_0101 input.
*  break jordan.
  case ok_code.
    when 'RETURN' or 'WB_BACK' or 'WB_END' or 'WB_CANCEL' or 'BACK' or 'RW' or '%EX'.
      perform skip_today using ok_code.
      perform leave_screen_101.
    when 'DEV2QAS'.
**  需要检查两个版本得有效比如生产的版本如果在本地不存在的情况下提示需要远程比较
      perform compare_versions using ok_code .

    when 'DEV2PRD'.
**  需要检查两个版本得有效比如生产的版本如果在本地不存在的情况下提示需要远程比较
      perform compare_versions using ok_code.
    when 'QAS2PRD'.
**  需要检查两个版本得有效比如生产的版本如果在本地不存在的情况下提示需要远程比较
      perform compare_versions using ok_code.
    when 'SKIP_TODAY'.
      perform skip_today using ok_code.
      perform leave_screen_101.
  endcase.
  clear ok_code.
endmodule.
" SELECT_TABLE_SBOOK

" SELECT_TABLE_SFLIGHT
form show_alv  .

  check lt_yabap_check_002[] is not initial.
* call dialog screen and display new alv control
  call screen 101
*  STARTING AT 10 20
  .
endform.                    " SHOW_ALV
*----------------------------------------------------------------------*
***INCLUDE ZXSEUF03.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  COMPARE_VERSIONS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form compare_versions  using ok_code like sy-ucomm .
  data:
    lt_sel_versions like vrsd occurs 0,
    lv_selnumber    type i,
    ls_vers_1       like vrsd,
    ls_vers_2       like vrsd,
    ls_infoline1a   like vrsinfolna,
    ls_infoline1b   like vrsinfolnb,
    ls_infoline2a   like vrsinfolna,
    ls_infoline2b   like vrsinfolnb,
    lv_objname1_l   like vrsd-objname,
    lv_objname2_l   like vrsd-objname.
  lv_selnumber = 2.
***这里是从屏幕上面勾选的两条并显示代码差异,我们这里不需要选的这段逻辑
*  PERFORM check_vers_selection TABLES lt_sel_versions
*                                 CHANGING lv_selnumber
*                                          ls_infoline1a
*                                          ls_infoline1b
*                                          ls_infoline2a
*                                          ls_infoline2b.
  check grid2 is not initial.
  data :lv_index_rows type lvc_t_row,
        lv_row_no     type lvc_t_roid.
  call method grid2->get_selected_rows
    importing
      et_index_rows = lv_index_rows
      et_row_no     = lv_row_no.
  if lv_row_no[] is initial.
* add your handling, for example
    call function 'POPUP_TO_INFORM'
      exporting
        titel = g_repid
        txt2  = sy-subrc
        txt1  = '比较时需要选中清单中任意一条'(500).
    exit.
  endif.
  break jordan.

  data:ls_row_no type lvc_s_roid.
  read table lv_row_no index 1  into ls_row_no.
  check sy-subrc is initial.

  data:lw_sel_versions type vrsd.

  data:lw_yabap_check_002 like line of lt_yabap_check_002[].
  check lt_yabap_check_002[] is not initial.
  read table lt_yabap_check_002[] index ls_row_no-row_id into lw_yabap_check_002.
  check sy-subrc is initial.
  data:lv_korrnum_is_not_initail type bool.
  case ok_code.
    when 'DEV2QAS'.
      perform check_korrnum_is_not_initail using lw_yabap_check_002-dev-korrnum lw_yabap_check_002-qas-korrnum changing lv_korrnum_is_not_initail.
      if lv_korrnum_is_not_initail eq abap_true.
        exit.
      endif.
      lw_sel_versions = lw_yabap_check_002-dev .
      ls_infoline1a-objname = lw_yabap_check_002-dev-objname.
      ls_infoline1b-korrnum = lw_yabap_check_002-dev-korrnum.
      ls_infoline1b-author  = lw_yabap_check_002-dev-author.
      ls_infoline1b-datum = lw_yabap_check_002-dev-datum.
      append lw_sel_versions  to lt_sel_versions.
      ls_infoline2a-objname = lw_yabap_check_002-qas-objname.
      ls_infoline2b-korrnum = lw_yabap_check_002-qas-korrnum.
      ls_infoline2b-author  = lw_yabap_check_002-qas-author.
      ls_infoline2b-datum = lw_yabap_check_002-qas-datum.
      lw_sel_versions = lw_yabap_check_002-qas .
      append lw_sel_versions  to lt_sel_versions.
    when 'DEV2PRD'.
      perform check_korrnum_is_not_initail using lw_yabap_check_002-dev-korrnum lw_yabap_check_002-prd-korrnum changing lv_korrnum_is_not_initail.
      if lv_korrnum_is_not_initail eq abap_true.
        exit.
      endif.
      lw_sel_versions = lw_yabap_check_002-dev .
      ls_infoline1a-objname = lw_yabap_check_002-dev-objname.
      ls_infoline1b-korrnum = lw_yabap_check_002-dev-korrnum.
      ls_infoline1b-author  = lw_yabap_check_002-dev-author.
      ls_infoline1b-datum = lw_yabap_check_002-dev-datum.
      append lw_sel_versions  to lt_sel_versions.
      lw_sel_versions = lw_yabap_check_002-prd .
      ls_infoline2a-objname = lw_yabap_check_002-prd-objname.
      ls_infoline2b-korrnum = lw_yabap_check_002-prd-korrnum.
      ls_infoline2b-author  = lw_yabap_check_002-prd-author.
      ls_infoline2b-datum = lw_yabap_check_002-prd-datum.
      append lw_sel_versions  to lt_sel_versions.
    when 'QAS2PRD'.
      perform check_korrnum_is_not_initail using lw_yabap_check_002-qas-korrnum lw_yabap_check_002-prd-korrnum changing lv_korrnum_is_not_initail.
      if lv_korrnum_is_not_initail eq abap_true.
        exit.
      endif.
      lw_sel_versions = lw_yabap_check_002-qas .
      ls_infoline1a-objname = lw_yabap_check_002-qas-objname.
      ls_infoline1b-korrnum = lw_yabap_check_002-qas-korrnum.
      ls_infoline1b-author  = lw_yabap_check_002-qas-author.
      ls_infoline1b-datum = lw_yabap_check_002-qas-datum.
      append lw_sel_versions  to lt_sel_versions.
      ls_infoline2a-objname = lw_yabap_check_002-prd-objname.
      ls_infoline2b-korrnum = lw_yabap_check_002-prd-korrnum.
      ls_infoline2b-author  = lw_yabap_check_002-prd-author.
      ls_infoline2b-datum = lw_yabap_check_002-prd-datum.
      lw_sel_versions = lw_yabap_check_002-prd .
      append lw_sel_versions  to lt_sel_versions.
    when others.
      exit.
  endcase.

  case lv_selnumber.
    when 0.
*      MESSAGE e102.                    "Bitte eine Version auswählen
    when 2.
      read table lt_sel_versions index 1 into ls_vers_1.
      read table lt_sel_versions index 2 into ls_vers_2.
      call function 'SVRS_SHORT2LONG_NAME'
        exporting
          objtype       = ls_vers_1-objtype
          objname_short = ls_vers_1-objname
        importing
          objname_long  = lv_objname1_l.

      call function 'SVRS_SHORT2LONG_NAME'
        exporting
          objtype       = ls_vers_2-objtype
          objname_short = ls_vers_2-objname
        importing
          objname_long  = lv_objname2_l.
      dir_f5_report = 'RSVRSRS3'.
*     compare report
      submit (dir_f5_report) and return
        with objname  = lv_objname1_l
        with objnam2  = lv_objname2_l
        with versno1  = ls_vers_1-versno
        with versno2  = ls_vers_2-versno
        with objtyp1  = ls_vers_1-objtype
        with objtyp2  = ls_vers_2-objtype
        with infoln1a = ls_infoline1a
        with infoln1b = ls_infoline1b
        with infoln2a = ls_infoline2a
        with infoln2b = ls_infoline2b.
    when others.
*      MESSAGE e103.
      "Bitte nur zwei Versionen miteinander vergleichen
  endcase.
  break jordan.
endform.                    " COMPARE_VERSIONS


*---------------------------------------------------------------------*
*       FORM CHECK_VERS_SELECTION_NEW                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  PT_SEL_REQUESTS                                               *
*  -->  PO_SEL_NUMBER                                                 *
*  -->  PS_VERS_1                                                     *
*  -->  PS_VERS_2                                                     *
*  -->  PS_INFOLINE1A                                                 *
*  -->  PS_INFOLINE1B                                                 *
*  -->  PS_INFOLINE2A                                                 *
*  -->  PS_INFOLINE2B                                                 *
*---------------------------------------------------------------------*
form check_vers_selection tables pt_sel_versions structure vrsd
                              changing po_sel_number
                                       ps_infoline1a like vrsinfolna
                                       ps_infoline1b like vrsinfolnb
                                       ps_infoline2a like vrsinfolna
                                       ps_infoline2b like vrsinfolnb.
************************************************************************
* FUNKTION:
* Auswahl im Verzeichnis auswerten.
* Es werden die ausgewählten Versionen gelesen und in
* DIR_VERSNO_1 und DIR_VERSNO_2 abgelegt.
* PO_SEL_NUMBER gibt die Anzahl der ausgewählten Versionen an.
* PO_SEL_NUMBER = 3 falls mehr als zwei Versionen ausgewählt wurden.
************************************************************************
  data: ls_vrs_dir_vrs like vrs_dir_vrs,
        lv_markfield   like vrsdynpro-x.

  refresh pt_sel_versions.
  po_sel_number = 0.

  do.
    clear: vrsdynpro-x, vrs_dir_vrs.
    read line sy-index field value vrsdynpro-x.
    ls_vrs_dir_vrs = vrs_dir_vrs.
    lv_markfield = vrsdynpro-x.
    clear: vrs_dir_vrs, vrsdynpro-x.

    if sy-subrc <> 0.
*     end of list reached
      exit.
    endif.

    if ( lv_markfield = 'x' ) or ( lv_markfield = 'X' ).
*     marked lie found
*     store request number
      append ls_vrs_dir_vrs to pt_sel_versions.
      po_sel_number = po_sel_number + 1.
      if po_sel_number = 1.

*       neues make_info_line
        perform make_info_line_new
          using ls_vrs_dir_vrs-objname ls_vrs_dir_vrs-korrnum
                ls_vrs_dir_vrs-datum   ls_vrs_dir_vrs-author
          changing ps_infoline1a
                   ps_infoline1b.

      elseif po_sel_number = 2.

*       neues make_info_line
        perform make_info_line_new
          using ls_vrs_dir_vrs-objname ls_vrs_dir_vrs-korrnum
                ls_vrs_dir_vrs-datum   ls_vrs_dir_vrs-author
          changing ps_infoline2a
                   ps_infoline2b.

      endif.
    endif.
  enddo.

endform.
*---------------------------------------------------------------------*
*       FORM SELECT_OBJECT                                            *
*&---------------------------------------------------------------------*
*&      Form  CHECK_KORRNUM_IS_NOT_INITAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LW_YABAP_CHECK_002_DEV_KORRNUM  text
*      -->P_LW_YABAP_CHECK_002_QAS_KORRNUM  text
*----------------------------------------------------------------------*
form check_korrnum_is_not_initail  using    p_korrnum_left type verskorrno
                                            p_korrnum_right type verskorrno
                                     changing pv_korrnum_is_not_initail type bool.
  if p_korrnum_left is initial or p_korrnum_right is initial.
    call function 'POPUP_TO_INFORM'
      exporting
        titel = g_repid
        txt2  = sy-subrc
        txt1  = '比较的版本不允许为空'(501).
    pv_korrnum_is_not_initail = abap_true.
  endif.


endform.                    " CHECK_KORRNUM_IS_NOT_INITAIL
*&---------------------------------------------------------------------*
*&      Form  SKIP_TODAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_OK_CODE  text
*----------------------------------------------------------------------*
form skip_today  using    p_ok_code.
  data ls_yabap_check_001 type yabap_check_001.
  ls_yabap_check_001-bname = sy-uname.
  ls_yabap_check_001-datum = sy-datum.
  ls_yabap_check_001-object = gv_object.
  ls_yabap_check_001-objname = gv_objectname.
  if  p_ok_code = 'SKIP_TODAY'.
    ls_yabap_check_001-disregard = abap_true.
  endif.
  modify yabap_check_001 from ls_yabap_check_001.

endform.                    " SKIP_TODAY
*&---------------------------------------------------------------------*
*&      Form  LEAVE_SCREEN_101
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form leave_screen_101 .
  if grid2 is not initial.
*        CALL METHOD grid2->free.
    clear lt_yabap_check_002[].
  endif.
  leave to screen 0.
endform.                    " LEAVE_SCREEN_101

注意 这两个变量依各公司中的配置而定。具体看tmsmconf这个表中的配置
dir_destination_qas = ‘TMSADM@QA1.DOMAIN_DEV’.
dir_destination_prd = ‘TMSADM@TPV.DOMAIN_DEV’.
还有问题请留言

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6