2006 Aug 28 4:12 AM
Hi All..
I need to find out a particular line of Z-Table and modify that line..
How to do it ...???
Ex: Ztable contains 4 fields and one among is 'Ticket No'. Let assume that table contains 100 Records..
I want to modify the particular line where Ticket no= 10.
2006 Aug 28 4:15 AM
Hi,
If you are planning to modify the ZTABLE then do the following..
1) SELECT SINGLE * FROM ZTABLE
WHERE TICKET_NO = '10'.
ZTABLE-FIEL2 = 'ABC'.
MODIFY ZTABLE.
2) UPDATE ZTABLE SET FIELD2 = 'ABC'
WHERE TICKET_NO = '10'.
If you are planning to modify the internal table of the ZTABLE.
SELECT * FROM ZTABLE INTO ITAB.
READ TABLE ITAB WITH KEY TICKET_NO = '10'.
IF SY-SUBRC = 0.
V_TABIX = SY-TABIX.
ITAB-FIELD2 = 'ABC'.
MODIFY ITAB INDEX V_TABIX
TRANSPORTING FIELD2.
ENDIF.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
2006 Aug 28 4:15 AM
Hi,
If you are planning to modify the ZTABLE then do the following..
1) SELECT SINGLE * FROM ZTABLE
WHERE TICKET_NO = '10'.
ZTABLE-FIEL2 = 'ABC'.
MODIFY ZTABLE.
2) UPDATE ZTABLE SET FIELD2 = 'ABC'
WHERE TICKET_NO = '10'.
If you are planning to modify the internal table of the ZTABLE.
SELECT * FROM ZTABLE INTO ITAB.
READ TABLE ITAB WITH KEY TICKET_NO = '10'.
IF SY-SUBRC = 0.
V_TABIX = SY-TABIX.
ITAB-FIELD2 = 'ABC'.
MODIFY ITAB INDEX V_TABIX
TRANSPORTING FIELD2.
ENDIF.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
2006 Aug 28 4:16 AM
Hi,
SELECT SINGLE * FROM ZTABLE
WHERE TICKET_NO = '10'.
UPDATE ZTABLE SET field2 = '122'
WHERE TICKET_NO = '10'.
Take all the values into one internal table and then modify taht line by reading that partcular fioled value where ticket no = '10'
Hope this helps.
Cheers,
SImha.
2006 Aug 28 4:30 AM
Changing Lines Column by Column>>
To change certain columns in the database table, use the following for lines:
UPDATE target SET set1 set2 ... [WHERE cond].
Overwriting Individual Lines with Work Areas>>
To overwrite a single line in a database table with the contents of a work area, use the following for lines:
UPDATE target FROM wa.
Overwriting Several Lines Using an Internal Table>> To overwrite several lines in a database table with the contents of an internal table, use the following for lines:
UPDATE target FROM TABLE itab.
The contents of the internal table itaboverwrite the lines in the database table dbtab that have the same primary keys. The same rules apply to the line type of itab as to the work area wa described above.
Inserting or Changing Several Lines
To insert or change several lines in a database table, use the following for lines:
MODIFY target FROM TABLE itab.
Regards,
Vishal