Query with collective information from MD04 in detail

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Locked
Flare
Posts: 17
Joined: Wed Jun 28, 2006 4:18 pm

Query with collective information from MD04 in detail

Post by Flare » Fri Aug 27, 2010 8:03 am

Hello gurus. I have a question about Infosets.

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.
Last edited by Gothmog on Fri Aug 27, 2010 8:11 am, edited 1 time in total.
Reason: added code blocks - please use them

baanbrecher
Posts: 105
Joined: Wed May 21, 2003 10:17 am

Re: Query with collective information from MD04 in detail

Post by baanbrecher » Fri Aug 27, 2010 8:08 am

Not directly answering you MDKP-question but I've looped over MARC and then:

Code: Select all

        CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'      "MD04
          EXPORTING
*           PLSCN                          =
            matnr                          = <gs_marc>-matnr
            werks                          = <gs_marc>-werks
*           BERID                          =
*           ERGBZ                          =
*           AFIBZ                          =
*           INPER                          =
*           DISPLAY_LIST_MDPSX             = 'X'
*           DISPLAY_LIST_MDEZX             = 'X'
*           DISPLAY_LIST_MDSUX             = 'X'
*           NOBUF                          =
*           PLAUF                          =
*         IMPORTING
*           E_MT61D                        =
*           E_MDKP                         =
*           E_CM61M                        =
*           E_MDSTA                        =
*           E_ERGBZ                        =
          TABLES
            mdpsx                          = gt_mdps
*           mdezx                          = gt_mdez
*           mdsux                          = gt_mdsu
          EXCEPTIONS
            material_plant_not_found       = 1
            plant_not_found                = 2
            OTHERS                         = 3.
        IF sy-subrc = 0.
          PERFORM loop_mdps.
          " ELSE.
          " MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          "         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
and i've found the stuff I need in gt_mpds.

Flare
Posts: 17
Joined: Wed Jun 28, 2006 4:18 pm

Re: Query with collective information from MD04 in detail

Post by Flare » Fri Aug 27, 2010 9:29 am

yeah, I think the material number can be found in different tables exported from this function. My problem is, since the Infoset only allows me to use one structure, where can I send the value of the MATNR?

baanbrecher
Posts: 105
Joined: Wed May 21, 2003 10:17 am

Re: Query with collective information from MD04 in detail

Post by baanbrecher » Fri Aug 27, 2010 10:02 am

Flare wrote:... since the Infoset ...
I'm sorry, whenever I hear infoset, my toenails roll-up backwards. I therefore oppose to giving advice on infosets. Write/let write a decent abap-code and all involved will be happier in the long run. (and with infosets, "longrun" means running a program more than once ;-))

Flare
Posts: 17
Joined: Wed Jun 28, 2006 4:18 pm

Re: Query with collective information from MD04 in detail

Post by Flare » Fri Aug 27, 2010 10:18 am

I understand you. My issue is I don't belong to the developing department in my organization, so I don't have a developer key and no access to create ABAP programs. I also lack the skills to build one.

My current authorizations only allow me to create Infosets for SAP Queries so it's what I use. I also needed this fast and wanted to do it myself so it works as I want it.

If you still would like to give advice on this, please post. Thank you.

cbkuah
Posts: 1
Joined: Thu Jun 30, 2011 3:11 am

Re: Query with collective information from MD04 in detail

Post by cbkuah » Thu Jun 30, 2011 3:35 am

Hi Flare,

Thank you for your question, and it has helped me to solve my problem. For your question, if you have not yet solve the problem. I would like to suggest 2 methods :
1. Get the material no from e_mdkp to it_data-MPNMT while you loop the id_data. or
2. Create another customized structure with the information you needs from mdez and add in the matnr field. Then, create another infoset for it.

Gothmog
Posts: 1954
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Query with collective information from MD04 in detail

Post by Gothmog » Thu Jun 30, 2011 5:06 am

Let's hope that after one year the problem is solved...
Locked.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67

Locked