Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zenrosadira/abap-tbox-random-data
Simple ABAP random data generator
https://github.com/zenrosadira/abap-tbox-random-data
abap abap-development abap-oo sap
Last synced: 3 days ago
JSON representation
Simple ABAP random data generator
- Host: GitHub
- URL: https://github.com/zenrosadira/abap-tbox-random-data
- Owner: zenrosadira
- Created: 2023-04-03T14:57:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-19T20:59:42.000Z (over 1 year ago)
- Last Synced: 2024-11-02T07:06:02.417Z (about 2 months ago)
- Topics: abap, abap-development, abap-oo, sap
- Language: ABAP
- Homepage:
- Size: 419 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ABAP Random Data Generator
![ex1](/img/ex1.jpg)
A utility class that simplifies the generation of random data and allows for quick population of variables (tables, structures, scalar data).
The data generated is devoid of meaning but is consistent with types domain: if fixed values are expected, one of these values will be randomly assigned; if a value table is assigned, values will be randomly chosen from it. Additionally, it is possible to configure ranges and value dimensions.It can be useful for preparing performance stress tests or managing test automation.
## Quick Start
```abap
* To generate a random table
DATA t_sflight TYPE TABLE OF sflight.
DATA(tab_rand) = ztbox_cl_rand=>table( ).
tab_rand->generate( IMPORTING table = t_sflight ).
* To generate a random structure
DATA s_sflight TYPE sflight.
DATA(str_rand) = ztbox_cl_rand=>struct( ).
str_rand->generate( IMPORTING struct = s_sflight ).
* To generate a random value
DATA amount TYPE wrbtr.
DATA(val_rand) = ztbox_cl_rand=>value( ).
val_rand->generate( IMPORTING value = amount ).
```
## ConfigurationYou can decide the number of rows in the generated table
```abap
DATA t_sbook TYPE TABLE OF sbook.
DATA(tab_rand) = ztbox_cl_rand=>table( ).tab_rand->rows( `10000` ). " Default is 100
tab_rand->generate( IMPORTING table = t_sbook ).
" Now t_sbook has exactly 10000 rows
```
The number of rows can also be a range in the form `[min, max]`
```abap
tab_rand->rows( `[10, 2000]` ).
tab_rand->generate( IMPORTING table = t_sbook ).
" Now t_sbook has a number of rows randomly chosen between 10 and 2000
```
You can manage fields configuration using `->field( )` method.
```abap
tab_rand->field( `MANDT` )->fixed( sy-mandt ). " To always assign the same value
tab_rand->field( `FORCURAM` )->range( `[1, 1000]` ). " To assign value randomly chosen from an interval
tab_rand->field( `FLDATE` )->range( `[19990101, 20251231]` ). " As above, also applies to dates and times
tab_rand->field( `FORCURAM` )->decimals( 2 ). " To set decimals precision for packed/float fields
tab_rand->field( `PASSNAME` )->len( `5` ). " To assign char-value with fixed length
tab_rand->field( `PASSNAME` )->len( `[3, 14]` ). " To assign char-value with a randomly chosen length
tab_rand->field( `PASSNAME` )->ascii( ). " To genere words using ASCII characters
tab_rand->field( `PASSNAME` )->words_upper( ). " To generate words in upper case
tab_rand->field( `WUNIT` )->use_check_table( abap_false ). " To de-activate the use of domain check-table
tab_rand->generate( IMPORTING table = t_sbook ).
```
The same `->field( )` configurations can be applied to structure generator too.
```abap
DATA s_uni TYPE bapimtcs_unicode.
DATA(str_rand) = ztbox_cl_rand=>struct( ).
* For string field generation you can set the number of words to generate and the length of each word
* (for both, fixed or randomly chosen from a range),
str_rand->field( `DATA` )->words_number( `[1, 15]` )->words_len( `[5, 10]` ).
str_rand->generate( IMPORTING struct = s_uni ).
```And you can configure the single value too.
```abap
DATA order_num TYPE n LENGTH 10.
DATA(val_rand) = ztbox_cl_rand=>value( ).
val_rand->len( `6` ).
val_rand->generate( IMPORTING value = order_num ). " It could be any value of the form `0000XXXXXX`.
```## Installation
Install this project using [abapGit](https://abapgit.org/) ![abapGit](https://docs.abapgit.org/img/favicon.png)