cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Rows of a table in smartform

Former Member
0 Kudos

Hi,

It seems to be a simple problem..only that I can't find the answer :).

There is a loop in the smartform which is looping over an internal table.

Say there are 5 rows to be printed.

Now when there is a text i hv to print only if it is the first row of the table. For sub sequent rows, the text will not be printed.

I can do this by using a code element and set a flag the first time.. etc etc. But i want to know if there is any system variable (like sy-tabix) or any such thing which can tell me which iteration of the loop i am in, so that i can just set a condition on the text element and get it done.

My output would be like

row1- text 1 1 2 3 4

row2- ______ 6 7 8 9

row3- ______ 10 11 12 13

'text1' will be printed only on row1.

Thanks in advance.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

follow karthiks reply.

Former Member
0 Kudos

Hi,

Define a counter variable like (count) in the global definitions and then use that one in the loop by incrementing the variable for every loop pass.

But before using that variable in the loop make sure that u have initialsed that variable (count) to Zero.

And then depending upon the variables value u can write your coding as per your requirement.

Hope this will help you.

Regards,

Venkat.

Former Member
0 Kudos

Hi,

SY-Tabix works fine within the loop in a smartform.

Do not use as a condition while looping.

But use it as a condition for the text node inside the loop.

Regards,

Ram

Edited by: Ramakrishna Peri on May 26, 2009 8:53 AM

Former Member
0 Kudos

Hi,

In smart forms we can use sy-tabix. By considering sy-tabix in Table node you can display that text.

Put in conditions tab of Text node as sy-tabix = 1.

Former Member
0 Kudos

Hi,

Thanks for your prompt replies. I tried capturing sy-tabix. It is not giving the desired value. I debugged the code and found that before the text element is getting painted, the tabix value goes through a lot of changes within the loop and looses its original value.

I'll try karthik's approach. I wanted to avoid coding :(. Wattodo. Unfortunate, sy-tabix is not working. Atleast there should be an sfsy-tabix don't u think .

Former Member
0 Kudos

>

> I wanted to avoid coding :(. Wattodo. Unfortunate, sy-tabix is not working. Atleast there should be an sfsy-tabix don't u think .

So Shall we append tabix to SFSY structure ? LOL

And writing code in smartform is not that much tougher, just declare a variable count of type int and initialize to 0. Then inside the program lines give count to the import and export parameter list. And write the following line;

Count = Count +  1.

Regards

Karthik D

Former Member
0 Kudos

Hi,

Your problem will be solved by using a counter variable. inside the loop create a program lines node and increment the counter by one at each pass, then give the counter in the condition.,

Regards

Karthik D

Former Member
0 Kudos

Hi,

In smart forms we can use sy-tabix. By considering sy-tabix in Table node you can display that text.

Put in conditions tab of Text node as sy-tabix = 1.

Former Member
0 Kudos

Hi,

While passing the data to the itab, pass text1 to the field1 with the following--

loop at itab.

if sy-tabix = 1.

itab-field1 = 'text1'.

else.

itab-field2 = field2.

.

.

.

.

endif.

endloop.

Former Member
0 Kudos

Thanks for the answer.

But I am not sure if you got the problem.

The loop is inside smartform. It is loop element.

So there is no option for coding there. And sy-tabix cannot be captured.