Giter VIP home page Giter VIP logo

anytabupdatetask's Introduction

AnyTabUpdateTask

Utility for DataBase Changes in Update Task

Utility is for avoiding creation additional function modules and table types for stable and fast code-writing.

Main functionality is in package ZC8A_005.
Demo-report is in addtional sub-package ZC8A_005_DEMO which is in separate folder(https://github.com/OlegBash599/AnyTabUpdateTask/tree/main/src/zc8a_005_demo) in this repository.


Simple Example for MODIFY table using this utility:

    DATA lc_db_tab_sample TYPE tabname VALUE 'ZTC8A005_SAMPLE'.
    DATA lt_sample_tab TYPE STANDARD TABLE OF ztc8a005_sample.

    lt_sample_tab = VALUE #(
        ( entity_guid = 'ANY_SIMPL_GUID_MOD' entity_param1 = 'CHAR10' entity_param2 = '0504030201' )
        ( entity_guid = 'ANY_SIMPL_GUID2_MOD' entity_param1 = '2CHAR10' entity_param2 = '0102030405'  )
        ( entity_guid = 'ANY_SIMPL_GUID2_DEL' entity_param1 = '2CHAR10' entity_param2 = '777909034' )
        ).

    NEW zcl_c8a005_save2db(
      )->save2db( iv_tabname = lc_db_tab_sample
                  it_tab_content = lt_sample_tab )->do_commit_if_any( ).

Without this utlity it could be like that (with creation of additional objects)

Show update by function (without the utility AnyTabUpdateTask)
    DATA lt_sample_tab TYPE STANDARD TABLE OF ztc8a005_sample.

    lt_sample_tab = VALUE #(
        ( entity_guid = 'ANY_SIMPL_GUID_MOD' entity_param1 = 'CHAR10' entity_param2 = '0504030201' )
        ( entity_guid = 'ANY_SIMPL_GUID2_MOD' entity_param1 = '2CHAR10' entity_param2 = '0102030405'  )
        ( entity_guid = 'ANY_SIMPL_GUID2_DEL' entity_param1 = '2CHAR10' entity_param2 = '777909034' )
        ).

    CALL FUNCTION 'Z_C8A_005_DEMO_UPD_SAMPLE'
      IN UPDATE TASK
      EXPORTING
        it_sample = lt_sample_tab.
  
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = abap_true.
  

Example for several tables

Utility AnyTabUpdateTask for several Tables
    DATA lc_db_tab_sample TYPE tabname VALUE 'ZTC8A005_SAMPLE'.
    DATA lt_sample_tab TYPE STANDARD TABLE OF ztc8a005_sample.
    DATA lt_sample_empty_tab TYPE STANDARD TABLE OF ztc8a005_sample.
    DATA lt_head_tab TYPE STANDARD TABLE OF ztc8a005_head.
    DATA lt_item_tab TYPE STANDARD TABLE OF ztc8a005_item.
    DATA lv_ts TYPE timestamp.
    DATA lo_saver_anytab TYPE REF TO zcl_c8a005_save2db.

    GET TIME STAMP FIELD lv_ts.

    lt_sample_tab = VALUE #(
        ( entity_guid = 'ANY_GUID_MOD' entity_param1 = 'CHAR10' entity_param2 = '0504030201'
            entity_param3 = sy-uzeit entity_param4 = sy-datum entity_param5 = lv_ts )
        ( entity_guid = 'ANY_GUID2_MOD' entity_param1 = '2CHAR10' entity_param2 = '0102030405'
          entity_param3 = sy-uzeit entity_param4 = sy-datum entity_param5 = lv_ts )
        ( entity_guid = 'ANY_GUID2_DEL' entity_param1 = '2CHAR10' entity_param2 = '777909034'
          entity_param3 = sy-uzeit entity_param4 = sy-datum entity_param5 = lv_ts )
        ).

    lt_head_tab = VALUE #(
        ( head_guid = 'ANY_GUID_UPD' head_param1 = 'ANY_GUID_ADD' head_param2 = '9988776655'
            head_param3 = sy-uzeit head_param4 = sy-datum head_param5 = lv_ts )
        ( head_guid = 'ANY_GUID2_UPD' head_param1 = 'ANY_GUID2_ADD' head_param2 = '9988776655'
            head_param3 = sy-uzeit head_param4 = sy-datum head_param5 = lv_ts )
        ( head_guid = 'ANY_GUID_DEL' head_param1 = 'ANY_GUID_ADD' head_param2 = '9988774444'
            head_param3 = sy-uzeit head_param4 = sy-datum head_param5 = lv_ts )
        ( head_guid = 'ANY_GUID2_DEL' head_param1 = 'ANY_GUID2_ADD' head_param2 = '9988774444'
            head_param3 = sy-uzeit head_param4 = sy-datum head_param5 = lv_ts )
     ).

    lt_item_tab = VALUE #(
        ( head_guid = 'ANY_GUID_UPD' item_guid = 'ANY_ITEM_GUID_ADD' item_param1 = '2CHAR10' item_param2 = '9988776655'
            item_param3 = sy-uzeit item_param4 = sy-datum item_param5 = lv_ts )
        ( head_guid = 'ANY_GUID2_UPD' item_guid = 'ANY_ITEM_GUID2_ADD' item_param1 = '2CHAR10'
            item_param3 = sy-uzeit item_param4 = sy-datum item_param5 = lv_ts )
        ( head_guid = 'ANY_GUID_DEL' item_guid = 'ANY_ITEM_GUID_ADD' item_param2 = '9988776655'
            item_param3 = sy-uzeit item_param4 = sy-datum item_param5 = lv_ts )
        ( head_guid = 'ANY_GUID2_DEL' item_guid = 'ANY_ITEM_GUID2_ADD' item_param1 = '2CHAR10'
            item_param3 = sy-uzeit item_param4 = sy-datum item_param5 = lv_ts )
    ).


    CREATE OBJECT lo_saver_anytab.
    lo_saver_anytab->save2db( EXPORTING iv_tabname     = lc_db_tab_sample
                                        it_tab_content = lt_sample_tab ).

    lo_saver_anytab->save2db( EXPORTING iv_tabname     = 'ZTC8A005_HEAD'
                                        it_tab_content = lt_head_tab ).

    lo_saver_anytab->save2db( EXPORTING iv_tabname     = 'ZTC8A005_ITEM'
                                        it_tab_content = lt_item_tab ).

    CLEAR lt_sample_empty_tab.
    lo_saver_anytab->save2db( EXPORTING iv_tabname     = lc_db_tab_sample
                                        it_tab_content = lt_sample_empty_tab ).


    " #RU:обновление всех таблиц будет одномоментно после commit
    " #EN:database changes are to be after commit-command
    " #RU:а по пустой таблицы ничего происходить не будет (не будет поставлен Update Task)
    " #EN: empty table does not take into account while commit command
    lo_saver_anytab->do_commit_if_any( ).
  

Option not to pass table name
    DATA lt_sample_tab TYPE STANDARD TABLE OF ztc8a005_sample.

    lt_sample_tab = VALUE #(
        ( entity_guid = 'ANY_SIMPL_GUID_MOD' entity_param1 = 'CHAR10' entity_param2 = '0504030201' )
        ( entity_guid = 'ANY_SIMPL_GUID2_MOD' entity_param1 = '2CHAR10' entity_param2 = '0102030405'  )
        ( entity_guid = 'ANY_SIMPL_GUID2_DEL' entity_param1 = '2CHAR10' entity_param2 = '777909034' )
        ).

    CREATE OBJECT lo_saver_anytab.
    lo_saver_anytab->save2db( EXPORTING it_tab_content = lt_sample_tab )->do_commit_if_any( ).

for the sake of fast debugging and tracing ControlGorup is added ZC8A005_CONTROL. So it is possible to switch on and off ControlGroup via tcode SAAB.


Additional examples and descriptions are on https://olegbash.ru/anytabupdatetask


The blog about the utility with commens is on https://blogs.sap.com/2022/08/21/database-update-with-utility-anytab-updatetask/


The well-structured educational and library source SAPLAND.ru: https://sappro.sapland.ru/kb/articles/stats/konsistentnoe-obnovlenie-bazi-dannih-pri-pomoschi-phunktsionala-any-tab-update-t.html


In Russian you can add your comments here: The Old-Merry SAPFORUM: https://sapboard.ru/forum/viewtopic.php?f=13&t=100324


HABR-blog https://habr.com/ru/articles/787282/

anytabupdatetask's People

Contributors

olegbash599 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

anytabupdatetask's Issues

ZC8A_005: Option not to pass table name in parameters, but only data

https://blogs.sap.com/2022/08/21/database-update-with-utility-anytab-updatetask/comment-page-1/#comment-635980
The need to pass the tablename as a parameter along with the data. It's not good to make ABAPers care about a type name during both the declaration and runtime. You can get rid of it, though, using RTTI to get the table name out of the type of passed data making only nessessary that there always should be a type directly connected with DB table name.

Target Solution proposed: provide option not to pass tablename in parameters. In case it is impossible to find target table - raise exception.

ZC8A_005: more user friendly tooling than existed SM13 for update queue

src
All data is being updated through one FM. All you see now in the update queue is a bunch of similar calls that is hard to analyse without drilling down through the parameters

The issue is outside the core of the project.
Tooling is in scope of standard SAP NetWeaver Team.
For now it is working as it is: it is necessary drill down into each line in SM13. Actually for mostly others function it is also necessary to drill down.

ZC8A_005: option transfer data by binary not by json

https://blogs.sap.com/2022/08/21/database-update-with-utility-anytab-updatetask/comment-page-1/#comment-636096

test: report https://gist.github.com/alezhu/f76e7427e8a44e6bd06912296bf69cc1

_I think your's solution will be useful sometimes. A similar idea is used in BOBF, where the FM '/BOBF/CL_DAC_UPDATE' is used to update node tables. But it uses xstring type to transfer data, which is obtained when exporting internal tables to a data buffer (EXPORT ... to DATA BUFFER...). You are using JSON for this. It's much slower.

I wrote a test program that compares the speed of serialization/deserialization using export/import and using the code from your solution. Serialization/deserialization via JSON is about 50 times slower.

I think you could change the type from string(JSON) to xstring(DATA BUFFER) for parameter passed to update-FM with serialized data, without changing the main logic and you'll get increase perfomance (and descrease amount of data transferred)._

Solution proposed: give the option to change from json to binary format.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.