awk help required

Hello, I am trying to get an output from awk and have been unsuccessful so far.
There is an input file which contains certain segments, that needs to be read and append with another data after matching the segment...

Input file is as shown below

ISA*00*          *00*          *01*781495650      *14*003306750INT   GS*FA*122092406*003306750*130318*1701*2408*X*002040
ST*997*0001
AK1*SH*3525
AK2*856*0001
AK5*A
AK9*A*1*1*1
SE*6*0001
ST*997*0002
AK1*SH*3526
AK2*856*0001
AK5*A
AK9*A*1*1*1
SE*6*0002
ST*997*0003
AK1*SH*3527
AK2*856*0001
AK5*A
AK9*A*1*1*1
AK1*SH*3528
AK2*856*0001
 
 

I am trying to get the output as

ISA*00*          *00*          *01*781495650      *14*003306750INT   GS*FA*122092406*003306750*130318*1701*2408*X*002040
ST*997*0001
AK1*SH*3525*1234
AK2*856*0001
AK5*A
AK9*A*1*1*1
SE*6*0001
ST*997*0002
AK1*SH*3526*5679
AK2*856*0001
AK5*A
AK9*A*1*1*1
SE*6*0002
ST*997*0003
AK1*SH*3527*3436
AK2*856*0001
AK5*A
AK9*A*1*1*1
AK1*SH*3528*8759
AK2*856*0001

My Unix shell script is reading first the AK1 segment from the original file,gets 3525 and lookup in another file where it gets 1234 now all I need is to append this new number (1234) to 3525. Here is what the awk script looks like

awk '
        BEGIN { OFS = "*" }
        $0 !~ /^AK1/ { print $0 }
        /^AK1/ { print $0, $DEL_NUM }' $A997_FILE >> new file

This DEL_NUM will contain the 1234, 5679, 3436 and 8759.

Thank you for all your help!!

-R

Assign it to an awk variable and print it:

awk -v D="$DEL_NUM" ' 
        BEGIN { OFS = "*" }
        $0 !~ /^AK1/ { print $0 }
        /^AK1/ { print $0, D }' $A997_FILE
awk '
        BEGIN { OFS = "*" }
        $0 !~ /^AK1/ { print $0 }
        /^AK1/ { print $0, "'$DEL_NUM"' }' $A997_FILE >> new file