t-code ZMM0127
infoset: ZMM_IDOC_READ_01
go to code:
AUTHORITY-CHECK OBJECT 'S_IDOCMONI'
ID 'ACTVT' FIELD '03'
ID 'EDI_DIR' FIELD edidc-direct
ID 'EDI_MES' FIELD edidc-mestyp
ID 'EDI_PRN' FIELD edidc-rcvprn
ID 'EDI_PRT' FIELD edidc-rcvprt
ID 'EDI_TCD' DUMMY.
CHECK sy-subrc = 0.
*add by zhiang zhang S20160808141051-BYJL-ACM99X
DATA l_e1edka1 TYPE e1edka1.
DATA l_sdata LIKE edid4-sdata.
IF edidc-direct = '2' AND edidc-mestyp = 'ORDERS'.
SELECT sdata INTO l_sdata FROM edid4
WHERE docnum = edidc-docnum
AND segnam = 'E1EDKA1'.
l_e1edka1 = l_sdata.
IF l_e1edka1-parvw = 'AG'.
customer = l_e1edka1-partn.
EXIT.
ENDIF.
ENDSELECT.
ENDIF.
*end by zhiang zhang S20160808141051-BYJL-ACM99X
*--Start by qihui 20171027 S20171020084240-EXJZ-ASB2UQ
DATA:l_roleid TYPE srrelroles-roleid,
l_objkey TYPE srrelroles-objkey,
BEGIN OF lt_idocrel OCCURS 0,
role_a TYPE idocrel-role_a,
END OF lt_idocrel.
CLEAR:docnum_rltd.
IF edidc-direct = '1'.
CLEAR:l_objkey,l_roleid,lt_idocrel[],lt_idocrel.
SELECT SINGLE roleid FROM srrelroles
INTO l_roleid
WHERE objkey = edidc-docnum
AND objtype = 'IDOC'
AND roletype = 'OUTIDOC'.
IF l_roleid IS NOT INITIAL.
SELECT role_a INTO TABLE lt_idocrel
FROM idocrel WHERE role_b = l_roleid.
IF lt_idocrel[] IS NOT INITIAL.
LOOP AT lt_idocrel.
SELECT SINGLE objkey FROM srrelroles
INTO l_objkey
WHERE roleid = lt_idocrel-role_a
AND objtype = 'IDOC'.
IF sy-subrc = 0.
docnum_rltd = l_objkey.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.