简体   繁体   English

在创建时检查存储库对象的原始语言?

[英]Check original language of repository objects at creation?

In our company, repository objects must be created with original language EN.在我们公司,存储库对象必须使用原始语言 EN 创建。 Is there a way to check the logon language in case of creating a new object in the ABAP repository?如果在 ABAP 存储库中创建新对象,是否可以检查登录语言?

Desired behaviour:期望的行为:

SE80 - Create program/class/data element/table/.... SE80 - 创建程序/类/数据元素/表/....

==> user exit/badi checks the logon language. ==> 用户出口/badi 检查登录语言。 When it is not 'EN', the creation will be refused.当它不是'EN'时,创建将被拒绝。

regards,问候,

Umar Abdullah奥马尔·阿卜杜拉

I know there is a exit for this but I haven't remember exact name.我知道有一个出口,但我不记得确切的名字。 You can use general purpose for finding exit.您可以使用通用来查找出口。 Go to SE24 and open CL_EXITHANDLER class, find GET_INSTANCE method and add break point.转到 SE24 并打开CL_EXITHANDLER类,找到GET_INSTANCE方法并添加断点。 Then start creating item, it will pause on debugger multiple times, try to find suitable one.然后开始创建项目,它会在调试器上暂停多次,尝试找到合适的项目。

As @mkysoft suggested, you may implement a check in the BAdI CTS_REQUEST_CHECK , method CHECK_BEFORE_ADD_OBJECTS , which is invoked when the object is about to be attached to a transport request. 正如@mkysoft 建议的那样,您可以在 BAdI CTS_REQUEST_CHECK方法 CHECK_BEFORE_ADD_OBJECTS 中实施检查,该方法在对象即将附加到传输请求时调用。 Raise the exception CANCEL to make the attachment fail (and so the object is not created too). 引发异常 CANCEL 以使附件失败(因此也不会创建对象)。

EDIT: sorry, ignore my answer, "this method is NOT released for Customer usage" as said in note 2150125 - Method CHECK_BEFORE_ADD_OBJECTS not triggered编辑:抱歉,请忽略我的回答,“此方法未发布供客户使用”,如注释 2150125 中所述- 未触发方法 CHECK_BEFORE_ADD_OBJECTS

DISCLAIMER: THE METHOD DESCRIBED HERE IS ABSOLUTELY NOT RECOMMENDED.免责声明:绝对不推荐此处描述的方法。

As correctly pointed out by the other members there is no standard and customer-exposed method to achieve your requirement, but if you absolutely must enable this check during creation you can use the below method.正如其他成员正确指出的那样,没有标准和客户公开的方法来满足您的要求,但如果您绝对必须在创建期间启用此检查,则可以使用以下方法。 As well as the previously offered to you, it also involves modification of SAP standard.除了之前提供给您的,它还涉及对 SAP 标准的修改。

There is a system BAdi CTS_TADIR_SUBSCREEN that is located inside enhancement point CTS_ES_TADIR_POPUP .有一个系统 BAdi CTS_TADIR_SUBSCREEN位于增强点CTS_ES_TADIR_POPUP They are SAP internal and not released for customer usage, so do this at your own risk.它们是 SAP 内部的,不供客户使用,因此请自行承担风险。

Implementation procedure:实施程序:

Step 0 .步骤 0 First thing you need to change is a SAP internal usage flag, for which you need Object Access key which can be obtained from SAP or from SAP partner that made the implementation in your org.您需要更改的第一件事是 SAP 内部使用标志,为此您需要对象访问密钥,该密钥可以从 SAP 或在您的组织中实施的 SAP 合作伙伴获得。 In virgin state this BAdi throws the error if you try to implement it在原始状态下,如果您尝试实现此 BAdi,则会抛出错误

在此处输入图片说明

So hereinafter we assume that you already ticked off this checkbox in BAdi settings所以在下文中我们假设您已经在 BAdi 设置中勾选了这个复选框

在此处输入图片说明

Step 1 .第 1 步

In order to implement the BAdi one need to implement enhancement spot prior to that.为了实施BAdi,需要在此之前实施增强点。 This is the most complicated part, because despite we disabled internality flag the SAP-namespaced enhancements must be stored only in SAP-namespaced objects.这是最复杂的部分,因为尽管我们禁用了内部性标志,但 SAP 命名空间增强功能必须仅存储在 SAP 命名空间对象中。 By SAP namespace I mean non-Z, non-Y and non-T (Test). SAP 命名空间是指非 Z、非 Y 和非 T(测试)。 This means to implement this enhancement, besides modifying the enhancement definition, one need to create, for example, CTS_ES_TADIR named enh.impl., and save it to non-Z package, which you also need to create.这意味着要实现这个增强,除了修改增强定义之外,还需要创建一个,例如名为enh.impl.的CTS_ES_TADIR,并保存到非Z包中,你也需要创建。 Your enhancement implementations selector should look somehow like this您的增强实现选择器应该看起来像这样

在此处输入图片说明

On the above screen only the second will work, all the rest Z will not.在上面的屏幕上,只有第二个会工作,其余的 Z 都不会。

Every non-Z object need Object Access Key, remember?每个非 Z 对象都需要对象访问密钥,还记得吗? Too bad.太糟糕了。 But just to show the proof-of-concept, I will proceed.但只是为了展示概念验证,我将继续。

Step 2 .第 2 步 After you created the enh.在你创建了 enh 之后。 implementation in SAP-namespace it will propose you to create the BAdi implementation. SAP 命名空间中的实现,它将建议您创建 BAdi 实现。 The same principle applies here: only SAP-namespaced container for SAP-namespaced objects, hence CTS_TADIR_SUBSCREEN should have implementing class for example CL_TADIR_SUBSCREEN .同样的原则在这里适用:只有 SAP 命名空间对象的 SAP 命名空间容器,因此CTS_TADIR_SUBSCREEN应该有实现类,例如CL_TADIR_SUBSCREEN During the creation of enhancement you will see many warnings在创建增强的过程中你会看到很多警告

在此处输入图片说明

but finally you should have something like this, where all system-named objects are created and the enhancement/BAdi is activated.但最后你应该有这样的东西,所有系统命名的对象都被创建,增强/BAdi被激活。

在此处输入图片说明

Step 3 .第 3 步 In order to get the BAdi working we need to enable this subscreen processing为了让 BAdi 工作,我们需要启用这个子屏幕处理

在此处输入图片说明

during the playing with enhancement I found out that BAdi class is not being triggered standalone, without screen events not enhanced, so to make it work you need to touch a screen enhancement for screen 100在玩增强的过程中,我发现 BAdi 类没有被独立触发,没有屏幕事件没有增强,所以为了让它工作,你需要触摸屏幕 100 的屏幕增强

在此处输入图片说明

If you do not wanna modify screen elements logic, just put the dummy enhancement in SHOW_TADIR dialog module in the end of the include LSTRDO18如果您不想修改屏幕元素逻辑,只需将SHOW_TADIR对话框模块中的虚拟增强放在包含LSTRDO18

PROCESS BEFORE OUTPUT.

MODULE SHOW_TADIR. "<-- create the dummy enhancement here
CALL SUBSCREEN subs_info INCLUDING gv_badi_prog gv_badi_dynnr.

for example declaration statement like I did例如像我一样的声明语句

在此处输入图片说明

Step 4 .第 4 步 Activate your created BAdi class and put the necessary logic there.激活您创建的 BAdi 类并将必要的逻辑放在那里。 I wasn't able to trigger method GET_DATA_FROM_SCREEN , but PUT_DATA_TO_SCREEN worked fine我无法触发方法GET_DATA_FROM_SCREEN ,但PUT_DATA_TO_SCREEN工作正常

在此处输入图片说明

If we put this simple processing for your requirement如果我们根据您的要求进行这种简单的处理

METHOD cts_if_tadir_subscreen~get_data_from_screen.

  IF object_data-l_mstlang <> 'E'.
    MESSAGE 'Objects in non-English languages are not allowed!' TYPE 'A'.
  ENDIF.

ENDMETHOD.

it will not allow creating objects in languages other than English.它不允许用英语以外的语言创建对象。

在此处输入图片说明

The check in method get_data_from_screen is being done before showing the screen so language is determined from system logon settings.签入方法get_data_from_screen在显示屏幕之前完成,因此语言是根据系统登录设置确定的。 If to play more with this BAdi, I suppose the method GET_DATA_FROM_SCREEN can also be enabled, which will make it possible to check user input, ie the case when the user gonna change the default language.如果要更多地玩这个 BAdi,我想也可以启用GET_DATA_FROM_SCREEN方法,这将使检查用户输入成为可能,即用户要更改默认语言的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM