Skip to Content
0
Former Member
Jul 23, 2008 at 01:11 PM

Issue with Shared Objects

478 Views

Hi all,

I've a problem with a program working on Shared Objects technology.

We have a Job, scheduled in 18 parallelism, and each one writes into the SHM controlled by a SHMA Class.

At jobs ending, a program reads content from the area and sends an automatic e-mail with the results.

Everything works well if the writer program is executed on-line.

Otherwise, in background, seems that nothing is stored in the SHM.

Here's the code executed by the writer program:

FORM shared_memory_access  TABLES  it_fehler STRUCTURE rpfausg.

  DATA: errors_reference TYPE REF TO data.
  DATA: lx_pterl00       TYPE REF TO zcx_pterl00_collector.

  TRY.
* --> Get SHM Access
      CALL METHOD zcl_pterl00_collector_root=>build
        EXPORTING
          invocation_mode = cl_shm_area=>invocation_mode_explicit.
* --> It's ok?
      IF zcl_pterl00_collector_root=>area_exists EQ 'X'.
* --> Fill Data:
        GET REFERENCE OF it_fehler[] INTO errors_reference.
        CALL METHOD zcl_pterl00_collector_root=>fill_area_with_data
          EXPORTING
            error_messages_dref = errors_reference.
      ENDIF.
    CATCH zcx_pterl00_collector INTO lx_pterl00.
      MESSAGE lx_pterl00 TYPE 'S' DISPLAY LIKE 'E'. "Non-blocking -> JOBS
  ENDTRY.

ENDFORM.                    " SHARED_MEMORY_ACCESS

Here is the section from the class handling the attachment to the SHMA:

METHOD if_shm_build_instance~build.

  DATA: lx_collector TYPE REF TO zcx_pterl00_collector.

* --> Automatic building of instance:
  TRY.
      CALL METHOD get_handle_for_update( inst_name ).
    CATCH zcx_pterl00_collector INTO lx_collector.
      MESSAGE lx_collector TYPE 'X'.
    CATCH: cx_shm_no_active_version.
      TRY.
          CALL METHOD get_handle_for_write( inst_name ).
        CATCH zcx_pterl00_collector INTO lx_collector.
          MESSAGE lx_collector TYPE 'X'.
      ENDTRY.
    CATCH: cx_shm_inconsistent.
      zcl_pterl00_collector=>free_area( ).
      TRY.
          CALL METHOD get_handle_for_write( inst_name ).
        CATCH zcx_pterl00_collector INTO lx_collector.
          MESSAGE lx_collector TYPE 'X'.
      ENDTRY.
  ENDTRY.

ENDMETHOD.

I cannot explain why multiple jobs do not populate the area...