Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
antonsikidin
Participant
1,117

source code https://github.com/AntonSikidin/global_settings

Time-to-time constants appear in your code. Some time constants are less constant. They have different types for example date of feature start, rfc_dest to other system, and number of parallel tasks.

To maintain settings you have to create a table of 1 row or class for constant. Both this way has different costs to create settings, add settings, and change settings. Less is better.

img_01.png

And you have tens of tables of 1 row that replicate each other.

I have a solution that has the best part of both ways to maintain settings. Easy to create, easy to add, and easy to maintain. As a bonus, you can have documentation for settings like flag_25 type xfeld.

We can hold

  • single value
  • single structure
  • table of value
  • table of struct

to hold this different variable in one table I serialized them in JSON and saved them in the table of text255

to read settings:

  • select data
  • join string
  • deserialize

After installation navigate to screen #2

img_02.png

We need to adjust something

Make layout bigger

from

img_03.png

to
img_04.png

Change field size: Double click

img_05.png

Visible length 50

img_06.png

Double click

img_07.png

Visible length 15

img_09.png

Double click

img_10.png

Text “Is Table?”

img_11.png

Activate!

To describe your settings go to ZTR_GS_CONFIG (Global Settings Configuration).

First level – project name

img_12.png

Second-level variables of this project

  1. Name of variable/structure/table
  2. Short description
  3. Abap type. For data elements, this element must be used in a table or structure
  4. Sign that it is a table. You can’t use table type

img_13.png

The third level is a long description of what these settings are for, how they change program flow, and what possible value can hold

img_14.png

Changes save in transport requests.

To edit the value of settings go to ZTR_GS_EDITOR in each system( development, quality, production )

Enter the project name or search.

img_15.png

img_16.png

In the variable block list all settings of this project. You can view or change by clicking on the var name.

img_17.png

Long description in Description block.

img_18.png

img_19.png to view history.

img_20.png

use  img_21.png for navigation.

img_22.png

You can easily work with these settings in the program.

 

 

 

REPORT Z_TEST_NEW_SETTINGS.

DATA
      : lr_gs TYPE REF TO zcl_gs " settings object

*        variable to hold settings data
      , lv_data  TYPE datum
      , lv_struct TYPE SCARR
      , lt_table_of_date  TYPE TABLE OF datum
      , lt_table_of_struct TYPE TABLE OF SCARR
      .

START-OF-SELECTION.
*create object
  lr_gs  = NEW zcl_gs( 'FIRST_PROJECT' ).

*read settings
  lr_gs->get_object( EXPORTING iv_var_name =  'DATE'
                     IMPORTING ev_data     =   lv_data ).

  lr_gs->get_object( EXPORTING iv_var_name =  'STRUCT'
                     IMPORTING ev_data     =   lv_struct ).

  lr_gs->get_object( EXPORTING iv_var_name =  'TABLE_OF_DATE'
                     IMPORTING ev_data     =   lt_table_of_date ).

  lr_gs->get_object( EXPORTING iv_var_name =  'TABLE_OF_STRUCT'
                     IMPORTING ev_data     =   lt_table_of_struct ).
*display
  cl_demo_output=>write( lv_data ).
  cl_demo_output=>write( lv_struct ).
  cl_demo_output=>write( lt_table_of_date ).
  cl_demo_output=>write( lt_table_of_struct ).

  cl_demo_output=>display( ).

 

 

 

 img_23.png

You cannot use a structure or table with includes with suffixes like this

img_24.png

2 Comments
shais
Participant

Interesting.

One improvement suggestion (I've already implemented once by myself):
A hybrid solution: Create a class automatically out of your parameters/settings table.

antonsikidin
Participant
0 Kudos

@shaisshow me your solution

Labels in this area