Skip to Content
Author's profile photo Guilherme Frisoni

How to get Overview Tree from MD04 with MD_SALES_ORDER_STATUS_REPORT FM

Recently I needed to get information from CO46 tcode to use in a custom development. More specifically, I needed Overview Tree from MD04.

/wp-content/uploads/2013/08/tela1_265701.jpg

The only FM to get this data is MD_SALES_ORDER_STATUS_REPORT, but this FM just open CO46 tcode.

So we have this NODISP parameter in the FM, but when enabled, it returns only the IIOELX table and any data from Overview Tree.

So, I did a huge workaround to get this information from this FM. As it is described below.

In the Z program we have to o the following:

Declare two variables:

DATA: lc_md_memory,
             gt_ord_outtab  TYPE ty_io_struc_tab.

You can copy ty_io_struc_tab structure from program LM61TTOP.

In your code, before call MD_SALES_ORDER_STATUS_REPORT FM, you need to set some memory information.

Note that NODISP parameter is set to space as default.

lc_md_memory = cc_x.    " Set var to export to memory
EXPORT lc_md_memory TO MEMORY ID 'MDREPORT'.
" Call FM with your parameters
CALL FUNCTION 'MD_SALES_ORDER_STATUS_REPORT'
EXPORTING
           edelet         = ls_mdpsx-delet
           edelkz         = ls_mdpsx-delkz
           edelnr         = ls_mdpsx-del12
           edelps         = ls_mdpsx-delps
           ewerks         = ls_mt61d-werks
           i_ignore_mtold = 'X'
           i_profid       = 'SAP000000002'
EXCEPTIONS
           error          = 1
          others         = 2.
" Import result table from memory
IMPORT gt_ord_outtab FROM MEMORY ID 'MDREPORT'.

After this points, you should have your internal table GT_ORD_OUTTAB with the same information from Overview Tree, but to work we need to create another piece of this puzzle: an implicit enhancement.

Go to program LM61TF27, enable Enhance and Show Implicit Enhance Options.

In the end of form ord_create_tree, create an enhance implamentation to insert the following code:

  DATA: lc_md_memory.
   IMPORT lc_md_memory FROM MEMORY ID 'MDREPORT'.
   IF lc_md_memory IS NOT INITIAL.
     EXPORT gt_ord_outtab TO MEMORY ID 'MDREPORT'.
     LEAVE PROGRAM.
   ENDIF.

In this code, we get lc_md_memory from memory to check if it is set from our calling program.

If is set, we export gt_ord_outtab to memory and finally leave current program to avoid open CO46 transaction.

It should be like this:

/wp-content/uploads/2013/08/tela2_265702.jpg

In our calling program, GT_ORD_OUTTAB will be populated as CO46.

/wp-content/uploads/2013/08/tela3_265727.jpg

Hope it helps!

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Edlene Correa
      Edlene Correa

      Frisoni, você é um ótimo profissional. Gosto muito do seu trabalho.

      Abraços.

      Author's profile photo Former Member
      Former Member

      Hi,Frisoni,

      What means for cc_x.

      lc_md_memory = cc_x.

      Can you help? I want to get the MD4C data from the function MD_SALES_ORDER_STATUS_REPORT with your solution.

      Author's profile photo Guilherme Frisoni
      Guilherme Frisoni
      Blog Post Author

      Hi Chao,

      It's just a constant with X value.

      CONSTANTS: cc_x TYPE string VALUE 'X'.

      Author's profile photo VELMURUGAN P
      VELMURUGAN P

      HI Guilherme Frisoni Machado

       

      Thank you for detailed explanation , appreciate your approach .

       

      1.i have come across the same scenario to display  'GT_ORD_OUTTAB will be populated as CO46 ' and am able to get records as expected in foreground not in Background job(SM37). i wanted to execute report which is calling the same FM-MD_SALES_ORDER_STATUS_REPORT  to get the GT_ORD_OUTTAB , it's Giving Runtime error . can you please help me on this scenario.

       

      Thank you .

      Raju G.

       

      Author's profile photo MAHESH K
      MAHESH K

      I have come across the same scenario to display  'GT_ORD_OUTTAB will be populated as CO46 ' and am able to get records as expected in foreground not in Background job(SM37). i wanted to execute report which is calling the same FM-MD_SALES_ORDER_STATUS_REPORT  to get the GT_ORD_OUTTAB , it's Giving Runtime error .

      can you please help me on this scenario.

       

      Thank you .

      Mahesh K

      Author's profile photo Fabio Junior Gross
      Fabio Junior Gross

      Olá Frisoni,

       

      Muito obrigado pelo tutorial, eu estava quebrando a cabeça a alguns dias tentando resolver este problema.

       

      Apenas uma pergunta: em relação a hierarquia apresentada na MD4C, existe algum campo na tabela gerada que indique a hierarquia?

       

      Att.

      Fabio J. Gross

      Author's profile photo Atos AMS SD
      Atos AMS SD

      Thanks a lot!!!

      Author's profile photo Clemens Li
      Clemens Li

      No need to use cc_x as we have the built-in constant abap_true.

      Someting some abapers need to get comfortable with.

      Regards Clemens

       

       

       

      Author's profile photo Sonali Priya
      Sonali Priya

      Thanks a lot .It really helped in solving my problem.

      Author's profile photo MAHESH K
      MAHESH K

      HI Guilherme Frisoni Machado

       

      i have come across the same scenario to display  'GT_ORD_OUTTAB will be populated as CO46 ' and am able to get records as expected in foreground not in Background job(SM37). i wanted to execute report which is calling the same FM-MD_SALES_ORDER_STATUS_REPORT  to get the GT_ORD_OUTTAB , it's Giving Runtime error .

      can you please help me on this scenario.

       

      Thank you .

      Mahesh K