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_PO_CREATE1

Former Member
0 Likes
1,648

Hii experts....help me..

when i create a purchase order using BAPI (BAPI_PO_CREATE1)... i am getting error message..

1.Check item number 0 in table POSCHEDULEX

(this is my first exp..with BAPI)...this is my code..how can i solve my problem...

FORM bapi_upload .

it_itab[] = itab[].

read table itab.

move-corresponding itab to G_BAPIMEPOHEADER.

G_BAPIMEPOHEADER-CREAT_DATE = sy-datum.

G_BAPIMEPOHEADER-CREATED_BY = sy-uname.

append G_BAPIMEPOHEADER.

g_poheaderx-comp_code = 'X'.

g_poheaderx-vendor = 'X'.

g_poheaderx-doc_type = 'X'.

g_poheaderx-purch_org = 'X'.

g_poheaderx-pur_group = 'X'.

g_poheaderx-suppl_plnt = 'X'.

loop at it_itab where material = itab-material.

move-corresponding it_itab to G_BAPIMEPOITEM.

append G_BAPIMEPOITEM.

move-corresponding it_itab to G_BAPIMEPOSCHEDULE.

append G_BAPIMEPOSCHEDULE.

g_poitemx-PO_ITEM = it_itab-PO_ITEM.

g_poitemx-PO_ITEMX = 'X'.

g_poitemx-item_cat = 'X'.

g_poitemx-stge_loc = 'X'.

g_poitemx-acctasscat = 'X'.

g_poitemx-short_text = 'X'.

g_poitemx-matl_group = 'X'.

g_poitemx-quantity = 'X'.

g_poitemx-po_unit = 'X'.

g_poitemx-orderpr_un = 'X'.

g_poitemx-trackingno = 'X'.

g_poitemx-delete_ind = 'X'.

append g_poitemx.

*G_BAPIMEPOSCHEDULE-PO_ITEM = it_itab-PO_ITEM.

*G_BAPIMEPOSCHEDULE-SCHED_LINE = 'X'.

*G_BAPIMEPOSCHEDULE-DEL_DATCAT_EXT = 'X'.

*G_BAPIMEPOSCHEDULE-DELIVERY_DATE = 'X'.

*G_BAPIMEPOSCHEDULE-QUANTITY = it_itab-quantity.

*G_BAPIMEPOSCHEDULE-DELIV_TIME = 'X'.

*G_BAPIMEPOSCHEDULE-STAT_DATE = 'X'.

*append G_BAPIMEPOSCHEDULE.

g_poschedulex-PO_ITEM = 'X'.

g_poschedulex-SCHED_LINE = 'X'.

g_poschedulex-PO_ITEMX = 'X'.

g_poschedulex-SCHED_LINEX = 'X'.

g_poschedulex-DEL_DATCAT_EXT = 'X'.

g_poschedulex-DELIVERY_DATE = 'X'.

g_poschedulex-QUANTITY = 'X'.

g_poschedulex-DELIV_TIME = 'X'.

g_poschedulex-STAT_DATE = 'X'.

g_poschedulex-PREQ_NO = 'X'.

g_poschedulex-PREQ_ITEM = 'X'.

g_poschedulex-PO_DATE = 'X'.

g_poschedulex-ROUTESCHED = 'X'.

g_poschedulex-MS_DATE = 'X'.

append g_poschedulex.

endloop.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = G_BAPIMEPOHEADER

POHEADERX = g_poheaderx

IMPORTING

EXPPURCHASEORDER = g_ebeln

TABLES

RETURN = G_BAPIRET2

POITEM = G_BAPIMEPOITEM

POITEMX = g_poitemx

POSCHEDULE = G_BAPIMEPOSCHEDULE

POSCHEDULEX = g_poschedulex

endform.

1 ACCEPTED SOLUTION
Read only

kanthimathikris
Advisor
Advisor
0 Likes
1,439

Use the function module

CONVERSION_EXIT_ALPHA_INPUT with the parameter vendor number and try to execute the BAPI again

10 REPLIES 10
Read only

Former Member
0 Likes
1,439
g_poschedulex-PO_ITEM = 'X'.
g_poschedulex-SCHED_LINE = 'X'.

the above fields have to be item number & schedule line number & not flag.

Hope this helps.

Murugesh AS

Read only

0 Likes
1,439

if i give these

g_poschedulex-PO_ITEM = it_itab-PO_ITEM.

g_poschedulex-SCHED_LINE = 1.

i am getting these errors..

PO header data still faulty

No master record exists for vendor 300001

No instance of object type PurchaseOrder has been created. External reference:

Please enter material number or account assignment category

Can delivery date be met?

we have this nedor..300001..

Read only

kanthimathikris
Advisor
Advisor
0 Likes
1,440

Use the function module

CONVERSION_EXIT_ALPHA_INPUT with the parameter vendor number and try to execute the BAPI again

Read only

0 Likes
1,439

I used CONVERSION_EXIT_ALPHA_INPUT for vendor..now my errors are..

PO header data still faulty

Enter Validity end

Enter Validity start

No instance of object type PurchaseOrder has been created. External reference:

Net price must be greater than 0

Please enter material number or account assignment category

Can delivery date be met

..i used same for material also,I am getting the same errors..

Read only

0 Likes
1,439

pass values in

BAPIMEPOHEADER-VPER_START, BAPIMEPOHEADER-VPER_END &

BAPIMEPOITEM-MATERIAL, BAPIMEPOITEM-NET_PRICE.

check the field desc., in relation to the messages and pass appropriate values!

best regards, Murugesh AS

Also you need to enable following fields:

BAPIMEPOHEADERX-VPER_START, BAPIMEPOHEADERX-VPER_END &

BAPIMEPOITEMX-MATERIAL, BAPIMEPOITEMX-NET_PRICE.

please post your complete code for further help!

Message was edited by:

Murugesh Arcot

Read only

0 Likes
1,439

i have already given the values for start date and end date...flat file values for those fields are..

G_BAPIMEPOHEADER-VPER_START = 01092007.

G_BAPIMEPOHEADER-VPER_END = 30092007.

G_BAPIMEPOHEADER-net_price = 1000.

Message was edited by:

Sugumar Ganesan

Read only

0 Likes
1,439

REPORT ZBAPI_SS no standard page heading.

data: begin of itab occurs 0,

DOC_TYPE(4),

VENDOR(10),

PURCH_ORG(4),

PUR_GROUP(3),

COMP_CODE(4),

VPER_START(8),

VPER_END(8),

PO_ITEM(5),

MATERIAL(18),

QUANTITY(16),

NET_PRICE(28),

PLANT(4),

STGE_LOC(4),

DELIVERY_DATE(8),

end of itab.

CONSTANTS : C_X VALUE 'X'.

data: g_ebeln like bapimepoheader-po_number.

data: begin of G_BAPIMEPOHEADER occurs 0.

include structure BAPIMEPOHEADER.

data: end of G_BAPIMEPOHEADER.

data: begin of g_poheaderx occurs 0.

include structure bapimepoheaderx.

data: end of g_poheaderx.

data: begin of G_BAPIMEPOSCHEDULE occurs 0.

include structure BAPIMEPOSCHEDULE.

data: end of G_BAPIMEPOSCHEDULE.

data: begin of g_poschedulex occurs 0.

include structure BAPIMEPOSCHEDULX.

data: end of g_poschedulex.

data: begin of G_BAPIEIKP occurs 0.

include structure BAPIEIKP.

data: end of G_BAPIEIKP.

data: begin of G_BAPIMEPOITEM occurs 0.

include structure BAPIMEPOITEM.

data: end of G_BAPIMEPOITEM.

data: begin of g_poitemx occurs 0.

include structure bapimepoitemx.

data: end of g_poitemx.

data: begin of G_BAPIRET2 occurs 0.

include structure BAPIRET2.

data: end of G_BAPIRET2.

data: it_itab like itab occurs 0 with header line.

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-100.

PARAMETERS : p_file LIKE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK blk.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM file_selection.

START-OF-SELECTION.

PERFORM data_upload.

PERFORM bapi_upload.

perform display.

&----


*& Form file_selection

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM file_selection.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = ' '

def_path = 'C:\'

mask = ',.txt,.txt.'

mode = 'O'

title = 'Open a TXT(Tab delimited) file only'

IMPORTING

filename = p_file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

ENDFORM. " file_selection

&----


*& Form data_upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_upload .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = itab

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

OTHERS = 11.

IF sy-subrc EQ 0 .

WRITE:/ 'Program : ', sy-repid.

WRITE:/ 'Filename: ', p_file.

WRITE AT /1(144) sy-uline.

  • ELSE .

  • MESSAGE i001.

ENDIF.

ENDFORM. " data_upload

&----


*& Form bapi_upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bapi_upload .

it_itab[] = itab[].

read table itab.

move-corresponding itab to G_BAPIMEPOHEADER.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = itab-VENDOR

IMPORTING

OUTPUT = itab-VENDOR.

G_BAPIMEPOHEADER-VENDOR = itab-VENDOR.

G_BAPIMEPOHEADER-CREAT_DATE = sy-datum.

G_BAPIMEPOHEADER-CREATED_BY = sy-uname.

append G_BAPIMEPOHEADER.

g_poheaderx-comp_code = 'X'.

g_poheaderx-vendor = 'X'.

g_poheaderx-doc_type = 'X'.

g_poheaderx-purch_org = 'X'.

g_poheaderx-pur_group = 'X'.

g_poheaderx-suppl_plnt = 'X'.

loop at it_itab where material = itab-material.

move-corresponding it_itab to G_BAPIMEPOITEM.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = it_itab-MATERIAL

IMPORTING

OUTPUT = it_itab-MATERIAL.

G_BAPIMEPOITEM-MATERIAL = it_itab-MATERIAL.

append G_BAPIMEPOITEM.

move-corresponding it_itab to G_BAPIMEPOSCHEDULE.

append G_BAPIMEPOSCHEDULE.

g_poitemx-PO_ITEM = it_itab-PO_ITEM.

g_poitemx-PO_ITEMX = 'X'.

g_poitemx-item_cat = 'X'.

g_poitemx-stge_loc = 'X'.

g_poitemx-acctasscat = 'X'.

g_poitemx-short_text = 'X'.

g_poitemx-matl_group = 'X'.

g_poitemx-quantity = 'X'.

g_poitemx-po_unit = 'X'.

g_poitemx-orderpr_un = 'X'.

g_poitemx-trackingno = 'X'.

g_poitemx-delete_ind = 'X'.

append g_poitemx.

*G_BAPIMEPOSCHEDULE-PO_ITEM = it_itab-PO_ITEM.

*G_BAPIMEPOSCHEDULE-SCHED_LINE = 'X'.

*G_BAPIMEPOSCHEDULE-DEL_DATCAT_EXT = 'X'.

*G_BAPIMEPOSCHEDULE-DELIVERY_DATE = 'X'.

*G_BAPIMEPOSCHEDULE-QUANTITY = it_itab-quantity.

*G_BAPIMEPOSCHEDULE-DELIV_TIME = 'X'.

*G_BAPIMEPOSCHEDULE-STAT_DATE = 'X'.

*append G_BAPIMEPOSCHEDULE.

g_poschedulex-PO_ITEM = it_itab-PO_ITEM.

g_poschedulex-SCHED_LINE = 1.

g_poschedulex-PO_ITEMX = 'X'.

g_poschedulex-SCHED_LINEX = 'X'.

g_poschedulex-DEL_DATCAT_EXT = 'X'.

g_poschedulex-DELIVERY_DATE = 'X'.

g_poschedulex-QUANTITY = 'X'.

g_poschedulex-DELIV_TIME = 'X'.

g_poschedulex-STAT_DATE = 'X'.

g_poschedulex-PREQ_NO = 'X'.

g_poschedulex-PREQ_ITEM = 'X'.

g_poschedulex-PO_DATE = 'X'.

g_poschedulex-ROUTESCHED = 'X'.

g_poschedulex-MS_DATE = 'X'.

append g_poschedulex.

endloop.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = G_BAPIMEPOHEADER

POHEADERX = g_poheaderx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER = G_BAPIEIKP

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

EXPPURCHASEORDER = g_ebeln

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = G_BAPIRET2

POITEM = G_BAPIMEPOITEM

POITEMX = g_poitemx

  • POADDRDELIVERY =

POSCHEDULE = G_BAPIMEPOSCHEDULE

POSCHEDULEX = g_poschedulex

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

  • NFMETALLITMS =

.

ENDFORM. " bapi_upload

Read only

0 Likes
1,439

hi,

in the header level,

G_BAPIMEPOHEADER-VPER_START = '01092007'.

G_BAPIMEPOHEADER-VPER_END = '30092007'.

G_BAPIMEPOHEADERX-VPER_START = 'X'.

G_BAPIMEPOHEADERX-VPER_END = 'X'

& in item level:

G_BAPIMEPOitem-net_price = 1000.

G_BAPIMEPOitemX-net_price = 'X'.

G_BAPIMEPOitem-MATERIAL = your specified material....

G_BAPIMEPOitemX-MATERIAL = 'X'.

I do not see this code in your program! I suggest you check whether the values are populated properly in debug mode.

Message was edited by:

Murugesh Arcot

Read only

0 Likes
1,439

hii..i modified my Program..now purchase order was created...with warning messages....

Trade Material created under the number 4500041541

Validity period less than a week-warning message

Start of validity period is in the past-warning message...

(i created 6 docu nos like this..)

but the problem is...when i tried to display the order in me23n..it tells that...

Document 4500041541 does not exist

also this entry is not updated in ekko and ekpo tables...

if i create manually...for the same data..i can able to see the docu no in me23n...also that is updated in pur.docu tables...give me the solution..

Read only

0 Likes
1,439

hii murugesh...thanks a lot for ur help..

in my program i am not included BAPI_TRANSACTION_COMMIT

thats why i got that problem...now the problem was solved...

once again thank u murugesh...