Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to modify changes of table control data in PAI

I have a table control where the columns are brought by dict fields.I am able to bring data into table control through an itab.

Now what i want is whenever user edits data in table control and clicks on save button the corresponding changes should be made in database.

For this according to my understanding we need to (in PAI) modify the changes in itab from the table control and then in SY-UCOMM of SAVE button we need to update in database table using itab.

For this , I am not able to write code for modifying the changes in itab from table control. Here is my code below.Please tell me how to do this.

PROCESS BEFORE OUTPUT.
 MODULE FILL_DATA.
 LOOP AT ITAB INTO ZEMPLOYEE_MASTER WITH CONTROL EMPTABLE CURSOR
EMPTABLE-CURRENT_LINE.
 ENDLOOP.
 MODULE STATUS_0001.
*
PROCESS AFTER INPUT.
 LOOP AT ITAB.
   MODULE MODIFY_ITAB.
 ENDLOOP.
 MODULE USER_COMMAND_0001.

REPORT  ZDATA_FORM1.

TABLES: ZEMPLOYEE_MASTER.

CONTROLS EMPTABLE TYPE TABLEVIEW USING SCREEN 0001.

data: begin of itab occurs 0,
       emp_no like zemployee_master-emp_no,
       name like zemployee_master-name,
       city like zemployee_master-city,
      end of itab,
      rowno TYPE I VALUE 1.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0001 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0001 INPUT.
  MESSAGE 'Inside INPUT' TYPE 'I'.
 CASE SY-UCOMM.
   WHEN 'SAVE'.
     UPDATE zemployee_master.
   WHEN 'EXIT'.
     LEAVE PROGRAM.
 ENDCASE.
ENDMODULE.                 " USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*
*&      Module  fill_data  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE fill_data OUTPUT.
  select emp_no name city from zemployee_master into TABLE itab ORDER BY emp_no.
  Describe table itab lines EMPTABLE-LINES.
ENDMODULE.                 " fill_data  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  modify_itab  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE modify_itab INPUT.
* MODIFY itab from zemployee_master index
* MESSAGE 'Inside modify_itab' TYPE 'I'.
ENDMODULE.                 " modify_itab  INPUT

Former Member replied

Hi

simply declare another Internal table of type dictionary table then

loop at itab into wa.
move-corresponding wa to jtab " JTAB is of type dictionary
append jtab 
endloop.
now use 

MODIFY DBTAB FROM TABLE JTAB " Check the syntax

Take care of the consistency of the data in database as you are updating only 5 fields of the database table 
use all primary key fields in the update statements else you end up in inconsistent data

Cheerz

Ram

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question