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: 

MD04 Report not running

Former Member
0 Kudos

Hi

I am running the following report to display MD04 data :

START-OF-SELECTION.

* Get the materials
   SELECT matnr m~werks fabkl
     FROM marc AS m JOIN t001w AS w
     ON m~werks = w~werks
     INTO TABLE gt_marc
     WHERE matnr IN s_matnr AND
           m~werks IN s_werks.

   LOOP AT gt_marc INTO gw_marc.

     CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
       EXPORTING
*   PLSCN                          =
         matnr                          = gw_marc-matnr
         werks                          = gw_marc-werks
*   BERID                          =
*   ERGBZ                          =
*   AFIBZ                          =
*   INPER                          =
*   DISPLAY_LIST_MDPSX             =
*   DISPLAY_LIST_MDEZX             =
*   DISPLAY_LIST_MDSUX             =
*   NOBUF                          =
*   PLAUF                          =
*   IS_SFILT                       =
*   IS_AFILT                       =
* IMPORTING
*   E_MT61D                        =
*   E_MDKP                         =
*   E_CM61M                        =
*   E_MDSTA                        =
*   E_ERGBZ                        =
      TABLES
        mdpsx                          = gt_mdpsx
        mdezx                          = gt_mdezx
        mdsux                          = gt_mdsux
      EXCEPTIONS
        material_plant_not_found       = 1
        plant_not_found                = 2
        OTHERS                         = 3
               .
     IF sy-subrc <> 0.
    ELSE.


       REFRESH i_outtab.
       LOOP AT gt_mdpsx
          INTO gw_mdpsx


          WHERE  delkz IN s_delkz AND
                 dat00 IN s_dat00 AND
                 dat01 IN s_dat01 AND
                 imwerk IN s_werks AND

                 ematn IN s_matnr.


         MOVE-CORRESPONDING gw_mdpsx TO gw_outtab.

         CLEAR gv_found.
         gv_days = gw_mdpsx-dat01 - gw_mdpsx-dat00.
         gw_outtab-new_date = gw_mdpsx-dat01.
         CLEAR gv_tabix.
         WHILE gv_found IS INITIAL.
           REFRESH gt_holidays.
           CALL FUNCTION 'HOLIDAY_GET'
            EXPORTING
*           HOLIDAY_CALENDAR                 = ' '
              factory_calendar                 = gw_marc-fabkl
              date_from                        = gw_mdpsx-dat00
              date_to                          = gw_outtab-new_date
*         IMPORTING
*           YEAR_OF_VALID_FROM               =
*           YEAR_OF_VALID_TO                 =
*           RETURNCODE                       =
             TABLES
               holidays                         = gt_holidays
            EXCEPTIONS
              factory_calendar_not_found       = 1
              holiday_calendar_not_found       = 2
              date_has_invalid_format          = 3
              date_inconsistency               = 4
              OTHERS                           = 5
                     .
           IF sy-subrc = 0.
             DESCRIBE TABLE gt_holidays LINES gv_days2.
             IF gv_tabix IS INITIAL.
               gw_outtab-ini_days gv_days2." Initial days of holidays
             ENDIF.
             gv_days2 = gw_outtab-new_date - gw_mdpsx-dat00 - gv_days2.
             IF  gv_days2 => gv_days.
               EXIT.
             ELSE.
               gw_outtab-new_date = gw_outtab-new_date + gv_days2.
             ENDIF.
           ELSE.
             CLEAR gw_outtab-new_date.
             EXIT.
           ENDIF.

         ENDWHILE.
         DESCRIBE TABLE gt_holidays LINES gv_days2.
         IF gv_tabix IS INITIAL.
           gw_outtab-fin_days = gv_days2." Final days of holidays
         ENDIF.
*        APPEND gw_outtab TO i_outtab.
*      ENDLOOP.
*    ENDIF.
APPEND gw_outtab TO i_outtab.
clear gw_outtab.
endloop.
endif.
   ENDLOOP.


END-OF-SELECTION.

* List data
   PERFORM f_list USING i_outtab[]
                        p_varid.

FORM f_list USING value(pi_outtab) TYPE ti_outtab
                   value(pe_varidTYPE slis_vari.

   DATA: li_fieldcat TYPE slis_t_fieldcat_alv,   "Field catalog
         li_sort     TYPE slis_t_sortinfo_alv,   "Default sorting
         lr_layout   TYPE slis_layout_alv,       "Output format
         lr_print    TYPE slis_print_alv,        "Print options
         lr_variant  TYPE disvariant.            "Layout

   CHECK NOT pi_outtab[] IS INITIAL.

* Creation of the table with the fields information of the list
   PERFORM f_field_catalog CHANGING li_fieldcat[].

* Standard sort of the fields of the list
   PERFORM f_sort CHANGING li_sort[].

* Layout definition
   PERFORM f_layout_format USING    pe_varid
                           CHANGING lr_layout
                                    lr_print
                                    lr_variant.

* Show data
   PERFORM f_data_list USING pi_outtab[]
                             li_fieldcat[]
                             li_sort[]
                             lr_layout
                             lr_print
                             lr_variant.
endform.



______________________

I am using 2 FM -  MD_STOCK_REQUIREMENTS_LIST_API to get the details

and FM HOLIDAY_GET to calculate the number of holidays btwn doc and delievery date..

However , on debugging, the FM MD_STOCK_REQUIREMENTS_LIST_API is running fine but the part of the code after   LOOP AT gt_mdpsx
INTO gw_mdpsx
is not getting executed. The control directly passes to line APPEND gw_outtab TO i_outtab.

The value of i_outtab  in APPEND gw_outtab TO i_outtab is initial and so the report doesnt get displayed.

Can anybody let me know what is happening here and what is wrong in the above report?


1 ACCEPTED SOLUTION

former_member182873
Participant
0 Kudos

Hi Shalini ,

your output table gt_mdpsx doesn't contain field  IMWERK,Can you check it once as it is in your where clause ( imwerk IN s_werks ).


Regards ,

Manju

8 REPLIES 8

former_member187748
Active Contributor
0 Kudos

Hi Shalini,

do one thing , just uncomment the below lines of holiday calender, and pass the holiday calender id/name into it, and uncomment the return code too, the plesae debug and see that it is working or not.

Please revert with your findings.

           CALL FUNCTION 'HOLIDAY_GET'

            EXPORTING

*           HOLIDAY_CALENDAR                 = ' '

0 Kudos

Hi Sanjeev

I did the changes.

However , its happening the same.

The lines after LOOP AT gt_mdpsx
INTO gw_mdpsx are
not getting executed. The control directly passes to line APPEND gw_outtab TO i_outtab skipping HOLIDAY_GET and other code in between.





0 Kudos

Hi Shalini,

please put your break point at below, and see that you are getting any data in gt_mdpsx or not, because it is remaining empty , thats why your debugger is not getting into it, i think its not the problem of FM HOLIDAY_GET, but the problem is in MD_STOCK_REQUIREMENTS_LIST_API  itself.

     TABLES

        mdpsx                          = gt_mdpsx               "Put breakpoint here and see that you have data in this or not

0 Kudos

Hi Sanjeev

I debugged already and found that gt_mdpsx has values.

I have attached the screenshot in my first post for the same.

However  i_outtab is not fetching those values.


karun_prabhu
Active Contributor
0 Kudos

Hello Shalini.

     Do not use the FM MD_STOCK_REQUIREMENTS_LIST_API.

     Instead use BAPI_MATERIAL_STOCK_REQ_LIST for your requirement. The FM is not released.

Regards.

former_member182873
Participant
0 Kudos

Hi Shalini ,

your output table gt_mdpsx doesn't contain field  IMWERK,Can you check it once as it is in your where clause ( imwerk IN s_werks ).


Regards ,

Manju

0 Kudos

Hi

I tried to replace the FM with BAPI but the problem is still not solved.

Output table gt_mdpsx is of the type mdps which has the field INMWERK.

Can there be any issue regd setting of filters in variants to display the report.

Any suggestions ?

Former Member
0 Kudos

Hi all

Problem solved with Manjunatha s inputs.

Thanks