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

Wizard generated table control: bug in insert line function?

Hi,

I added a table control to a dynpro using the wizard in the screen painter. Now I have an issue with the inserting line button:

If I add a new line the first time, a new empty line is added to the table control before my last line. So far so good.

If I add now another line, again a new line empty is added before my last line and two lines are added after my last line: one empty line and a line with the same content as my former second last line.

The following should explain it a bit better:

table before inserting new line:

line 1

line 2

line 3

line 4

line 5

after inserting a new line:

line 1

line 2

line 3

line 4

new empty line

line 5

table before inserting the second line:

line 1

line 2

line 3

line 4

line 5

line 6

after inserting the second line:

line 1

line 2

line 3

line 4

line 5

new empty line

line 6

new empty line

line 5

I didn't change the generated coding yet!

Thanks in advance and regards,

Martin

Edited by: fischerman on May 29, 2008 9:08 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2008 at 08:09 AM

    Here is the code of the form which is called in PAI if the insert button was pressed:

    FORM fcode_insert_row
                   USING    p_tc_name           TYPE dynfnam
                            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------------------------------------------*
    
       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

    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.