I think it is already easier
What do you actually do with your zkey fields?
you only need
MATNR in E1MARAM
MATNR and WERKS in E1MARCM
MATNR and WERKS and LGORT for E1MARDM
If you want to keep your Zkey fields, then please do it this way:
Header Input (E1MARAM)
zkey1 matnr matkl
1 1000000001 001
Item data (E1MARCM)
zkey1 zkey2 matnr werks ekgrp
1 1 1000000001 0001 001
1 2 1000000001 1000 001
Sub item data (E1MARDM)
zkey1 zkey2 matnr werks lgort
1 1 1000000001 0001 0001
1 1 1000000001 0001 0002
1 2 1000000002 0001 0001
1 2 1000000002 0001 0002