Skip to Content
0
Former Member
Dec 15, 2006 at 06:36 AM

Updating database table using Table Control

24 Views

hi ABAPers,

i have a problem while updating the database table using table control,

please,check the code

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 PAI Code

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