Split single file into multiple files using pattern matching

I have one single shown below and I need to break each ST|850 & SE to separate file using unix script. Below example should create 3 files. We can use ST & SE to filter as these field names will remain same.

Please advice with the unix code.

ST|850
BEG|PO|1234
LIN|1|23
SE|4
ST|850
BEG|PO|234
LIN|1|43
LIN|1|41
SE|5
ST|850
BEG|PO|345
LIN|1|53
SE|4

Post is much too vague.

Please post:
What Operating System and version you are running and what Shell or Programming Language you normally use.

Please post:
Sample output to match your sample input and a brief explanation of the process.

Not the best solution...but should work
Considering file as your input file

i=1

while read LINE
do
    END_OF_FILE=`echo $LINE | awk -F "|" '{print $1}'`
    
    if [[ $END_OF_FILE != "SE" ]]
    then
        echo $LINE >> file_${i}
    else
        echo $LINE >> file_${i}
        
        i=`expr $i + 1`
    fi
done < file
awk '$1{print RS$0 > "file_"NR-1}' RS="ST" infile