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: 

Outbound INVOIC IDoc User Exit - EXIT_SAPLVEDF_002

Former Member
0 Kudos

Hi ABAP and EDI Experts,

I have a simple requirement. I want to send Unit price for item after discount.

There are 3 E1EDP05 segments in the outbound INVOIC IDoc.

E1EDP05 + -->> Contain Unit price before Discount

E1EDP05 - -->> Contain Discount Price

E1EDP05 + -->> Contain Unit price after discount.

The discount will not be applied for every item.

How can I send the unit price after applying discount to my mapping Team.

Their mapping tool doesn't support looking in 2 same segments.

Any suggestions?? Plz

Do I have to implement an User Exit?? Is this supposed to be EXIT_SAPLVEDF_002 ??

Best Regards,

Creasy Matt

1 ACCEPTED SOLUTION

Former Member
0 Kudos

In my opinion, yes .. you have to use EXIT_SAPLVEDF_002 for populating your custom field with the calculated unit price value.

For that you have to extend INVOIC02 to add the custom segment (under E1EDP01) with custom field (Calculated unit price) . And then within the user exit, calculate unit price based on E1EDP05 values.

You may have to use "Export / Import to memory ids" to capture the calculated values. This is required to determine when the line item is changing as you have to refresh your calculated variables at the start of each E1EDP01.

Coding tips:

int_edidd-segnam = <Your custom segment name>.

<Your custom segment name>-calc_unit_price = Calculated unit price

MOVE <Your custom segment name> TO int_edidd-sdata.

append int_edidd.

17 REPLIES 17

Former Member
0 Kudos

In my opinion, yes .. you have to use EXIT_SAPLVEDF_002 for populating your custom field with the calculated unit price value.

For that you have to extend INVOIC02 to add the custom segment (under E1EDP01) with custom field (Calculated unit price) . And then within the user exit, calculate unit price based on E1EDP05 values.

You may have to use "Export / Import to memory ids" to capture the calculated values. This is required to determine when the line item is changing as you have to refresh your calculated variables at the start of each E1EDP01.

Coding tips:

int_edidd-segnam = <Your custom segment name>.

<Your custom segment name>-calc_unit_price = Calculated unit price

MOVE <Your custom segment name> TO int_edidd-sdata.

append int_edidd.

0 Kudos

Thanks Bhaskar for your valuable reply.

Isn't it possible to update the value of one of the segment with the calculated price.

I mean in the E1EDP26-BETRG segment (QUALF = 011) i am getting Net Price.

in E1EDPO1-MENGE segment i am getting Net quanity at line item level.

Unit price = E1EDP26-BETRG / E1EDP01-MENGE ( Rounded to two decimals).

Without adding customized segment is it possible to do in this way ??

Please let me know.

Best Regards,

Creasy Matt

0 Kudos

Did any one of you have similar problem??

0 Kudos

Hi C

Put on custom code for calculation in SAP exit. calculate unit price and output in the same segment with different qualifier.

EDI folks would read the new qualifier for unit price.

If you find it difficult to make changes in SAP then it's possible EDI subsystem to make this work.

They need to read previous segment value before they really process the current segment. Handling it thru store fields.

What kind of EDI tool is used in your company?

Hope this solution works for you. I did worked on multiple EDI tools and they support pre reading of the data.

regards

C

0 Kudos

Here is my code will someone please look at this code tell what am i doing wrong??


*&---------------------------------------------------------------------*
*&  Include           ZXEDFU02
*&---------------------------------------------------------------------*

DATA: w_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,
      w_e1edk01 LIKE e1edk01,
      w_e1edk14 LIKE e1edk14,
      w_e1edk02 LIKE e1edk02,
      w_e1edp26 LIKE e1edp26,
      w_e1edp01 LIKE e1edp01,
      w_ZCUSseg LIKE ZCUSseg.


DATA: segnam(27).

segnam = int_edidd-segnam.

TABLES: vbak, vbap, vbkd, likp.

DATA: vtweg LIKE vbak-vtweg,
      belnr LIKE vbak-vbeln,
      invno LIKE vbak-vbeln,
      menge LIKE vbap-zmeng,
      kzwi2 LIKE vbap-kzwi2,
      vkorg LIKE vbak-vkorg,
      spart LIKE vbak-spart,
      delno LIKE likp-vbeln,
      betrg like w_e1edp26-betrg.

DATA: w_vbdpr LIKE xtvbdpr.

CASE segnam.

  WHEN 'E1EDK01'.

    MOVE w_e1edk01-belnr TO invno.

  WHEN 'E1EDK14'.

    CASE w_e1edk14-qualf.
      WHEN '006'.
        MOVE w_e1edk14-orgid TO spart.

      WHEN '007'.
        MOVE w_e1edk14-orgid TO vtweg.

      WHEN '008'.
        MOVE w_e1edk14-orgid TO vkorg.

    ENDCASE.

  WHEN 'E1EDP26'.
    CASE w_e1edp26-qualf.
      WHEN '003'.
        MOVE w_e1edp26-betrg TO betrg.
    ENDCASE.

    WHEN 'E1EDP01'.
    CLEAR int_edidd.

    MOVE w_e1edp01-menge TO menge.

    int_edidd-segnam = 'ZCUSSEG'.
    w_ZCUSseg-PRICE  = betrg / menge.
    int_edidd-sdata = w_ZCUSseg.
    APPEND int_edidd.

ENDCASE.

Edited by: Creasy Matthew on Jan 9, 2009 9:03 PM

0 Kudos

your IDOC will have E1EDP26 under E1EDO01 segment. So when you are using code for E1EDP01, E1EDP26 is not read yet, so BETRG is still blank

WHEN 'E1EDP01'.

CLEAR int_edidd.

MOVE w_e1edp01-menge TO menge.

int_edidd-segnam = 'ZCUSSEG'.

w_ZCUSseg-PRICE = betrg / menge.

int_edidd-sdata = w_ZCUSseg.

APPEND int_edidd.

0 Kudos

MxG,

I am glad you reply to my message.

What do you think is the best way to do this??

I am having really hard time solving this.

Can you please tell me the best approach to this issue?

Thanks,

C

0 Kudos

Can someone tell me what is wrong with this code??

 
DATA: w_edidd LIKE edidd OCCURS 0 WITH HEADER LINE.
DATA: yjfgseg1 LIKE zjfgseg,
      w_e1edk02 like e1edk02,
      w_e1edp01 like e1edp01,
      w_e1edk14 like e1edk14.

Data: vbeln like vbak-vbeln,
      vkorg like vbak-vkorg,
      vtweg like vbak-vtweg,
      spart like vbak-spart,
      posex like vbap-posex,
      netpr like vbap-netpr..

w_edidd[] = int_edidd[].

LOOP AT w_edidd.

  IF w_edidd-segnam = 'E1EDK02'.
    IF w_e1edk02-qualf = '002'.
      MOVE w_e1edk02-belnr TO vbeln.
    ENDIF.
  ENDIF.

  IF w_edidd-segnam  = 'E1EDP01'.
    READ TABLE w_edidd  WITH KEY segnam  = 'ZJFGSEG'.
    IF sy-subrc <> 0.
w_e1edp01-posex = posex.

Select single netpr from vbap into netpr where vbeln = vbeln and posex = posex.

      CLEAR w_edidd.

      yjfgseg1-price = netpr.
      w_edidd-sdata = yjfgseg1-price.
      w_edidd-segnam = 'ZJFGSEG'.

      APPEND w_edidd.

    ENDIF.
  ENDIF.

ENDLOOP.

int_edidd[] = w_edidd[].

0 Kudos

what are you tryig to achieve? if you just want the unit price after discount, it is already there in E1EDP05 segment as you said. Why are you trying to recalculate that again?

E1EDP05 + -->> Contain Unit price before Discount

E1EDP05 - -->> Contain Discount Price

E1EDP05 + -->> Contain Unit price after discount.

What is the reason for creating this new segment? There should not be able to do any coding here.Let me know what you are trying to do then I would be in better codition to reply

0 Kudos

Our client outsourced the IDoc-X12 translation to en external agency.

They are not able to pick the unit price.

The reason is:

Two Cases:

1st: Not everytime we apply discount to the items.

You know very well, when there is no discount, there will be only one E1EDP05 segment.

No problem grabbing in the unit price in this case.

2nd: Whenever we apply discount to certain Items.

This case, there will be 3 E1EDP05 segments. Their mapping tool is having problems reading this value after discount.

They are having problems grabbing the value from 3rd E1EDP05 segment (QUALF = '+').

They asked to send it in some other segment.

Tell me what is best option i can do in this regard.

With Best Regards,

Creasy Matt

0 Kudos

ideally you should push back to the external agency to find the way to read the 3rd E1EDP05 segment.

else you have several options

1-

E1EDP05 gets the data from ikomvd internal table. You need to see what value you want from that to pass it as Unit Price after discount. Then you can use that to create your own custom segment after E1EDP26.

2 - Read INT_EDIDD in the exit for E1EDP05, and see if there are any more subsequent E1EDP0% segments immediately after that, if yes, delete the first one. that will deleete the earlier E1EDP05 segments, and will leave only the last one as you want

0 Kudos

How exactly we can delete an IDoc segment?? I like this idea.

loop at int_edidd.

can you give some pseudocode.

I can develop from it.

endloop.

Thanks and Regards,

Creasy Matt

0 Kudos

something like :

loop at int_edidd where segnam = 'E1EDP05'.

... read table int_edidd into <another variable> index -- sy-tabix + 1

---if ,<another_variable>-egnam = E1EDP05

delete int_edidd.

endif

endloop.

0 Kudos

Thanks MxG for your help.

0 Kudos

Hi Creasy,

I need some information about your requirement..

when are you creating a idoc while performing VF01 and VF02 ? please confirm

I have a simillar requirement please check my thread

http://scn.sap.com/message/14563736#14563736

and suggest how to achieve it ...i am working on the user exit right now..am i in the right direction

regards

Vishnu

0 Kudos

Hi Creasy,

My question is when the IDOC is getting triggered ? my scenarion is after performing excise invoice and we need to post commercial invoice for the we need to generate idoc ..

Hope i am clear.

regards

Vishnu

0 Kudos

i need to fill the most of standard fields like invoice no and inv date etc... along with some custom fields like excise no and excise date etc both at header level and item level...

I believe this user exit  Enhancement LVEDF001 exit EXIT_SAPLVEDF_002

gets triggered when there is an outbound idoc is getting triggered ..? please confirm..

regards

Vishnu