Application Development 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: 

How to generate data randomly in database table ABAP SAP?

mahmood_hammood
Participant
0 Kudos
507

I have this code, with it I can select table from system and dispaly its content. I want to add records for example 10 and generate random data in my table, I have to findthe data in se11 TCode. have someone an idea please? Idea, code which can I learn from, or video. I am still beginner. Thank you

*&---------------------------------------------------------------------*
*& Report Z_THIRD_REPORT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_THIRD_REPORT.


TABLES: DFIES,
X030L.

DATA: BEGIN OF INTTAB OCCURS 100.
INCLUDE STRUCTURE DFIES.
DATA: END OF INTTAB.


DATA: FIELD_DATA_TYPE TYPE DFIES-DATATYPE,
NUM_RECORDS TYPE I.

*PARAMETERS: p_taname TYPE DDOBJNAME OBLIGATORY.
PARAMETERS: TABLENM TYPE dd02l-tabname OBLIGATORY,
RECORDS TYPE I.
*FIELDNM TYPE DFIES-FIELDNAME.

SELECT * FROM dd02l INTO TABLE @DATA(lt_tables)
WHERE ( tabname LIKE 'Z%' OR tabname LIKE 'Y%' )
AND as4local = 'A'
AND tabclass IN ('TRANSP', 'INTTAB').

CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = TABLENM
*FIELDNAME = FIELDNM
LANGU = SY-LANGU
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* IMPORTING
* X030L_WA = WATAB
* DDOBJTYPE =
* DFIES_WA =
* LINES_DESCR =
TABLES
DFIES_TAB = INTTAB
* FIXED_VALUES =
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.



IF sy-subrc <> 0.
WRITE:/ 'Field name not found'.
ELSE.

WRITE:/ 'Fields', 'Data Type'. " Column headers
LOOP AT INTTAB.
FIELD_DATA_TYPE = INTTAB-DATATYPE. " Store the data type in FIELD_DATA_TYPE.
WRITE:/ INTTAB-FIELDNAME, FIELD_DATA_TYPE.
ENDLOOP.
ENDIF.

3 REPLIES 3

matt
Active Contributor
391

I don't know where you're getting your training from, but TABLES is obsolete and shouldn't be used, nor should you use tables with header lines.

mahmood_hammood
Participant
0 Kudos
391

I search and learn. I get no training.

Sandra_Rossi
Active Contributor
0 Kudos
391

You can see in the ABAP documentation that TABLES and header lines are obsolete. There is an index so no chance to miss it. Easy and fast way to get information by SAP company itfself.