Hi Ming,
Use below method by code:
1. To activate program through code, use FM 'REPS_OBJECT_ACTIVATE' and pass program name to parameter 'object_name'.
2. Yes, table TRDIR is write protected. Instead you can use Database View 'PROGDIR'. Both use same DB table as base and this one is not write protected.
I used the below test code to verify and it worked fine for me. It might not be the best code practice but to it works fine to test.
DATA: wa_reposrc TYPE progdir. SELECT SINGLE * FROM progdir INTO wa_reposrc WHERE name = 'YRA_TEST2' AND state = 'I'. CHECK sy-subrc = 0. IF wa_reposrc-uccheck IS INITIAL. wa_reposrc-uccheck = 'X'. ENDIF. MODIFY progdir FROM wa_reposrc. CALL FUNCTION 'DB_COMMIT'. CALL FUNCTION 'REPS_OBJECT_ACTIVATE' EXPORTING object_name = 'YRA_TEST2' * OBJECT_TYPE = 'REPS' * EXCEPTIONS * NOT_EXECUTED = 1 * OTHERS = 2 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF.
Regards,
Ravi