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

Insert, Delete and Update options in Table control

Former Member
0 Likes
1,197

Experts,

I have writen code for Insert, Delete and Update options in Table control. They are not working properly...

can any one send the code for the above please...

Thanks in advance..

2 REPLIES 2
Read only

Former Member
0 Likes
745

Hi ,

Like this u can write for insert and delete

In your PBO, you can adjust the field properties using the usual "loop

at screen." style logic - but with a table control, you just need to do

this inside the table control loop e.g. along the lines of this (not

syntax checked):

Screen flow PBO

loop at gt_data1 into gs_data1 with control gtc_9999.

module d9999_modify_screen_tc.

endloop.

PBO module

Module d9999_modify_screen_tc output.

if sy-ucomm eq 'INSERT'.

loop at screen. "for current row of TC

if screen-name = 'XYZ'. "for one cell

screen-input = 1.

endif.

modify screen.

endloop.

endif.

endmodule.

Regards,

Read only

Former Member
0 Likes
745

Hi,

Following steps will help you.

1.TOP-INCLUDE

DATA: ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA: ITAB2 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA: WA LIKE KNA1.

DATA: ANT TYPE I,CUR TYPE I.

DATA: OK_CODE TYPE SY-UCOMM.

CONTROLS: TABCTRL TYPE TABLEVIEW USING SCREEN 100.

IN FLOWLOGIC

PROCESS BEFORE OUTPUT.

LOOP AT ITAB1 CURSOR CUR WITH CONTROL TABCTRL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE CLEAR_DATA.

LOOP AT ITAB1.

MODULE MOVE_DATA.

ENDLOOP.

ADD “OK_CODE” IN ELEMENT LIST. CLICK ON LAYOUT AND ADD TABLE CONTROL(name it as TABCTRL) AND PUSHBUTTONS AS FOLLOWS.

SELECT THE FIELDS FROM PROGRAM. SAVE CHECK AND ACTIVATE.

CLICK ON FLOWLOGIC EDITOR FROM APPLICATION TOOL BAR.

DOUBLE CLICK ON MODULE “CLEAR_DATA”.

write the in this module as below.

CLEAR ITAB2. REFRESH ITAB2.

DOUBLE CLICK ON MODULE “MOVE_DATA”.

write the code in this module as below.

APPEND ITAB1 TO ITAB2.

ACTIVATE PAI AND WRITE THE CODE AS BELOW.

CASE OK_CODE.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB1 UP TO 20 ROWS.

TABCTRL-LINES = SY-DBCNT.

WHEN 'ADD'.

GET CURSOR LINE CNT.

CNT = TABCTRL-TOP_LINE + CNT - 1.

CLEAR WA.

INSERT WA INTO ITAB1 INDEX CNT.

WHEN 'MODIFY'.

GET CURSOR LINE CNT.

READ TABLE ITAB2 INDEX CNT.

LOOP AT ITAB2.

MODIFY KNA1 FROM ITAB2.

ENDLOOP.

SELECT * FROM KNA1 INTO TABLE ITAB1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

SAVE,CHECK AND ACTIVATE ALL.

CREATE TCODE AND EXECUTE.

contact if u hv any issues regarding this code.

reward points,if it is useful.

Thanks,

Chandu.