cancel
Showing results for 
Search instead for 
Did you mean: 

Doubts in BAPI_PO_CREATE1

Former Member
0 Kudos

Hai friends,

Thanks to the replies for my previous doubts.

I have doubts in the BAPI, BAPI_PO_CREATE1.

the error is "Please enter Reason for ord."

But i give the reason for order(001) in item data and update the field aslo in itemx table also. still i am getting the error. What is the solution for this?

plz, if u know post it to me.

thanks,

Elamaran

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Please post the code.

Regards,

Rich Heilman

Former Member
0 Kudos

The coding of my program is:

*DATA DECLARATION

CONSTANTS : c_x VALUE 'X'.

*Structures to hold PO header data

DATA : header LIKE bapimepoheader ,

headerx LIKE bapimepoheaderx .

*Internal Tables to hold PO ITEM DATA

DATA : item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,

itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

*Internal table to hold messages from BAPI call

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA : w_header(40) VALUE 'PO Header'.

DATA : ws_langu LIKE sy-langu.

*text-001 = 'PO Header' - define as text element

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : company LIKE header-comp_code DEFAULT 'V130' ,

doctyp LIKE header-doc_type DEFAULT 'NB' ,

cdate LIKE header-creat_date DEFAULT sy-datum ,

vendor LIKE header-vendor DEFAULT '0000001390',

pur_org LIKE header-purch_org DEFAULT 'U001' ,

pur_grp LIKE header-pur_group DEFAULT 'VM8' .

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS : item_num LIKE item-po_item DEFAULT '00001',

material LIKE item-material DEFAULT '100039' ,

plant LIKE item-plant DEFAULT 'V700' ,

quantity LIKE item-quantity DEFAULT 10.

SELECTION-SCREEN END OF BLOCK b2.

*&----

-

-

-

-

-

-


*

START-OF-SELECTION.

*&----

-

-

-

-

-

-


*

*DATA POPULATION

*&----

-

-

-

-

-

-


*

ws_langu = sy-langu. "Language variable

*POPULATE HEADER DATA FOR PO

header-comp_code = company .

header-doc_type = doctyp .

header-creat_date = cdate .

header-doc_date = '20060321'.

header-vendor = vendor .

header-langu = ws_langu .

header-purch_org = pur_org .

header-pur_group = pur_grp .

*&----

-

-

-

-

-

-


*

*POPULATE HEADER FLAG.

*&----

-

-

-

-

-

-


*

headerx-comp_code = c_x.

headerx-doc_type = c_x.

headerx-creat_date = c_x.

headerx-vendor = c_x.

headerx-langu = c_x.

headerx-purch_org = c_x.

headerx-pur_group = c_x.

headerx-doc_date = c_x.

*&----

-

-

-

-

-

-


*

*POPULATE ITEM DATA.

*&----

-

-

-

-

-

-


*

item-po_item = item_num.

item-material = material.

item-plant = plant.

item-quantity = quantity.

item-order_reason = '001'.

APPEND item.

*&----

-

-

-

-

-

-


*

*POPULATE ITEM FLAG TABLE

*&----

-

-

-

-

-

-


*

itemx-po_item = item_num.

itemx-material = c_x.

itemx-plant = c_x .

itemx-stge_loc = c_x .

itemx-quantity = c_x .

ITEM-ORDER_REASON = c_x.

itemx-tax_code = c_x .

itemx-item_cat = c_x .

itemx-acctasscat = c_x .

APPEND itemx.

*&----

-

-

-

-

-

-


*

*BAPI CALL

*&----

-

-

-

-

-

-


*

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = header

poheaderx = headerx

  • POADDRVENDOR =

  • TESTRUN =

  • IMPORTING

  • EXPPURCHASEORDER =

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

return = return

poitem = item

poitemx = itemx.

BREAK-POINT.

*&----

-

-

-

-

-

-


*

*Confirm the document creation by calling database COMMIT

*&----

-

-

-

-

-

-


*

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

  • IMPORTING

  • RETURN =

.

END-OF-SELECTION.

*&----

-

-

-

-

-

-


*

*Output the messages returned from BAPI call

*&----

-

-

-

-

-

-


*

LOOP AT return.

WRITE / return-message.

ENDLOOP.

Former Member
0 Kudos

Here is your problem


*&---------------------------------------------------------------------*
*POPULATE ITEM FLAG TABLE
*&---------------------------------------------------------------------*
itemx-po_item = item_num.
itemx-material = c_x.
itemx-plant = c_x .
itemx-stge_loc = c_x .
itemx-quantity = c_x .
<b>*ITEM-ORDER_REASON = c_x. <---problem</b>
<b>ITEM<u>X</u>-ORDER_REASON = c_x. <---should have been this</b>
itemx-tax_code = c_x .
itemx-item_cat = c_x .
itemx-acctasscat = c_x .
APPEND itemx.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Please see the following.....




*&---------------------------------------------------------------------*
*POPULATE ITEM DATA.
*&---------------------------------------------------------------------*
  item-po_item = item_num.
  item-material = material.
  item-plant = plant.
  item-quantity = quantity.
  item-order_reason = '001'.
  append item.

*&---------------------------------------------------------------------*
*POPULATE ITEM FLAG TABLE
*&---------------------------------------------------------------------*
  itemx-po_item = item_num.
  itemx-material = c_x.
  itemx-plant = c_x .
  itemx-stge_loc = c_x .
  itemx-quantity = c_x .
<b>  item-order_reason = c_x.</b>
  itemx-tax_code = c_x .
  itemx-item_cat = c_x .
  itemx-acctasscat = c_x .
  append itemx.


Notice in BOLD, that the field that you are filling here is the ITEM structure not the ITEMX structure.

REgards,

Rich Heilman

Answers (1)

Answers (1)

Former Member
0 Kudos

Is '001' a valid value for order reason?

Former Member
0 Kudos

hai srini,

You fix the problem and Purchase order has been created.

thank you very much.

And i want to know what are the user-exits available for the BAPIs. How can i know which BAPI having which User-Exits?

thanks a lot.

Elamaran

Former Member
0 Kudos

Rich got the points even though I fixed it? Just kidding, not an issue with that. For the user exits in the BAPIs, they typically execute the same user exits that are there in the corresponding transactions. So all the user exits in ME21N should theoritically be executed even with the BAPI.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Usually the BAPIs will use the same exact logic that the regular gui transaction will use. SO for example, the BAPI_PO_CREATE1 will fire the same user exits that get fired when running transaction ME21 or ME21N. Juse look for user exits in these transactions.

Regards,

Rich Heilman

Former Member
0 Kudos

Just saw that you changed the points. I was just kidding when I said that. It doesn't matter who gets it as long as your problem is resolved.

Former Member
0 Kudos

Hai srini,

sorry for the confusion which made.

ok, let me tell one thing, can we call custom function module from the BAPIs?

Thanks,

Elamaran

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

the BAPI is like any other standard SAP object, you will need a registration key in order to access it to make changes, you could do that, or you can find a user exit in the code to put your call to custom function module.

Regards,

Rich Heilman

Former Member
0 Kudos

What do you want in this custom function module? Can it be called from the regular ME21N user exit? If so, then you can just call it there and the BAPI will do the same call. Using the BAPI to create the PO goes through the same logic, same config, same user exits as creating a PO from ME21N. I hope that clears.

Srinivas