Input 1 (always negative values)

A -2000

B -2500

B -2500

INPUT 2 (always zero or positive values)

A +100 280

A +200 280

A +300 281

A +400 282

A +500 283

A +600 288

A +700 290

B +100 280

B +200 280

B +300 281

B +400 284

B +500 284

B +600 290

B +700 299

B +800 300

A +200 280

A +300 281

A +400 282

A +500 283

A +600 288

A +700 290

B +100 280

B +200 280

B +300 281

B +400 284

B +500 284

B +600 290

B +700 299

B +800 300

Read (always negative) value against 'A' from INPUT1 and Start Reading 'A' records from INPUT2 from top to bottom till it covers (-ve from INPUT1 plus 'added up' +ve from INPUT2 is equal to or greater than zero). Once -ve value is fully covered, take value associated with the last read row, from the third column of INPUT2 and apply to all the rows previously read, leaving the remaining ('unread') rows intact.

Desired OUTPUT

A +100 288

A +200 288

A +300 288

A +400 288

A +500 288

A +600 288

A +700 290

B +100 299

B +200 299

B +300 299

B +400 299

B +500 299

B +600 299

B +700 299

B +800 300

A +200 288

A +300 288

A +400 288

A +500 288

A +600 288

A +700 290

B +100 299

B +200 299

B +300 299

B +400 299

B +500 299

B +600 299

B +700 299

B +800 300

Any suggestions/help is greatly appreciated. If this can be achieved in a multi-step SORT, that would be great! Otherwise, the only option would be COBOL Program with Arrays!