"Blocked list in ALV" Code Answer's

You're definitely familiar with the best coding language SQL that developers use to develop their projects and they get all their queries like "Blocked list in ALV" answered properly. Developers are finding an appropriate answer about Blocked list in ALV related to the SQL coding language. By visiting this online portal developers get answers concerning SQL codes question like Blocked list in ALV. Enter your desired code related query in the search bar and get every piece of information about SQL code related question on Blocked list in ALV. 

Blocked list in ALV

By Calm CrossbillCalm Crossbill on Apr 30, 2021
REPORT ZSAPN_ALV_BLOCKEDLIST.
TYPES: BEGIN OF TY_MARA, "user defined type for mara
        MATNR TYPE MARA-MATNR,
        MTART TYPE MARA-MTART,
        MBRSH TYPE MARA-MBRSH,
        MATKL TYPE MARA-MATKL,
        MEINS TYPE MARA-MEINS,
      END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA, "mara internal table
       WA_MARA TYPE TY_MARA. "mara work area
DATA : T_FCAT TYPE SLIS_T_FIELDCAT_ALV. "field catalog for MARA table
DATA : W_FCAT LIKE LINE OF T_FCAT.

TYPES: BEGIN OF TY_MAKT, "user defined type for MAKT
        MATNR TYPE MAKT-MATNR,
        SPRAS TYPE MAKT-SPRAS,
        MAKTX TYPE MAKT-MAKTX,
      END OF TY_MAKT.
DATA : IT_MAKT TYPE TABLE OF TY_MAKT, "makt internal table
       WA_MAKT TYPE TY_MAKT.
DATA : T_FCAT_MAKT TYPE SLIS_T_FIELDCAT_ALV. "makt field catalog
DATA : W_FCAT_MAKT LIKE LINE OF T_FCAT_MAKT.
PARAMETERS : P_MTART TYPE MARA-MTART. "material type input

START-OF-SELECTION.

  SELECT MATNR
         MTART
         MBRSH
         MATKL
         MEINS FROM MARA "get MARA data
    INTO TABLE IT_MARA UP TO 10 ROWS WHERE MTART = P_MTART.
  IF NOT IT_MARA IS INITIAL .
    SELECT MATNR
           SPRAS
           MAKTX FROM MAKT INTO TABLE IT_MAKT "get makt data
      FOR ALL ENTRIES IN IT_MARA WHERE MATNR = IT_MARA-MATNR.
  ENDIF.
***build fcat for MARA
  W_FCAT-COL_POS       = '1'. "coloum position
  W_FCAT-FIELDNAME     = 'MATNR'. "column name
  W_FCAT-TABNAME       = 'IT_MARA'. "table
  W_FCAT-REF_TABNAME   = 'MARA'. "table
  W_FCAT-REF_FIELDNAME = 'MATNR'. "referance field, it will show descriptions automatically
  APPEND W_FCAT TO T_FCAT.
  CLEAR W_FCAT.

  W_FCAT-COL_POS       = '2'.
  W_FCAT-FIELDNAME     = 'MTART'.
  W_FCAT-TABNAME       = 'IT_MARA'.
  W_FCAT-REF_TABNAME   = 'MARA'.
  W_FCAT-REF_FIELDNAME = 'MTART'.
  APPEND W_FCAT TO T_FCAT.
  CLEAR W_FCAT.

  W_FCAT-COL_POS       = '3'.
  W_FCAT-FIELDNAME     = 'MBRSH'.
  W_FCAT-TABNAME       = 'IT_MARA'.
  W_FCAT-REF_TABNAME   = 'MARA'.
  W_FCAT-REF_FIELDNAME = 'MBRSH'.
  APPEND W_FCAT TO T_FCAT.
  CLEAR W_FCAT.

  W_FCAT-COL_POS       = '4'.
  W_FCAT-FIELDNAME     = 'MATKL'.
  W_FCAT-TABNAME       = 'IT_MARA'.
  W_FCAT-REF_TABNAME   = 'MARA'.
  W_FCAT-REF_FIELDNAME = 'MATKL'.
  APPEND W_FCAT TO T_FCAT.
  CLEAR W_FCAT.

  W_FCAT-COL_POS       = '5'.
  W_FCAT-FIELDNAME     = 'MEINS'.
  W_FCAT-TABNAME       = 'IT_MARA'.
  W_FCAT-REF_TABNAME   = 'MARA'.
  W_FCAT-REF_FIELDNAME = 'MEINS'.
  APPEND W_FCAT TO T_FCAT.
  CLEAR W_FCAT.

***build fcat for MAKT
  W_FCAT_MAKT-COL_POS       = '1'.
  W_FCAT_MAKT-FIELDNAME     = 'MATNR'.
  W_FCAT_MAKT-TABNAME       = 'IT_MAKT'.
  W_FCAT_MAKT-REF_TABNAME   = 'MAKT'.
  W_FCAT_MAKT-REF_FIELDNAME = 'MATNR'.
  APPEND W_FCAT_MAKT TO T_FCAT_MAKT.
  CLEAR W_FCAT_MAKT.
  W_FCAT_MAKT-COL_POS       = '2'.
  W_FCAT_MAKT-FIELDNAME     = 'SPRAS'.
  W_FCAT_MAKT-TABNAME       = 'IT_MAKT'.
  W_FCAT_MAKT-REF_TABNAME   = 'MAKT'.
  W_FCAT_MAKT-REF_FIELDNAME = 'SPRAS'.
  APPEND W_FCAT_MAKT TO T_FCAT_MAKT.
  CLEAR W_FCAT_MAKT.
  W_FCAT_MAKT-COL_POS       = '3'.
  W_FCAT_MAKT-FIELDNAME     = 'MAKTX'.
  W_FCAT_MAKT-TABNAME       = 'IT_MAKT'.
  W_FCAT_MAKT-REF_TABNAME   = 'MAKT'.
  W_FCAT_MAKT-REF_FIELDNAME = 'MAKTX'.
  APPEND W_FCAT_MAKT TO T_FCAT_MAKT.
  CLEAR W_FCAT_MAKT.
*  * init
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT' "initialize Block List ALV
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID.

  DATA S_EVENTS TYPE SLIS_T_EVENT.
  DATA S_LAYOUT TYPE SLIS_LAYOUT_ALV.
  S_LAYOUT-ZEBRA = 'X'.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' "append ALV lists
    EXPORTING
      IS_LAYOUT   = S_LAYOUT "set layout
      IT_FIELDCAT = T_FCAT "set field catalog
      I_TABNAME   = 'IT_MARA' "table
      IT_EVENTS   = S_EVENTS "events
*     IT_SORT     =
*     I_TEXT      = ' '
    TABLES
      T_OUTTAB    = IT_MARA "out put table
*   EXCEPTIONS
*     PROGRAM_ERROR                    = 1
*     MAXIMUM_OF_APPENDS_REACHED       = 2
*     OTHERS      = 3
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' "append ALV lists
    EXPORTING
      IS_LAYOUT   = S_LAYOUT "set layout
      IT_FIELDCAT = T_FCAT_MAKT "set field catalog
      I_TABNAME   = 'IT_MAKT' "table
      IT_EVENTS   = S_EVENTS "events
*     IT_SORT     =
*     I_TEXT      = ' '
    TABLES
      T_OUTTAB    = IT_MAKT "out put table
*   EXCEPTIONS
*     PROGRAM_ERROR                    = 1
*     MAXIMUM_OF_APPENDS_REACHED       = 2
*     OTHERS      = 3
    .
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY' . "display blocked list

Source: www.sapnuts.com

Add Comment

0

All those coders who are working on the SQL based application and are stuck on Blocked list in ALV can get a collection of related answers to their query. Programmers need to enter their query on Blocked list in ALV related to SQL code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Blocked list in ALV for the programmers working on SQL code while coding their module. Coders are also allowed to rectify already present answers of Blocked list in ALV while working on the SQL language code. Developers can add up suggestions if they deem fit any other answer relating to "Blocked list in ALV". Visit this developer's friendly online web community, CodeProZone, and get your queries like Blocked list in ALV resolved professionally and stay updated to the latest SQL updates. 

SQL answers related to "Blocked list in ALV"

View All SQL queries

SQL queries related to "Blocked list in ALV"

Browse Other Code Languages

CodeProZone