2008 Nov 19 1:57 PM
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.
2008 Nov 19 2:45 PM
Did you set a break-point in your function to see if it is executed at all (if not activate your exit in transaction CMOD first).
If it does stop you should be able to verify that the IDOC_DATA table has been updated. Instead of offsets you could also access the fields directly, which makes it more clear what you are changing.
e.g.
WHEN 'E1EDL24'.
ls_e1edl24 = idoc_data-sdata.
IF NOT ls_e1edl24-posnr is initial.
ls_e1edl24-YOUR_FIELD = ls_e1edl24-posnr.
L_41POSEX = ls_e1edl24-posnr.
* move the data back
idoc_data-sdata = ls_e1edl24.
ELSE.
You are saying that the external system is passing additional data which is not in the iDoc. Did you add fields to the standard segment to store the values? Because if you did it is not enough to populate the fields you would also have to take care of passing the values into the standard transaction, because the iDoc only looks at standard fields.
Hope that points you in the right direction,
Regards,
Michael
2008 Nov 19 2:45 PM
Did you set a break-point in your function to see if it is executed at all (if not activate your exit in transaction CMOD first).
If it does stop you should be able to verify that the IDOC_DATA table has been updated. Instead of offsets you could also access the fields directly, which makes it more clear what you are changing.
e.g.
WHEN 'E1EDL24'.
ls_e1edl24 = idoc_data-sdata.
IF NOT ls_e1edl24-posnr is initial.
ls_e1edl24-YOUR_FIELD = ls_e1edl24-posnr.
L_41POSEX = ls_e1edl24-posnr.
* move the data back
idoc_data-sdata = ls_e1edl24.
ELSE.
You are saying that the external system is passing additional data which is not in the iDoc. Did you add fields to the standard segment to store the values? Because if you did it is not enough to populate the fields you would also have to take care of passing the values into the standard transaction, because the iDoc only looks at standard fields.
Hope that points you in the right direction,
Regards,
Michael
2008 Nov 19 7:28 PM
Michael,
The user exit is activated and while I debug the structure is complete. I used WE19 to test the inbound and the strucutre is changed.. even in the standard fm... is another IDOC number assigned since it changed so much? I don't think so..
2008 Nov 19 7:35 PM
WE19 always creates a new iDoc number when you execute it. But anyway since the data is passed into the structure even in the standard function module the next question would be where do you want to store the data in the delivery from those additional fields? Are you taking care of passing the data into the delivery document in another user exit, because any additional non standard fields in the iDoc structure are NOT passed by standard.
So if the additional fields are populated in the iDoc structure but not filled in the delivery which was created they either 'get lost' somewhere during processing (for standard fields) or you don't pass them into the delivery (for non standard fields).
Hope that helps,
Michael
2008 Nov 20 3:49 AM
Hi,
You have written the code perfectly but you have missed 1 statement. You are receiving the IDOC into your userexit in the internal table INT_EDIDD and you have moved that data to a temporary internal table IDOC_DATA, you have modified the temporary internal table and you have never bothered to update the main internal table INT_EDIDD.
INT_EDIDD is the final internal table which is going to be replicated into the IDOC. Use the below statement after modify IDOC_DATA statement.
INT_EDIDD[] = IDOC_DATA[].
and that would solve your problem.
Thanks,
Mahesh.