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

Problem with BAPI_RESERVATION_CREATE into Badi.

Former Member
0 Likes
891

Hi Gurus,

I'm trying to implement BAPI_RESERVATION_CREATE into badi WORKORDER_UPDATE.

However with my code I'm getting the error:

The code is:


method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.


TYPES: BEGIN OF t_resb.
       
INCLUDE TYPE  bapiresbc .
TYPES: END OF t_resb.

TYPES: BEGIN OF t_rkpf.
       
INCLUDE TYPE bapirkpfc .
TYPES: END OF t_rkpf.

DATA :  i_resb    TYPE STANDARD TABLE OF T_RESB INITIAL SIZE 0,
        wa_resb  
TYPE t_resb.

DATA :  i_rkpf    TYPE STANDARD TABLE OF t_rkpf,
        wa_rkpf  
TYPE t_rkpf.

DATA:   i_return TYPE TABLE OF bapireturn.
DATA: vl_rsnum TYPE rkpf-rsnum.

wa_resb
-GR_RCPT    = 'A000'.
wa_resb-plant    
= '2000'.
wa_resb
-material  = '000000000000000008'.
wa_resb-store_loc
= '0002'.
wa_resb-quantity 
= '90.00'.
wa_resb-unit
      = 'G'.
wa_resb-movement 
= 'X'.

Append wa_resb to i_resb.

wa_rkpf-plant    
= '2000'.
wa_rkpf-res_date 
= sy-datum.
wa_rkpf-move_type
= '311'.

Append wa_rkpf to i_rkpf.

break-point.
CALL FUNCTION 'BAPI_RESERVATION_CREATE'
 
EXPORTING
    reservation_header
= i_rkpf
 
IMPORTING
    reservation       
= vl_rsnum
 
TABLES
    reservation_items  =
i_resb
   
return             = i_return.
endmethod.

Please help!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
719

Hello Felipe,

Please try declaring as below:

DATA :  i_rkpf    TYPE bapirkpfc .

Please note that bapirkpfc is a structure and is holding  only one record at run time. Hence you can avoid using the workarea.

Please see below code :

method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

TYPES: BEGIN OF t_resb.

        INCLUDE TYPE  bapiresbc .

TYPES: END OF t_resb.

DATA :  i_resb    TYPE STANDARD TABLE OF T_RESB INITIAL SIZE 0,

        wa_resb   TYPE t_resb.

DATA :  i_rkpf    TYPE bapirkpfc .

*        wa_rkpf   TYPE bapirkpfc.

DATA:   i_return TYPE TABLE OF bapireturn.

DATA: vl_rsnum TYPE rkpf-rsnum.

wa_resb-GR_RCPT    = 'A000'.

wa_resb-plant     = '2000'.

wa_resb-material  = '000000000000000008'.

wa_resb-store_loc = '0002'.

wa_resb-quantity  = '90.00'.

wa_resb-unit      = 'G'.

wa_resb-movement  = 'X'.

Append wa_resb to i_resb.

i_rkpf-plant     = '2000'.

i_rkpf-res_date  = sy-datum.

i_rkpf-move_type = '311'.

break-point.

CALL FUNCTION 'BAPI_RESERVATION_CREATE'

  EXPORTING

    reservation_header = i_rkpf

  IMPORTING

    reservation        = vl_rsnum

  TABLES

    reservation_items  = i_resb

    return             = i_return.

endmethod.

I hope this solves your problem.

Regards,

Khushbu

3 REPLIES 3
Read only

Former Member
0 Likes
719

Why not directly use:

DATA :  i_rkpf    TYPE STANDARD TABLE OF BAPIRKPFC,
       wa_rkpf  
TYPE BAPIRKPFC.

Read only

Former Member
0 Likes
720

Hello Felipe,

Please try declaring as below:

DATA :  i_rkpf    TYPE bapirkpfc .

Please note that bapirkpfc is a structure and is holding  only one record at run time. Hence you can avoid using the workarea.

Please see below code :

method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

TYPES: BEGIN OF t_resb.

        INCLUDE TYPE  bapiresbc .

TYPES: END OF t_resb.

DATA :  i_resb    TYPE STANDARD TABLE OF T_RESB INITIAL SIZE 0,

        wa_resb   TYPE t_resb.

DATA :  i_rkpf    TYPE bapirkpfc .

*        wa_rkpf   TYPE bapirkpfc.

DATA:   i_return TYPE TABLE OF bapireturn.

DATA: vl_rsnum TYPE rkpf-rsnum.

wa_resb-GR_RCPT    = 'A000'.

wa_resb-plant     = '2000'.

wa_resb-material  = '000000000000000008'.

wa_resb-store_loc = '0002'.

wa_resb-quantity  = '90.00'.

wa_resb-unit      = 'G'.

wa_resb-movement  = 'X'.

Append wa_resb to i_resb.

i_rkpf-plant     = '2000'.

i_rkpf-res_date  = sy-datum.

i_rkpf-move_type = '311'.

break-point.

CALL FUNCTION 'BAPI_RESERVATION_CREATE'

  EXPORTING

    reservation_header = i_rkpf

  IMPORTING

    reservation        = vl_rsnum

  TABLES

    reservation_items  = i_resb

    return             = i_return.

endmethod.

I hope this solves your problem.

Regards,

Khushbu

Read only

0 Likes
719

Thanks to Elzkie and Khushbu for your time. Following the solution path guided by Khushbu, I got the expected reserves. The final code is:

method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

TYPES: BEGIN OF t_resb.

         INCLUDE TYPE  bapiresbc .

TYPES: END OF t_resb.

TYPES: BEGIN OF t_rkpf.

         INCLUDE TYPE bapirkpfc .

TYPES: END OF t_rkpf.

DATA i_resb    TYPE STANDARD TABLE OF T_RESB INITIAL SIZE 0,

         wa_resb   TYPE t_resb.

DATA i_rkpf    TYPE BAPIRKPFC.

*        wa_rkpf   TYPE t_rkpf.

DATA:   i_return TYPE TABLE OF bapireturn.

DATA: vl_rsnum TYPE rkpf-rsnum.

wa_resb-GR_RCPT    = 'A000'.

wa_resb-plant     = '2000'.

wa_resb-material  = '000000000000000008'.

wa_resb-store_loc = '0002'.

wa_resb-quantity  = '90.00'.

wa_resb-unit      = 'G'.

wa_resb-movement  = 'X'.

Append wa_resb to i_resb.

i_rkpf-plant     = '2000'.

i_rkpf-res_date  = sy-datum.

i_rkpf-move_type = '311'.

*Append wa_rkpf to i_rkpf.

break-point.

CALL FUNCTION 'BAPI_RESERVATION_CREATE'

   EXPORTING

     reservation_header = i_rkpf

     no_commit = 'X'

   IMPORTING

     reservation        = vl_rsnum

   TABLES

     reservation_items  = i_resb

     return             = i_return.

endmethod.