Skip to Content
0
Former Member
Aug 04, 2010 at 09:30 PM

How to get the count of entries in each field of a table

50 Views

Hi !

I am looking to get the count of individual fields of a table in my query. For example

Suppose my VBPA table has a total number of entries of 15 in whole, just like below.

MANDT VBELN POSNR PARVW KUNNRLIFNR LIFNR PERNR PARNR ADRNR ABLAD LAND1 ADRDA XCPDK HITYP PRFRE BOKRE HISTUNR KNREF LZONE HZUOR STCEG PARVW_FF ADRNP KALE .INCLU--AP

10 20000000 AG 101874 43290 IN D TBD

10 20000000 RE 101874 43290 IN D TBD

10 20000000 RG 101874 43290 IN D TBD

10 20000000 WE 5037346 90501 IN D TBD

10 20000002 AG 118799 291008 IN D 1399

10 20000002 RE 118799 291008 IN D 1399

10 20000002 RG 118799 291008 IN D 1399

10 20000002 WE 118799 291008 IN D 1399

10 20000002 ZE 81582 289399 IN D

10 20000003 AG 124065 362797 IN D TBD

10 20000003 RE 124065 362797 IN D TBD

10 20000003 RG 124065 362797 IN D TBD

10 20000003 WE 124065 362797 IN D TBD

10 20000004 AG 119594 291803 IN D 1399

Then the output should look like below in the last column if you see.

Table Field DT Used fields

VBPA MANDT CLNT 15

VBPA VBELN CHAR 15

VBPA POSNR NUMC 0

VBPA PARVW CHAR 15

VBPA KUNNR CHAR 14

VBPA LIFNR CHAR 1

VBPA PERNR NUMC 0

VBPA PARNR NUMC 0

VBPA ADRNR CHAR 15

VBPA ABLAD CHAR 0

VBPA LAND1 CHAR 15

VBPA ADRDA CHAR 15

VBPA XCPDK CHAR 0

VBPA HITYP CHAR 0

VBPA PRFRE CHAR 0

VBPA BOKRE CHAR 0

VBPA HISTUNR NUMC 0

VBPA KNREF CHAR 0

VBPA LZONE CHAR 8

VBPA HZUOR NUMC 6

VBPA STCEG CHAR 0

VBPA PARVW_FF CHAR 0

VBPA ADRNP CHAR 0

VBPA KALE CHAR 0

VBPA .INCLU--AP 0

VBPA OIPBL CHAR 0

Is it possible to do this.

I have used the following but then the used field value is always the same as its counts the entries of the table instead of the fields.

*SELECT COUNT(*) FROM DD03L INTO USEDFIELDS
WHERE TABNAME = DD02L-TABNAME
    AND AS4LOCAL = DD02L-AS4LOCAL.

.

Thanks