Saturday, February 6, 2016

Table Manipulations



  • Deleting all records from database table
DELETE FROM <ztable-name>.
DELETE FROM <ztable-name> WHERE <field-name> EQ 'condition'.

  • Adding new records to an empty database table
If you are inserting new records, always use insert. When I used update, it didnot work.
LOOP AT lt_equip INTO lw_equip.
  INSERT ZEQUIP_SERNO FROM lw_equip.
CLEAR lw_equip.
ENDLOOP.
IF sy-subrc EQ 0.
     COMMIT WORK.

  ENDIF.

  • Update and Modify
Update means it is only modify the record.
UPDATE <Table> FROM <work_area>.
Modify means it going to modify the record if it exists. If record is not there it going to add that record. 
  • Commit Work
Commit work is needed to commit the changes to table immediately. The commit can be placed inside the after each insert, but it takes lot more time.
https://scn.sap.com/thread/157718



No comments:

Post a Comment