cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC Error

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

replace

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

by


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

Regards,

Adi

Former Member
0 Kudos

Hi,

I have removed the mandt key but it is still showing the status error 26 and two segments are getting created.

Regards,

Sangeeta.

Edited by: Sangeeta on Oct 11, 2008 8:39 AM

Former Member
0 Kudos

hi,

put a break point in your user exit and then reprocess an idoc from WE19 in foreground in debugging

then placing either a watchpoing on idoc_data OR actually single stepping through the exit, you would be able to identify the bug

Regards,

adi

Former Member
0 Kudos

Hi Adi,

I debugged it and found out that the segment E1LFA1A is getting populated twice in idoc_data in the second run,i.e. when it is entering the exit second time.

So I added this piece of code at the end to remove duplicate entries from the idoc_data[] between case and endcase:

when 'E1LFA1A'.

sort idoc_data by segnam.

delete adjacent duplicates from idoc_data comparing segnam.

Now it is throwing me status error' EDI: IDoc has more than 1 syntax errors and

'EDI: Syntax error in IDoc (mandatory group missing)

Message no. E0079

Diagnosis

The segment group E1LFA1M has the attribute 'Mandatory' in the syntax description of the basic type CREMAS05 (customer enhancement ). However, the segment group is missing in the IDoc. The segment number logged in the status record identifies the item before which the segment group is missing.

The segments position of E1LFA1M and E1LFA1A' got interchanged.

Regards,

Sangeeta.

Former Member
0 Kudos

hi sangeeta,

DO NOT SORT idoc_data - because that will change the order of the segments defined in the idoc syntax and cause havoc as u are seeing now

Instead of delete duplicate, before you append the IDoc_data with segnam = 'E1LFA1A' - read IDOC_DATA with key segnam = 'E1LFA1A' and if sy-subrc <> 0 then append, else dont append since it's already present

please try this approach

regards,

adi

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Your existing code:

if sy-subrc 0.

append idoc_data.

else.

modify idoc_data[] from idoc_data transporting mandt segnam sdata.

endif.

Replace above code with:

if sy-subrc 0.

modify idoc_data[] from idoc_data transporting mandt segnam sdata.

else.

append idoc_data.

endif.

Former Member
0 Kudos

Hello,

Did you check for some OSS Note regarding this Error? Because, in my earlier requirement where one of the Segments was populating more than once, it was throwing an error with Status 26. So, I would suggest that you check for some OSS Note.

Alternatively, in your exit if you have some custom Code to include some Extended Fields, then check the Location (Parent Segment) where exactly you are adding the Custom Segment(s). Make sure to use Proper attributes such as INDEX addition while modifying the IDOC_DATA Table or it will overwrite the existing segments /records in the IDOC_DATA table.

Thanks and Regards,

Venkat Phani Prasad Konduri

former_member188685
Active Contributor
0 Kudos

some thing wrong with the below code. just remove the mandt in the key and see..


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

if sy-subrc ne 0.
append idoc_data.
else.
modify idoc_data[] from idoc_data transporting mandt segnam sdata.
endif.