cancel
Showing results for 
Search instead for 
Did you mean: 

Orders iDoc - UoM conversion in sales order

peter_wallner2
Active Contributor
0 Kudos

Dear experts,

We are receiving sales orders from a customer who only orders in EA (eaches) using the EAN number (other customers order in CS (cases)).

I do not include the UoM in the iDoc, only the order quantity.

In VB13 we set up "EAN number - SAP material" with UoM "EA" and reason "0003" with that customer number.

In the sales order I get the correct SAP material, the quantity and UoM "EA".

The materials are maintained with:

Base unit of measure: EA

Sales unit: CS

Additonal data-Units of measure: conversion 1 CS = 6 EA

Is there a possibility to convert the UoM to "CS" (case) and recalculate the order quantity upon sales order processing?

Or do the materials need a different set up for that?

A SAP standard solution would be preferred.

Thank you for your help and best regards,

Peter

Accepted Solutions (1)

Accepted Solutions (1)

peter_wallner2
Active Contributor
0 Kudos

We went for a user exit when the iDoc is processed in ERP and recalculate the quantity from EA to CS.

Answers (4)

Answers (4)

Former Member

Hi Peter -  Which user-exit are you using?  I've been working on this same issue in customer function 009 but the material is not been determined from the EAN yet.  How did you handle this?

Thanks!

peter_wallner2
Active Contributor
0 Kudos

Hello Maggie,

It is exit  EXIT_SAPLVEDA_009

try this:


method CONVERT_UOM_CU_TO_TU_VB13.

  CONSTANTS:

        lc_appl_sd         TYPE kappl  VALUE 'V',  " Sales / Distribution

        lc_scheme_matdet   TYPE kalsm_d  VALUE 'ZRU001'.

  DATA: ld_idx            TYPE i,

        ld_material       TYPE matnr,

        ld_input          TYPE i,

        ld_uom_meins      TYPE mara-meins,

        ld_umrez          TYPE marm-umrez,

        ld_umren          TYPE marm-umren,

        ld_quantity_new   TYPE lmeng,

        ld_wmeng_c(18)    TYPE c,

        ld_kunnr          TYPE kunnr,

        ls_header_comm    TYPE komkd,

        ls_item_comm      TYPE kompd,

        ls_condition      TYPE konddp,

        lt_conditions     TYPE STANDARD TABLE OF konddp.

  FIELD-SYMBOLS:

        <ls_xvbap>        TYPE ANY,

        <ls_xvbep>        TYPE ANY,

        <ls_xvbadr>       TYPE ANY,

        <ld_matnr>        TYPE vbap-matnr,

        <ld_matwa>        TYPE vbap-matwa,

        <ld_ean11>        TYPE vbap-ean11,

        <ld_wmeng>        TYPE ANY,

        <ld_meins>        TYPE vbap-meins,

        <ld_posnr>        TYPE vbap-posnr,

        <ld_posnr_vbep>   TYPE vbep-posnr,

        <ld_wmeng_vbep>   TYPE ANY,

        <ld_parvw>        TYPE parvw,

        <ld_kunnr>        TYPE kunnr.

  LOOP AT ct_dxvbap ASSIGNING <ls_xvbap>.  " into ls_xvbap.

    ld_idx = syst-tabix.

    CLEAR: ls_header_comm,

           ls_item_comm.

    REFRESH: lt_conditions.

    ASSIGN COMPONENT 'EAN11' OF STRUCTURE <ls_xvbap> TO <ld_ean11>.

    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

      EXPORTING

        input        = <ld_ean11>  " ls_xvbap-ean11

      IMPORTING

        output       = ls_item_comm-matwa

      EXCEPTIONS

        length_error = 1

        OTHERS       = 2.

    IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      CONTINUE.

    ENDIF.

    LOG-POINT ID zidoc

      SUBKEY 'USER_EXIT_SAPLVEDA'

      FIELDS <ls_xvbap> <ld_ean11> ls_item_comm-matwa.

** Assign KUNNR to header structure for product substitution

  LOOP AT ct_dxvbadr ASSIGNING <ls_xvbadr>.

    ASSIGN COMPONENT 'PARVW' OF STRUCTURE <ls_xvbadr> TO <ld_parvw>.

    IF ( <ld_parvw> = zcl_exit_saplveda_services=>mc_partner_soldto ).

         ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <ls_xvbadr> TO <ld_kunnr>.

         ld_kunnr = <ld_kunnr>.

    ENDIF.

  ENDLOOP.

  ls_header_comm-kunnr = ld_kunnr.

    CALL FUNCTION 'PRODUCT_SUBSTITUTION'

      EXPORTING

        application                = lc_appl_sd

        date                       = syst-datum

        dialog                     = ' '

        header_communication       = ls_header_comm

        item_communication         = ls_item_comm

        scheme                     = lc_scheme_matdet

*       PROTOKOLL                  = ' '

*     IMPORTING

*       KONDD_DATA                 =

      TABLES

        konddp_data                = lt_conditions.

    IF ( LINES( lt_conditions ) = 1 ).

      CLEAR: ls_condition,

             ld_material,

             ld_uom_meins,

             ld_umrez,

             ld_umren.

      READ TABLE lt_conditions INTO ls_condition INDEX 1.

      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

        EXPORTING

          input        = ls_condition-smatn

        IMPORTING

          output       = ld_material

        EXCEPTIONS

          length_error = 1

          OTHERS       = 2.

      IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

        CONTINUE.

      ENDIF.

      LOG-POINT ID zidoc

        SUBKEY 'USER_EXIT_SAPLVEDA'

        FIELDS ls_condition ls_condition-smatn ld_material.

      ld_input = 1.

      CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

        EXPORTING

          input                        = ld_input

*         KZMEINH                      = ' '

          matnr                        = ld_material

          meinh                        = md_uom_traded_unit

*         MEINS                        =

*         EXTENDED_CONV                = ' '

*         TYPE_UMR                     = ' '

          no_output                    = 'X'  " Essential!!!

*         CHARGE                       =

*         CHARG_CUOBJ                  =

*         WERKS                        =

        IMPORTING

*         ADDKO                        =

          meins                        = ld_uom_meins

*         OUTPUT                       =

          umren                        = ld_umren

          umrez                        = ld_umrez

*         BATCH_CONVERSION_ERROR       =

*         KZWSO                        =

        EXCEPTIONS

          conversion_not_found         = 1

          input_invalid                = 2

          material_not_found           = 3

          meinh_not_found              = 4

          meins_missing                = 5

          no_meinh                     = 6

          output_invalid               = 7

          overflow                     = 8

          OTHERS                       = 9.

      IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

        CONTINUE.

      ENDIF.

      ASSIGN COMPONENT 'MATNR' OF STRUCTURE <ls_xvbap> TO <ld_matnr>.

**      ASSIGN COMPONENT 'MATWA' of STRUCTURE <ls_xvbap> to <ld_matwa>.

      ASSIGN COMPONENT 'WMENG' OF STRUCTURE <ls_xvbap> TO <ld_wmeng>.

      ASSIGN COMPONENT 'MEINS' OF STRUCTURE <ls_xvbap> TO <ld_meins>.

      <ld_matnr> = ld_material.

      LOG-POINT ID zidoc

        SUBKEY 'USER_EXIT_SAPLVEDA'

        FIELDS <ls_xvbap> <ld_matnr> <ld_wmeng> <ld_meins>.

      LOG-POINT ID zidoc

        SUBKEY 'USER_EXIT_SAPLVEDA'

        FIELDS <ld_wmeng> ld_wmeng_c ld_umrez ld_umren.

      ld_quantity_new = ld_wmeng_c * ( ld_umren / ld_umrez ).

      MOVE ld_quantity_new TO <ld_wmeng>.

      <ld_meins> = ld_uom_meins.

      ASSIGN COMPONENT 'POSNR' OF STRUCTURE <ls_xvbap> TO <ld_posnr>.

      LOOP AT ct_dxvbep ASSIGNING <ls_xvbep>.

        ASSIGN COMPONENT 'POSNR' OF STRUCTURE <ls_xvbep> TO <ld_posnr_vbep>.

        ASSIGN COMPONENT 'WMENG' OF STRUCTURE <ls_xvbep> TO <ld_wmeng_vbep>.

        IF ( <ld_posnr_vbep> = <ld_posnr> ).

          ld_quantity_new =  ld_wmeng_c * ( ld_umren / ld_umrez ).

          MOVE ld_quantity_new TO <ld_wmeng_vbep>.

        ENDIF.

      ENDLOOP.

    ELSE.

      CONTINUE. " no product substitution

    ENDIF.

  ENDLOOP.

endmethod.

Best regards,

Peter

Former Member
0 Kudos

Thank you so much Peter.  It's very generous of you to share your code.  I really appreciate it! 

peter_wallner2
Active Contributor
0 Kudos

You are welcome.

former_member187610
Active Participant
0 Kudos

Hi Peter,

In Material Master you have an option to change the Unit of Measure.

Check in Basic Material 1 Tab -> Additional Data -> then Unit of Measure (UoM) where you could change the UoM based on measure/EAN/dimensions.

Regards,

Sharan

peter_wallner2
Active Contributor
0 Kudos

Hello Sharan,

Thank you, yes the UoMs and conversion quantities are maintained in "Additional Data" - please see screenshot further up.

Best regards,

Peter

former_member182609
Active Contributor
0 Kudos

You can do one thing.You need to create a custom table add one custom field in customer master to identify EA  ordering Customers.Based on this flag the program will identify the Customer and convert the qty into CS.

Similar kind of exercise we did in MM side.Where few of vendors wants the purchase orders information in EA where as some vendors in Ordering unit of measure.However the orders are created on Order UoM (not EA) .So we added one flag in Vendor master to identify to read UoM eaches.

While generation of the Idoc system will check this flag and convert the Ordered UOM qty into Base UoM  to Vendor.We are also using ORDERS05 for communicating to the Vendor.You also can do this.

peter_wallner2
Active Contributor
0 Kudos

Hello Sridhar Jayavarapu,


Thank you for your suggestion. I will think about that and will let you know, we could also go for a user exit in IDOC_INPUT_ORDERS I think.


Best regards,

Peter

former_member182609
Active Contributor
0 Kudos

All the best.Please let me know if you need any help !!

Former Member
0 Kudos

Hi Peter,

Check the conversion in the sales order on the line item data-->Sales A tab?

And also let me know if this is the same case if you are creating the sales order manually?

Thanks

Rajesh


peter_wallner2
Active Contributor
0 Kudos

Hello Rajesh,

Sorry for my very late answer.

Sales A tab looks fine to me:

Yes, it is the same if I create a sales order manually.

I also found thread  Each(EA) to Case(CS) Conversion which did not get answered in the end.

I think I figured it out though:

*) In the ORDERS iDoc I have order quantity 16 (no UoM). In VB13 I map EAN to SAP material and I give UoM = EA (because customer orders in EA).

In the sales order it correctly chooses EA as UoM.

*) If I do not give a UoM in VB13 in the sales order it chooses CS as UoM (I think because sales unit of material is in CS).

--> CS in the sales order is wrong because customer is ordering in EA.

My conclusion: when the sales order is created SAP can't recalculate EA-quantity to CS-quantity. It can only set the correct UoM. It either takes UoM from VB13 or from MM03 (sales unit).

Best regards,

Peter

former_member186385
Active Contributor
0 Kudos

Hi Peter,

As i understood you are asking for some customer Sales unit should be CS (cases) and for some it should be EA For same material master settings?

Is my understanding correct ?

regards,

santosh

peter_wallner2
Active Contributor
0 Kudos

Hello Santosh,

Not exactly. Some customers order with CS (cases) and some with EA (eaches).

But in the sales order they should all be CS for the same material master settings.

Best regards,

Peter

former_member186385
Active Contributor
0 Kudos

Hi,

are you creating Orders from front end system ?

Did you enter Sales UoM in Material Master and corresponding conversion from Base UoM to Sales UoM ?

peter_wallner2
Active Contributor
0 Kudos

Hello Santosh,

No, the orders get created via an iDoc (coming from SAP PI).

Yes, the conversion is set, please see my screenshots:

Thank again for your help,

Peter

former_member186385
Active Contributor
0 Kudos

Hi Peter,

If this setting is available,, then your sales order will be created with Sales Unit CS

If it is overwriting, then please dont pass UoM through Idoc to R/3 and check

thanks

santosh

peter_wallner2
Active Contributor
0 Kudos

Hello Santosh,

I am not passing the UoM in the iDoc. But I set the UoM in VB13 to "CS" and in the sales order the UoM is also "CS".

But the quantities are for eaches. So in the sales order it says 696 CS but it actually is 696 EA.

Can the quantity be converted with a certain setting?

Thank you again for your input,

Peter

former_member186385
Active Contributor
0 Kudos

Hi peter,

Right now i don't access to Sandbox, i will test your scenario and get back to you

regards,

santosh