Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/olegbash599/anytabupdatetask
Utility for DataBase Changes in Update Task
https://github.com/olegbash599/anytabupdatetask
Last synced: about 2 months ago
JSON representation
Utility for DataBase Changes in Update Task
- Host: GitHub
- URL: https://github.com/olegbash599/anytabupdatetask
- Owner: OlegBash599
- License: mpl-2.0
- Created: 2022-06-29T14:19:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T16:37:02.000Z (3 months ago)
- Last Synced: 2024-11-12T15:43:27.688Z (about 2 months ago)
- Language: ABAP
- Size: 157 KB
- Stars: 24
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/OlegBash599/AnyTabUpdateTask/tree/main/src/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:
```ABAP
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)
```ABAP
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
```ABAP
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
```ABAP
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/