I’ve being asked to create a query that shows the information from transaction MD04, but for multiple materials. It should be a list that essentially lists every MD04 record for material in our plant, one after the other.
I found a Function called MD_STOCK_REQUIREMENTS_LIST_API which contains this information. The problem is, this function exports the detailed data to a structure called MDEZ and the header data to a separate one called MDKP.
I created an Infoset using “Data Retrieval by program†and I typed MDEZ as the structure. I then coded this under the “Data Reading Program†tab (our plant number is 1350)::
Code: Select all
REPORT RSAQDVP_TEMPLATE .
*
*---------------------------------------------------------------------*
* declarations
* (insert your declarations in this section)
*---------------------------------------------------------------------*
data:
MDEZ type MDEZ ,
it_data type standard table of MDEZ .
field-symbols: <struc> type MDEZ .
*-------------------------------------------------------------------*
* selection screen statements
*-------------------------------------------------------------------*
* (define your selection-screen here)
* !! the following comment MUST NOT BE CHANGED !!
*<QUERY_HEAD>
*-------------------------------------------------------------------*
* read data into IT_DATA
*-------------------------------------------------------------------*
* (select your data here into internal table IT_DATA)
CLEAR: it_data.
REFRESH: it_data.
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
" PLSCN = Planning Scenario of Long-Term Planning
"matnr = Material Number
werks = '1350' "Plant
" BERID = "MRP Area
" IMPORTING
" E_MT61D =
" E_MDKP =
" E_CM61M =
"* E_MDSTA =
TABLES
" MDPSX =
mdezx = it_data
" MDSUX =
EXCEPTIONS
MATERIAL_PLANT_NOT_FOUND = 1
PLANT_NOT_FOUND = 2
OTHERS = 3.
*------------------------------------------------------------*
* output of the data
* (this section can be left unchanged)
*------------------------------------------------------------*
loop at it_data assigning <struc>.
move-corresponding <struc> to MDEZ .
* !! the following comment MUST NOT BE CHANGED !!
*<QUERY_BODY>
endloop.
The problem is, MDEZ doesn’t have the material number; this is exported to E_MDKP.
My question is; how can I also have the contents of MDKP added to this Infoset? When I create it, it only lets me use one single structure, I cannot also add MDKP.
I tried creating an additional field just for the MATNR, but those extra fields cannot read what I coded under the “Data Reading Program†tab. I tried to use a second internal table to drop the values of E_MDKP, and then loop it to fetch the MATNR, but I can’t add it to the additional field nor can I add it to a second structure.
I made a query and it shows the MDEZ data correctly; I get one line per item found in MD04 for the materials I imported from our Plant 1350, but I don’t know which material is which because that info is in the other structure MDKP.