Application Development 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: 

How to Add new blank rows or records in the table control in editable mode

Former Member
0 Kudos
4,044

Hi Experts,

How to Add new blank rows or records in the table control in editable mode ( it should be below the current records which are retrived from the database in the same page) after clicking on a "New" push button.

The retrieved data records from database should be in a displayed mode, and after clicking on the

"New" push button, the new blank records or rows should be in editable mode in the same page.

Please help me out.

Thanks in advance.

Ananth.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
759

if you loop with control in PBO

you can just modify the attribute of table control to make the next row writable

and insert this new line to itab in PAI

if you loop at itab in PBO

just APPEND INITIAL LINE will work

hope this will help

6 REPLIES 6

Former Member
0 Kudos
759

Hi!

Your TC has an internal table.

You have to APPEND empty rows to this internal table, based on the actual visible rowcount and the maximum displayable rowcount.

Regards

Tamá

Former Member
0 Kudos
759

when click on the NEW button

loop ur internal table and later at the required postion append balnk line into your internal table and modify that internal table

to insert a blank line just append blank work area in you internal table..

This will solve your problem..

Let me know if you need further info

Regards

Satish Boguda

Former Member
0 Kudos
759

Hi Satish and Tamas,

I am unable to get that logic..... can you help me out more elaborately.

That will be helpful.

Thanks in Advance,

Ananth.

0 Kudos
759

Hi

[Check this Thread also for more info, Below is Modified Code for your requirement|]

in PBO
 module isert_line. " TO insert a new blank Line.
loop at itab with control tc.
module modify_screen. " If you place your loop at screen in this module the row will be editable/changed to disabled mode
endlooop.
 
in program.

module insert_line.
data : tabix type sy-tabix.
read table itab with key mark = 'X'.  " This gives the current Line selected
tabix = sy-tabix + 1. " At next line Initial line is inserted
loop at itab.
insert INITIAL LINE INTO itab index tabix.
clear tabix.
endloop.
endmodule


module modify_screen.
 CASE ok.
    WHEN 'MOD'.  " Your Modify OK code
 
        LOOP AT SCREEN.
      IF jtab-mark = 'X'. " You can check here for Initial line
" if itab is initial .  " here the work Area
          IF screen-group1 = 'GRP'. " You Assign  screen group for all fields you want editable
" Assign a GRP1 for all key fields and GRP2 for other fields
" if screen-group2 = 'GRP2'. " All the screens belong to GRP2 will be modified here
            screen-input = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
clear jtab-mark.
modify jtab index sy-tabix. " This clears the Table control Row selector 
" If you dont want just remove this.
  ENDCASE.
endmodule.
 
in PAI
 
loop at  itab.
module modify_tab.
" In Top include
data : begin of jtab occurs 0,
mark type c,
 matnr type matnr,
maktx type maktx,
end of jtab.
 
" dont forget to enter JTAB-MARK in screenpainter at Table control W/SelColumn
in program
 
MODULE modify_tab.
  DESCRIBE TABLE jtab LINES tc-lines.
  MODIFY jtab INDEX tc-current_line. " This will transfer the Selected line back to internal table of program
ENDMODULE. 
endloop.
" Happy new year to you ALL
" This is a tested program and working fine in my system

Cheerz

Ram

Former Member
0 Kudos
759

Hi

Try this code.It will solve your query.

MODULE CREATE_RECORD INPUT.

DATA: CURR TYPE I, IDX TYPE I.

IF OK_CODE = 'CREATE'.

CLEAR OK_CODE.

CURR = TAB_CTRL-CURRENT_LINE.

IDX = CURR + 1.

  • Adding blank line to the table control

INSERT INITIAL LINE INTO IT_tab INDEX IDX.

tab_ctrl-current_line = idx.

endif.

ENDMODULE.

Thanks

Khushboo

Former Member
0 Kudos
760

if you loop with control in PBO

you can just modify the attribute of table control to make the next row writable

and insert this new line to itab in PAI

if you loop at itab in PBO

just APPEND INITIAL LINE will work

hope this will help