Application Development and Automation 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: 
Read only

Get SE16 count

Former Member
0 Likes
3,232

I am still stuggling with the subjet !!

Within a secatt; how can I get the number of entries in a table (se16/enter/CtrlF+F7) and export this in an E_parameter !?

Sorry sound stupid but 'DBCount' (Value out in Dynpro 450) is not open for a insertion of E_param_test_out !

Tks for any hints

(yes i also user command CHETAB in parrallel)

Etienne

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,515

Hi!

You might check out the SELECT COUNT ... ABAP statement for this.

An example:

TABLES: SCUSTOM, SBOOK. 
DATA:   COUNT TYPE I. 

SELECT SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY 
         COUNT( DISTINCT SBOOK~LOCCURAM ) 
       INTO (SCUSTOM-NAME, SCUSTOM-POSTCODE, SCUSTOM-CITY, 
             COUNT) 
       FROM SCUSTOM INNER JOIN SBOOK 
         ON SCUSTOM~ID = SBOOK~CUSTOMID 
       WHERE SBOOK~FLDATE BETWEEN '19950101' AND '19951231' AND 
             SBOOK~CARRID   = 'LH '                         AND 
             SBOOK~CONNID   = '0400' 
       GROUP BY SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY 
       ORDER BY SCUSTOM~NAME. 
  WRITE: / SCUSTOM-NAME, SCUSTOM-POSTCODE, SCUSTOM-CITY, COUNT. 
ENDSELECT.

Regards

Tamá

8 REPLIES 8
Read only

Former Member
0 Likes
2,515

you can get database table count using FM, CATT_GET_TABLE_ENTRIES

Read only

0 Likes
2,515

Hi,

how nice of you for the quick hint.

Yes indeed - this is working (workaround) but i am struggling with the 'where'. I did also check via the se37

for instance /se37 on the famous table t003

t003

mandt=030

BLART=10

>>> not working !! (even if i drop the mandt or if i add

t003

t003-mandt=030

t003-BLART=10

Any idea !?

have a good day

Read only

0 Likes
2,515

chk system field SY_DBCNT to get records of the database table.

you can use

SELECT COUNT( * ) ... FROM ... WHERE ...

sy-dbcnt will give you the number of entries.

in this case, if you need the total number in the DB table:

SELECT COUNT( * ) ...

FROM MARA.

Read only

0 Likes
2,515

Hi,

the complete answer is


ABAP.

SELECT COUNT(*) FROM <TABLE> INTO <eCATT_local_param>.

ENDABAP.

<eCATT_export_param> = <eCATT_local_param>.

Best regards

Sebastian

Read only

0 Likes
2,515

Hi,

I tried with the SAPGUI mode recording of SE16 to find the total count and used the GETGUI to read the values from the pop-up when it is displayed if you click the number of entries button. It worked fine. In the log I can see the total count.

I tried to export the same and it worked.

SAPGUI ( SE16_230_STEP_1 ).

SAPGUI ( SE16_1000_STEP_1 ).

GETGUI ( SE16_450_STEP_1 ).

e_count = i_count.

LOG ( i_COUNT ).

thanks

Venkat

Read only

Former Member
0 Likes
2,516

Hi!

You might check out the SELECT COUNT ... ABAP statement for this.

An example:

TABLES: SCUSTOM, SBOOK. 
DATA:   COUNT TYPE I. 

SELECT SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY 
         COUNT( DISTINCT SBOOK~LOCCURAM ) 
       INTO (SCUSTOM-NAME, SCUSTOM-POSTCODE, SCUSTOM-CITY, 
             COUNT) 
       FROM SCUSTOM INNER JOIN SBOOK 
         ON SCUSTOM~ID = SBOOK~CUSTOMID 
       WHERE SBOOK~FLDATE BETWEEN '19950101' AND '19951231' AND 
             SBOOK~CARRID   = 'LH '                         AND 
             SBOOK~CONNID   = '0400' 
       GROUP BY SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY 
       ORDER BY SCUSTOM~NAME. 
  WRITE: / SCUSTOM-NAME, SCUSTOM-POSTCODE, SCUSTOM-CITY, COUNT. 
ENDSELECT.

Regards

Tamá

Read only

former_member131788
Active Participant
0 Likes
2,515

Hello Member,

You can achieve this by using a dynamic ABAP statement in an eCATT script. Declare an variable and export structure parameter of type table(table[ ]). You can concatenate as many conditions and append it to structure V_COND(is of type catpaval[ ] ). The dynamic ABAP statements retrieves values for the condition in V_COND and stores it in V_TABLE structure parameter. Finally the GETLEN gets the count in local parameter V_NUMBER. Depending on the V_COUNT you can therefore export the local structure into an exporting parameter(structure).

  • take conditions in a variable since ABAP block does not identify Import and export view

V_MATNR = 'raw_material'.

V_MANDT = &CLIENT.

ABAP.

DATA : cond(132) TYPE C.

  • build condition dynamically.

IF ( '' = '' ).

  • set client

CONCATENATE 'MANDT = ''' V_MANDT '''' INTO cond.

APPEND cond TO V_COND.

  • read values from tables

SELECT *

INTO CORRESPONDING FIELDS OF TABLE V_TABLE

FROM TABLE

WHERE (V_COND).

ENDIF.

ENDABAP.

GETLEN ( V_TABLE , V_NUMBER ).

IF ( V_NUMBER > 0 ).

E_TABLE = V_TABLE.

E_NUMBER = V_NUMBER.

ENDIF.

Hope this helps.

Thanks and Kind Regards

-


Mohan

Read only

Former Member
0 Likes
2,515

Fabulous

and many thks too all of you.

Very promising in our Competence center 'public sector specifiq.

tks from Brussel,