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

Table control

Former Member
0 Likes
832

Hi All,

I am using a table control to display some info and would need to bring up a new screen when a row in the table is double clicked. Do you know how I can assign a function code for this ?

It's been a long time since I used the table controls. So any help would be greatly appreciated.

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
808

Hi,

In your GUI Status (PF-STATUS) assign a function code (for example PICK) for F2 Function Key.

And then code for it in your user_command routine.

Like,

CASE ok_code.

"or OKCODE whatever is given in your screen elements list

WHEN 'PICK'.

****Your processing here..

ENDCASE.

Double click on any screen element including a table control row trigger F2 function key..

You can use

GET CURSOR LINE line. "To get the line dbl clicked

and then,

get the corresponding internal table line by,

line = tctrl-top_line + line - 1.

Hope this helps..

Sri

Message was edited by: Srikanth Pinnamaneni

9 REPLIES 9
Read only

Former Member
0 Likes
809

Hi,

In your GUI Status (PF-STATUS) assign a function code (for example PICK) for F2 Function Key.

And then code for it in your user_command routine.

Like,

CASE ok_code.

"or OKCODE whatever is given in your screen elements list

WHEN 'PICK'.

****Your processing here..

ENDCASE.

Double click on any screen element including a table control row trigger F2 function key..

You can use

GET CURSOR LINE line. "To get the line dbl clicked

and then,

get the corresponding internal table line by,

line = tctrl-top_line + line - 1.

Hope this helps..

Sri

Message was edited by: Srikanth Pinnamaneni

Read only

Former Member
0 Likes
808

Hi

The code of doubleclick is the code you assign to F2 function key in your stauts gui.

So:

PROCESS PAI.

LOOP AT...

MODULE GET_CURSOR.

ENDLOOP.

MODULE USER_COMMAND.

MODULE GET_CURSOR.

  • Get the line of table control where doubleclick is done

GET CURSORD LINE V_LINE.

ENDMODULE.

MODULE USER_COMMAND.

CASE OK_CODE.

WHEN 'F2'.

  • Get (calculate) the record of internal table

INDEX_ITAB = TABLECONTROL-TOP_LINE + V_LINE - 1.

  • read the the table

READ TABLE ITAB INDEX INDEX_ITAB.

  • Call new screen

SET SCREEN XXXX.

LEAVE SCREEN.

ENDMODULE.

Max

Read only

0 Likes
808

Only problem here is I do not have a GUI status. This is a SAP CRM screen and I am calling my table control in a subscreen. I do see that that the GUI status in SAP main screen has the Fcode defined for F2 but when I double click on my table control, it gives an error message saying - Function code cannot be selected.

Any ideas???

Read only

0 Likes
808

Hi,

Are you sure that there is a function code defined for F2 in the main screen's gui status?

Normally the message "Function code cannot be selected"

will come only if there is no function code specified for F2 function key..

You can check by placing the cursor on any field in the main screen and then go to menu System->Status. You can see the GUI Status in the popup, double click on it to navigate and see whether F2 has a function code..

And then if this is not working out then I suggest you add a Pushbutton as column to your table control and then

give a fcode to it like 'PICK'.

Sri

Read only

0 Likes
808

Hi

If you can't change the status gui of main screen, because it's std, I think you can't use the doubleclick. You could use a column with pushbutton instead of doubleclick. If you give a code with %, the system'll replace % symbol with the number of selected row.

For example if you give F2% as code of pushbutton, if user press the pushbutton of second row, the code'll be F22.

So in your user_command:

MODULE USER_COMMAND.

if OK_CODE(2) = 'F2'.

MOVE OK_CODE+2 TO V_LINE.

  • Get (calculate) the record of internal table

INDEX_ITAB = TABLECONTROL-TOP_LINE + V_LINE - 1.

  • read the the table

READ TABLE ITAB INDEX INDEX_ITAB.

  • Call new screen

SET SCREEN XXXX.

LEAVE SCREEN.

ENDIF.

ENDMODULE.

Max

Message was edited by: max bianchi

Read only

0 Likes
808

Yes, it is defined in the main screen Gui status. I am puzzeled too as to why I get that error message.

Anyways thanks for the helpful suggestion!

Read only

0 Likes
808

Even if its defined , if it is disabled in PBO with statement SET PF-STATUS .... EXCLUDING ITAB. , you will still see the error .

Cheers.

Read only

0 Likes
808

Hi Max/Sri,

How do you define a column as pushbutton in the internal table?

Read only

0 Likes
808

Hi,

In your graphical screen painter, just drag and drop a push button element on to your table control's column list, specify a name, fcode and give a header for it.

If you are working with Alpha numeric screen painter,

then first double click on the table control,

go to control elements,

click on button "New Table Column", give a name, press ENTER and then it will ask whether it is a push button or not and from that point onwards it is same as above..

Also, what sanjay said is quite possible that the fcode given for F2 function key is excluded while setting PF-STATUS. May be you should check that as well whether it is possible to remove it from the exlusion list (if it is done based upon certain conditions)..

Sri

Message was edited by: Srikanth Pinnamaneni

Message was edited by: Srikanth Pinnamaneni