Excuse skolusu, forget my last comment.
I finally need the records with 'A', 'B' and 'M' because after I have to update information at database. But, i don't understand why I have been cases where I obtain two record (one with a 'B' and the other with an 'M') diferent with the same key and the last 4 position different. When the key is the same and the last 4 position are diferent only must be write one only record with a 'M'.
Input file (after day)
xxxx027444740052
xxxx027444870443
xxxx027444900116
xxxx027445130443
xxxx027445260003
xxxx027445550091
xxxx027445710148
xxxx027446100443
xxxx027446230026
xxxx027446490054
xxxx027446520154
xxxx027447750443
xxxx027448270154
xxxx027448690037
xxxx027448720443
xxxx027448980037
xxxx027449080443
input file (before day)
xxxx027444160020
xxxx027444740052
xxxx027444870443
xxxx027444900116
xxxx027445130443
xxxx027445260003
xxxx027445550091
xxxx027445710148
xxxx027446100443
xxxx027446230026
xxxx027446490054
xxxx027446520052
xxxx027447750443
xxxx027448270154
xxxx027448690037
xxxx027448720443
xxxx027448980037
output
......
xxxx027446520052B
xxxx027446520154M
......
Do you know why happen? I need know it because If I do delete of record at database and after I want update database with the next record, I have a problem because the record not exist.
Thank you very much and excuse for my last comment