Writing CDR

hi
i’m wondering if i can make asterisk write CDR to the Master.csv from a AGI secript by giving it the channel id i mean i want asterisk to commited this file so i can read the CDR from the same AGI scripts plz help me and thank u