Find a string and print all lines upto another string

Ok I would like to do the following

file test contains the following lines. between the lines ABC there may be any amount of lines up to the next ABC entry.
I want to grep for the filename.txt entry and print the lines in between (and including that line) up to and including the last line before the next ABC
I want do this so I could also specify filename3.txt and get all 4 lines in between.
All help much appreciated.

ABC  4 5 filename.txt 3
line 1 2 3 4 5 
line 1 2 3 4 5
ABC 4 5 filename2.txt 5
line 1 2 3 4 6 
ABC 6 6 filename3.txt 6
line 1 2 3 4 5 
line 3 4 5 6 7
line 5 6 6 7 8
line 4 3 2 1 3
ABC 4 3 filename44.txt 5

any ideas?

---------- Post updated at 04:15 PM ---------- Previous update was at 03:40 PM ----------

Think I've got it

 awk '/string_to_search/ {a=1;next} /ABC/{f=0} f {print}'

With the correct order you can save a next :

awk '/ABC/ {f=0} ($0 ~ search) {f=1} f' search="filename3"

or

awk '/ABC/ {f=0} f; ($0 ~ search) {f=1}' search="filename3"

MadeInGermany,

I cannot get your script to work.

I am having to loop what I have in my filename.txt search

so I am doing a

for file in `cat filename`
do
awk '/ABC/ {f=0} ($0 ~ search) {f=1} f' search="$file" /anotherfile,txt
done

this fails with

awk: /ABC/ {f=1} (./fragfind ~ search (f=1) f
awk:                ^ syntax error

Please use code tags as required by forum rules!

I'm pretty sure

awk '/ABC/ {f=0} ($0 ~ search) {f=1} f' search="$file" /anotherfile,txt

will give the error message

awk: /ABC/ {f=1} (./fragfind ~ search (f=1) f
awk: ^ syntax error

Are you sure you have the quoting correct? And, the comma in the filename? And, why do you assign 1 to f twice?