‎2007 Jan 22 6:57 AM
Hi everyone,
I have an User Exit, which is being used by the main program to add certain segments to the IDOC and also to delete the unwanted one's.
According to my requirement i should populate the Sales Order details in Idoc segments only that of Finished Good's( MARA -MTART = Z030 ) and Sales Kit's ( Z070 ).and delete all other material type from idoc segments.
My problem is the User exit is working fine when the order is being created with only material types Z030 or Z070. but when ever we create an order with other material types it is also deleting two segments,both are header details( Sales district and Account assingnment group.Sales district is in segment E1EDK14 and Account assignment group is in E1EDK35.
Plz try to find the solution for this i am pasting the code below.
Code:
DATA: begin of e1edp19.
include structure e1edp19.
DATA: end of e1edp19,
wa_xvbap like vbap,
wa_idoc_data like edidd,
l_last_seg type i,
l_posnr like vbap-posnr.
IF dxvbak-auart = 'ZOR' and dxvbak-bstzd = 'SEBL'.
DESCRIBE TABLE int_edidd LINES l_last_seg.
READ TABLE int_edidd INDEX l_last_seg INTO wa_idoc_data.
IF wa_idoc_data-segnam = 'E1EDP19'.
l_posnr = wa_idoc_data-sdata(6).
read table xvbap into wa_xvbap with key mandt = sy-mandt.
LOOP at dxvbap into wa_xvbap where mandt = sy-mandt
and vbeln = dxvbak-vbeln
and posnr = dxvbap-posnr.
IF ( wa_xvbap-matwa <> wa_xvbap-matnr ).
-----add superseded material number -
clear int_edidd.
clear e1edp19.
int_edidd-segnam = 'E1EDP19'.
e1edp19-qualf = '013'.
e1edp19-idtnr = wa_xvbap-matwa.
-----fill internal table -
move e1edp19 to int_edidd-sdata.
append int_edidd.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
*end of changes for ADR 5434
*>>>+++ Start of Changes by
TABLES : e1edka3 .
DATA: begin of e1edp01.
include structure e1edp01.
DATA: end of e1edp01.
DATA: begin of e1edka1.
include structure e1edka1.
DATA: end of e1edka1.
DATA: begin of e1edk14.
include structure e1edk14.
DATA: end of e1edk14.
DATA: begin of e1edk35.
include structure e1edk35.
DATA: end of e1edk35.
DATA : l_sortl TYPE kna1-sortl .
DATA :
BEGIN OF lx_vbap ,
posnr TYPE vbap-posnr ,
matnr TYPE vbap-matnr ,
END OF lx_vbap ,
BEGIN OF lx_mara ,
matnr TYPE mara-matnr ,
mtart TYPE mara-matnr ,
END OF lx_mara .
DATA : w_index TYPE sy-index ,
w_idoc_data TYPE edidd ,
w_ktgrd TYPE vbkd-ktgrd .
CLEAR :
lx_mara ,
lx_vbap .
IF dobject-kschl = 'ZIES' .
CHECK dxvbak-auart EQ 'ZEX' .
DESCRIBE TABLE int_edidd LINES w_index .
READ TABLE int_edidd INDEX w_index INTO w_idoc_data .
Appending the Sales district to the Idoc
IF w_idoc_data-segnam = 'E1EDK14'.
MOVE w_idoc_data-sdata TO e1edk14 .
IF e1edk14-qualf = '012' .
w_idoc_data-segnam = 'E1EDK14' .
e1edk14-qualf = '020' .
IF NOT dxvbkd-bzirk IS INITIAL .
e1edk14-orgid = dxvbkd-bzirk .
MOVE e1edk14 TO w_idoc_data-sdata .
APPEND w_idoc_data TO int_edidd .
ELSE .
e1edk14-orgid = SPACE .
ENDIF .
CLEAR e1edk14 .
ENDIF .
ENDIF .
IF w_idoc_data-segnam = 'E1EDK18'.
Appending Customer Account group
SELECT SINGLE ktgrd
FROM vbkd
INTO w_ktgrd
WHERE vbeln = dxvbak-vbeln .
IF NOT w_ktgrd IS INITIAL .
w_idoc_data-segnam = 'E1EDK35' .
e1edk35-qualz = '20' .
IF w_ktgrd EQ 'Z1' OR w_ktgrd EQ 'Z3' .
e1edk35-cusadd = '625'.
ELSEIF w_ktgrd EQ 'Z2' .
e1edk35-cusadd = '630'.
ENDIF .
move e1edk35 TO w_idoc_data-sdata .
APPEND w_idoc_data TO int_edidd .
ENDIF.
ENDIF.
Deleting the materials other then Finished Goods and Sales Kit
IF w_idoc_data-segnam = 'E1EDP01'.
clear w_delete .
MOVE w_idoc_data-sdata TO e1edp01 .
SELECT SINGLE
posnr
matnr
INTO lx_vbap
FROM vbap
WHERE vbeln = dxvbak-vbeln
AND posnr = e1edp01-posex .
SELECT SINGLE
matnr
mtart
FROM mara
INTO lx_mara
WHERE matnr = lx_vbap-matnr
AND ( mtart = C_Z030 OR
mtart = C_Z070 ) .
IF lx_mara IS INITIAL .
w_delete = c_x.
DELETE int_edidd INDEX w_index .
CLEAR w_index .
ENDIF.
ELSEIF w_idoc_data-segnam = 'E1EDS01' .
clear w_delete .
ELSE .
IF w_delete = c_x .
DELETE int_edidd INDEX w_index .
ENDIF .
ENDIF .
ENDIF .
Thanks in advance.
‎2007 Jan 22 11:24 AM
Hi Praveen,
The problem is here. Here you are looking for material type C_Z030 or C_Z070. And deleting other material types.
SELECT SINGLE
matnr
mtart
FROM mara
INTO lx_mara
WHERE matnr = lx_vbap-matnr
AND ( mtart = C_Z030 OR
mtart = C_Z070 ) .
IF lx_mara IS INITIAL .
w_delete = c_x.
DELETE int_edidd INDEX w_index .
CLEAR w_index .
ENDIF.
Try to add or C_Z080 and create a material of type Z080 and check if it is deleting.
Then you can confirm the error is here.
Regards
Arun
‎2007 Jan 22 12:55 PM
HI Praveen,
Put a condition to check the SY-SUBRC and then go ahead with the condition to check IF lx_mara IS INITIAL.
IF SY-SUBRC IS INITIAL.
IF lx_mara IS INITIAL ....
Confirm if it solves your issue.
Regards,
Mayank
Reward Point if the post is helpful.