Hi Anji,
To delete the log, you have to delete the text type for which the log has been maintained , i.e. A002(Log). This will delete A008 automatically.
data: lv_transaction_id TYPE crmt_object_id,
lv_guid TYPE crmt_object_guid,
lv_tdname TYPE string,
lt_data TYPE TABLE OF stxl,
ls_stxl TYPE stxl.
lv_transaction_id = 'your transaction id/opprtunity id /sales order id '.
SELECT SINGLE guid FROM crmd_orderadm_h INTO lv_guid WHERE object_id = lv_transaction_id.
lv_tdname = lv_guid.
CONCATENATE lv_tdname '%' INTO lv_tdname.
SELECT * FROM stxl INTO TABLE lt_data WHERE tdname LIKE lv_tdname AND tdid = 'A002'.
LOOP AT lt_data INTO ls_stxl.
DELETE FROM stxl CLIENT SPECIFIED
WHERE relid = 'TX'
AND mandt = sy-mandt
AND tdobject = ls_stxl-tdobject
AND tdname = ls_stxl-tdname
AND tdid = ls_stxl-tdid
AND tdspras = ls_stxl-tdspras.
ENDLOOP.