07-22-2008 12:41 PM
Hi,
I have added extra zfields for each line item of the delivery in VL02N. Once this delivery saved, these details will be saved in one ztable with reference to that delivery no.
Ex-1:
VL02N
Delivery Line items:
ItemNo. -- MaterialNo. -- qty -- units -- ZField1
00010 -- mat1 -- 5 -- gms -- 3
00020 -- mat2 -- 7 -- gms -- 5
In the above example1, for the idoc DELVRY05, i've extended with zfield1. I have placed the segment under E1EDL24(Delivery Item)(for zsegment, E1EDL24 is the parent segment).
After entering the line item values, & saved VL02N, it is saved in ztable, which contains the fields: delivNo.,ItemNo.,materialno.,zfield1.
I have written the following code in userexit EXIT_SAPLV56K_002:
&----
*& Include ZXTRKU02
&----
TABLES: ZDELTAG.
BREAK-POINT.
*Segment Delivery Item
DATA: I_E1EDL24 LIKE E1EDL24,
*Segment added under E1EDL24
I_ZPBDELV LIKE ZPBDELV.
*EDIDD-Data record (IDoc)
DATA: BEGIN OF S_IDOC_DATA OCCURS 0.
INCLUDE STRUCTURE EDIDD.
DATA: END OF S_IDOC_DATA.
*Constants
CONSTANTS: lc_E1EDL24 LIKE edidd-segnam VALUE 'E1EDL24',
lc_ZPBDELV like edidd-segnam value 'ZPBDELV'.
check segment_name = 'E1EDL24'.
CASE SEGMENT_NAME.
WHEN 'E1EDL24'.
IF control_record_out-cimtyp = 'DELVEXT'. "'DESADV'. " Message type
I_E1EDL24 = IDOC_DATA-SDATA.
*Assign ZPBDELV Segment to IDOC_DATA-SEGMENT.
IDOC_DATA-SEGNAM = lc_ZPBDELV.
SELECT SINGLE * FROM ZDELTAG.
IF SY-SUBRC EQ 0.
I_ZPBDELV-VBELN = ZDELTAG-VBELN.
I_ZPBDELV-POSNR = ZDELTAG-POSNR.
I_ZPBDELV-TAGNO = ZDELTAG-TAGNO.
ENDIF.
*Finally assign all the data to S_IDOC_DATA-sdata and Append to idoc_data.
S_IDOC_DATA-sdata = I_ZPBDELV.
S_IDOC_DATA-segnam = lc_ZPBDELV.
Append S_IDOC_DATA to idoc_data.
Clear S_IDOC_DATA.
Endif.
ENDCASE.
Idoc is generated with proper hierarchy is fine. Now structure looks as shown below:
Data records
-
E1EDL20
-
E1EDL24........(for 1st line item)
-
ZPBDELV-----(is the zsegment)
-
E1EDL25
-
E1EDL26
-
E1EDL27...
-
E1EDL24........(for 2nd line item)
-
ZPBDELV-----(is the zsegment)
-
E1EDL25
-
E1EDL26
-
E1EDL27...
************************************************************************
Now, my actual requirement is as shown below:
Ex-2:
VL02N
Delivery Line items:
ItemNo. -- MaterialNo. -- qty -- units -- ZField1
00010 -- mat1 -- 5 -- gms -- 1
-
2
-
3
-
4
-
5
-
6
00020 -- mat2 -- 7 -- gms -- 1
-
2
-
3
-
4
-
5
Above line item1 contains 6 zfield values. So in this case hw shall i see the idoc segment hierarchy? what code lines are required for this? can anybody share their experience...
tanx & rgds,
balu
07-23-2008 6:29 AM
08-13-2008 10:19 AM