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: 

table control add a new row

Former Member
0 Kudos

Dear All,

I am still unable find the solution for my following problem

Table control has 9 columns and 4 of them r input column. Initially all columns are display only. When the user

click Create Record, it should copy 2 columns data to the next row and remaing 4 columns should be input

enabled.

I have got a CREA button, the moement I press it, all the 4 columns a input enabled and working fine. But

the first 2 columns it should copy the data from the previous row and should get displayed which

is not happening.

Please help.

Regards,

Ankith

12 REPLIES 12

former_member1245113
Active Contributor
0 Kudos

Hi, Harsha,

I couldn't make it out till now, though i saw this much earlier

The below code can be implemented both in PBO and PAI but if in PAI after the LOOP and ENDLOOP of PAI

and if it is in PBO then before the LOOP at itab with control Tc and Endloop,

case ok_code.
when 'CREA'
describe table itab lines tc-lines." This give the total number of records
read table itab into tmp_wa index tc-lines." The tmp_wa contains last row of the itab.
This means you also have copied the 2 columns from previous row.

data :  line type sy-index.
line = tc-lines + 1.

insert tmp_wa into itab index line. " Means Next row.

Now here as you just want first 2 columns only clear tmp_wa-col3, col4 etc "before the Insert statment

" This is not a syntax checked one so need to fine tuen and just an Idea only
endcase.

IF you want to copy earlier 2 columns and insert next row inbetween 2 existing rows
then your Current row is as mentioned in the earlier post
" NO = TC-CURRENT_LINE + LINE - 1. " The line on which you Click in Internal Table
now you can insert at this position the same procedure applicable here also like READ TABLE ITAB INDEX NO " NO here.
Hope this serves your purpose.

0 Kudos

Thanks for the replies. I have solved that portion. Whenever I add a row and enter some data in table row and I

am unable to save the row data into a itab as its either gives me a blank row or existing row being copies.

Please help me save the current row instead of previous row or blank row.

Regards,

Harsha

0 Kudos

Between chain endchain insert a new module like below

chain.

field a1.

.

.

.

.

MODULE modify_data ON CHAIN-REQUEST.

endchain

code for modify_data

MODIFY itab

INDEX table_ctrl-current_line.

Former Member
0 Kudos

Hi,

In PAI write the below code :


Loop at it_tab.
module modify.
endloop.

Form Module_modify.
Modify it_tab from wa_tab line tc-current line.
Endform.

Regards

Arbind

0 Kudos

Dear Ramchander,

Use the code like below reference :

in PAI.

loop at itab.

chain.

field tblctrl-field1.

field tblctrl-field2.

field tblctrl-field3.

field tblctrl-field4.

field tblctrl-field5.

module modify_itab on chain-request.

endchain.

endloop.

now use the logic of modify_itab as follows :

module modify_itab.

data : selline type sy-tabix. "Get the cursor line where you want to insert.

get cursor line selline.

modify itab from tblctrl index selline.

endmodule.

hope this will work for you.

0 Kudos

IN the table control i am greying all the columns at PBO level. Whenever user uses OK_code to create a record

I want input to be enable on the next row and rest of existing records should be remain greyed.

Basically, I want to grey rows wise, as of now i am using tblctl-cols and column to grey the columns, is there any

way to grey the rows also ?

Thanks,

Harsha

0 Kudos

Dear Harsha,

Use the logic like below :

IN PBO.

loop at itab with control tc.

module modify_screen.

endlooop.

module modify_screen.

if itab-column1 is not initial.

loop at screen.

if screen-name = 'ITAB-COLUMN1'.

screen-active = 0.

endif.

endloop.

endif.

endmodule.

Do this for your required columns.

Hope it will solve ur problem.

0 Kudos

Thanks for the reply.

I am unable to loop at itab with control TBL200 ( within single quote also tried) is not working.

Giving me syntax error and using 4.6c.

Regards,

Harsha

0 Kudos

Dear Harsha,

Try the coding like below :

If you want to disable a perticular line in a table control then first gets the cursor position of it like,

GET CURSOR LINE VLINE.

then in PROCESS BEFORE OUTPUT use the code like,

LOOP AT ITAB

INTO ITAB "Here I took ITAB with header line

WITH CONTROL TBLCTRL

CURSOR TBLCTRL-CURRENT_LINE.

MODULE ROW_SCREEN_SETTINGS.

ENDLOOP.

now in the module ROW_SCREEN_SETTING use the following code like,

module ROW_SCREEN_SETTINGS output.

data : wa2 type SCXTAB_COLUMN.

IF TBLCTRL-CURRENT_LINE EQ VLINE.

LOOP AT SCREEN.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDLOOP.

endif.

endmodule.

here also you choose your desired screen column that you want to disable, only you have to add a if statement in loop at screen , like if screen-name = 'COL1'

screen-input = 0.

modify screen.

endif.

This will solve your problem.

Edited by: CONTACTSANKU on May 28, 2010 12:42 PM

0 Kudos

It didnt solve my problem. The moment I use ok_code to increment the row, the rest of rows screen-input = 1 along

with new row. I want only the last row to be input enabled.

Hope you got my point.

Regards,

Harsha

0 Kudos

I am calling a screen using CALL SCREEN 200 STARTING AT 2 5 ENDING AT 120 20.

This is could be reason for not able grey the data cells in a table control, please help.

Regards,

Harsha

Former Member
0 Kudos

Solved myself.