Application Development 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: 

FM MD_STOCK_REQUIREMENTS_LIST_API behaviour when used in a program.

walkerist
Participant
0 Kudos
711

Hi, I'm using the FM MD_STOCK_REQUIREMENTS_LIST_API to fetch some data. However, when used in a program, it only provides 1 data. But when it is executed in SE37, it provides 37 columns of data.

My issue is, when used in the program, only the first data were fetched and the first data is not the one I needed. Is there a way to fix this?

4 REPLIES 4

DominikTylczyn
Active Contributor
0 Kudos
558

Hello walkerist

The way to fix it is to call the function from your program in exactly the same way as you call it from SE37.

Also, you'd be better off using the BAPI_MATERIAL_STOCK_REQ_LIST function. It gets the same data as MD_STOCK_REQUIREMENTS_LIST_API i.e. stock/requirements list, but is officially released for customers.

Best regards

Dominik Tylczynski

raymond_giuseppi
Active Contributor
0 Kudos
558

Usually when program and SE37 don't share their behavior, it's related to conversion-exits. SE37 convert your input to internal format when your program doesn't. (Of course you can also have some typo in your code)

Can you post your code.

NB: Most SAP documentations on this API link also to BAPI_MATERIAL_STOCK_REQ_LIST .

0 Kudos
558
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
 EXPORTING
 matnr = lx_tab-matnr
 werks = lx_tab-werks
 TABLES
 mdpsx = lt_mdps
 EXCEPTIONS
 material_plant_not_found = 1
 plant_not_found = 2
 OTHERS = 3.

the lx_tab comes from t_tab.

Scenario 1: when there are multiple rows of materials in T_TAB, the FM is working as expected.

Scenario 2: But when only the material 1888234 is in T_TAB, the FM is not working as expected. When used in SE37, there were several entries. What I need is the 6th entry. However, when used in the program, it only returns the first row which has a blank value.

0 Kudos
558

The problem could come from a parameter not explicitly passed in your code (With SE37 every parameter is used, so some ckeck as <parameter IS REQUESTED> are positive with SE37 and negative for your code)

NB: Also the BAPI, BAPI_MATERIAL_STOCK_REQ_LIST, refresh some data between calls of the same FM, compare your code with the code of the BAPI.