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: 

BAPI for ME41 (Quotation)

Former Member
0 Kudos

BAPI for ME41 (Quotation)

Hello all.

Here is the code to create a Request for Quotation in MM through BAPI .

There were some themes about it. (https://scn.sap.com/thread/1400550)

Someone suggested Call transaction, someone suggested FM 'BAPI_QUOTATION_CREATEFROMDATA2'
but it was about SD. Someone knows about FM 'BS01_MM_QUOTATION_CREATE',
but it doesn't work correctly without ECC-DIMP activation.

(There is a note 1666702 - Syntax Error occurs when using BS01_MM_QUOTATION_CREATE...

Function module BS01_MM_QUOTATION_CREATE is part of software component ECC-DIMP...

Please do not consider activating the Business Function Set DIMP because you only would
like to use this specific function BAPI BS01_MM_QUOTATION_CREATE...)

Well, I think FM ''BS01_MM_QUOTATION_CREATE' is the most suitable.

We only need to correct some code without activating ECC-DIMP.

There are some corrections about quantity, type of document and currency.

Code is mostly similar like in ECC-DIMP.

Start FM:

FORM bapi_quotation_create .

  DATA wa_quotation_header    TYPE bs01mmhead.
  DATA wa_quotation_address   TYPE bapiaddress.
  DATA p_quotation            TYPE bapiekkoc-po_number.
  DATA wa_quotation_items     TYPE bs01mmitem.
  DATA gt_quotation_items     TYPE STANDARD TABLE OF bs01mmitem.
  DATA wa_schedules           TYPE bs01mmschedule.
  DATA gt_schedules           TYPE STANDARD TABLE OF bs01mmschedule.
  DATA gt_return              TYPE STANDARD TABLE OF bapiret2.
  DATA wa_return              TYPE bapiret2.
*"      QUOTATION_ACCOUNT_ASSIGNMENT STRUCTURE  BAPIEKKN OPTIONAL
*"      QUOTATION_ITEM_TEXT STRUCTURE  BS01MMITEMTX OPTIONAL
*"      QUOTATION_LIMITS STRUCTURE  BAPIESUHC OPTIONAL
*"      QUOTATION_CONTRACT_LIMITS STRUCTURE  BAPIESUCC OPTIONAL
*"      QUOTATION_SERVICES STRUCTURE  BSMMESLLC OPTIONAL
*"      QUOTATION_SRV_ACCASS_VALUES STRUCTURE  BAPIESKLC OPTIONAL
*"      QUOTATION_SERVICES_TEXT STRUCTURE  BAPIESLLTX OPTIONAL
*"      EXTENSIONIN STRUCTURE  BAPIPAREX OPTIONAL

********************************************


  CLEAR wa_quotation_header.
  wa_quotation_header-CREATED_BY  = sy-uname.
  wa_quotation_header-co_code     = 'JNZ'.
  wa_quotation_header-doc_cat     = 'A'.
  wa_quotation_header-doc_type    = 'AN'.
  wa_quotation_header-vendor      = '0000000123'.
  wa_quotation_header-language    = sy-langu.
  wa_quotation_header-purch_org   = 'YNOS'.
  wa_quotation_header-pur_group   = '10'.
  wa_quotation_header-currency    = 'RUB'.
  wa_quotation_header-doc_date    = sy-datum.  
  wa_quotation_header-APPLIC_BY   = '20131231'. " BWBDT
  wa_quotation_header-quot_dead   = '20131231'. " ANGAB "
  wa_quotation_header-COLL_NO     = '1'.        "

**********************************************


  CLEAR wa_quotation_items.
  wa_quotation_items-material     = '000000000000340060'.
  wa_quotation_items-PUR_MAT      = wa_quotation_items-material.
  wa_quotation_items-co_code      = 'JNZ'.
  wa_quotation_items-plant        = 'YNOS'.
  wa_quotation_items-store_loc    = '0001'.
  wa_quotation_items-trackingno   = '1001'.  " bednr
  wa_quotation_items-DOC_CAT      = 'A'. "
  wa_quotation_items-QUOT_DEAD    = '20131231'."ANGAB
  APPEND wa_quotation_items TO gt_quotation_items.


************************************************
  CLEAR wa_schedules.
  wa_schedules-DEL_DATCAT  = '1'. "
  wa_schedules-deliv_date  = '20140101'.
  wa_schedules-QUANTITY    = '3'.
  APPEND wa_schedules TO gt_schedules.

***********************************************


  CALL FUNCTION 'BS01_MM_QUOTATION_CREATE'
  EXPORTING
       quotation_header   = wa_quotation_header
*"     VALUE(QUOTATION_ADDRESS) LIKE  BAPIADDRESS STRUCTURE
*"        BAPIADDRESS OPTIONAL
*"     VALUE(SKIP_ITEMS_WITH_ERROR) LIKE  BAPIMMPARA-SELECTION DEFAULT
*"       'X'
  IMPORTING
       quotation                  = p_quotation
  TABLES
       quotation_items            = gt_quotation_items[]
       quotation_item_schedules   = gt_schedules[]
*"      QUOTATION_ACCOUNT_ASSIGNMENT STRUCTURE  BAPIEKKN OPTIONAL
*"      QUOTATION_ITEM_TEXT STRUCTURE  BS01MMITEMTX OPTIONAL
*"      QUOTATION_LIMITS STRUCTURE  BAPIESUHC OPTIONAL
*"      QUOTATION_CONTRACT_LIMITS STRUCTURE  BAPIESUCC OPTIONAL
*"      QUOTATION_SERVICES STRUCTURE  BSMMESLLC OPTIONAL
*"      QUOTATION_SRV_ACCASS_VALUES STRUCTURE  BAPIESKLC OPTIONAL
*"      QUOTATION_SERVICES_TEXT STRUCTURE  BAPIESLLTX OPTIONAL
*"      EXTENSIONIN STRUCTURE  BAPIPAREX OPTIONAL
       return             = gt_return[]  .


  LOOP AT gt_return INTO  wa_return
                    WHERE type = 'E'
                    OR    type = 'A'.
    ROLLBACK WORK.
    EXIT.
  ENDLOOP.  " return

  IF NOT sy-subrc = 0.
    COMMIT WORK AND WAIT.
    message i096(zm) with p_quotation.
  ENDIF.

ENDFORM.                    " BAPI_QUOTATION_CREATE

LBOS04F01 . form DOC_HEADER_GENERATE

find block

  if not tekko is initial.

    tekkorel = 'X'.

  endif.

  call function 'ME_CREATE_PO_HEADER'

modify block

* "Request or Quotation

  call function 'ME_CREATE_PO_HEADER'

       exporting

            i_bedat       = cekko-bedat

            i_bsart       = cekko-bsart

            i_bukrs       = cekko-bukrs

            i_ekgrp       = cekko-ekgrp

            i_ekorg       = cekko-ekorg

            i_konnr       = cekko-konnr

            i_lifnr       = cekko-lifnr

            i_reswk       = cekko-reswk

            i_ebeln       = cekko-ebeln

            i_tekko       = tekko

            i_tekkorel    = tekkorel

            i_address     = cadr

            i_vorga       = 'A'  "Needs to be "A" for MM RFQ/Quotation

*            i_bstyp       = document_category  "DIMP

*            i_angdt       = cekko-angdt        "DIMP

            z_bstyp       = document_category

            z_angdt       = cekko-angdt

       exceptions

            error_message = 1.

FM 'ME_CREATE_PO_HEADER'

find block

  ekko-spras = i_spras.                                     "567213

  ekko-scmproc = i_scmproc.                    "APO Push Deployment

insert block

*"Create Request for Quotation

  if sy-tcode cs 'ZZZ'

  or sy-tcode = 'SE38'.

    if z_bstyp = 'A'.

      EKKO-ANGDT = Z_ANGDT.

      EKKO-BSTYP = Z_BSTYP.

      ekko-waers = I_TEKKO-waers.

    endif.

  endif.

MM06EF0I_INIT_FC. FORM init_fc

find block

  ekko-mandt     = sy-mandt.

  ekko-aedat     = sy-datum.

  ekko-spras     = sy-langu.

  IF ekko-ernam EQ space.

    ekko-ernam     = sy-uname.

  ENDIF.

  ekko-bstyp = bstyp-best.

insert block

* " Request for Quotation

  IF sy-tcode CS 'ZZZ'

  OR sy-tcode = 'SE38'.

    IF i_vorga = bstyp-anfr.  " 'A'-Quotation

      auswahl0   = 'ME41'.

      t160-bstyp = bstyp-anfr.

      t160-vorga = vorga-anfr.

      ekko-bstyp = bstyp-anfr.

      rfq_language = sy-langu. 

      CLEAR ekko-statu.

    ENDIF.

ENDIF.

MM06EF0E_EKPO-NETWR_MOD. FORM ekpo-netwr_mod

find block

CASE ekko-bstyp.

    WHEN bstyp-anfr.

insert block

     *" Request for Quotation

      if sy-tcode cs 'ZZZ'

      or sy-tcode = 'SE38'.

        IF ( NOT fc_call IS INITIAL ) AND

          ekko-bstyp = bstyp-anfr AND

          ekpo-pstyp = pstyp-lagm.  " pstyp = 0

          rm06e-anmng = ekpo-menge.

        ENDIF.

      ENDIF.

That's all.

(My system is SAP ECC 6.0, SAPKB70026, SAPKH60021)

5 REPLIES 5

kiran_kumar262
Explorer
0 Kudos

Hi,

Im also facing the same issue can you tell me how you modified the standard code in the above logic.

sankar_roy
Participant
0 Kudos

Hi Sergey,

I have also the same requirement.

Good to know that there is a BAPI for the same.

If i execute the BAPI in SE37, it is showing 'Program SAPLBOS04 contains syntax error.

What does that mean?

Do i need to activate ECC-DIMP?

If not the code given by you is an enhancement or you have copied the standard to a custom FM.

Thanks in advance.

Regards,

Sankar Roy

SAP ABAP Consultant

former_member192050
Participant
0 Kudos

Hi Sergey,

I have also the same requirement.

Good to know that there is a BAPI for the same.

If i execute the BAPI in SE37, it is showing 'Program SAPLBOS04 contains syntax error.

please halp me on this.

0 Kudos

Hello all,

It is possible that you have syntax error for development objects that are assigned to a package (Dev class) that is 'switchable' and that its switch is off.

In general, these development objects are meant to be used when specific 'business functions' are switched on.

Switching on a business function has to be analyzed and tested carefully because most of them CANNOT be switched off. Even Reversible business functions cannot be switched off when they are activated in a productive system. This is forbidden.

In this specific example, program SAPLBOS04 belongs to package AD_BOS_01. This package contains switchable objects related to switch ECO_BOS. This switch can be switched on via more than one 'industry-specific' business functions all belonging to DIMP.
Switching on DIMP has to be analyzed thoroughly because some business functions are getting automatically switched on (Bfunc DIMP_SDUD) and cannot be reverted.

Each business function activates different functionality. Documentation can be found in IMG -> Activate Business Functions (TA SFW5). There you have a Documentation column with a link to the Help Portal.

Using TA SFW_BROWSER you can see the different objects related to business functions displayed in a tree.

Before switching on business functions you have to take precautions. See http://help.sap.com/saphelp_nw70ehp1/helpdata/en/de/899442047b0831e10000000a1550b0/content.htm

Regards,
Pascale Boyer
SAP Dev Support

0 Kudos

We raised the same to SAP and get the following answer.

The FM BS01_MM_QUOTATION_CREATE belongs to Bill of services which is
part of industry solution DIMP and can be used only if DIMP is
activated in SFW5 transaction. Please note that BOS solution offers
industry specific functionality related to services on the sales side
and activating DIMP just for using BAPI BS01_MM_QUOTATION_CREATE is
not recommended. Only if your business need demands should you look
into the option of activating DIMP.
I noticed that DIMP is not activated in DE1 system and hence you
cannot use  BS01_MM_QUOTATION_CREATE