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

updating record using table contorl

Former Member
0 Likes
393

hi ABAPers,

i have a problem while updating the record to a database table from table control,

please,check the code writtern,

Code in Top include:

Tables: MARA,

MAKT.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

SPRAS LIKE MAKT-SPRAS,

MAKTX LIKE MAKT-MAKTX,

END OF ITAB.

*data:ok_code(20).

CONTROLS TC1 TYPE TABLEVIEW USING SCREEN 2000.

*

*DATA: cols LIKE LINE OF TC1-cols,

  • lines TYPE i.

Screen_1000:Code in PAI:

module USER_COMMAND_1000 input.

CASE SY-UCOMM.

WHEN 'DISPLAY'.

SELECT SPRAS MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR = MARA-MATNR.

IF SY-DBCNT IS INITIAL.

MESSAGE I127(ZKC_MSGCLS).

ELSE.

SET SCREEN 2000.

ENDIF.

WHEN 'EXIT'.

LEAVE PROGRAM.

SET SCREEN 0.

ENDCASE.

endmodule. " USER_COMMAND_1000 INPUT

Screen_2000:Code in PBO:

module ctrl_pai output.

MOVE-CORRESPONDING ITAB TO MAKT.

endmodule. " ctrl_pai OUTPUT

Screen_2000:Code in PAI:

module USER_COMMAND_2000 input.

CASE SY-UCOMM.

WHEN 'UPDATE'.

  • LOOP AT TC1-cols INTO cols WHERE index GT 2.

  • IF cols-screen-input = '0'.

  • cols-screen-input = '1'.

  • ELSEIF cols-screen-input = '1'.

  • cols-screen-input = '0'.

  • ENDIF.

  • MODIFY TC1-cols FROM cols INDEX sy-tabix.

  • ENDLOOP.

WHEN 'EXIT'.

LEAVE PROGRAM.

SET SCREEN 0.

WHEN 'BACK'.

SET SCREEN 1000.

ENDCASE.

endmodule. " USER_COMMAND_2000 INPUT

Screen_2000:Code outside PBO

LOOP AT itab WITH CONTROL TC1 CURSOR TC1-TOP_LINE.

MODULE ctrl_pai.

ENDLOOP.

Screen_2000:Code outside PAI

LOOP AT itab.

ENDLOOP.

regards,

vinod

3 REPLIES 3
Read only

sourabhshah
Product and Topic Expert
Product and Topic Expert
0 Likes
369

Hi,

Check out this demo program..it will help you

demo_dynpro_tabcont_loop_at

Regards,

Sourabh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
369

Hi,

Go thro' the coding in this link.It will help you.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table%20c...

Message was edited by:

Jayanthi Jayaraman

Read only

Former Member
0 Likes
369

hai

u want to update the database with respect to the value present in the table control.

use this syntax.

loop at it_tctable.

updata zdatabase .......

endloop.