Skip to Content
0
Former Member
Nov 19, 2008 at 01:57 PM

IDOC structure not changing

354 Views

Hello,

I am using IDOC_INPUT_DESADV1 for delivery inbound function module. I create an order, post goods issue and deliver. The standard outbound function module sends the complete IDOC to the external shipping system. The delivery is shipped and then the inbound delivery IDOC is sent back to SAP. The IDOC structure has only 4 fields which belong to the DELVRY03 - E1EDL20 segment. This is incomplete so I am using the user exit ZXTRKU12 which is called by CUSTOMER-FUNCTION '004' or EXIT_SAPLV55K_004 to take the original IDOC SAP sent and update the 4 fields that were sent by external shipping system. When I modify the structure it doesn't change... WHY????

Below is my code... search for 'use original structure' for the copy of the table

************************************************************************

*Tables *

************************************************************************

TABLES : EDIDD, EDIDC.

************************************************************************

*/Data Declaration *

************************************************************************

************************************************************************

*Constants *

************************************************************************

CONSTANTS:

C_SEGMENT LIKE EDISEGMHD-SEGTYP VALUE 'E1EDL20',

C_FIELD(5) VALUE 'VBELN'.

************************************************************************

*Internal tables *

************************************************************************

TYPES: BEGIN OF STRUC_PROT_LIST.

INCLUDE STRUCTURE EDIDC.

TYPES: SEGNUM TYPE EDI_SEGNUM,

END OF STRUC_PROT_LIST.

DATA: T_PROX LIKE PROTT OCCURS 100 WITH HEADER LINE.

DATA BEGIN OF P_IDOC_DATA OCCURS 0.

INCLUDE STRUCTURE EDIDD.

DATA: END OF P_IDOC_DATA.

DATA BEGIN OF P_IDOC_CONTRL OCCURS 0.

INCLUDE STRUCTURE EDIDC.

DATA: END OF P_IDOC_CONTRL.

DATA BEGIN OF WA_VBKOK OCCURS 0.

INCLUDE STRUCTURE VBKOK.

DATA: END OF WA_VBKOK.

DATA BEGIN OF IT_TLINE OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF IT_TLINE.

DATA: INT_EDISEGSTRU TYPE EDISEGSTRU OCCURS 0 WITH HEADER LINE.

DATA: WA_LIKP TYPE LIKP.

************************************************************************

*Variables *

************************************************************************

DATA: OFFSET1_1 TYPE I,

OFFSET1_2 TYPE I,

EXPLENG1_1 TYPE I,

EXPLENG1_2 TYPE I,

END1_1 TYPE I,

END1_2 TYPE I,

INT_EDIDC TYPE EDIDC OCCURS 100 WITH HEADER LINE,

INT_EDIDD TYPE EDIDD OCCURS 100 WITH HEADER LINE,

ANZ_INT_EDIDC TYPE I.

DATA: FOUND1_1 TYPE C, FOUND_1 TYPE C.

DATA: L_FIELD(1000) TYPE C,

L_VBELN LIKE LIKP-VBELN,

L_VSTEL LIKE LIKP-VSTEL,

L_BOLNR LIKE LIKP-LIFEX,

  • l_lifex(35) type C,

L_LIFEX LIKE KOMV-KWERT,

L_KBETR LIKE BDCDATA-FVAL,

L_MODE TYPE C VALUE 'N'.

DATA: L_DATUM LIKE SY-DATUM,

L_DOCNUM LIKE EDIDD-DOCNUM,

L_VSART LIKE LIKP-VSART,

L_VSBED LIKE LIKP-VSBED,

L_BEZEI LIKE T173T-BEZEI,

L_VTEXT LIKE TVSBT-VTEXT.

DATA: BEGIN OF WA_THEAD.

INCLUDE STRUCTURE THEAD.

DATA: END OF WA_THEAD.

DATA: L_TDID TYPE THEAD-TDID VALUE '0017',

L_LANG TYPE THEAD-TDSPRAS VALUE 'E',

L_TDNAME TYPE THEAD-TDNAME,

L_TDOBJECT TYPE THEAD-TDOBJECT VALUE 'VBBK',

L_41POSEX(6) TYPE C,

L_POSEX(6) TYPE C.

************************************************************************

OFFSET1_1 = 0.

OFFSET1_2 = 0.

FOUND1_1 = ' '.

FOUND_1 = ' '.

READ TABLE IDOC_DATA INDEX 1.

IF IDOC_DATA-SDATA IS INITIAL.

EXIT.

ELSE.

CLEAR : L_FIELD, L_VBELN, L_VSTEL, L_BOLNR, L_LIFEX, L_KBETR, L_DATUM,

L_DOCNUM.

L_DOCNUM = IDOC_DATA-DOCNUM.

MOVE IDOC_DATA-SDATA TO L_FIELD.

MOVE: L_FIELD+0(10) TO L_VBELN,

L_FIELD+10(4) TO L_VSTEL,

L_FIELD+150(50) TO L_BOLNR,

L_FIELD+218(50) TO L_LIFEX.

WRITE L_LIFEX TO L_KBETR LEFT-JUSTIFIED.

SHIFT: L_BOLNR LEFT DELETING LEADING 0,

L_KBETR LEFT DELETING LEADING 0.

SHIFT : L_BOLNR LEFT DELETING LEADING SPACE,

L_KBETR LEFT DELETING LEADING SPACE.

CONDENSE : L_BOLNR NO-GAPS,

L_KBETR NO-GAPS.

ENDIF.

CALL FUNCTION 'SEGMENT_READ'

EXPORTING

SEGMENTTYP = C_SEGMENT

TABLES

SEGMENTSTRUCTURE = INT_EDISEGSTRU

EXCEPTIONS

NO_AUTHORITY = 1

SEGMENT_NOT_EXISTING = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT INT_EDISEGSTRU.

IF INT_EDISEGSTRU-FIELDNAME = C_FIELD.

EXPLENG1_1 = INT_EDISEGSTRU-EXPLENG.

EXIT.

ENDIF.

OFFSET1_1 = OFFSET1_1 + INT_EDISEGSTRU-EXPLENG.

ENDLOOP.

OFFSET1_1 = OFFSET1_1 + 1.

END1_1 = OFFSET1_1 + EXPLENG1_1 - 1.

IF OFFSET1_1 IS INITIAL AND END1_1 IS INITIAL.

OFFSET1_1 = 1.

END1_1 = 1000.

ENDIF.

L_DATUM = SY-DATUM - 5.

SELECT * FROM EDIDC INTO TABLE INT_EDIDC

WHERE CREDAT LE SY-DATUM AND

CREDAT GE L_DATUM

AND DIRECT EQ '1'

AND STATUS EQ '03'

AND IDOCTP EQ 'DELVRY03'

AND MESTYP = 'DESADV'

AND RCVPOR = 'KEWILL'

ORDER BY PRIMARY KEY. " already sorted

DESCRIBE TABLE INT_EDIDC LINES ANZ_INT_EDIDC.

IF ANZ_INT_EDIDC <> 0.

LOOP AT INT_EDIDC.

CLEAR INT_EDIDD.

REFRESH INT_EDIDD.

CALL FUNCTION 'IDOC_READ_COMPLETELY'

EXPORTING

DOCUMENT_NUMBER = INT_EDIDC-DOCNUM

TABLES

INT_EDIDD = INT_EDIDD

EXCEPTIONS

DOCUMENT_NOT_EXIST = 1

DOCUMENT_NUMBER_INVALID = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT INT_EDIDD WHERE SEGNAM = C_SEGMENT.

SEARCH INT_EDIDD-SDATA FOR L_VBELN STARTING AT OFFSET1_1

ENDING AT END1_1.

IF SY-SUBRC = 0.

FOUND1_1 = 'X'.

EXIT.

ENDIF.

ENDLOOP.

ENDLOOP.

IF FOUND1_1 = 'X'.

  • IDOC_CONTROL = int_edidc.

IDOC_CONTROL-DOCNUM = L_DOCNUM.

IDOC_DATA-DOCNUM = L_DOCNUM.

REFRESH IDOC_DATA. CLEAR IDOC_DATA.

IDOC_DATA[] = INT_EDIDD[]. " use original structure

LOOP AT IDOC_DATA.

IDOC_DATA-DOCNUM = L_DOCNUM.

CASE IDOC_DATA-SEGNAM.

WHEN 'E1EDL24'.

IF NOT IDOC_DATA-SDATA+0(6) is initial.

IDOC_DATA-SDATA540(6) = IDOC_DATA-SDATA0(6).

L_41POSEX = IDOC_DATA-SDATA+0(6).

ELSE.

IDOC_DATA-SDATA+0(6) = L_POSEX + 10.

IDOC_DATA-SDATA+540(6) = L_POSEX + 10.

L_41POSEX = IDOC_DATA-SDATA+0(6).

ENDIF.

WHEN 'E1EDL41'.

IDOC_DATA-SDATA+62(6) = L_41POSEX.

ENDCASE.

MODIFY IDOC_DATA.

ENDLOOP.

ENDIF.