‎2015 Nov 15 4:15 PM
Hi,
I am creating the IDOC from RFFOEDI1 . In data table E1IDT01 segment is not there. So from the user exit EXIT_SAPLIEDP_002, I am inserting segment E1IDT01 to EDIDD_TABLE at the current index as below. When I see the IDOC from WE02 , the status is coming as 26 which is IDOC has errors and status records are filling as 'Get Details from previous status records with status 26' .
My Coding to insert segment is as below.
create_segment_e1idt01
TABLES P_EDIDD_TABLE STRUCTURE EDIDD
USING P_SEGMENT_DATA LIKE EDIDD-SDATA
p_reguh_data TYPE REGUH.
DATA: lv_idoctype TYPE edi_iapi00-idoctyp.
DATA: lt_edi_iapi02 TYPE STANDARD TABLE OF edi_iapi02 WITH HEADER LINE.
DATA: ls_e1idt01 TYPE e1idt01.
DATA: lv_compl .
DATA: lv_tabix TYPE sy-tabix.
FIELD-SYMBOLS: <l_idocs> TYPE edidd.
DATA: lv_nr TYPE posno.
DATA: lv_email(130) TYPE C,
lv_intad TYPE lfb1-intad,
lv_smtp_addr TYPE adr6-smtp_addr.
lv_idoctype = 'PEXR2001' .
CHECK P_REGUH_DATA-ZBUKR = '123' .
READ TABLE p_edidd_table WITH KEY segnam = 'E1IDT01' .
IF sy-subrc NE 0 .
** If there is no record then add vendor email address in to the segment E1IDT01 .
CALL FUNCTION 'IDOCTYPE_READ'
EXPORTING
pi_idoctyp = lv_idoctype
pi_check_authority = ' '
TABLES
pt_syntax = lt_edi_iapi02
EXCEPTIONS
object_not_found = 1
db_error = 2
no_authority = 3
OTHERS = 4
.
IF sy-subrc <> 0.
EXIT.
ELSE.
READ TABLE lt_edi_iapi02 WITH KEY segtyp = 'E1IDT01' .
IF sy-subrc <> 0 .
EXIT.
ELSE.
lv_nr = lt_edi_iapi02-nr .
ENDIF.
ENDIF.
** Identify the exact index no. where to insert the new segment.
LOOP AT p_edidd_table ASSIGNING <l_idocs> .
lv_tabix = sy-tabix.
READ TABLE lt_edi_iapi02 WITH KEY segtyp = <l_idocs>-segnam.
IF lt_edi_iapi02-nr > lv_nr AND lv_compl = space.
lv_compl = 'X' .
ENDIF.
ENDLOOP.
** prepare the emailaddress.
p_edidd_table-segnam = 'E1IDT01'.
ls_e1idt01-txtvw = '0010' .
ls_e1idt01-txt01 = 'test_new_email@test.com' .
MOVE ls_e1idt01 TO p_edidd_table-sdata.
IF lv_compl = 'X' .
INSERT p_edidd_table INDEX lv_tabix.
ELSE.
APPEND p_edidd_table.
ENDIF.
ENDIF.
Could you please anyone help me in filling the segment int to IDOC data table at correct index and any thing need consider to filling the segment?
Thank you,
Praveen.
‎2015 Nov 15 7:48 PM
Hello,
If you see segments previous to segment E1IDT01, they are not mandatory segments except E1IDKU1 so logic to determine the exact position might not correct(It can include segments which are below the E1IDT01).
In my opinion, you can read the segments positions starting from E1IDKU3 ->E1IDKU4->E1IDKU5.
If any of those segment found then insert the segment E1IDT01 at previous position to it,
If first two segments (E1IDKU3 and E1IDKU4) are not there then segment E1IDKU5 must be there since it is mandatory segment.
‎2015 Nov 15 7:48 PM
Hello,
If you see segments previous to segment E1IDT01, they are not mandatory segments except E1IDKU1 so logic to determine the exact position might not correct(It can include segments which are below the E1IDT01).
In my opinion, you can read the segments positions starting from E1IDKU3 ->E1IDKU4->E1IDKU5.
If any of those segment found then insert the segment E1IDT01 at previous position to it,
If first two segments (E1IDKU3 and E1IDKU4) are not there then segment E1IDKU5 must be there since it is mandatory segment.
‎2015 Nov 16 7:57 AM
Hi Jitendar,
Thank you.
Identified the issue i.e. at line 46 in the above coding, Once I found the correct position, I should exit from the loop. otherwise last index number as new insert position index.
Thank you.
Praveen.