Skip to Content

How to refresh the cache after mass creation of release strategies for purchase requisition?

Dear SAP-Experts,

i have a small report, wich have to create mass release strategies for purchase requisition from a Excel file. My report works fine for all new release strategies (not allready existing in SAP). When a release strategy already exist in SAP, it will be overwritten with the release strategy from Excel file (the new release code will be addopted). The code is as follow.

REPORT ztof_rs.

TYPE-POOLS: truxs.

TYPES:
  BEGIN OF gty_relstrat,
    gruppe      TYPE frggr,
    strategie   TYPE frgsx,
    bezeichnung TYPE frgxt,
    code_1      TYPE frgco,
    code_2      TYPE frgco,
    code_3      TYPE frgco,
    code_4      TYPE frgco,
    code_5      TYPE frgco,
    code_6      TYPE frgco,
    code_7      TYPE frgco,
    code_8      TYPE frgco,
  END OF gty_relstrat.

DATA: lt_relstrat TYPE TABLE OF gty_relstrat,
      ls_relstrat TYPE gty_relstrat,
      lt_t16fv    TYPE TABLE OF t16fv,
      ls_t16fv    TYPE t16fv,
      lt_t16fk    TYPE TABLE OF t16fk,
      ls_t16fk    TYPE t16fk,
      lt_t16ft    TYPE TABLE OF t16ft,
      ls_t16ft    TYPE t16ft,
      lt_t16fs    TYPE TABLE OF t16fs,
      ls_t16fs    TYPE t16fs.

DATA: oerror           TYPE REF TO cx_root,
      lt_raw           TYPE truxs_t_text_data,
      lv_txterror      TYPE string,
      lv_txterror_long TYPE string,
      f_path           TYPE string.


DATA: lv_rc         TYPE i,
      lt_file_table TYPE filetable,
      ls_file_table LIKE LINE OF lt_file_table,
      lv_nr         TYPE i.



PARAMETERS lp_fname TYPE rlgrap-filename.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR lp_fname.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Datei auswählen'
      file_filter             = '*.XLS)|*.XLSX'
    CHANGING
      file_table              = lt_file_table
      rc                      = lv_rc
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.

  IF sy-subrc EQ 0.
    READ TABLE lt_file_table INTO ls_file_table INDEX 1.
    WRITE ls_file_table-filename TO lp_fname.
  ELSE.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.



START-OF-SELECTION.
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_line_header        = abap_true
      i_tab_raw_data       = lt_raw
      i_filename           = lp_fname
    TABLES
      i_tab_converted_data = lt_relstrat
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.


  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.





    TRY.
        LOOP AT lt_relstrat INTO ls_relstrat.
          DELETE FROM t16fs WHERE frggr = ls_relstrat-gruppe AND frgsx = ls_relstrat-strategie.
          DELETE FROM t16fk WHERE frggr = ls_relstrat-gruppe AND frgsx = ls_relstrat-strategie.
          DELETE FROM t16ft WHERE frggr = ls_relstrat-gruppe AND frgsx = ls_relstrat-strategie.
          DELETE FROM t16fv WHERE frggr = ls_relstrat-gruppe AND frgsx = ls_relstrat-strategie.
        ENDLOOP.
        COMMIT WORK.
      CATCH cx_sy_zerodivide INTO oerror.
        ROLLBACK WORK.
        lv_txterror_long = oerror->get_longtext( ).
        MESSAGE lv_txterror_long TYPE 'I'.
    ENDTRY.



    LOOP AT lt_relstrat INTO ls_relstrat.
      " Add dataset to lt_t16fs from excel file
      ls_t16fs-mandt = sy-mandt.
      ls_t16fs-frggr = ls_relstrat-gruppe.
      ls_t16fs-frgsx = ls_relstrat-strategie.
      ls_t16fs-frgc1 = ls_relstrat-code_1.
      ls_t16fs-frgc2 = ls_relstrat-code_2.
      ls_t16fs-frgc3 = ls_relstrat-code_3.
      ls_t16fs-frgc4 = ls_relstrat-code_4.
      ls_t16fs-frgc5 = ls_relstrat-code_5.
      ls_t16fs-frgc6 = ls_relstrat-code_6.
      ls_t16fs-frgc7 = ls_relstrat-code_7.
      ls_t16fs-frgc8 = ls_relstrat-code_8.
      APPEND ls_t16fs TO lt_t16fs.
      CLEAR ls_t16fs.



      " Add dataset to lt_t16ft from excel file
      ls_t16ft-mandt = sy-mandt.
      ls_t16ft-spras = sy-langu.
      ls_t16ft-frggr = ls_relstrat-gruppe.
      ls_t16ft-frgsx = ls_relstrat-strategie.
      ls_t16ft-frgxt = ls_relstrat-bezeichnung.
      APPEND ls_t16ft TO lt_t16ft.
      CLEAR ls_t16ft.



      " Add dataset to lt_t16fk from excel file
      IF ls_relstrat-code_1 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frgkx = 'G'.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        IF ls_relstrat-code_2 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.



      IF ls_relstrat-code_2 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        IF ls_relstrat-code_3 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.

      IF ls_relstrat-code_3 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        IF ls_relstrat-code_4 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.

      IF ls_relstrat-code_4 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        ls_t16fk-frga4 = 'X'.
        IF ls_relstrat-code_5 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.

      IF ls_relstrat-code_5 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        ls_t16fk-frga4 = 'X'.
        ls_t16fk-frga5 = 'X'.
        IF ls_relstrat-code_6 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.


      IF ls_relstrat-code_6 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        ls_t16fk-frga4 = 'X'.
        ls_t16fk-frga5 = 'X'.
        ls_t16fk-frga6 = 'X'.
        IF ls_relstrat-code_7 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.

      IF ls_relstrat-code_7 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        ls_t16fk-frga4 = 'X'.
        ls_t16fk-frga5 = 'X'.
        ls_t16fk-frga6 = 'X'.
        ls_t16fk-frga7 = 'X'.

        IF ls_relstrat-code_8 IS NOT INITIAL.
          ls_t16fk-frgkx = 'G'.
        ELSE.
          ls_t16fk-frgkx = 'F'.
        ENDIF.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.


      IF ls_relstrat-code_8 IS NOT INITIAL.
        ls_t16fk-mandt = sy-mandt.
        ls_t16fk-frggr = ls_relstrat-gruppe.
        ls_t16fk-frgsx = ls_relstrat-strategie.
        ls_t16fk-frga1 = 'X'.
        ls_t16fk-frga2 = 'X'.
        ls_t16fk-frga3 = 'X'.
        ls_t16fk-frga4 = 'X'.
        ls_t16fk-frga5 = 'X'.
        ls_t16fk-frga6 = 'X'.
        ls_t16fk-frga7 = 'X'.
        ls_t16fk-frga8 = 'X'.
        ls_t16fk-frgkx = 'F'.
        APPEND ls_t16fk TO lt_t16fk.
        CLEAR ls_t16fk.
      ENDIF.



      " Add dataset to dataset to lt_t16fv from excel file
      IF ls_relstrat-code_1 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_1.
        ls_t16fv-frga1 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.


      IF ls_relstrat-code_2 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_2.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_3 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_3.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_4 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_4.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = '+'.
        ls_t16fv-frga4 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_5 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_5.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = '+'.
        ls_t16fv-frga4 = '+'.
        ls_t16fv-frga5 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_6 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_6.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = '+'.
        ls_t16fv-frga4 = '+'.
        ls_t16fv-frga5 = '+'.
        ls_t16fv-frga6 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_7 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_7.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = '+'.
        ls_t16fv-frga4 = '+'.
        ls_t16fv-frga5 = '+'.
        ls_t16fv-frga6 = '+'.
        ls_t16fv-frga7 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.



      IF ls_relstrat-code_8 IS NOT INITIAL.
        ls_t16fv-mandt = sy-mandt.
        ls_t16fv-frggr = ls_relstrat-gruppe.
        ls_t16fv-frgsx = ls_relstrat-strategie.
        ls_t16fv-frgco = ls_relstrat-code_8.
        ls_t16fv-frga1 = '+'.
        ls_t16fv-frga2 = '+'.
        ls_t16fv-frga3 = '+'.
        ls_t16fv-frga4 = '+'.
        ls_t16fv-frga5 = '+'.
        ls_t16fv-frga6 = '+'.
        ls_t16fv-frga7 = '+'.
        ls_t16fv-frga8 = 'X'.
        APPEND ls_t16fv TO lt_t16fv.
        CLEAR ls_t16fv.
      ENDIF.

    ENDLOOP.

    TRY.


        INSERT t16fv FROM TABLE lt_t16fv.
        INSERT t16ft FROM TABLE lt_t16ft.
        INSERT t16fk FROM TABLE lt_t16fk.
        INSERT t16fs FROM TABLE lt_t16fs.
        COMMIT WORK.
        DESCRIBE TABLE lt_relstrat LINES lv_nr.
        IF lv_nr = 1.
          lv_txterror_long = 'Ein Datensatz wurde aus der Excel-Datei in Freigabestrategien übernommen'.
        ELSE.
          lv_txterror_long = lv_nr && ' Datensätze wurden aus Excel-Datei in Freigabestrategien übernommen'.
        ENDIF.
        MESSAGE lv_txterror_long TYPE 'I'.

      CATCH cx_sy_zerodivide INTO oerror.

        ROLLBACK WORK.
        lv_txterror_long = oerror->get_longtext( ).
        MESSAGE lv_txterror_long TYPE 'I'.

    ENDTRY.


  ENDIF.

But it appears a display problem. When I click on the "Release Statuses" button, the indicator within the release strategy drift from datasets of T16FK table .

When I log out form SAP and logon again, than disappear the display problem. The display problem is also resolved, when I logon without ending any other logons (see Figure below).

How can I solve the cache problem? Is there some OSS?

Kind regard

Emal

Add comment
10|10000 characters needed characters exceeded

  • If the values in the tables are correct, but other values are retrieved and shown to the user then SAP is probably taking these other values from the memory instead by reading the tables. With your logoff you actually delete this memory and with the logon SAP read the new values from the table.

    I had initially asked if you are on a HANA database, I did this because we have been notified about similar issues. Our basis team is working on that, so I have no solution. You also said you are on a different database, for which I can't give any solution at all, but it might be worth to talk with the basis admins about this issue.

  • Emal,

    To me the usage of word Cache in the query is misleading.

    Are the screens that you attached are from a Standard Prog ? If yes,then you have to debug and not get carried away by the word "Cache".

    K.Kiran.

  • Jürgen you have right. I have debugged and find out the different. The new logged in SAP-client has the correct value in internal table VOR in CHECK_CODE_SEQUENCE subroutine. But the old logged in SAP-client has the incorrect value.

    I think, the SAP should now search for solution. I post also the ABAP stack, maybe it will help.

  • Get RSS Feed

5 Answers

  • May 14 at 02:22 PM

    Emal,

    It looks like you have written a custom program to directly maintain the standard SAP tables t16fs t16fk t16ft t16fv. You use the delete and insert statements and do not make use of any SAP standard BAPIs, function modules or batch input techniques. It is understandable why SAP support have taken the stance they have.

    As for your problem is there no standard technique that you can use to achieve the same result? For example with use of an approved BAPI, function module, call transaction, batch input etc?

    Add comment
    10|10000 characters needed characters exceeded

  • May 04 at 04:24 PM

    are you on a HANA database?

    Add comment
    10|10000 characters needed characters exceeded

  • May 04 at 06:25 PM

    No, our SAP instances are on SYBASE release 16.0.02.04.

    Add comment
    10|10000 characters needed characters exceeded

  • May 14 at 01:33 PM

    Hello SAP-Experts,

    I create a OSS message to SAP Support Team.

    "Dear Sir or Madam,

    there is a display issue in MM module, which appears after mass creation of release strategies for purchase requisition (see https://answers.sap.com/questions/505034/how-to-refresh-the-cache-after-mass-creation-of-re.html?childToView=504350#comment-504350).

    Kind regards

    Emal Rahman"

    I got an answor from SAP.

    From SAP point of view this issue is a pure consulting issue which is out of SAP support scope, because the release settings are uploaded from my program.

    Now the question ist: How to update the memory after insertion of new datasets in database tables?

    Kind regards

    Add comment
    10|10000 characters needed characters exceeded

  • May 15 at 09:48 AM

    Hi Surbjeet,

    at the beginning I search for mass creation of release strategies for purchase requisition to find some standard FM or BAPI, but I found any. Do you know some FM or BAPI?

    Kind regards

    Add comment
    10|10000 characters needed characters exceeded

    • Emal,

      I have tried this myself and there seems to be an issue as you say. I have noticed that if you access Release Strategies thorough SE16 or SE16N on view V_T16FS then it works. Try running your code and then try viewing Release Statuses using SE16 or SE16N on view V_T16FS.

      Don't think it will help but take a look at note 2625086 - Error ME194 in a Release Strategy.