cancel
Showing results for 
Search instead for 
Did you mean: 

why this output is coming for sy-index

Former Member
0 Kudos
251

for the code

-


do 5 times.

hide sy-index.

wrtie sy-index.

enddo.

at line-selection.

write sy-index.

-


o/p is

1

2

3

4

5

-


if one clicks on 3 we get 4 on so on..can anyone xplain the logic behind this.

Accepted Solutions (1)

Accepted Solutions (1)

andreas_mann3
Active Contributor
0 Kudos

Hi Henry,

this will be run:

( set hide behind write)

DO 5 TIMES.

WRITE: / sy-index.

HIDE sy-index."<----


ENDDO.

AT LINE-SELECTION.

WRITE sy-index.

regards Andreas

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi ,

I don't think set hide behind write is the only problem.If you removed <b>/</b> in write statement,we won't get desired result.

  • Check this it won't work

DO 5 TIMES.

WRITE: sy-index.<b>"<--check here-</b>

HIDE sy-index.

ENDDO.

AT LINE-SELECTION.

WRITE sy-index.

So either if you want to use hide behind write , you should use <b>/</b> in write as Andreas mentioned.

Or you should use skip or Uline command as I suggested.

Anyway you cannot write everything in same horizontal line.

Output should be vertical .

Former Member
0 Kudos

Hi jayanthi both urs n Andreas'(if / is placed) code is wrkg fine,can u please let me knwo the technical reason for this behavior of the code

Message was edited by: henry

andreas_mann3
Active Contributor
0 Kudos

Hi Henry,

from Abap-docu:

...

HIDE <f>.

This statement places the contents of the variable <f> for the current output line (system field SY-LINNO) into the HIDE area. The variable <f> must not necessarily appear on the current line.

To make your program more readable, <b>always place the HIDE statement directly after the output statement</b> for the variable <f> or after the last output statement for the current line.

...

have a look here:

http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba42335c111d1829f0000e829fbfe/frameset.htm

regards Andreas

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi Henry,

As I already replied,it is because in your original code you mentioned the sy-index to be in the same line.

Usually,the purpose of AT Line-selection is pick that line.That's why it is taking the sy-index in your code as 5.

But in my code and Andreas code , we are displaying the output vertically.

And in the below mentioned code,I think while processing write statement itself since it needs to process both sy-index and '/' , it is incrementing sy-index by one.

do 3 times.

hide sy-index.

write : / sy-index.

enddo.

at line-selection.

write sy-index.

Write sy-index and Hide should be consecutive.

The behaviour of write 😕 sy-index is it first process / and then sy-index.

In Andreas coding, he has written write and then hide.

While processing the write 😕 sy-index, it is first processing hide and then / and then sy-index.

In my coding, I have written hide and then write(without /).Here also it is consecutive.

But in the coding you mentioned , you have written hide and then write (with /).It is processing hide and then / and then sy-index.In this case Hide and Write sy-index are not consecutive.That's why you get the output incremented by one.

Hope this is clear.

For more information about HIDE and At Line-selection,check this.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/hide.htm

Check this also.It will also work fine since write sy-index and Hide are consecutive.

do 3 times.

hide sy-index.

write sy-index.

new-line.

enddo.

at line-selection.

write sy-index.

Regards,

J.Jayanthi

Message was edited by: Jayanthi Jayaraman

Former Member
0 Kudos

Hi Jayanthi Jayaraman,

I appreciate ur effort n knowledge sharing,

I'm unable to find the radio buttons/options to allot points.

thanks n regards

Message was edited by: henry

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi Henry,

If your problem is solved,could you please close the thread and reward points for the helpful answers.

For problem in assigning points,you can send a mail to the person marilyn.pratt@sap.com stating the problem.He will do the needful.

Regards,

J.Jayanthi

Message was edited by: Jayanthi Jayaraman

Former Member
0 Kudos

Ok jayanthi

Answers (2)

Answers (2)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi Henry,

It is because it is in horizontal line.At line-selection will consider the entire line.So it takes the last sy-index.

Now try this.

do 3 times.

uline.

hide sy-index.

write sy-index.

enddo.

at line-selection.

write sy-index.

Now it will work fine.

Hope this clear.If not,get back to me.

For more information about HIDE and At Line-selection,check this.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/hide.htm

Regards,

J.Jayanthi

Former Member
0 Kudos

do 5 times.

hide sy-index.

write/ sy-index.

enddo.

at line-selection.

write /sy-index.

the above code gives the folowng o/p

1

2

3

4

5

and click on any of the o/p numbers gives n+1 o/p in sc list.but this is nto consisten with increse in the do times.

Former Member
0 Kudos

Hi,

I have tried with the program, what actually happens is when u click on any of the number its giving 5 alone.

In ur code u have specified as at line-selection. write sy-index.

Sy-index holds the value 5. So what ever value u press it will display 5.

Added

<b>AT LINE-SELECTION.</b>

Effect

Event in interactive reporting

This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.

<b>The processing for the event AT LINE-SELECTION usually generates further list output (the details list)</b> which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.

In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.

For more info see F1 help.

Thanks & Regards,

Judith.

Former Member
0 Kudos

Hi,

I think it is because you have a column heading line which sets your sy-tabix to a value +1.

regards

Siggi