Se usará el siguiente include ZXF05U01 y se pondrá lo siguiente :
IF sy-tcode EQ 'MK01' OR sy-tcode EQ 'MK02'.
*I_LFB1-BUKRS
*Primero se valida que el grupo de cuenta inicie con 'P'
IF i_lfa1-ktokk+0(1) = 'P'.
CLEAR ls_stcd1.
SELECT SINGLE a~stcd1 INTO ls_stcd1
FROM lfa1 AS a INNER JOIN lfb1 AS b ON
a~lifnr = b~lifnr
WHERE a~stcd1 = i_lfa1-stcd1 AND
b~bukrs = i_lfb1-bukrs.
*Si se crea acreedor
IF sy-subrc EQ 0 AND sy-tcode EQ 'MK01'.
MESSAGE 'Nº ident.fis.1 ya existe' TYPE 'E'.
ENDIF.
*Si se modifica acreedor
IF sy-tcode EQ 'MK02'.
SELECT SINGLE a~lifnr INTO ls_lifnr FROM lfa1 AS a INNER JOIN lfb1 AS b ON
a~lifnr = b~lifnr
WHERE a~stcd1 = i_lfa1-stcd1
AND a~lifnr = i_lfa1-lifnr
AND b~bukrs = i_lfb1-bukrs.
IF sy-subrc EQ 0.
ELSE.
SELECT SINGLE * FROM lfa1 WHERE stcd1 = i_lfa1-stcd1.
IF sy-subrc = 0.
MESSAGE 'Nº ident.fis.1 ya existe' TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.