Hi Tobias,
Memory IDs are basically pointers and are used to make temporary (in-memory) data accessible across programs. You can't directly read data created in one program (in this case an SD program) from another (in this case a CO program), so you assign the value you want to read to a specific memory location designated by the memory ID and then read that. Your requirement is itself a good example.
This is deep ABAP territory, so an ABAP developer would be able to provide more detailed and more accurate information.
I hope this helps.
Best wishes.