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 we find number of record in table by using before save event in table maintenance generator

former_member199023
Participant
0 Kudos

Hi Expert,

How we find number of record in table by using before save event in table maintenance generator

Thanks

Rajeev

14 REPLIES 14

Former Member
0 Kudos

Hi Rajeev,

in the event,their will be Table Variable called 'TOTAL'.

you can use this code,

DATA : lin type I.

Describe table TOTAL lines lin.

you will get the total records number in the variable LIN.

Regards,

Sangamesh.

0 Kudos

Kindly use table events on the table maintenance generator screen. In that there will be an event which gets called just before save. Event number is 01. Once you create an event you need to assign an subroutine to that event. In that subroutine the whole table entries are available.

Now using Describle table command you can get the number of table entries in the table.

former_member209120
Active Contributor
0 Kudos

Hi Rajeev,

before saving click enter it will shows how many records in it as highlighted

Former Member
0 Kudos

Hi,

There are two tables in TMG  

1)TOTAL

2)EXTRACT.

TOTAL table contains the entire table contents that is present in the DB.


EXTRACT  internal table contains the extract of the data that was created, deleted or changed during an action on the table maintenance screen.

Hope this helps you understand Total and Extract now..

Now you can decide what you want...reward if useful..

Regards,

Abdul


Former Member
0 Kudos

Hi Rajeev,

Create a event in table maintenance and try to find the number of records using describe table lines...

Thanks & Regards

akshay

former_member186077
Active Participant
0 Kudos

Hi ,

In the table maintenance generator you can use the event 01 for this purpose.

The table total contains both the existing entries as well as newly added entries.

In order to get the count of old entries , you can use in the following way :

Delcare a internal table which is of structure TOTAL.

   DATA : BEGIN OF wa_total .

           INCLUDE STRUCTURE zXXX. ( Name of the table to which the event is assigned )

   DATA:    action TYPE c,

          END OF wa_total.

DATA : IT_TOTAL LIKE STRANDARD STRUCTURE OF WA_TOTAL.

DATA : i_count TYPE i.

IT_TOTAL[] = TOTAL[].

DELETE IT_TOTAL where action = 'N'.

DESCRIBE TABLE it_total LINES i_count.

Thanks and Regards,

Sriranjani Chimakurthy.

0 Kudos

Hi All ,

Thanks for your reply.

We solved the issue. describe will not work in TMG(table maintenance generator ) .

two way we found that either use total and get based on sy-tabix value or simply fetch the data from table and get the count from sy-dbcnt .

0 Kudos

Hi Rajeev,

Good to know that you have resolved the issue. But i do not agree that describe will not work in TMG.

Can you please explain why will it not work?

Thanks and Regards,

Sriranjani Chimakurthy.

0 Kudos

Hi Srir,

Thanks for asking the question. I checked with Describe only but count is only 1. so better use loop the total and use sy-tabix value to get number of count or i explained other logic .

0 Kudos

Hi Sriranjani,

I have a requirement where i have to work on the changed /created or deleted records of a table through SM30.To get such records , I have followed the same way as you  have described.

But while assigning total to created internal table i am getting dump that Two internal tables are neither compatible nor convertible.

My custom table has a field of type int4.Is that a problem.

Can you help me on this.

Regards,

Priyaranjan

0 Kudos

Hi Gupta,

\Which two internal tables have you used? And which procedure you followed? Rajeev has used only one internal table to loop.

Regards,

-Vijay

0 Kudos

I have done as follows : (As described by Sriranjani)

Delcared an internal table which is of structure TOTAL.

   DATA : BEGIN OF wa_total .

           INCLUDE STRUCTURE zXXX. ( Name of the table to which the event is assigned )

   DATA:    action TYPE c,

          END OF wa_total.

DATA : IT_TOTAL LIKE STRANDARD STRUCTURE OF WA_TOTAL.

IT_TOTAL[] = TOTAL[].  - this statement is giving dump.

Regards,

Priyaranjan

0 Kudos

Hi Priyaranjan,

The Total[] will hold your all the table data with new maintained value also. In the above code just change the

DATA : it_total LIKE STANDARD TABLE OF wa_total.

else you can directly use table[] as a internal table.

Thanks 

0 Kudos

Hi,

Please find the below link to find total number of records, modify or delete the record :

Table Maintenance Generator for event Number 01 and 05 - Contributor Corner - SCN Wiki

Problems with Table Maintenance Generator for e... | SCN

Thanks & Regards,

Akshay Ruia