通过 MD_SALES_ORDER_STATUS_REPORT 建立MD04展开树

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

tela1.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:

 

  1. DATA: lc_md_memory,  
  2.              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.

 

  1. lc_md_memory = cc_x.    " Set var to export to memory  
  2. EXPORT lc_md_memory TO MEMORY ID 'MDREPORT'.  
  3. " Call FM with your parameters  
  4. CALL FUNCTION 'MD_SALES_ORDER_STATUS_REPORT'  
  5. EXPORTING  
  6.            edelet         = ls_mdpsx-delet  
  7.            edelkz         = ls_mdpsx-delkz  
  8.            edelnr         = ls_mdpsx-del12  
  9.            edelps         = ls_mdpsx-delps  
  10.            ewerks         = ls_mt61d-werks  
  11.            i_ignore_mtold = 'X'  
  12.            i_profid       = 'SAP000000002'  
  13. EXCEPTIONS  
  14.            error          = 1  
  15.           others         = 2.  
  16. " Import result table from memory  
  17. 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:

 

  1.   DATA: lc_md_memory.  
  2.    IMPORT lc_md_memory FROM MEMORY ID 'MDREPORT'.  
  3.    IF lc_md_memory IS NOT INITIAL.  
  4.      EXPORT gt_ord_outtab TO MEMORY ID 'MDREPORT'.  
  5.      LEAVE PROGRAM.  
  6.    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:

tela2.jpg

 

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

tela3.jpg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值