Macro messes up CDR

I’m trying to simplify my Dialplan structure, with macro’s.
I have gotten the Macro syntax down, and everything works. Except it messes up the dst in the CDR’s
Instead of the dest number, it shows s. I read somewhere that you can use ${MACRO_EXTEN} variable, but even that does nothing.
This is the cli output when I use this macro.

– Executing [00298202020@External:1] Gosub(“SIP/sipa-0006f668”, “dialInt,s,1(00298202020,voxbeam,net2phone,callwithus,0011101,99900,*31)”) in new stack
– Executing [s@dialInt:1] MSet(“SIP/sipa-0006f668”, “LOCAL(ext)=”) in new stack
– Executing [s@dialInt:2] MSet(“SIP/sipa-0006f668”, “LOCAL(trunk1)=provider 1”) in new stack
– Executing [s@dialInt:3] MSet(“SIP/sipa-0006f668”, “LOCAL(trunk2)=provider2”) in new stack
– Executing [s@dialInt:4] MSet(“SIP/sipa-0006f668”, “LOCAL(trunk3)=provider3”) in new stack
– Executing [s@dialInt:5] MSet(“SIP/sipa-0006f668”, “LOCAL(rate1)=dialprefix1”) in new stack
– Executing [s@dialInt:6] MSet(“SIP/sipa-0006f668”, “LOCAL(rate2)=dialprefix2”) in new stack
– Executing [s@dialInt:7] MSet(“SIP/sipa-0006f668”, “LOCAL(rate3)=dialprefix3”) in new stack
– Executing [s@dialInt:8] MSet(“SIP/sipa-0006f668”, “LOCAL(EXTEN)=s”) in new stack
– Executing [s@dialInt:9] MSet(“SIP/sipa-0006f668”, “LOCAL(EXTEN)=s”) in new stack
– Executing [s@dialInt:10] NoOp(“SIP/sipa-0006f668”, “”) in new stack
– Executing [s@dialInt:11] MSet(“SIP/sipa-0006f668”, “CALLERPRES()=allowed”) in new stack
– Executing [s@dialInt:12] MSet(“SIP/sipa-0006f668”, “CDR(amaflags)=billing”) in new stack
– Executing [s@dialInt:13] MSet(“SIP/sipa-0006f668”, “CDR(accountcode)=“To-Int””) in new stack
– Executing [s@dialInt:14] Set(“SIP/sipa-0006f668”, “CALLERID(all)=+354”) in new stack
– Executing [s@dialInt:15] Set(“SIP/sipa-0006f668”, “LOCAL(EXTEN)=”) in new stack
– Executing [s@dialInt:16] SIPAddHeader(“SIP/sipa-0006f668”, “P-Asserted-Identity: sip:+3546921503@46.22.96.14:5060”) in new stack
– Executing [s@dialInt:17] Dial(“SIP/sipa-0006f668”, “SIP/voxbeam/,60,Ttr”) in new stack

I notice that on two occations Local(EXTEN)=s might be causing this but this is something that the Macro does by it self.

This is how my Macro looks

macro dialInt (ext,trunk1,trunk2,trunk3,rate1,rate2,rate3) {

            CALLERPRES()=allowed;
            CDR(amaflags)=billing;
            CDR(accountcode)="To-Int";
            Set(CALLERID(all)=+354${CALLERID(num)});
            SipAddHeader(P-Asserted-Identity: <sip:${CALLERID(num)}@<IP ADDRESS>:5060>);
            Dial(SIP/${trunk1}/${rate1}${EXTEN:2},60,Ttr);
            switch(${DIALSTATUS}) {
            case CONGESTION:
            Dial(SIP/${trunk2}/${rate2}${EXTEN:2},60,Ttr);
            case CHANUNAVAIL:
            Dial(SIP/${trunk2}/${rate2}${EXTEN:2},60,Ttr);  
    };
    switch(${DIALSTATUS}) {
            case CONGESTION:
            Dial(SIP/${trunk3}/${rate3}${EXTEN:2},60,Ttr);
            case CHANUNAVAIL:
            Dial(SIP/${trunk3}/${rate3}${EXTEN:2},60,Ttr);
    };
    Hangup();

return;
}

Macros are deprecated, and have been for about half a decade.

In any case, AEL implements macros as dialplan subroutines. I presume that s is an artefact of how it does that.

If you want to preserve the called number, call subroutine explicitly, using the context for the name and passing it the extension, unchanged.