Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Check original language of repository objects when creating

jrgkraus
Active Contributor
495

In our company, repo objects must be created with original language EN. Is there a way to check the logon language in case of creating a new object in the ABAP repository?

Desired behaviour: SE80 - create program/class/data element/table/....

--> user exit/badi checks the logon language. When it is not 'EN', the creation will be refused.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
223

Although your requirement is fully justified, a user exit probably doesn't exist, so you'll be the first one to do a modification of the standard (enhancement framework). Almost every ABAP Workbench action is initiated through the CL_WB_REQUEST class, so you could do something around it. But you must be very careful with any modification in the ABAP workbench, you could put down the whole system if your code has a syntax error one day (installation of support package or upgrade, SAP note, etc.), so if you do anything at all, I advise you to take all possible precautions : dynamic linking of your modification to the code (call method ('CLASS')=>('NAME'))+ restriction of your modification to only the developers + assigning the modification to the + option to switch it off at any time (switch framework, reversible business function).

9 REPLIES 9

matt
Active Contributor
223

I don't think there is. You could however put a check at transport release time in an implementation of BADI CTS_REQUEST_CHECK.


jrgkraus
Active Contributor
223

At transport release would be too late for the objects are already created with the wrong language. But I already put a check at the creation of work bench requests. But one colleague has created placeholder requests with english logon and uses them instead of creating new ones....

Sandra_Rossi
Active Contributor
224

Although your requirement is fully justified, a user exit probably doesn't exist, so you'll be the first one to do a modification of the standard (enhancement framework). Almost every ABAP Workbench action is initiated through the CL_WB_REQUEST class, so you could do something around it. But you must be very careful with any modification in the ABAP workbench, you could put down the whole system if your code has a syntax error one day (installation of support package or upgrade, SAP note, etc.), so if you do anything at all, I advise you to take all possible precautions : dynamic linking of your modification to the code (call method ('CLASS')=>('NAME'))+ restriction of your modification to only the developers + assigning the modification to the + option to switch it off at any time (switch framework, reversible business function).

223
  data zz_lv_oper_failed type abap_bool.
    try.
        call method ('ZCL_DV07_WB_REQUEST_ENH')=>('OPERATION_NOT_VALID')
          exporting iv_operation = p_operation
          receiving rv_failed = zz_lv_oper_failed.
        if zz_lv_oper_failed = abap_true.
          message id sy-msgid type 'I' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
            display like 'E'.
          return.
        endif.
      catch CX_SY_DYN_CALL_ERROR.
        " do nothing.
    endtry.

This is what I implemented as an enhancement in two positions:

1. method constructor of CL_WB_REQUEST

2. FORM CREATE_PROGRAM of SAPLWBABAP (SE38 does not call CL_WB_REQUEST when creating a report)

both at the implicit enh point at the beginning

The class ZCL_DV07_WB_REQUEST_ENH reads an own DB table where workbench actions are flagged with "check logon language". Based on this settings, a check of sy-langu is being performed and in case of the wrong language, RV_FAILED is set to ABAP_TRUE.

Thanks for your help!

matt
Active Contributor
0 Kudos
223

Thanks for sharing your solution. 🙂

0 Kudos
223

Well done and thanks for the feedback 🙂

As I had a bad experience, I recommand again to have the minimal code inside the enhancement, only a CALL METHOD + CATCH cx_root. Do the MESSAGE inside your method.

Don't forget to limit to a subset of users.

Don't forget to assign your enhancement to a switchable package ("disaster-driven development" ;-))

223

Good suggestions. I now stripped it down to

  data zz_lv_oper_failed type abap_bool.
  try.
      call method ('ZCL_DV07_WB_REQUEST_ENH')=>('OPERATION_NOT_VALID')
        exporting iv_operation = 'CREATE'
        receiving rv_failed = zz_lv_oper_failed.
      if zz_lv_oper_failed = abap_true.
        return.
      endif.
    catch CX_SY_DYN_CALL_ERROR.
      " do nothing.
  endtry.<br>

The rest is done in the called method:

  method operation_not_valid.
      if so_dp is not bound.<br>        " create a static data provider that contains all SEU operations
        " with additional checks (stored in a customizing table)
        so_dp = new #( ).  " see data provider class
      endif.
      try.
          " get the action from the data provider
          data(ls_action) = so_dp->mt_settings[ id = iv_operation ].
        catch cx_sy_itab_line_not_found.
          " no checks for this action set - leave
          return.
      endtry.
      if ls_action-langu_check = abap_true.  " logon language check active
        if sy-langu <> 'E'.  " English is mandatory
          message i001(zm_dv07) display like 'E'. " show a message
          rv_failed = abap_true. " return the failed-flag
        endif.
      endif.
  endmethod.

*--------- the data provider class ------------------<br>class lcl_dp_settings definition final.
  public section.
    types gty_t_settings type standard table of zdb_dv07_001 with default key.
    data mt_settings type gty_t_settings.
    methods constructor.
endclass.

class lcl_dp_settings implementation.
  method constructor.
    select * from zdb_dv07_001
      into table @mt_settings.
  endmethod.
endclass.

*------------ the customizing table ZDB_DV07_001
|ID         |LANGU_CHECK |
+-----------+------------+
|CREANOEDIT |X           |
|CREATE     |X           |
|CREATE_CPT |X           |
|CREATE_DMD |X           |
|CREATE_OBJ |X           |
|CREATE_OP  |X           |
|CREATE_PRP |X           |
|CREATE_REF |X           |
|CREATE_REL |X           |
|CREATE_SOB |X           |
|EDIT       |X           |




Gilmour213
Explorer
0 Kudos
223

Hello Jörg,

we are facing the same problem especially when working with external Developers. So your solution sounds good, I can't see where you've implemented this coding and Method call.

Do you use an implicit Enhancement or are there any Userexits in the Class Sandra Rossi mentioned ?

Best regards

Mario

jrgkraus
Active Contributor
223

Yes, it's an implicit enhancement. I had to do it in two places:

- for SE38 when creating a new program: Include LWBABAPF00, at the beginning of FOMR create_program

FORM create_program.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form CREATE_PROGRAM, Start                                                                                                                        A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENH_DV07_SE38_CREATE.    "active version
*
  data zz_lv_oper_failed type abap_bool.
  try.
      call method ('ZCL_DV07_WB_REQUEST_ENH')=>('OPERATION_NOT_VALID')
        exporting iv_operation = 'CREATE'
        receiving rv_failed = zz_lv_oper_failed.
      if zz_lv_oper_failed = abap_true.
        return.
      endif.
    catch CX_SY_DYN_CALL_ERROR.
      " do nothing.
  endtry.


ENDENHANCEMENT.

- for SE80 in class CL_WB_REQUEST, beginning of method constructor

  METHOD constructor.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Class CL_WB_REQUEST, Method CONSTRUCTOR, Start                                                                                                    A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZENH_DV07_WB_REQUEST.    "active version
  data zz_lv_oper_failed type abap_bool.
  try.
      call method ('ZCL_DV07_WB_REQUEST_ENH')=>('OPERATION_NOT_VALID')
        exporting iv_operation = p_operation
        receiving rv_failed = zz_lv_oper_failed.
      if zz_lv_oper_failed = abap_true.
        return.
      endif.
    catch CX_SY_DYN_CALL_ERROR.
      " do nothing.
  endtry.


ENDENHANCEMENT.