Skip to Content
-2

Error in BAPI_RESERVATION_CREATE Program?

Jan 12, 2017 at 11:14 AM

81

avatar image
Former Member

Hi,

Pl find my coding below, while executing the same, the value of the cost center field is saved to Profit center field in RKPF table,

pl suggest.

type-pools :truxs.
selection-screen begin of block blck with frame title text-011.
parameters:p_file type rlgrap-filename .

selection-screen end of block blck.

types: begin of st_resb,

bwart type rkpf-bwart,
werks type resb-werks,
matnr type resb-matnr,
erfmg type resb-erfmg,
lgort type resb-lgort,
end of st_resb.

data:it_itab type table of st_itab,
wa_itab type st_itab,
it_raw type truxs_t_text_data.

at selection-screen on value-request for p_file. "F1 help for file input

call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = p_file.



start-of-selection.

call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
* I_FIELD_SEPERATOR =
* i_line_header = p_head
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_itab[] "ACTUAL DATA
exceptions
conversion_failed = 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.



data :wa1_headdata type bapirkpfc,
wa_headdata type bapirkpfc ,
it2_headdata type bapirkpfc,
it_itemdata type table of bapiresbc,
wa_itemdata type bapiresbc,
wa_return type bapireturn occurs 0 with header line .

data: res_no like bapirkpfc-res_no,
tlines type i.

loop at it_itab into wa_itab.

wa_headdata-res_date = sy-datum.
* WA_HEADDATA-MOVE_PLANT = WA_ITAB-WERKS.
wa_headdata-move_type = wa_itab-bwart.
wa_headdata-cost_ctr = wa_itab-kostl.
* WA_HEADDATA-CREATED_BY = SY-UNAME.


*LOOP AT IT_ITAB INTO WA_ITAB.
wa_itemdata-material = wa_itab-matnr.
wa_itemdata-quantity = wa_itab-erfmg.
wa_itemdata-store_loc = wa_itab-lgort.
wa_itemdata-plant = wa_itab-werks.
wa_itemdata-req_date = sy-datum.
append wa_itemdata to it_itemdata.
clear wa_itemdata.
perform check.
clear wa_resb.
endloop.

*BREAK-POINT.
call function 'BAPI_RESERVATION_CREATE'
exporting
reservation_header = wa_headdata
* NO_COMMIT =
movement_auto ='X'
importing
reservation = res_no
tables
reservation_items = it_itemdata
* RETURN =
.
*BREAK-POINT.

call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
* IMPORTING
* RETURN = WA_RETURN
.
*BREAK-POINT.

describe table wa_return lines tlines.
if tlines gt 0.
format color col_negative.
write : / 'Update Failed.',wa_return-message(200), 255 ' '.
else.
format color col_normal.
write :res_no, 'Reservation created successfully ', 255 ' '.
endif.
form check.
loop at it_resb into wa_resb.
wa1_headdata-move_type = wa_resb-bwart.


if wa1_headdata-move_type ne wa_headdata-move_type.
message 'Pl Maintain a Single movement type throughout the Excel file' type 'A'.
endif.
endloop.
endform.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Jürgen L
Jan 16, 2017 at 06:37 AM
0

what about showing some screenshots, e.g. from source file and from debugger with the cost center field value

Did you already create a reservation manually and checked if the values came correct?

Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
Jan 12, 2017 at 11:22 AM
0

So what is the prioblem, did you get an error in return table?

Regards,
Raymond

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mr.Raymond,

The problem is the data is not getting saved in database ,

i checked with breakpoint too,the values are correctly fetched by BAPI from internal tables but the data is not etting saved and in return message it shows ''update plant'' even after i updated the plant details in both heater and itemdata.

0

What are the actual message class and number, also where did you pass header-plant field, could you post the actual tested code, the code where the return-type is checked for 'E' error before commit?

0
Jürgen L
Jan 12, 2017 at 12:04 PM
0

Can you point me to a place in your coding where you deal with profit center and/or cost center?

And if there is no place in your coding then the value falls either from heaven or the data in your Excel source are in different order as you expect it in your program.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 16, 2017 at 04:20 AM
0

Hi,

Thanks for your reply,

"wa_headdata-cost_ctr = wa_itab-kostl." in this line that im placing the value of cost center from excel to the internal table ,

pl note that i checked the program execution with breakpoint and in that the values are assigning correctly the "kostl" field but after program execution while checking database the saved cost center is different(i.e) cost center value is saved in profit center field, and the generated reservation cost center value is some other cost center than the input given to BAPI.

I didnt assign the profit center field at any point in the program

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 16, 2017 at 07:44 AM
0

Hi,

Thanks for your reply , the issue has been resolved..issue raised due to wrong field reference given

Share
10 |10000 characters needed characters left characters exceeded