Application Development and Automation 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: 
Read only

BAPI or Function for ME41?

Former Member
0 Likes
4,995

Is there any BAPI or Function Module exists to create VENDOR

QUOTATION(ME41). I need to write an Inquiry into the SAP-System.

Can anyone help me?

Greets,

Said

11 REPLIES 11
Read only

Former Member
0 Likes
2,823

Hi Said,

You can use this BAPI <b>BAPI_VENDOR_CREATE</b> .

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
2,823

Hi Ferry,

thank you for your answer. But i need a Bapi or Function to insert an Quotation, not a vendor! It is Transactioncode ME41 (Vendorquotation).

Can somebody help me??

Read only

0 Likes
2,823

Use function module BAPI_REQUISITION_CREATE.

Read only

Former Member
0 Likes
2,823

Hi,

Check the below mentioned BAPI.

BAPI_QUOTATION_CREATEFROMDATA

Regards,

Vara

Read only

Former Member
0 Likes
2,823

Hi Said,

Apologies give you wrong BAPI.

Please try this FM <b>ME_CREATE_REQUISITION_EXT.</b>

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
2,823

Hi all,

and thank you for your Messages! When I use the BAPI BAPI_REQUISITION_CREATE, where can i change the DOC_Type, because the DOC_TYPE for Inquiry is "AN". But then i get a Message that "AN" is not supported!

The same Problem for the BAPI BAPI_QUOTATION_CREATEFROMDATA. There i can only use the DOC_TYPE for the QUOTATION in the Sales and not for the Purchase!

The last BAPI ME_CREATE_REQUISITION_EXT is not remotable? Is it possible to use it nevertheless?

Greets,

Said

Message was edited by: Said Acharkaoui

Read only

0 Likes
2,823

I am attaching sample code here.

You can pass DOC_TYPE parameter using REQUISITION_ITEMS-DOC_TYPE.

  • set up requisition Item

CLEAR ATB_REQ_ITEM.

REFRESH ATB_REQ_ITEM.

LOOP AT BAN.

IF BAN-MAT_GRP = '020004'.

BAN-GR_IND = ' '.

ELSE.

BAN-GR_IND = 'X'.

ENDIF.

BAN-IR_IND = 'X'.

BAN-MATERIAL = BAN-PUR_MAT.

BAN-ASSIGNED = 'X'.

IF BAN-DOC_TYPE = 'YC'. "For confirmation orders, adopt req price

BAN-PO_PRICE = '2'.

ENDIF.

MOVE-CORRESPONDING BAN TO ATB_REQ_ITEM.

APPEND ATB_REQ_ITEM.

ENDLOOP.

  • set up requisition item accounting information

CLEAR ATB_REQ_ITEM_ACCT.

REFRESH ATB_REQ_ITEM_ACCT.

LOOP AT BSC.

MOVE-CORRESPONDING BSC TO ATB_REQ_ITEM_ACCT.

  • uncomment out the following code if you want to force an error.

  • IF sy-tabix = 2.

  • atb_req_item_acct-g_l_acct = 'xxxxx'.

  • ENDIF.

APPEND ATB_REQ_ITEM_ACCT.

ENDLOOP.

  • set up requisition item text information

CLEAR ATB_REQ_ITEM_TEXT.

REFRESH ATB_REQ_ITEM_TEXT.

LOOP AT BANTX.

IF NOT BANTX-TEXT_LINE IS INITIAL.

MOVE-CORRESPONDING BANTX TO ATB_REQ_ITEM_TEXT.

APPEND ATB_REQ_ITEM_TEXT.

ENDIF.

ENDLOOP.

CLEAR ATB_RETURN.

REFRESH ATB_RETURN.

  • Aufruf BAPI zum Erzeugen der Bestellanforderung

CALL FUNCTION 'BAPI_REQUISITION_CREATE'

IMPORTING

NUMBER = H_BANFN

TABLES

REQUISITION_ITEMS = ATB_REQ_ITEM

REQUISITION_ACCOUNT_ASSIGNMENT = ATB_REQ_ITEM_ACCT

REQUISITION_ITEM_TEXT = ATB_REQ_ITEM_TEXT

RETURN = ATB_RETURN

EXCEPTIONS

OTHERS = 0.

Read only

Former Member
0 Likes
2,823

Hi Ashish,

thank you for the code, but how can i use this code? I am using Java with JCo. I am not a ABAP-developper! How can i use this code in my Java-Application?

And i do not understand what happens with the DOC-Type!

As I understood, i had to use the Requisition and change the DOC_TYPE, or what are the relations between these Points?

Thank you,

Said

Read only

0 Likes
2,823

You must be passing data to REQUISITION_ITEMS in your function call.

This has one of the fields DOC_TYPE.

I am not sure how are u passing data to this RFC from Java. But i can just suggest that from Java the Document Type variable needs to be assigned to this field.

If you specify clearly how are you passing data to this function, it will be helpful.

Read only

0 Likes
2,823

EME013Document type YC not allowed with doc. category B (Please check input)

Do you know about that?

f change 'YC' by 'NB' it works correctly but it generates a purchase requisition when I need to create an RFQ

please, someone?

sorry for my english, Im fron Arg

Thenks

Adr!

Read only

ayyappan_venugopal2
Participant
0 Likes
2,823

You can use FM :BS01_MM_QUOTATION_CREATE

Sample code:

METHOD CREATE_QUOTATION.
*----------------------------------------------------------------------*
*Data Definition
*----------------------------------------------------------------------*
DATA:
L_QUOTATION TYPE BAPIEKKOC-PO_NUMBER,
L_CNT_I TYPE EBELP.

*----------------------------------------------------------------------*
*Constants Definition
*----------------------------------------------------------------------*
CONSTANTS:
L_C_INDXKEY TYPE INDX-SRTFD VALUE 'ARIBA_RFQ',
L_C_ZA TYPE RELID VALUE 'ZA'.

*----------------------------------------------------------------------*
*Internal Table & Workarea Definition
*----------------------------------------------------------------------*
DATA:
IT_ITEMS TYPE STANDARD TABLE OF BS01MMITEM,
IT_SCHEDULES TYPE STANDARD TABLE OF BS01MMSCHEDULE,
IT_EXTN TYPE STANDARD TABLE OF BAPIPAREX,
L_WA_EXTN TYPE BAPIPAREX,
IT_RETURN TYPE BAPIRET2_T,
IT_ERRORS TYPE EHFNDT_SBJ_SRC_T100_KEYS.

LOOP AT C_INPUT_TAB ASSIGNING FIELD-SYMBOL(<FS_INPUT_TAB>).
*--Fill Log Header--*
APPEND VALUE #( MSGID = C_MSGID
MSGNO = '160'
ATTR1 = <FS_INPUT_TAB>-SUPPLIERCODE
ATTR2 = <FS_INPUT_TAB>-ITEMCODE ) TO G_ERRORS.

*--Validate any existing RFQ exists with same Item Code & Supplier--*
IF LINE_EXISTS( G_QUOTATION[ SUPPLIER = <FS_INPUT_TAB>-SUPPLIERCODE
ITEM = <FS_INPUT_TAB>-ITEMCODE ] ).
IF <FS_INPUT_TAB>-ETP > SY-DATUM.
APPEND VALUE #( MSGID = C_MSGID
MSGNO = '000'
ATTR1 = TEXT-001
ATTR2 = TEXT-002
ATTR3 = TEXT-003 ) TO G_ERRORS.
CONTINUE.
ENDIF.
ENDIF.

*--Fill Header--*
L_CNT_I = L_CNT_I + 10.
DATA(L_WA_HEADER) = VALUE BS01MMHEAD(
CO_CODE = C_1000
DOC_CAT = C_A
DOC_TYPE = 'ZH20'
DOC_DATE = <FS_INPUT_TAB>-STARTMONTH
CREATED_ON = <FS_INPUT_TAB>-STARTMONTH
ITEM_INTVL = C_0010
VENDOR = <FS_INPUT_TAB>-SUPPLIERCODE
PURCH_ORG = C_1000
PUR_GROUP = C_A01
QUOT_DEAD = <FS_INPUT_TAB>-ETP
MAST_COND = ABAP_TRUE
LANGUAGE = VALUE #( G_SUPPLIER[ SUPPLIER = <FS_INPUT_TAB>-SUPPLIERCODE ]-SUPPLIER
DEFAULT SPACE ) ).
*--Fill Items--*
DATA(L_WA_ITEMS) = VALUE BS01MMITEM(
DOC_ITEM = L_CNT_I
SHORT_TEXT = <FS_INPUT_TAB>-ITEMCODE
CO_CODE = C_1000
PLANT = C_1000
MAT_GRP = '01'
TARGET_QTY = C_9999
QUANTITY = C_9999
UNIT = C_TAG
ACCTASSCAT = 'U' ) .
APPEND L_WA_ITEMS TO IT_ITEMS.

*--Fill Schedules Lines--*
DATA(L_WA_SCHEDULES) = VALUE BS01MMSCHEDULE(
DOC_ITEM = L_CNT_I
SERIAL_NO = ''
DEL_DATCAT = '1'
DELIV_DATE = <FS_INPUT_TAB>-ETP
QUANTITY = C_9999
CREATE_IND = C_R
DEL_DATCAT_EXT = C_D ).
APPEND L_WA_SCHEDULES TO IT_SCHEDULES.


*--Call FM to create RFQ--*
CALL FUNCTION 'BS01_MM_QUOTATION_CREATE'
EXPORTING
QUOTATION_HEADER = L_WA_HEADER
SKIP_ITEMS_WITH_ERROR = ABAP_TRUE
IMPORTING
QUOTATION = L_QUOTATION
TABLES
QUOTATION_ITEMS = IT_ITEMS
QUOTATION_ITEM_SCHEDULES = IT_SCHEDULES
RETURN = IT_RETURN
EXTENSIONIN = IT_EXTN.
IF L_QUOTATION IS NOT INITIAL.
*--Fill Success Message--*
APPEND VALUE #( MSGID = C_MSGID
MSGNO = '161'
ATTR1 = L_QUOTATION ) TO G_ERRORS.
ELSE.
*--Fill Error Message--*
IT_ERRORS = VALUE #( FOR L_WA_RETURN IN IT_RETURN
( MSGID = L_WA_RETURN-ID
MSGNO = L_WA_RETURN-NUMBER
ATTR1 = L_WA_RETURN-MESSAGE_V1
ATTR2 = L_WA_RETURN-MESSAGE_V2
ATTR3 = L_WA_RETURN-MESSAGE_V3
ATTR4 = L_WA_RETURN-MESSAGE_V4 ) ).
APPEND LINES OF IT_ERRORS TO G_ERRORS.
ENDIF.

CLEAR:
L_WA_HEADER,L_QUOTATION,IT_ITEMS,IT_SCHEDULES,IT_ERRORS,IT_RETURN,IT_EXTN.

ENDLOOP.
ENDMETHOD.