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

Read line in table control

Former Member
0 Likes
3,139

hi ,

In my table control i have 100 entries , i scroll down and double click on the 90th entry of field vbak-vbeln.

i used get cursor field f1 value v1.

get cursor line line1.

here line1 is giving the value 10.

since when i scroll down to find the 90th record, at apoint i can see 10 records only in table control.

plz help me out how to pick line number from all the records.

i constructed the table control from the work area defined in the program.

i dont want to go with selection (Mark) in table control.

hi ,

In my table control i have 100 entries , i scroll down and double click on the 90th entry of field vbak-vbeln.

i used get cursor field f1 value v1.

get cursor line line1.

here line1 is giving the value 10.

since when i scroll down to find the 90th record, at apoint i can see 10 records only in table control.

plz help me out how to pick line number from all the records.

i constructed the table control from the work area defined in the program.

i dont want to go with selection (Mark) in table control.

6 REPLIES 6
Read only

Former Member
0 Likes
1,741

Hi

U should considere you're working with two tables:

- table for memory: your internal table with the data to be dispalyed;

- table for video: your table control;

The internal table can have an infinty number of records: it depends on how many records you've appended

The table control can have the number of records you've designed by screen painter: u can see the value by system variable SY-LOOPC, so the index can be from 1 to SY-LOOPC.

When u do a double click on table control the statament GET CURSOR return the index of the table control, not the index of internal table, if yuo want to know the index of internal table u need to calculate:

INDEX OF SELECTED RECORD = INDEX RECORD AT THE TOP + INDEX TABLE CONTROL - 1

so

A) v_index = <table control>-top_line + line1 - 1.

B) U can also find out the value from <table control>-current_line.

Which solution to be used depends on where u need to store the value of the selected line:

A) It's better out of the LOOP of PAI (for example in the user_command):

MODULE USER_COMMAND.
* Get selected line
  V_INDEX = <TABLE CONTROL>-TOP_LINE + LINE1 - 1.
ENDMODULE.

B) It's better inside of the LOOP of PAI:

PROCESS PAI.
  LOOP AT ITAB.
     MODULE GET_LINE.
  ENDLOOP.

MODULE GET_LINE
  GET CURSOR LINE LINE1.
  IF LINE1 = SY-STEPL
    V_INDEX = <TABLE CONTROL>-CURRENT_LINE.
  ENDIF.
ENDMODULE.

But I prefer the A solution

Max

Read only

0 Likes
1,741

hi max,

thanks for u r reply,

i am using table control wizard.intially to the empty table control.when a new line was created in my table control and press enter.the table is showing one line and rest is greyed out and i am unable to create an new line .

i defined my table control using the work area created in program.

plz help us in this

Read only

0 Likes
1,741

Hi

U need to update the field LINES of table control: <TABLE CONTROL>-LINES should have the number of lines have to be displayed:

PROCESS PBO.
  
    MODULE SET_LINES_FOR_OUTPUT.
    
   LOOP AT ITAB....

MODULE SET_LINES_FOR_OUTPUT.
  DESCRIBE TABLE ITAB LINES <TABLE CONTROL>-LINES.
ENDMODULE.

U can use another logic of course, it depends on you need to do

Max

Read only

0 Likes
1,741

max,

so u mean that i have to append blank entries to that table ?and delete blank lines before save ?

but in standrd transactions even when u enter 1 entry the table control will have the rest row enable not greyed out.howz it possible

Read only

0 Likes
1,741

Hi

No...of course.

Try to check how the logic of dynpro is written, it should be like this:

PROCESS BEFORE OUTPUT.

  MODULE T_CTRL_CHANGE_TC_ATTR.

  LOOP AT   ITAB
       WITH CONTROL T_CTRL
       CURSOR T_CTRL-CURRENT_LINE.
    MODULE T_CTRL_GET_LINES.

  ENDLOOP.

PROCESS AFTER INPUT.
  LOOP AT ITAB.
    CHAIN.
      FIELD ITAB-FIELD1.
      FIELD ITAB-FIELD2.
      FIELD ITAB-FIELD3.
    endchain.
  ENDLOOP.

Max

Read only

Former Member
0 Likes
1,741

u just use tc-top_line for your issue.

for example .

get cursor line line.

if tc-top_line > 1.

line = line + tc-top_line -1 .

endif .

that will definately solve your problem.