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_RESERVATION_CREATE

Former Member
0 Likes
6,162

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,467

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

3 REPLIES 3
Read only

eyal_alsheikh
Active Participant
0 Likes
3,467

Hi,

Maybe try to use BAPI_RESERVATION_CREATE1

Eyal.

Read only

Former Member
0 Likes
3,468

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

Read only

0 Likes
3,467

thanx srikanth