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 display records of a table

Former Member
0 Kudos
205

I'm using PNP LDB in my report and I'd like to display how many records I have so I wrote this code

If i_tab is not initial.

DESCRIBE TABLE i_tab LINES counter.

WRITE counter .

Endif.

but I'm getting wrong result. Can anybody help please.

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos
185

Hi Shaheen,

1) counter = lines( i_tab ). "This is up-tp-date use of system function

2) It is not clear where (and even if) you fill this i_tab.

3) Using LDB you will have a GET statement. Place command

ADD 1 to counter directly after the GET.

END-OF-SELECTION is the right moment to check the counter.

Regards,

Clemens

10 REPLIES 10

Former Member
0 Kudos
185

Does ur Internal table have a Header line. If yes, the IF condition takes into account the header line. Check if this solves ur problem. If no, give more particulars.

Please award points if this was helpful.

Former Member
0 Kudos
185

Like what i mean to say is change your code to this if itab has a header line.

If <b>i_tab[]</b> is not initial.

DESCRIBE TABLE i_tab LINES counter.

WRITE counter .

Endif.

Former Member
0 Kudos
185

If ur i_tab is with header line , then u have to include square brackets

If not i_tab[] is initial.
DESCRIBE TABLE i_tab LINES counter.
WRITE counter .
Endif.

0 Kudos
185

No it's not working

0 Kudos
185

Hi shaheen,

try with system field.

SY-TFILL.

Regards,

Francis .

Reward points .

Clemenss
Active Contributor
0 Kudos
186

Hi Shaheen,

1) counter = lines( i_tab ). "This is up-tp-date use of system function

2) It is not clear where (and even if) you fill this i_tab.

3) Using LDB you will have a GET statement. Place command

ADD 1 to counter directly after the GET.

END-OF-SELECTION is the right moment to check the counter.

Regards,

Clemens

Former Member
0 Kudos
185

Yes it is working now I'm geting the correct result ..... thanks alot ..... but when I try to put in the top_of_page event it is not ..... any suggestions please.

Former Member
0 Kudos
185

shaheen,

Initialization event will call first TOP-OF PAGE event.That time Count will not available.

Initialization event will triggered only once,that is at first execution of the system.

Pls. reward if useful

0 Kudos
185

Hi muralikrishna kaipha,

I can't believe this.

TOP-OF PAGE page is triggered before the first line is written to a page. That means TOP-OF PAGE is triggered by first write statement in program. INITIALIZATION is normally not used to write anything.

You must avoid to write more than one page during TOP-OF PAGE event because this will trigger TOP-OF PAGE recursively endless.

Think about it.

Regards,

Clemens

Former Member
0 Kudos
185

hi,

in your code you are using like

If i_tab is not initial.

then it will treated as headerline (because table name and header line name are same). so modify your code as follows.

If i_tab[] is not initial.

now it will treated as table.