Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

user exit for IDOC in INVOICE

Former Member
0 Kudos
2,571

Hi all,

I need to add a value in a custom IDOC segment for INVOICE. The IDOC basic type used is INVOIC02. Is there any user exit which I can use to populate the IDOC data? Any help will be greatly appreciated.

Thanks,

Lalyn

1 ACCEPTED SOLUTION

Former Member
0 Kudos
316

Hi Sailesh,

But EXIT_SAPLVEDF_001 doesn't have a paramater EDIDD. Where will I put the fields in the extension?

Lalyn

10 REPLIES 10

Former Member
0 Kudos
316

Function: EXIT_SAPLVEDF_002

Enhancement: LVEDF001

Former Member
0 Kudos
316

This is an outbound INVOICE. The external need an additional segment that is not in transaction VL03N.

0 Kudos
316

Hi Lalyn,

Extend the basic type and add the additional field. In user exit, just pass that value.

sailesh

Former Member
0 Kudos
316

Hi Sailesh,

Can you please give me a sample code? I can't get the point where I would simply pass the value.

Thanks,

Lalyn

0 Kudos
316

Hi Lalyn,

I do not have an exact code for this.

But just go through the following code, where we are doing some validations in the segments.

  • Code below this line was to exclude ZRTN materials for which Subtotal 2 (KZWI2) is zero. And,

  • this is done for billing types:

  • ZEXP,

  • ZXAD,

  • ZXDR,

  • ZXL2,

  • ZXG2,

  • ZXPT.

IF INT_EDIDD-SEGNAM = 'E1EDS01'.

ZE1EDS01 = INT_EDIDD-SDATA.

IF ZE1EDS01-SUMID = '001'.

  • Start deleting when on 1st E1EDS01 segment

DESCRIBE TABLE INT_EDIDD LINES POS.

LOOP AT XTVBDPR.

CLEAR MARA.

SELECT SINGLE MTART MATKL FROM MARA INTO "DV2K920646

(MARA-MTART,MARA-MATKL) "DV2K920646

WHERE MATNR = XTVBDPR-MATNR. " Find material type MTART

IF XVBDKR-FKART EQ 'ZEXP' OR XVBDKR-FKART EQ 'ZXL2' OR

XVBDKR-FKART EQ 'ZXAD' OR XVBDKR-FKART EQ 'ZXG2' OR

XVBDKR-FKART EQ 'ZXDR' OR XVBDKR-FKART EQ 'ZXPT'.

IF MARA-MTART = 'ZRTN' AND XTVBDPR-KZWI2 EQ 0

AND MARA-MATKL <> 'KEGS DM'. "DV2K920646

MOVE XTVBDPR-POSNR TO POSNRS-POSNR.

APPEND POSNRS. " Store ZRTNs to be deleted

ENDIF.

ENDIF.

ENDLOOP.

DESCRIBE TABLE POSNRS LINES COUNT.

  • Reduce the number of line items by the number of them to be deleted

ZE1EDS01-SUMME = ZE1EDS01-SUMME - COUNT.

SHIFT ZE1EDS01-SUMME LEFT DELETING LEADING SPACE.

INT_EDIDD-SDATA = ZE1EDS01.

MODIFY INT_EDIDD INDEX POS TRANSPORTING SDATA.

LOOP AT INT_EDIDD INTO IEDIDD. " Loop and delete if in POSNRS

IF IEDIDD-SEGNAM = 'E1EDP01' OR IEDIDD-SEGNAM = 'E1EDS01'.

CLEAR DELETE_FLAG.

  • Reset delete_flag when on next line item or done with all

ENDIF.

IF IEDIDD-SEGNAM = 'E1EDP01'.

ZE1EDP01 = IEDIDD-SDATA.

READ TABLE POSNRS WITH KEY POSNR = ZE1EDP01-POSEX.

IF SY-SUBRC EQ 0.

DELETE_FLAG = 'X'.

  • Set delete_flag if the line item is to be deleted

ENDIF.

ENDIF.

IF DELETE_FLAG = 'X'. " Delete the line item fully

DELETE INT_EDIDD.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

At this function module, you have to create an include and write your code.

But remember, before that you have to extend your basic type.

Hope it will help you.

sailesh

Former Member
0 Kudos
316

Sailesh,

Is this for the outbound Invoice? Function Module IDOC_OUTPUT_INVOIC? What is the user exit that I must use?

Thanks,

Lalyn

0 Kudos
316

Hi Lalyn,

I hope this function module will work.

EXIT_SAPLVEDF_001

sailesh

Former Member
0 Kudos
317

Hi Sailesh,

But EXIT_SAPLVEDF_001 doesn't have a paramater EDIDD. Where will I put the fields in the extension?

Lalyn

0 Kudos
316

exit_saplvedf_002 should help.

Former Member
0 Kudos
316

Thanks Sailesh. I'll let you know how it worked.