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

Calling Bapi through BADI gives data statement error

Former Member
0 Likes
545

Dear Experts,

I am trying to call BAPI through BADI ME_PROCESS_REQ_CUST --> process_item.

I get an error stating that "The addition OCCURS no longer supported in OO objects"

If, I remove OCCURS statement I get an error stating that "Tables with headers are no longer supported in OO context" for the following data statement.

Appreciate, if you could provide possible solution to overcome the problem.

Regards

Kumar

BAPI code is as follows.

*----


DATA: LV_TABIX LIKE SY-TABIX,

LT_WMDVSX LIKE BAPIWMDVS OCCURS 0 WITH HEADER LINE,

LT_WMDVEX LIKE BAPIWMDVE OCCURS 0 WITH HEADER LINE.

*----


LV_TABIX = SY-TABIX.

CLEAR: LT_WMDVSX, LT_WMDVEX.

REFRESH: LT_WMDVSX, LT_WMDVEX.

  • Fill communication table

LT_WMDVSX-REQ_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.

LT_WMDVSX-REQ_QTY = ET_PROCUREMENT_ITEM-QUANTITY.

APPEND LT_WMDVSX.

  • Availability check with check rule '03'

CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'

EXPORTING

PLANT = ET_PROCUREMENT_ITEM-PLANT

MATERIAL = ET_PROCUREMENT_ITEM-MATERIAL

UNIT = ET_PROCUREMENT_ITEM-UNIT

CHECK_RULE = '03'

TABLES

WMDVSX = LT_WMDVSX

WMDVEX = LT_WMDVEX

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC EQ 0.

READ TABLE LT_WMDVEX WITH KEY

COM_DATE = ET_PROCUREMENT_ITEM-DELIV_DATE.

IF SY-SUBRC EQ 0.

ET_PROCUREMENT_ITEM-AVAIL_QTY = LT_WMDVEX-COM_QTY.

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

MohanChauhan
Product and Topic Expert
Product and Topic Expert
0 Likes
500

Hi,

Occurs is no more supported by SAP ( is an obsolete statement )

<b>Instead of following code</b>

DATA: LV_TABIX LIKE SY-TABIX,

LT_WMDVSX LIKE BAPIWMDVS OCCURS 0 WITH HEADER LINE,

LT_WMDVEX LIKE BAPIWMDVE OCCURS 0 WITH HEADER LINE.

you can use

data: LT_WMDVSX type standard table of BAPIWMDVS,

LT_WMDVEX type standrad table of BAPIWMDVE,

LS_WMDVSX like line of LT_WMDVSX , "( work area )

LS_WMDVEX like line of LT_WMDVEX. "(work area)

use workarea to get the data and then append the records from workarea to Internal tables

Reward points if usefull

Regards,

Mohan

3 REPLIES 3
Read only

Former Member
0 Likes
500

Hi,

Header lines are not supported in ABAP OO.

Instead use work areas and declare your internal tables as such.

DATA: wa <b>type</b> mytable.

DATA: itab<b> type</b> standard table of mytable.

Rregards

Read only

MohanChauhan
Product and Topic Expert
Product and Topic Expert
0 Likes
501

Hi,

Occurs is no more supported by SAP ( is an obsolete statement )

<b>Instead of following code</b>

DATA: LV_TABIX LIKE SY-TABIX,

LT_WMDVSX LIKE BAPIWMDVS OCCURS 0 WITH HEADER LINE,

LT_WMDVEX LIKE BAPIWMDVE OCCURS 0 WITH HEADER LINE.

you can use

data: LT_WMDVSX type standard table of BAPIWMDVS,

LT_WMDVEX type standrad table of BAPIWMDVE,

LS_WMDVSX like line of LT_WMDVSX , "( work area )

LS_WMDVEX like line of LT_WMDVEX. "(work area)

use workarea to get the data and then append the records from workarea to Internal tables

Reward points if usefull

Regards,

Mohan

Read only

0 Likes
500

Hi,

Thanks for the provided solution. Honestly, I am basically from Functional side and our technical team is on vacation. Hence, I require your help in defining the exact logic to call this bapi and read the results.

Would you please provide me the sample logic for calling the BAPI in the BADI to verify the availability of stock.

1. BAPI_MATERIAL_AVAILABILITY.

2. BADI Method: IF_EX_ME_PROCESS_REQ_CUST~PROCESS_ITEM

I will definately award the points for this help.

Reg

Kumar