Skip to Content
author's profile photo Former Member
Former Member

Adding New line in table control at sel postition

Hello gurus,

i m working with a table control

i have coded to insert a row inthe table control on a button click command

i am able to insert it perfectly in the internal table and cud also c the total line of table control incremented

but in output cannt c the new blank row.

i m using following code passing table control name and internal table name.

form FCODE_INSERT_ROW using p_tc_name

p_table_name.

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA l_lines_name LIKE feld-name.

DATA l_selline LIKE sy-stepl.

DATA l_lastline TYPE i.

DATA l_line TYPE i.

DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <lines> TYPE i.

&SPWIZARD: END OF LOCAL DATA----


*BREAK DEVELOPER.

ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.

ASSIGN (l_lines_name) TO <lines>.

*&SPWIZARD: get current line *

GET CURSOR LINE l_selline.

IF sy-subrc <> 0. " append line to table

l_selline = <tc>-lines + 1.

*&SPWIZARD: set top line *

IF l_selline > <lines>.

<tc>-top_line = l_selline - <lines> + 1 .

ELSE.

<tc>-top_line = 1.

ENDIF.

ELSE. " insert line into table

l_selline = <tc>-top_line + l_selline - 1.

l_lastline = <tc>-top_line + <lines> - 1.

ENDIF.

*&SPWIZARD: set new cursor line *

l_line = l_selline - <tc>-top_line + 1.

*&SPWIZARD: insert initial line *

INSERT INITIAL LINE INTO <table> INDEX l_selline.

<tc>-lines = <tc>-lines + 1.

*&SPWIZARD: set cursor *

SET CURSOR LINE l_line.

endform. " FCODE_INSERT_ROW

please verify the code and tell me is ther any other setting missing or please anyone giveme the sample code to do so ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 18, 2008 at 04:42 AM

    Hi,

    Thats OK,

    Are you using any select queries with in the program, which will be re-executed after you insert an initial row in to the table control??. if so please restrict the execution of select query for the second time.

    then your insertion will become effective.

    Hope this would solve your problem.

    Regards

    Ramchander rao.K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:05 AM

    for insert a line.

    data n type i.

    when 'insert'.

    describe table itab lines n.

    tabcon-lines = n + 1.

    or

    data n type i value 0.

    when 'INSERT'.

    loop at itab.

    n = n + 1.

    end loop.

    tabcon-lines = n + 1.

    foe delete.

    loop at itab.

    n = n + 1.

    end loop.

    tabcon-lines = n - 1.

    check this link too.

    table-control-adding-lines-deleting-lines

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.