Thursday, March 20, 2014

SAP ABAP Shared memory objects tutorial

Hi Folks,
this is an advanced topic.
I was looking for a way to share data across application servers for parallel jobs (so many concurrent  read and write accesses)

At first it seemed that shared memory objects could do the trick: but then i read that they "live" only on an application server.
You can set them to get invalidated and synchronized from the database when data changes cross application server, so they basically act as a memory cache for DB data.

Not really what i need.

Anyway you find here a nice tutorial that explains the main concepts of abap shared objects.

ABAP Shared memory programming made easy

HTH
cheers

Tuesday, March 11, 2014

ABAP change PNP LDB select options behaviour SELECT_OPTIONS_RESTRICT



Hi Folks,
this time i needed to change a select option from the PNP logical data base.
Normally you can change things from the HR report class. But some things you cannot.
For example i want to select only one person in an Hr report with the PNP logical database.
I could have used no-interval if it were a select option defined by me in my program.
But it is defined in the PNP LDB so i cannot access its coding.

Luckily enough there is a function module called SELECT_OPTIONS_RESTRICT
that allow to change parameters and select options from both the LDB and the current program.
Here a coding example and below the result.

INITIALIZATION.

* Include des Typepools SSCR
  TYPE-POOLS sscr.
* define objects for restriction
  DATA restrict TYPE sscr_restrict.
* helpobject to fill restriction
  DATA opt_list TYPE sscr_opt_list.
  DATA ass TYPE sscr_ass.

* EQ: only EQ allowed
  CLEAR opt_list.
  MOVE 'ONLY_EQ' TO opt_list-name.
  MOVE 'X' TO: opt_list-options-eq.
  APPEND opt_list TO restrict-opt_list_tab.

* options you want to allow
  CLEAR ass.
  MOVE: 'S' TO ass-kind,
  'PNPPERNR' TO ass-name,
  'I'  TO ass-sg_main,
  'N'  TO ass-sg_addy, "removes the interval selections
  'ONLY_EQ' TO ass-op_main.
  APPEND ass TO restrict-ass_tab.

* Eingrenzung der möglichen Selektionsoptionen
  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
*     PROGRAM                =
      restriction            = restrict
*     DB                     = ' '
    EXCEPTIONS
      too_late               = 1
      repeated               = 2
      selopt_without_options = 3
      selopt_without_signs   = 4
      invalid_sign           = 5
      empty_option_list      = 6
      invalid_kind           = 7
      repeated_kind_a        = 8
      OTHERS                 = 9
    . " Punkt
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF. " sy-subrc <> 0 - CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'


And here the result.
 
 
Enjoy!