Application Development 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: 

delete data from my DB TABLE

Former Member
0 Kudos

Hallow I build a table in se11 that I can put on her data from my itab how can I clean the table before I put a new data. I try with delete but its not working and refresh given me an error that I have not a header line . what can I do. Thankes

DELETE yhr_ex_mushlach.

LOOP AT itab1.

SPLIT itab1 AT ',' INTO:

itab-id_number

itab-rama

itab-hagbla1

itab-date_start_hagbl

itab-date_stop_hagbla.

IF itab-id_number > 0 .

w_length = STRLEN( itab-id_number ).

w_length = w_length - 1.

itab-pernr = itab-id_number+0(w_length).

ELSE.

itab-pernr = 0.

ENDIF.

APPEND itab.

ENDLOOP.

loop at itab.

modify yhr_table_muslah from itab.

end loop.

1 ACCEPTED SOLUTION

rahulkavuri
Active Contributor
0 Kudos

hi i think u want to clear the Z TABLE and again enter new data into it...

Just follow this sample code....

DELETE FROM ZTABLE WHERE ACCNO <> 1.

<b>just identify a key field which will never be equal to a value, in the above statement ACCNO will never be equal to the value '1', so it will be cleared</b>

award points if found helpful, this worked fine in my case

8 REPLIES 8

rahulkavuri
Active Contributor
0 Kudos

hi i think u want to clear the Z TABLE and again enter new data into it...

Just follow this sample code....

DELETE FROM ZTABLE WHERE ACCNO <> 1.

<b>just identify a key field which will never be equal to a value, in the above statement ACCNO will never be equal to the value '1', so it will be cleared</b>

award points if found helpful, this worked fine in my case

Former Member
0 Kudos

I am assuming ITAB is of the same structure of YHR_TABLE_MUSLAH.

If that is the case, do this

<b>modify yhr_table_muslah from table itab.</b>

Regards,

Ravi

0 Kudos

HI RAVI I TRY IT BUT ITS NOT WORKING REGARDS

0 Kudos

HI RAVI I TRY IT BUT ITS NOT WORKING THIS WHAY REGARDS

0 Kudos

Do you have a COMMIT after the MODIFY statement?

Is it throwing a error?

Regards,

Ravi

0 Kudos

hi ravi no i dont have commit and it dont bring err but when i get a new file that i wont to put in yhr_table_muslh the table is full with old data

rahulkavuri
Active Contributor
0 Kudos

<b>DELETE yhr_ex_mushlach where PRIMARYKEY <> SPACE.</b>

this will erase the whole Z TABLE.

This should work if u want to just clear the Z TABLE.

If u want to insert data into the same table yhr_ex_mushlach then u can use this statement

<b>modify yhr_table_muslah from itab.</b>

Former Member
0 Kudos

try this code.

DELETE from yhr_ex_mushlach.

LOOP AT itab1.

SPLIT itab1 AT ',' INTO:

itab-id_number

itab-rama

itab-hagbla1

itab-date_start_hagbl

itab-date_stop_hagbla.

IF itab-id_number > 0 .

w_length = STRLEN( itab-id_number ).

w_length = w_length - 1.

itab-pernr = itab-id_number+0(w_length).

ELSE.

itab-pernr = 0.

ENDIF.

APPEND itab.

ENDLOOP.

before doing this sort the itab by the primary keys in your database table and delete itab by comparing the primary keys,

DELETE ADJACENT DUPLICATES FROM itab comparing <fields>

INSERT yhr_table_muslah FROM TABLE itab.

or you can use ths also

update yhr_table_muslah FROM TABLE itab.

Hope this will solve u r problem.

Thanks n regards