如何以编程方式判断系统是 R/3 还是 S/4 [英] How to programmatically tell if system is R/3 or S/4

查看:27
本文介绍了如何以编程方式判断系统是 R/3 还是 S/4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过代码判断当前系统是R/3还是S/4?

Is it possible to determine via code if the current system is R/3 or S/4?

我需要它,因为我有一个方法可以返回人力资源相关数据的软件组件,但是这个组件应该与 R/3 和 S/4 系统不同.

I need it because I have a method that returns the software component of Human Resources related data, but this component should be different to R/3 and S/4 systems.

    DATA(lv_software_component) = mo_configuration->get_software_component( ).

    SELECT * FROM tadir INTO TABLE @DATA(lt_inftype_tables)
            WHERE pgmid  = 'R3TR'
              AND object = 'TABL'
              AND devclass IN ( SELECT devclass FROM tdevc
                                               WHERE dlvunit = @lv_software_component
                                                  OR dlvunit = 'SAP_HRGXX'
                                                  OR dlvunit = 'SAP_HRRXX' )

例如,在 R/3 上,lv_software_component 应该是 'SAP_HRCMX',而在 S/4 上,它应该是 'S4HCMCMX'.目前,我不知道如何以编程方式区分版本之间的差异.

On R/3, lv_software_component should be 'SAP_HRCMX', for example, while on S/4 it should be 'S4HCMCMX'. Currently, I have no idea on how to tell the difference between the releases, programmatically speaking.

我想出的最好的方法是硬编码 SY-SYSID,因为我知道哪些系统是 S/4,哪些不是,但这不应该是理想的.

The best I've come up with is hardcoding SY-SYSID, since I know which systems are S/4 and which aren't, but that shouldn't be ideal.

感谢您的帮助,谢谢!

推荐答案

您可以使用下面的类方法来确定它.另一方面, is_s4h 方法仅存在于 S4 系统上.您需要在调用之前检查方法退出.

You can use below class method for determining it. On the other hand is_s4h method only exists on S4 system. You need to check method exits before calling it.

cl_cos_utilities=>is_s4h( )

工作完整示例:

REPORT ZMKY_ISS4.
CLASS cl_oo_include_naming DEFINITION LOAD.

DATA oref TYPE REF TO if_oo_class_incl_naming.
DATA: lt_methods TYPE seop_methods_w_include,
      lv_clskey  TYPE seoclskey,
      ls_cpdkey  TYPE seocpdkey,
      lv_iss4    TYPE abap_bool,
      lt_params  TYPE abap_parmbind_tab.

lv_clskey = 'CL_COS_UTILITIES'.
oref ?= cl_oo_include_naming=>get_instance_by_cifkey( lv_clskey ).
lt_methods = oref->get_all_method_includes( ).
ls_cpdkey-clsname = lv_clskey.
ls_cpdkey-cpdname = 'IS_S4H'.
READ TABLE lt_methods WITH KEY cpdkey = ls_cpdkey TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
  lt_params = VALUE #( ( name  = 'RV_IS_S4H'
                  kind  = cl_abap_objectdescr=>returning
                  value = REF #( lv_iss4 ) ) ).
  CALL METHOD CL_COS_UTILITIES=>('IS_S4H')
    PARAMETER-TABLE
      lt_params.
ELSE.
  lv_iss4 = abap_false.
ENDIF.

这篇关于如何以编程方式判断系统是 R/3 还是 S/4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆