Skip to Content
0
Former Member
Jan 27, 2009 at 06:58 AM

hi iamdoing material master dat summary so i wrote code for this as fallow

20 Views

ACTUALLY THE SYNTATICALLY CORRECT UT IT GOES TO DUMP IAM UNABLE TO FIND ERROR SO PLS HELP ME ANY BODY EVEN DEBUUGING IT GOES TO STANDARD CODE.

REPORT  ysyam_alv_materialmasterdata .

TABLES : mara,                                  " General material data
         marc,                                  " Plant data for material
         makt.                                  " Material description
TYPE-POOLS : slis.

TYPES :
 BEGIN OF type_s_mat,
  werks TYPE marc-werks,                        " PLANT
  mtart TYPE mara-mtart,                        " MATERIAL TYPE
  matkl TYPE mara-matkl,                        " MATERIAL GROUP
  matnr TYPE mara-matnr,                        " MATERIAL NUMBER
  END OF type_s_mat.
TYPES :
 BEGIN OF t_output ,
  werks TYPE marc-werks,
  mtart TYPE mara-mtart,
  matkl TYPE mara-matkl,
  matnr TYPE mara-matnr,
  maktx TYPE makt-maktx,
  prctr TYPE marc-prctr,
  disls TYPE marc-disls,
  fixls TYPE marc-fixls,
  losgr TYPE marc-losgr,
  beskz TYPE marc-beskz,
  sobsl TYPE marc-sobsl,
  dismm TYPE marc-dismm,
  minbe TYPE marc-minbe,
  dispo TYPE marc-dispo,
  fxhor TYPE marc-fxhor,
  plifz TYPE marc-plifz,
  END OF t_output.
DATA :
 it_output TYPE STANDARD TABLE OF t_output INITIAL SIZE 0 WITH HEADER LINE.
* wa_output TYPE t_output.

DATA :

i_mat TYPE STANDARD TABLE OF type_s_mat
           INITIAL SIZE 30
           WITH HEADER LINE.
DATA :
      wa_fieldcatlog  TYPE slis_fieldcat_alv,
      it_fieldcatlog  TYPE slis_t_fieldcat_alv with header line,

      it_layout           TYPE slis_layout_alv ,
      wa_sortinfo         TYPE slis_sortinfo_alv,
      it_sortinfo         TYPE slis_t_sortinfo_alv with header line,
      it_events           TYPE slis_t_event .


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
SELECT-OPTIONS : s_plant FOR marc-werks,      "plant
                 s_mtart FOR mara-mtart,      " material type
                 s_matkl FOR mara-matkl,      " material group
                 s_matnr FOR mara-matnr.      " material no

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON s_plant.
  SELECT werks INTO  i_mat
               FROM  marc
           WHERE werks IN s_plant.
    IF sy-subrc NE 0.
*      MESSAGE E000 WITH  'ENTER VALID PLANT'.
      WRITE :/ 'ENTER VALID PLANT'.

    ENDIF.
  ENDSELECT.

AT SELECTION-SCREEN ON s_mtart.
  SELECT mtart INTO  i_mat
               FROM  mara
              WHERE  mtart  IN s_mtart.
    IF sy-subrc NE 0.
     WRITE :/ 'ENTER VALID MATERIAL TYPE'.

*      MESSAGE E001 WITH  'ENTER VALID MATERIAL TYPE'.
    ENDIF.
  ENDSELECT.

AT SELECTION-SCREEN ON s_matkl.
  SELECT matkl INTO  i_mat
               FROM  mara
              WHERE  matkl  IN s_matkl.
    IF sy-subrc NE 0.
    WRITE :/ 'ENTER VALID MATERIAL GROUP'.
*      MESSAGE E002 WITH  'ENTER VALID MATERIAL GROUP'.
    ENDIF.
  ENDSELECT.

AT SELECTION-SCREEN ON s_matnr.
  SELECT matnr INTO  i_mat
               FROM  mara
              WHERE  matnr  IN s_matnr.
    IF sy-subrc NE 0.
    WRITE :/ 'ENTER VALID MATERIAL NO'.
*      MESSAGE E003 WITH  'ENTER VALID MATERIAL NO'.
    ENDIF.
  ENDSELECT.


  DATA: v_repid TYPE sy-repid.
*        wa_mara_field TYPE slis_fieldcat_alv,       "it is for field catalog
*        wa_marc_field TYPE slis_fieldcat_alv,
*        wa_makt_field TYPE slis_fieldcat_alv,
*        wa_mara TYPE mara,
*        wa_marc TYPE marc,
*        wa_makt TYPE makt,
*        it_mara_field TYPE slis_t_fieldcat_alv,
*        it_marc_field TYPE slis_t_fieldcat_alv,
*        it_makt_field TYPE slis_t_fieldcat_alv,
*        it_mara TYPE TABLE OF mara,
*        it_marc TYPE TABLE OF marc,
*        it_makt TYPE TABLE OF makt,

*        v_layout TYPE slis_layout_alv,
**        it_events TYPE slis_t_event,                 "it is for events
**        wa_events TYPE slis_alv_event.
*
*        wa_fieldcat type slis_fieldcat_alv,
*        wa_events   type slis_alv_event.

START-OF-SELECTION.
  PERFORM data_retrivel.
  PERFORM build_fieldcatalog..
  PERFORM sort_info.
*  END-OF-SELECTION.
  PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*&      Form  build_fieldcatalog
*&---------------------------------------------------------------------*
* IN THIS FORM WE R GOING TO PREPARE FIELDCATALOG AS PER OUTPUT.
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcatalog .

  wa_fieldcatlog-fieldname   = 'WERKS'.
  wa_fieldcatlog-seltext_m   = 'PLANT'.
  wa_fieldcatlog-col_pos     = '1'.
  wa_fieldcatlog-outputlen   = 4.

  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'MATKL'.
  wa_fieldcatlog-seltext_m   = 'MATERIAL TYPE '.
  wa_fieldcatlog-col_pos     = '2'.
  wa_fieldcatlog-outputlen   = 4.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.


  wa_fieldcatlog-fieldname   = 'MATNR'.
  wa_fieldcatlog-seltext_l   = 'MATERIAL GROUP'.
  wa_fieldcatlog-col_pos     = '3'.
  wa_fieldcatlog-outputlen   = 9.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'MAKTX'.
  wa_fieldcatlog-seltext_l   = 'MATERIAL DESCRIPTION'.
  wa_fieldcatlog-col_pos     = '4'.
  wa_fieldcatlog-outputlen   = 25.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'PRCTR'.
  wa_fieldcatlog-seltext_l   = 'PROFIT CENTER'.
  wa_fieldcatlog-col_pos     = '5'.
  wa_fieldcatlog-outputlen   = 6.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'DISLS'.
  wa_fieldcatlog-seltext_l   = 'LOT SIZE'.
  wa_fieldcatlog-col_pos     = '6'.
  wa_fieldcatlog-outputlen   = 8.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'FIXLS'.
  wa_fieldcatlog-seltext_l   = 'FIXED LOT SIZE'.
  wa_fieldcatlog-col_pos     = '7'.
  wa_fieldcatlog-outputlen   = 8.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'LOSGR'.
  wa_fieldcatlog-seltext_l   = 'COSTING LOT SIZE'.
  wa_fieldcatlog-col_pos     = '8'.
  wa_fieldcatlog-outputlen   = 8.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.
  wa_fieldcatlog-fieldname   = 'BESKZ'.
  wa_fieldcatlog-seltext_l   = 'PROCURTMENT TYPE'.
  wa_fieldcatlog-col_pos     = '9'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'SOBSL'.
  wa_fieldcatlog-seltext_l   = 'SPECIAL PROCURMENT'.
  wa_fieldcatlog-col_pos     = '10'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'DISMM'.
  wa_fieldcatlog-seltext_l   = 'MRP TYPE'.
  wa_fieldcatlog-col_pos     = '11'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'MINBE'.
  wa_fieldcatlog-seltext_l   = 'REORDER POINT'.
  wa_fieldcatlog-col_pos     = '12'.
  wa_fieldcatlog-outputlen   = 8.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'DISPO'.
  wa_fieldcatlog-seltext_l   = 'MRP CONTROLLER'.
  wa_fieldcatlog-col_pos     = '13'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'FXHOR'.
  wa_fieldcatlog-seltext_l   = 'PLAN TIME FENCE'.
  wa_fieldcatlog-col_pos     = '14'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

  wa_fieldcatlog-fieldname   = 'PLIFZ'.
  wa_fieldcatlog-seltext_l   = 'PLAN DELV TIME'.
  wa_fieldcatlog-col_pos     = '15'.
  wa_fieldcatlog-outputlen   = 3.
  APPEND wa_fieldcatlog TO it_fieldcatlog.
  CLEAR  wa_fieldcatlog.

ENDFORM.                    " build_fieldcatalog
**&---------------------------------------------------------------------*
**&      Form  display_alv_report
**&---------------------------------------------------------------------*
**       text
**----------------------------------------------------------------------*
**  -->  p1        text
**  <--  p2        text
**----------------------------------------------------------------------*
FORM display_alv_report.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING

      i_callback_program                = sy-repid
***   I_CALLBACK_PF_STATUS_SET          = ' '
**    I_CALLBACK_USER_COMMAND           = ' '
**     I_STRUCTURE_NAME                  =

**    I_GRID_TITLE                      =
**    I_GRID_SETTINGS                   =
**    IS_LAYOUT                         =
     it_fieldcat                         = it_fieldcatlog[]

     it_sort                             = it_sortinfo[]
**    IT_FILTER                         =
**    IS_SEL_HIDE                       =
**    I_DEFAULT                         = 'X'
**    I_SAVE                            = 'X '
**    IS_VARIANT                        =
**    IT_EVENTS                         =
**    IT_EVENT_EXIT                     =
**    IS_PRINT                          =
**
**  IMPORTING
**    E_EXIT_CAUSED_BY_CALLER           =
**    ES_EXIT_CAUSED_BY_USER            =
    TABLES
     t_outtab                           = it_output
  EXCEPTIONS
    PROGRAM_ERROR                     = 1
    OTHERS                            = 2.

  if sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.                    " display_alv_report
**&---------------------------------------------------------------------*
**&      Form  data_retrivel
**&---------------------------------------------------------------------*
**       text
**----------------------------------------------------------------------*
**  -->  p1        text
**  <--  p2        text
**----------------------------------------------------------------------*
FORM data_retrivel .
*
  SELECT a~werks  b~mtart b~matkl b~matnr c~maktx a~prctr a~disls a~fixls a~losgr a~beskz a~sobsl a~dismm
        a~minbe  a~dispo  a~fxhor INTO TABLE it_output
        FROM marc AS a

         INNER JOIN mara AS b ON b~matnr = a~matnr

         INNER JOIN makt AS c ON c~matnr = a~matnr

         WHERE a~werks   IN s_plant  AND
               b~mtart   IN s_mtart AND
               b~matkl   IN s_matkl AND
               b~matnr  IN s_matnr.
  IF sy-subrc NE 0.
  WRITE :/ 'NO DATA WITH THIS SELECTION'.
*    MESSAGE E004 WITH'NO DATA WITH THIS SELECTION'.
  ENDIF.





ENDFORM.                    " data_retrivel
*&---------------------------------------------------------------------*
*&      Form  sort_info
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM sort_info .
  wa_sortinfo-fieldname = 'WERKS'.
  wa_sortinfo-subtot    = ''.
  APPEND wa_sortinfo TO it_sortinfo.
  CLEAR wa_sortinfo.

  wa_sortinfo-fieldname = 'MTART'.
  wa_sortinfo-subtot    = ''.
  APPEND wa_sortinfo TO it_sortinfo.
  CLEAR wa_sortinfo.

  wa_sortinfo-fieldname = 'MATKL'.
  wa_sortinfo-subtot    = ''.
  APPEND wa_sortinfo TO it_sortinfo.
  CLEAR wa_sortinfo.

  wa_sortinfo-fieldname = 'MATNR'.
  wa_sortinfo-subtot    = ''.
  APPEND wa_sortinfo TO it_sortinfo.
  CLEAR wa_sortinfo.

Edited by: Matt on Jan 27, 2009 11:20 AM tags added