on 05-17-2006 12:46 AM
Hi Guys,
E1EDP04 is the segment which carries the tax code but it doesnt get populated for the PO Idoc.I am trying to push the segment contents in a User exit. There are 2 exits for a PO idoc..EXIT_SAPLEINM_002 which is called after every segment in the idoc and then there is exit EXIT_SAPLEINM_011 which gets executed after all the segments are populated.
Its getting difficult for me to insert the segment becoz of the uncertainity of the segments before and after it.so i often get syntax errors.has someone successfully implemented the tax code on orders05?can you please guide me
thanks
Hello Abaper,
I have done same thing in user exit "EXIT_SAPLMRMH_011".
Check below code for your reference..
*----
*
Internal table
*----
*
DATA: gt_tmp TYPE TABLE OF edidd.
*----
*
Work Area
*----
*
DATA: gw_temp TYPE edidd,
gw_temp1 TYPE edidd.
*----
*
Variables Declaration
*----
*
DATA: gv_e1edp01 TYPE e1edp01, " Document Item General Data
gv_e1edp02 TYPE e1edp02, " Document Item Reference Data
gv_e1edp04 TYPE e1edp04, " Document Item Taxes
gv_e1edk04 TYPE e1edk04, " Document header taxes
gv_mwskz TYPE e1edk04-mwskz, " VAT indicator
Begin of insert E20K901453
gv_mwsbt TYPE rtax1u12-fwste. " Tax Amount.
End of insert E20K901453
*----
*
Constant Declaration
*----
*
CONSTANTS:
gc_segnam_e1edk04 TYPE edidd-segnam VALUE 'E1EDK04',
gc_segnam_e1edp01 TYPE edidd-segnam VALUE 'E1EDP01',
gc_segnam_e1edp02 TYPE edidd-segnam VALUE 'E1EDP02',
gc_segnam_e1edp04 TYPE edidd-segnam VALUE 'E1EDP04'.
*----- Loop über IDOC-Segmente -
*
LOOP AT t_idoc_data .
**----- Moves abhängig vom Segmenttyp -
*
CASE t_idoc_data-segnam.
*----- ... IDoc: Document header taxes -
*
WHEN gc_segnam_e1edk04.
APPEND t_idoc_data TO gt_tmp.
*----- ... IDoc: Document Item General Data -
*
WHEN gc_segnam_e1edp01.
CLEAR : gv_e1edp01,
gv_e1edp02,
gv_e1edp04.
MOVE t_idoc_data-sdata TO gv_e1edp01.
APPEND t_idoc_data TO gt_tmp.
*----- ... IDoc: Document Item Reference Data -
*
WHEN gc_segnam_e1edp02.
MOVE t_idoc_data-sdata TO gv_e1edp02.
APPEND t_idoc_data TO gt_tmp.
*----- ... IDoc: Document Item Taxes -
*
WHEN gc_segnam_e1edp04.
MOVE t_idoc_data-sdata TO gv_e1edp04.
Find out new tax code from ekpo table at line item level
& Update line item tax code with new tax code.
MOVE gv_e1edp04-mwskz TO gv_mwskz.
SELECT SINGLE mwskz
FROM ekpo
INTO gv_e1edp04-mwskz
WHERE ebeln EQ gv_e1edp02-belnr
AND ebelp EQ gv_e1edp02-zeile.
MOVE : gv_e1edp04 TO t_idoc_data-sdata.
APPEND t_idoc_data TO gt_tmp.
Calculate new tax amount for line item
gv_mwsbt = gv_e1edp01-vprei * ( gv_e1edp04-msatz / 100 ).
Update header tax code with new tax code.
Check for header tax code & update it with line item tax code
LOOP AT t_idoc_data WHERE segnam EQ gc_segnam_e1edk04.
MOVE t_idoc_data-sdata TO gv_e1edk04.
IF gv_e1edk04-mwskz EQ gv_mwskz.
gv_e1edk04-mwskz = gv_e1edp04-mwskz.
READ TABLE gt_tmp INTO gw_temp WITH
KEY segnam = gc_segnam_e1edk04
sdata+0(3) = gv_mwskz.
Begin of change E20K901453
Record found with tax code, update record with new
tax code / tax amount
IF sy-subrc EQ 0.
MOVE: gv_mwsbt TO gv_e1edk04-mwsbt,
gv_e1edk04 TO gw_temp-sdata.
MODIFY gt_tmp FROM gw_temp INDEX sy-tabix
TRANSPORTING sdata
.
ELSE.
gv_e1edk04-msatz = gv_e1edp04-msatz.
CLEAR : gw_temp1.
READ TABLE gt_tmp INTO gw_temp1 WITH
KEY segnam = gc_segnam_e1edk04
sdata+0(3) = gv_e1edk04-mwskz.
if tax code record already exist in header then update with tax sum
IF sy-subrc EQ 0.
CLEAR : gv_e1edk04.
MOVE : gw_temp1-sdata TO gv_e1edk04.
gv_e1edk04-mwsbt = gv_e1edk04-mwsbt + gv_mwsbt.
MOVE gv_e1edk04 TO gw_temp-sdata.
Update sum of tax amount
MODIFY gt_tmp FROM gw_temp INDEX sy-tabix
TRANSPORTING sdata.
ELSE.
Else append new header tax segment with tax amount.
gv_e1edk04-mwsbt = gv_mwsbt.
MOVE gv_e1edk04 TO gw_temp-sdata.
APPEND gw_temp TO gt_tmp.
ENDIF. "IF sy-subrc EQ 0.
End of change E20K901453
ENDIF. "IF sy-subrc EQ 0.
ENDIF. "IF gv_e1edk04-mwskz EQ gv_mwskz
ENDLOOP. "LOOP AT t_idoc_data WHERE segnam EQ
If any other segment add as it is ..
WHEN OTHERS.
APPEND t_idoc_data TO gt_tmp.
ENDCASE. "CASE t_idoc_data-segnam.
ENDLOOP. "LOOP AT i_idoc_data.
Delete old data..
REFRESH : t_idoc_data.
Replace old data with new data with new tax codes
t_idoc_data[] = gt_tmp[].
Hope this will help you to solve your problem.
Cheers,
Nilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Perhaps you code something like this in user exits EXIT_SAPLEINM_002.
TABLES E1EDP04.
DATA H_LINES LIKE SY-TABIX.
...
CASE INT_EDIDD-SEGNAM.
WHEN 'E1EDP04'.
MOVE INT_EDIDD-SDATA TO E1EDP04.
IF NOT XEKPO-MWSKZ IS INITIAL.
E1EDP04-MWSKZ = XEKPO-MWSKZ.
MOVE E1EDP04 TO INT_EDIDD-SDATA.
DESCRIBE TABLE INT_EDIDD LINES H_LINES.
MODIFY INT_EDIDD INDEX H_LINES.
ENDIF.
...
ENDCASE.
Have you set the tax condition to S (Printing at totals level) in t/code V/08?
Hope this will help.
Regards,
Ferry Lianto
Please reward points if helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ferry,
thanks for the quick reply.
sadly the FM that populates ORDERS05 for a PO doesnt have the segment E1EDP04 in the code. its used in the SO world.not having the segment code is the problem for me since i am uncertain on what segments before or after will be populated and i cant append or modify or insert any.....location is a problem for me..once i know that one segment before or after E1EDP04 is going to be surely present i could go ahead and add it....any thoughts??
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.