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_member239066
Participant
0 Likes
1,726

Hi Experts,

I am using the bapi BAPI_PO_CREATE1 with a set of data and TESTRUN = X, it does not give me any error messages. When i run the bapi again with the same data and TESATRUN = ' ', it gives me error messages. This is done in the same program. Does anyone know why this is happening? Does it have anything to do with global variables? Does anyone know how to clear global variables of a specific function group?

Thanks,

Vitz

12 REPLIES 12
Read only

Former Member
0 Likes
1,616

TESTRUN is Test Indicator..

This parameter is a test switch.

If you activate the switch, the system does not save the document.

Space = Document should be saved

X = Document should not be saved

but it is better to use....BAPI_PO_CREATE if you really want that item to save in the database..

Read only

0 Likes
1,616

This does not solve my problem since i have to do the test run first and then create the PO.

Read only

Former Member
0 Likes
1,616

Hi,

What is the error message you are getting ?

Regards

Read only

0 Likes
1,616

the error message is not the issue. the issue is why am i getting the error message when calling the bapi with testrun eq space. i do not get any error message when calling the bapi the first time with testrun eq x with the same set of data

Read only

Former Member
0 Likes
1,616

check this

REPORT ZPURCHASEORDER.

data:

header like BAPIMEPOHEADER,

headerx like BAPIMEPOHEADERX,

it_item like standard table of BAPIMEPOITEM,

it_itemx like standard table of BAPIMEPOITEMX,

return like standard table of BAPIRET2,

wa_item like BAPIMEPOITEM,

wa_itemx like BAPIMEPOITEMX,

p_int type i,

p_matnr like mara-matnr,

p_pono like ekko-ebeln.

DATA: BEGIN OF BAPIRETURN OCCURS 0.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF BAPIRETURN.

constants:

c_x type c value 'X'.

*if sy-uname 'ABAP'.

*if program = 'ZPURCHASEORDER' .

*

*raise cancelled.

*

*endif.

*endif.

header-comp_code = '3000'.

header-doc_type = 'DP25'.

header-creat_date = sy-datum.

header-item_intvl = '10'.

header-vendor = 'ARAMI-00'.

header-langu = sy-langu.

header-pmnttrms = '0001'.

header-purch_org = '3000'.

header-pur_group = '010'.

header-currency = 'USD'.

headerx-comp_code = c_x.

headerx-doc_type = c_x.

headerx-creat_date = c_x.

headerx-item_intvl = c_x .

headerx-vendor = c_x.

headerx-langu = c_x.

headerx-pmnttrms = c_x .

headerx-purch_org = c_x.

headerx-pur_group = c_x.

*LOOP AT it_final2 INTO wa_final2.

p_int = p_int + 10.

wa_item-po_item = p_int.

p_matnr = 'T-SRM01'.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = p_matnr

IMPORTING

output = p_matnr

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.

*ENDIF.

wa_item-material = p_matnr.

wa_item-plant = '3200'.

wa_item-quantity = 100.

wa_item-conf_ctrl = 'Z01'.

wa_item-ACKN_REQD = 'X'.

WA_ITEM-ERS = ''.

APPEND wa_item TO it_item.

wa_itemx-po_item = p_int.

wa_itemx-material = c_x.

wa_itemx-plant = c_x .

wa_itemx-stge_loc = c_x .

wa_itemx-quantity = c_x .

wa_itemx-item_cat = c_x .

wa_itemx-acctasscat = c_x .

wa_itemx-conf_ctrl = 'X'.

wa_itemx-ACKN_REQD = 'X'.

WA_ITEMX-ERS = 'X'.

APPEND wa_itemx TO it_itemx.

*ENDLOOP.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = header

poheaderx = headerx

IMPORTING

exppurchaseorder = p_pono

TABLES

return = return

poitem = it_item

poitemx = it_itemx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRETURN.

write:/ p_pono.

Read only

0 Likes
1,616

This is not the issue. I NEED to do the test run first. the problem is that in the same program i am calling the bapi twice. first with test run and second without tes run. when i call it with test run there are no error messages with a particular set of data. when i call the bapi without test run with the same set of data, it returns me errors messages. which should not be the case since the test run did not return any error messages.

Read only

0 Likes
1,616

Hi,

What error message are you getting?

The finance related messages are not captured in test run.

Regards,

Kritesh Shah

Read only

Former Member
0 Likes
1,616

hii

when you run without testrun.it will take by default value as space.that means your data will be saved.so it will check data for updation and it will have some error in data so it will display error messages.what error messages you are getting?try to solve that error.

you will not get error when you will run with testrun = 'X'.because it will not save data,so no updation is done.

Regards,

twinkal

Read only

0 Likes
1,616

i already know the use of testrun and that is why i am using it.

Read only

0 Likes
1,616

Hi Vitish,

As you already know the use of Test Run and want to test the BAPI..check my post for the same in wiki... I have used the same BAPI in this

https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/functionModuleTest+Sequence

Sachin

Read only

0 Likes
1,616

This message was moderated.

Read only

Former Member
0 Likes
1,616

BAPI_PO_CREATE if you really want then item to save in the database..