Application Development and Automation 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: 
Read only

Data fetch from live cache

Former Member
0 Likes
795

How can I retrieve data from live cache?This is in Demand Planning : SCM APO.

Please suggest ways.

Thanks & Regards,

Savitha

2 REPLIES 2
Read only

0 Likes
539

Hi.

Does anyone knows this? I would also know how to get data from LiveCache by ABAP coding.

Thanks,

BR, Jari Seppänen

Read only

Former Member
0 Likes
539

Hi,

some time ago I worked on SAP APO.

To read live cache, you first have to open a SIM session.

You can do this as shown in this function module:


FUNCTION ZS_SIMSESSION_GET.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_SIMID) TYPE  /SAPAPO/VRSIOID
*"  EXPORTING
*"     REFERENCE(EV_SIMSESSION) TYPE  /SAPAPO/OM_SIMSESSION
*"----------------------------------------------------------------------
CONSTANTS:
  lc_simsession_new       TYPE c LENGTH 1 VALUE 'N'.

DATA:
  lt_rc                   TYPE /sapapo/om_lc_rc_tab,
  lv_simsession           LIKE ev_simsession.

  IF NOT ev_simsession IS INITIAL.
    EXIT.
  ENDIF.

*--> create Simsession
  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      ev_guid_22 = lv_simsession.

*--> create transactional simulation
  CALL FUNCTION '/SAPAPO/TSIM_SIMULATION_CONTRL'
    EXPORTING
      iv_simversion            = iv_simid
      iv_simsession            = lv_simsession
      iv_simsession_method     = lc_simsession_new
      iv_perform_commit        = space
    IMPORTING
      et_rc                    = lt_rc
    EXCEPTIONS
      lc_connect_failed        = 1
      lc_com_error             = 2
      lc_appl_error            = 3
      multi_tasim_registration = 4.
  IF sy-subrc > 0.
    CLEAR ev_simsession.
*   error can be found in lt_rc
  ENDIF.

* return simsession
  ev_simsession = lv_simsession.

ENDFUNCTION.

Then you can access the live cache.

In this case we read an order (if I rememver correctly, it's a plan order):


DATA:
  lv_vrsioid                  TYPE /sapapo/vrsioid,
  lv_simsession           TYPE /sapapo/om_simsession.

* Get vrsioid
  CALL FUNCTION '/SAPAPO/DM_VRSIOEX_GET_VRSIOID'
    EXPORTING
      i_vrsioex_fld = '000'  "By default
    IMPORTING
      e_vrsioid_fld = lv_vrsioid
    EXCEPTIONS
      not_found     = 1
      OTHERS        = 2.

CALL FUNCTION 'ZS_SIMSESSION_GET'
      EXPORTING
        iv_simid      = iv_vrsioid
      IMPORTING
        ev_simsession = lv_simsession.

  CALL FUNCTION '/SAPAPO/RRP_LC_ORDER_GET_DATA'
    EXPORTING
      iv_order      = iv_orderid
      iv_simversion = iv_vrsioid
    IMPORTING
      et_outputs    = lt_outputs
      et_inputs     = lt_inputs.

If you change something in your simsession, you have to merge it back afterwards, so that your changes become effective.

You can do this like that:


* Merge simulation version (to commit order changes)
  CALL FUNCTION '/SAPAPO/TSIM_SIMULATION_CONTRL'
    EXPORTING
      iv_simversion                = lv_vrsioid
      iv_simsession                = lv_simsession
      iv_simsession_method         = 'M'
    EXCEPTIONS
      lc_connect_failed            = 1
      lc_com_error                 = 2
      lc_appl_error                = 3
      multi_tasim_registration     = 4
      target_deleted_saveas_failed = 5
      OTHERS                       = 6.

I hope this helps...