6 Columns with Active Background
Active List Item Background

24REPORT1708 – Blocked ALV Report Example

*&———————————————————————*
*& Report ZBLOCK_ALV_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT ZBLOCK_ALV_REPORT.

TABLES EKKOEKPOLFA1.
TYPES : BEGIN OF GTY_EKKO,
        EBELN TYPE EBELN,
        LIFNR TYPE LIFNR,
        BUKRS TYPE BUKRS,
  END OF GTY_EKKO.

DATA IT_EKKO TYPE STANDARD TABLE OF GTY_EKKO,
       GT_EKKO TYPE GTY_EKKO.

TYPES BEGIN OF GTY_EKPO,
        EBELN TYPE EBELN,
        EBELP TYPE EBELP,
        TXZ01 TYPE TXZ01,
        MATNR TYPE MATNR,
        MENGE TYPE MENGE,
        MEINS TYPE MEINS,
        NETWR TYPE NETWR,
  END OF GTY_EKPO.

DATA GT_EKPO TYPE STANDARD TABLE OF GTY_EKPO,
       GS_EKPO TYPE GTY_EKPO.

TYPES BEGIN OF GTY_LFA1,
        LIFNR TYPE LIFNR,
        NAME1 TYPE NAME1,
END OF GTY_LFA1.

DATA GT_LFA1 TYPE STANDARD TABLE OF GTY_LFA1,
       GS_LFA1 TYPE GTY_LFA1.

DATA GT_FCAT    TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT    TYPE SLIS_FIELDCAT_ALV,
       GT_FCAT1   TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT1   TYPE SLIS_FIELDCAT_ALV,
       GT_FCAT2   TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT2   TYPE SLIS_FIELDCAT_ALV,
       GT_EVENTS  TYPE SLIS_T_EVENT,
       GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
       GS_LAYOUT  TYPE SLIS_LAYOUT_ALV,

       hdr_cnt TYPE i,

       itm_cnt TYPE i,

       vend_cnt TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT001.

SELECT-OPTIONS S_EBELN FOR EKKOEBELN,
                 S_LIFNR FOR EKKOLIFNR,
                 S_BUKRS FOR EKKOBUKRS.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
PERFORM GET_BUILD_DATA.
END-OF-SELECTION.
*&———————————————————————*

*& Form get_build_data

*&———————————————————————*

*& text

*&———————————————————————*

*& –>  p1        text

*& <–  p2        text

*&———————————————————————*
FORM GET_BUILD_DATA.
“PO HEADER DATA
  SELECT EBELNBUKRSLIFNRRLWRT
    FROM EKKO INTO TABLE @DATA(GT_EKKO)
    WHERE EBELN IN @S_EBELN
    AND BUKRS IN @S_BUKRS
    AND LIFNR IN @S_LIFNR.

  IF GT_EKKO[] IS NOT INITIAL.
  SORT GT_EKKO BY LIFNR.

“NAME OF VENDOR
  SELECT LIFNRNAME1
    FROM LFA1 INTO TABLE @DATA(GT_LFA1)
    FOR ALL ENTRIES IN @GT_EKKO WHERE LIFNR @GT_EKKOLIFNR.
  SORT GT_EKKO BY EBELN.

“PO LINE ITEM
SELECT EBELNEBELPTXZ01MATNRMENGEMEINSNETWR
  FROM EKPO INTO TABLE @DATA(GT_EKPO)
  FOR ALL ENTRIES IN @GT_EKKO WHERE EBELN @GT_EKKOEBELN.

   SORT GT_LFA1 BY LIFNR.
   SORT GT_EKKO BY LIFNR EBELN.
   SORT GT_EKPO BY EBELN EBELP.

******************************************************************************
CLEAR GT_FCAT[]GT_FCAT1[]GT_FCAT2[]GS_FCATGS_LAYOUTGS_KEYINFO.

*”PO header

  GS_FCATCOL_POS   ‘1’.
  GS_FCATFIELDNAME ‘EBELN’.
  GS_FCATTABNAME   ‘GT_EKKO’.
  GS_FCATSELTEXT_L ‘PO_NUMBER’.

  APPEND GS_FCAT TO GT_FCAT.
  CLEAR GS_FCAT.

  GS_FCATCOL_POS   ‘3’.
  GS_FCATFIELDNAME ‘LIFNR’.
  GS_FCATTABNAME   ‘GT_EKKO’.
  GS_FCATSELTEXT_L ‘Vendor  ID’.

  APPEND GS_FCAT TO GT_FCAT.
  CLEAR GS_FCAT.

*”Vendor

  GS_FCATCOL_POS     ‘4’.
  GS_FCAT1FIELDNAME  ‘LIFNR’.
  GS_FCAT1SELTEXT_L  ‘Vendor ID’.

  APPEND GS_FCAT1 TO GT_FCAT1.
  CLEAR GS_FCAT1.

  GS_FCATCOL_POS   ‘5’.
  GS_FCAT1FIELDNAME ‘NAME1’.
  GS_FCAT1SELTEXT_L ‘Vendor Name’.

  APPEND GS_FCAT1 TO GT_FCAT1.
  CLEARGS_FCAT1.

*”PO line items

  GS_FCATCOL_POS   ‘6’.
  GS_FCAT2FIELDNAME ‘EBELN’.
  GS_FCAT2SELTEXT_L ‘PO Number’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘7’.
  GS_FCAT2FIELDNAME ‘EBELP’.
  GS_FCAT2SELTEXT_L ‘PO Line Item’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘8’.
  GS_FCAT2FIELDNAME ‘MATNR’.
  GS_FCAT2SELTEXT_L ‘Material ID’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘9’.
  GS_FCAT2FIELDNAME ‘TXZ01’.
  GS_FCAT2SELTEXT_L ‘Material Description’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEARGS_FCAT2.

  GS_FCATCOL_POS   ’10’.
  GS_FCAT2FIELDNAME ‘MENGE’.
  GS_FCAT2SELTEXT_L ‘ORDER QTY’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS    ’11’.
  GS_FCAT2FIELDNAME ‘MEINS’.
  GS_FCAT2SELTEXT_L ‘UOM’.
  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS    ’12’.
  GS_FCAT2FIELDNAME ‘NETWR’.
  GS_FCAT2SELTEXT_L ‘Item PO Value’.
  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.
******************************************************************************

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_INIT’

  EXPORTING

    i_callback_program             syrepid

*   I_CALLBACK_PF_STATUS_SET       = ‘ ‘

*   I_CALLBACK_USER_COMMAND        = ‘ ‘

*   IT_EXCLUDING                   =

          .

 “Vendor data

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat1

    i_tabname                        ‘GT_LFA1’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_lfa1

 EXCEPTIONS

   PROGRAM_ERROR                    1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3

          .

IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.

“PO header

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat

    i_tabname                        ‘GT_EKKO’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_ekko

 EXCEPTIONS

   PROGRAM_ERROR                    = 1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3

          .
IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.

“PO line items

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat2

    i_tabname                        ‘GT_EKPO’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_ekpo

 EXCEPTIONS

   PROGRAM_ERROR                    1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3
      .

IF sysubrc <> 0.

ENDIF.

“display data

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_DISPLAY’

* EXPORTING

*   I_INTERFACE_CHECK             = ‘ ‘

*   IS_PRINT                      =

*   I_SCREEN_START_COLUMN         = 0

*   I_SCREEN_START_LINE           = 0

*   I_SCREEN_END_COLUMN           = 0

*   I_SCREEN_END_LINE             = 0

* IMPORTING

*   E_EXIT_CAUSED_BY_CALLER       =

*   ES_EXIT_CAUSED_BY_USER        =

 EXCEPTIONS

   PROGRAM_ERROR                 = 
1

   OTHERS                        = 2

          .

IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.
  else.

    message No record found TYPE I.

    set SCREEN 0.

  endif.
ENDFORM.

 

Output:

Author : Aniket Pawar, 9373518385                                                

6 Columns with Active Background

24REPORT1708 – Blocked ALV Report Example

*&———————————————————————*
*& Report ZBLOCK_ALV_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT ZBLOCK_ALV_REPORT.

TABLES EKKOEKPOLFA1.
TYPES : BEGIN OF GTY_EKKO,
        EBELN TYPE EBELN,
        LIFNR TYPE LIFNR,
        BUKRS TYPE BUKRS,
  END OF GTY_EKKO.

DATA IT_EKKO TYPE STANDARD TABLE OF GTY_EKKO,
       GT_EKKO TYPE GTY_EKKO.

TYPES BEGIN OF GTY_EKPO,
        EBELN TYPE EBELN,
        EBELP TYPE EBELP,
        TXZ01 TYPE TXZ01,
        MATNR TYPE MATNR,
        MENGE TYPE MENGE,
        MEINS TYPE MEINS,
        NETWR TYPE NETWR,
  END OF GTY_EKPO.

DATA GT_EKPO TYPE STANDARD TABLE OF GTY_EKPO,
       GS_EKPO TYPE GTY_EKPO.

TYPES BEGIN OF GTY_LFA1,
        LIFNR TYPE LIFNR,
        NAME1 TYPE NAME1,
END OF GTY_LFA1.

DATA GT_LFA1 TYPE STANDARD TABLE OF GTY_LFA1,
       GS_LFA1 TYPE GTY_LFA1.

DATA GT_FCAT    TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT    TYPE SLIS_FIELDCAT_ALV,
       GT_FCAT1   TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT1   TYPE SLIS_FIELDCAT_ALV,
       GT_FCAT2   TYPE SLIS_T_FIELDCAT_ALV,
       GS_FCAT2   TYPE SLIS_FIELDCAT_ALV,
       GT_EVENTS  TYPE SLIS_T_EVENT,
       GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
       GS_LAYOUT  TYPE SLIS_LAYOUT_ALV,

       hdr_cnt TYPE i,

       itm_cnt TYPE i,

       vend_cnt TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT001.

SELECT-OPTIONS S_EBELN FOR EKKOEBELN,
                 S_LIFNR FOR EKKOLIFNR,
                 S_BUKRS FOR EKKOBUKRS.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
PERFORM GET_BUILD_DATA.
END-OF-SELECTION.
*&———————————————————————*

*& Form get_build_data

*&———————————————————————*

*& text

*&———————————————————————*

*& –>  p1        text

*& <–  p2        text

*&———————————————————————*
FORM GET_BUILD_DATA.
“PO HEADER DATA
  SELECT EBELNBUKRSLIFNRRLWRT
    FROM EKKO INTO TABLE @DATA(GT_EKKO)
    WHERE EBELN IN @S_EBELN
    AND BUKRS IN @S_BUKRS
    AND LIFNR IN @S_LIFNR.

  IF GT_EKKO[] IS NOT INITIAL.
  SORT GT_EKKO BY LIFNR.

“NAME OF VENDOR
  SELECT LIFNRNAME1
    FROM LFA1 INTO TABLE @DATA(GT_LFA1)
    FOR ALL ENTRIES IN @GT_EKKO WHERE LIFNR @GT_EKKOLIFNR.
  SORT GT_EKKO BY EBELN.

“PO LINE ITEM
SELECT EBELNEBELPTXZ01MATNRMENGEMEINSNETWR
  FROM EKPO INTO TABLE @DATA(GT_EKPO)
  FOR ALL ENTRIES IN @GT_EKKO WHERE EBELN @GT_EKKOEBELN.

   SORT GT_LFA1 BY LIFNR.
   SORT GT_EKKO BY LIFNR EBELN.
   SORT GT_EKPO BY EBELN EBELP.

******************************************************************************
CLEAR GT_FCAT[]GT_FCAT1[]GT_FCAT2[]GS_FCATGS_LAYOUTGS_KEYINFO.

*”PO header

  GS_FCATCOL_POS   ‘1’.
  GS_FCATFIELDNAME ‘EBELN’.
  GS_FCATTABNAME   ‘GT_EKKO’.
  GS_FCATSELTEXT_L ‘PO_NUMBER’.

  APPEND GS_FCAT TO GT_FCAT.
  CLEAR GS_FCAT.

  GS_FCATCOL_POS   ‘3’.
  GS_FCATFIELDNAME ‘LIFNR’.
  GS_FCATTABNAME   ‘GT_EKKO’.
  GS_FCATSELTEXT_L ‘Vendor  ID’.

  APPEND GS_FCAT TO GT_FCAT.
  CLEAR GS_FCAT.

*”Vendor

  GS_FCATCOL_POS     ‘4’.
  GS_FCAT1FIELDNAME  ‘LIFNR’.
  GS_FCAT1SELTEXT_L  ‘Vendor ID’.

  APPEND GS_FCAT1 TO GT_FCAT1.
  CLEAR GS_FCAT1.

  GS_FCATCOL_POS   ‘5’.
  GS_FCAT1FIELDNAME ‘NAME1’.
  GS_FCAT1SELTEXT_L ‘Vendor Name’.

  APPEND GS_FCAT1 TO GT_FCAT1.
  CLEARGS_FCAT1.

*”PO line items

  GS_FCATCOL_POS   ‘6’.
  GS_FCAT2FIELDNAME ‘EBELN’.
  GS_FCAT2SELTEXT_L ‘PO Number’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘7’.
  GS_FCAT2FIELDNAME ‘EBELP’.
  GS_FCAT2SELTEXT_L ‘PO Line Item’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘8’.
  GS_FCAT2FIELDNAME ‘MATNR’.
  GS_FCAT2SELTEXT_L ‘Material ID’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS   ‘9’.
  GS_FCAT2FIELDNAME ‘TXZ01’.
  GS_FCAT2SELTEXT_L ‘Material Description’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEARGS_FCAT2.

  GS_FCATCOL_POS   ’10’.
  GS_FCAT2FIELDNAME ‘MENGE’.
  GS_FCAT2SELTEXT_L ‘ORDER QTY’.

  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS    ’11’.
  GS_FCAT2FIELDNAME ‘MEINS’.
  GS_FCAT2SELTEXT_L ‘UOM’.
  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.

  GS_FCATCOL_POS    ’12’.
  GS_FCAT2FIELDNAME ‘NETWR’.
  GS_FCAT2SELTEXT_L ‘Item PO Value’.
  APPEND GS_FCAT2 TO GT_FCAT2.
  CLEAR GS_FCAT2.
******************************************************************************

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_INIT’

  EXPORTING

    i_callback_program             syrepid

*   I_CALLBACK_PF_STATUS_SET       = ‘ ‘

*   I_CALLBACK_USER_COMMAND        = ‘ ‘

*   IT_EXCLUDING                   =

          .

 “Vendor data

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat1

    i_tabname                        ‘GT_LFA1’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_lfa1

 EXCEPTIONS

   PROGRAM_ERROR                    1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3

          .

IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.

“PO header

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat

    i_tabname                        ‘GT_EKKO’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_ekko

 EXCEPTIONS

   PROGRAM_ERROR                    = 1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3

          .
IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.

“PO line items

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_APPEND’

  EXPORTING

    is_layout                        gs_layout

    it_fieldcat                      gt_fcat2

    i_tabname                        ‘GT_EKPO’

    it_events                        gt_events

*   IT_SORT                          =

*   I_TEXT                           = ‘ ‘

  TABLES

    t_outtab                         gt_ekpo

 EXCEPTIONS

   PROGRAM_ERROR                    1

   MAXIMUM_OF_APPENDS_REACHED       = 2

   OTHERS                           = 3
      .

IF sysubrc <> 0.

ENDIF.

“display data

CALL FUNCTION ‘REUSE_ALV_BLOCK_LIST_DISPLAY’

* EXPORTING

*   I_INTERFACE_CHECK             = ‘ ‘

*   IS_PRINT                      =

*   I_SCREEN_START_COLUMN         = 0

*   I_SCREEN_START_LINE           = 0

*   I_SCREEN_END_COLUMN           = 0

*   I_SCREEN_END_LINE             = 0

* IMPORTING

*   E_EXIT_CAUSED_BY_CALLER       =

*   ES_EXIT_CAUSED_BY_USER        =

 EXCEPTIONS

   PROGRAM_ERROR                 = 
1

   OTHERS                        = 2

          .

IF sysubrc <> 0.

* Implement suitable error handling here

ENDIF.
  else.

    message No record found TYPE I.

    set SCREEN 0.

  endif.
ENDFORM.

 

Output:

Author : Aniket Pawar, 93735183