‎2005 Nov 23 5:19 AM
hi i am using the bapi BAPI_RESERVATION_CREATE for Reservation creation
REPORT ztest NO STANDARD PAGE HEADING.
TYPES: BEGIN OF t_resb.
INCLUDE STRUCTURE bapiresbc .
TYPES: END OF t_resb.
TYPES: BEGIN OF t_rkpf.
INCLUDE STRUCTURE bapirkpfc .
TYPES: END OF t_rkpf.
DATA : i_resb TYPE t_resb OCCURS 0 WITH HEADER LINE,
i_rkpf TYPE t_rkpf OCCURS 0 WITH HEADER LINE,
i_return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
DATA vl_rsnum LIKE rkpf-rsnum.
i_resb-plant = '2100'.
i_resb-material = '20100400017'.
i_resb-store_loc = 'R20C'.
i_resb-quantity = '90.00'.
i_resb-unit = 'NOS'.
APPEND i_resb.
i_rkpf-plant = '2100'.
i_rkpf-res_date = sy-datum.
i_rkpf-move_type = '201'.
i_rkpf-gr_rcpt = '0204001275'.
i_rkpf-cost_ctr = '0021010203'.
APPEND i_rkpf.
CLEAR : i_rkpf, i_resb .
CALL FUNCTION 'BAPI_RESERVATION_CREATE'
EXPORTING
reservation_header = i_rkpf
IMPORTING
reservation = vl_rsnum
TABLES
reservation_items = i_resb
return = i_return.
WRITE vl_rsnum .
LOOP AT i_return.
WRITE / i_return-message .
ENDLOOP.my problem is that when i run the BAPI thru SE37 with the above parameters it run successfully, but when i run it thr ABAP code it gives error 'Posting Date is initial', when i debug the BAPI, it takes the Cost Center Blank thru ABAP Code, but accepts when i debug thru SE37.
i don't know why it is happening
pl. help ur early response will be helpful.
Abhishek Suppal
Message was edited by: Abhishek Suppal
‎2005 Nov 23 7:17 AM
Hi Abhi,
In your code, take a look at the following statement,
<b>CLEAR : i_rkpf, i_resb .</b>
You are clearing i_rkpf before calling BAPI_RESERVATION_CREATE so i_rkpf that is passed reservation_header will be empty !!
Importing parameter reservation_header of BAPI_RESERVATION_CREATE accepts only a structure and not an internal table. Do you really need to declare i_rkpf as a table? I think you can define it as a structure and fill and send.
Ok here is the revised code,
REPORT ztest NO STANDARD PAGE HEADING.
TYPES: BEGIN OF t_resb.
INCLUDE STRUCTURE bapiresbc .
TYPES: END OF t_resb.
TYPES: BEGIN OF t_rkpf.
INCLUDE STRUCTURE bapirkpfc .
TYPES: END OF t_rkpf.
DATA : i_resb TYPE t_resb OCCURS 0 WITH HEADER LINE,
<b> i_rkpf TYPE t_rkpf, " OCCURS 0 WITH HEADER LINE,</b>
i_return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
DATA vl_rsnum LIKE rkpf-rsnum.
i_resb-plant = '2100'.
i_resb-material = '20100400017'.
i_resb-store_loc = 'R20C'.
i_resb-quantity = '90.00'.
i_resb-unit = 'NOS'.
APPEND i_resb.
i_rkpf-plant = '2100'.
i_rkpf-res_date = sy-datum.
i_rkpf-move_type = '201'.
i_rkpf-gr_rcpt = '0204001275'.
i_rkpf-cost_ctr = '0021010203'.
<b>*APPEND i_rkpf.
*CLEAR : i_rkpf, i_resb .
CLEAR i_resb. "New</b>
CALL FUNCTION 'BAPI_RESERVATION_CREATE'
EXPORTING
reservation_header = i_rkpf
IMPORTING
reservation = vl_rsnum
TABLES
reservation_items = i_resb
return = i_return.
WRITE vl_rsnum .
LOOP AT i_return.
WRITE / i_return-message .
ENDLOOP.
Hope this helps..
Did this help??
Sri
Message was edited by: Srikanth Pinnamaneni
Message was edited by: Srikanth Pinnamaneni
‎2005 Nov 23 6:57 AM
‎2005 Nov 23 7:17 AM
Hi Abhi,
In your code, take a look at the following statement,
<b>CLEAR : i_rkpf, i_resb .</b>
You are clearing i_rkpf before calling BAPI_RESERVATION_CREATE so i_rkpf that is passed reservation_header will be empty !!
Importing parameter reservation_header of BAPI_RESERVATION_CREATE accepts only a structure and not an internal table. Do you really need to declare i_rkpf as a table? I think you can define it as a structure and fill and send.
Ok here is the revised code,
REPORT ztest NO STANDARD PAGE HEADING.
TYPES: BEGIN OF t_resb.
INCLUDE STRUCTURE bapiresbc .
TYPES: END OF t_resb.
TYPES: BEGIN OF t_rkpf.
INCLUDE STRUCTURE bapirkpfc .
TYPES: END OF t_rkpf.
DATA : i_resb TYPE t_resb OCCURS 0 WITH HEADER LINE,
<b> i_rkpf TYPE t_rkpf, " OCCURS 0 WITH HEADER LINE,</b>
i_return LIKE bapireturn OCCURS 0 WITH HEADER LINE.
DATA vl_rsnum LIKE rkpf-rsnum.
i_resb-plant = '2100'.
i_resb-material = '20100400017'.
i_resb-store_loc = 'R20C'.
i_resb-quantity = '90.00'.
i_resb-unit = 'NOS'.
APPEND i_resb.
i_rkpf-plant = '2100'.
i_rkpf-res_date = sy-datum.
i_rkpf-move_type = '201'.
i_rkpf-gr_rcpt = '0204001275'.
i_rkpf-cost_ctr = '0021010203'.
<b>*APPEND i_rkpf.
*CLEAR : i_rkpf, i_resb .
CLEAR i_resb. "New</b>
CALL FUNCTION 'BAPI_RESERVATION_CREATE'
EXPORTING
reservation_header = i_rkpf
IMPORTING
reservation = vl_rsnum
TABLES
reservation_items = i_resb
return = i_return.
WRITE vl_rsnum .
LOOP AT i_return.
WRITE / i_return-message .
ENDLOOP.
Hope this helps..
Did this help??
Sri
Message was edited by: Srikanth Pinnamaneni
Message was edited by: Srikanth Pinnamaneni
‎2005 Nov 23 2:28 PM