Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

IDOC Error

Hi experts,

In FM EXIT_SAPLKD01_001, I have implemented the user exit which takes adrnr field from the E1LFA1M segment and does a select query on adrct,adr6 and adrc tables and populate the fetched data in the segment E1LFA1A.

The data is getting populated correctly but the E1LFA1A segment is created twice and so I am getting error no. 20 stating "EDI: Syntax error in IDoc (too many repetitions of a segment)"

Please suggest how to solve the problem.

Is there any issue relating to modifying table.

For reference I am pasting my code here:

tables: edidd,

E1LFA1A,

E1LFA1M.

*-- Types Declaration

types: BEGIN OF typ_edidd,

mandt TYPE edidd-mandt,

docnum TYPE edidd-docnum,

segnum TYPE edidd-segnum,

segnam TYPE edidd-segnam,

psgnum TYPE edidd-psgnum,

hlevel TYPE edidd-hlevel,

dtint2 TYPE edidd-dtint2,

sdata TYPE edidd-sdata,

END OF typ_edidd.

*-- Data Declaration

data : l_remark type AD_REMARK1,

l_stdcom type AD_COMM,

l_adrnr type ADRNR,

l_email type AD_SMTPADR,

l_save_tabix type sy-tabix.

data: wa_idoc_data type typ_edidd.

CASE segment_name.

when 'E1LFA1M'.

E1LFA1M = idoc_data-sdata.

l_adrnr = E1LFA1M-adrnr.

select single remark

into l_remark

from adrct

where addrnumber = l_adrnr.

select single DEFLT_COMM

into l_stdcom

from adrc

where addrnumber = l_adrnr.

select single smtp_addr

into l_email

from adr6

where addrnumber = l_adrnr.

  • read table idoc_data into wa_idoc_data with key segnum = ' E1LFA1A'.

*

  • if sy-subrc = 0.

l_save_tabix = sy-tabix.

E1LFA1A = wa_idoc_data-sdata.

E1LFA1A-PSON1 = l_remark.

E1LFA1A-PSON2 = l_stdcom.

E1LFA1A-PSON3 = l_email.

clear idoc_data.

idoc_data-sdata = E1LFA1A.

  • append wa_idoc_data to idoc_data.

  • modify idoc_data from wa_idoc_data index l_save_tabix.

  • call function 'IDOC_REDUCTION_FIELD_REDUCE'

*

  • exporting

*

  • message_type = 'CREMAS'

*

  • segment_type = 'E1LFA1A'

*

  • segment_data = idoc_data-sdata

*

  • importing

*

  • segment_data = idoc_data-sdata.

  • modify idoc_data from wa_idoc_data index l_save_tabix.

  • append wa_idoc_data to idoc_data.

idoc_data-segnam = 'E1LFA1A'.

idoc_data-mandt = sy-mandt.

read table idoc_data transporting no fields with key mandt = sy-mandt segnam = 'E1LFA1A'.

if sy-subrc <> 0.

append idoc_data.

else.

modify idoc_data[] from idoc_data transporting mandt segnam sdata.

endif.

  • endif.

Former Member
Not what you were looking for? View more on this topic or Ask a question