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

Table Control Insert

Former Member
0 Likes
2,246

Hi,

In a Table Control i have 2 columns .When i enter records in the control..it should get inserted to the Internal table..Can anyone pls help me with the example?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
901

DATA: BEGIN OF ITAB OCCURS 0,

COL1(5),

COL2(10),

END OF ITAB.

CONTROLS TC TYPE TABLEVIEW USING SCREEN 100.

PBO OF 100

LOOP AT ITAB WITH TC CURSOR TC-CURRENT_LINE.

MODULE DISPLAY_RECORDS.

ENDLOOP.

MODULE DISPLAY_RECORDS OUTPUT.

TC-COL1 = ITAB-COL1.

TC-COL2 = ITAB-COL2.

ENDMODULE.

PAI OF 100.

LOOP AT ITAB.

MODULE MODIFY_ITAB.

ENDLOOP.

MODULE MODIFY_ITAB INPUT.

CASE OKCODE.

WHEN 'ADD' OR ' '.

READ TABLE ITAB INDEX TC-CURRENT_LINE.

IF SY-SUBRC <> 0.

ITAB-COL1 = TC-COL1.

ITAB-COL2 = TC-COL2.

APPEND ITAB.

ELSE.

MODIFY ITAB.

ENDIF.

ENDCASE.

ENDMODULE.

7 REPLIES 7
Read only

Former Member
0 Likes
901

When you create the table control in se51, use the option, get from the program.

Use the internal table that has been already declared in the Module pool program, with the two columns you are talking about.

Read only

Former Member
0 Likes
902

DATA: BEGIN OF ITAB OCCURS 0,

COL1(5),

COL2(10),

END OF ITAB.

CONTROLS TC TYPE TABLEVIEW USING SCREEN 100.

PBO OF 100

LOOP AT ITAB WITH TC CURSOR TC-CURRENT_LINE.

MODULE DISPLAY_RECORDS.

ENDLOOP.

MODULE DISPLAY_RECORDS OUTPUT.

TC-COL1 = ITAB-COL1.

TC-COL2 = ITAB-COL2.

ENDMODULE.

PAI OF 100.

LOOP AT ITAB.

MODULE MODIFY_ITAB.

ENDLOOP.

MODULE MODIFY_ITAB INPUT.

CASE OKCODE.

WHEN 'ADD' OR ' '.

READ TABLE ITAB INDEX TC-CURRENT_LINE.

IF SY-SUBRC <> 0.

ITAB-COL1 = TC-COL1.

ITAB-COL2 = TC-COL2.

APPEND ITAB.

ELSE.

MODIFY ITAB.

ENDIF.

ENDCASE.

ENDMODULE.

Read only

Former Member
0 Likes
901

hi

in the PAI

module modify1.

MODULE modify1 INPUT.

IF sel1 = 'X'.

it_kna1-chk1 = 'X'.

MODIFY it_kna1 INDEX tc1-current_line.

ELSE.

CLEAR it_kna1-chk1.

ENDIF.

ENDMODULE.

MODULE user_command_0200 INPUT.

case sy-ucomm.

WHEN 'INSE'.

IF v_dynnr = '0300'.

CLEAR it_kna1.

APPEND it_kna1.

DESCRIBE TABLE it_kna1 LINES tc1-lines.

endcase.

MODULE user_command_0200 INPUT.

hope this helps,

priya

Read only

Former Member
0 Likes
901

hi suganya...

check out with these example programs in the following links...

http://m2.aol.com/skarkada/sap/table_control/table_control.htm

and also at:

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm

check out whether they help you...

regards,

Ananaya.S

Read only

Former Member
0 Likes
901

Hi

Herewith i am giving one link.Go throgh that its really a good example to overcome your problem.

http://m2.aol.com/skarkada/sap/table_control/table_control.htm

Thanks

Mrutyunjaya Tripathy

Read only

Former Member
0 Likes
901

Hi,

Check this Demo program on Table control <b>RSDEMO02</b>

Regards

Vijay

Read only

Former Member
0 Likes
901

HI,

Chek out this pdf for a simple tablecontrol:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf

MODULE EXTRACT_USERDATA INPUT.

CASE SAVE_CODE.

WHEN 'DELE'.

IF SELECTION IS INITIAL AND

confirmation = 'G'.

PERFORM TRANSFER.

ENDIF.

WHEN 'SAVE'.

PERFORM TRANSFER.

WHEN 'APND'.

PERFORM TRANSFER.

ENDCASE.

ENDMODULE. " EXTRACT_USERDATA INPUT

*&----


*& Form TRANSFER

*&----


  • text

*----


  • --> p1 text

  • <-- p2 text

*----


FORM TRANSFER.

CLEAR ITAB_PHONELIST.

ITAB_PHONELIST-NAME = RECORD-NAME.

ITAB_PHONELIST-PHONE = RECORD-PHONE.

ITAB_PHONELIST-EMAIL = RECORD-EMAIL.

APPEND ITAB_PHONELIST.

ENDFORM. " TRANSFER

Use the APPEND statement to add data to the internal table .

Use MODIFY <DBtable> from table <itab> if you want to modify ur dbtable.

Regards,

Anjali