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

Looping a Z-Table

Former Member
0 Likes
835

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
703

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

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.

3 REPLIES 3
Read only

Former Member
0 Likes
704

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

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
703

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.

Read only

Former Member
0 Likes
703

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