Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
1,402

Hi

can any one tel the way of displaying the more than one lists in output in alv

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,377

Hi,

You can do this using ALV blocked list.

Regards,

Rajitha.

Hi

can any one tel the way of displaying the more than one lists in output in alv

12 REPLIES 12
Read only

Former Member
0 Likes
1,377

Use Block list.

Check the Program BALVBT01

Read only

Former Member
0 Likes
1,378

Hi,

You can do this using ALV blocked list.

Regards,

Rajitha.

Read only

0 Likes
1,377

Hi Rajitha ,

my requirement is using alv i want to display 2 lists seperately

Read only

0 Likes
1,377

hi,

If u need i ll give simple codding to display blocked alv display

thanks and regards

Devalla Tarun Kumar

Edited by: Devalla Tarun Kr. on Aug 28, 2008 2:35 PM

Read only

0 Likes
1,377

Hi Deva,

yes i need that code can u give that plz

Read only

Former Member
0 Likes
1,377

hi Surendra Polamreddy

Use 2 container in Se51, pass 2 set of data from2 internal tables to 2 container

Regards

Deva

Read only

0 Likes
1,377

Hi Deva,

can u send any sample program plz if u have

Read only

Former Member
0 Likes
1,377

Hi,

Here is the code to display ALV BLOCKED list display.

Use this function modules

REUSE_ALV_BLOCK_LIST_INIT

REUSE_ALV_BLOCK_LIST_APPEND

REUSE_ALV_BLOCK_LIST_DISPLAY.

* Table declarations --------------------------------------------------*
TABLES:
  LAGP,                                " Storage bins
  LTAP.                                " Transfer order item

TYPE-POOLS:
  SLIS.

* Type declarations --------------------------------------------------*

* Structure to hold Storage bins
TYPES:
  BEGIN OF TYPE_S_LAGP,
    LGNUM TYPE LGNUM,                  " Warehouse No./Warehouse Complex
    LGTYP TYPE LGTYP,                  " Storage Type
    LGPLA TYPE LGPLA,                  " Storage Bin
    SKZUA TYPE LAGP_SKZUA,             " Block Indicator:Stock Removal
    SKZUE TYPE LAGP_SKZUE,             " Blocking Indicator:for putaways
    SPGRU TYPE LVS_SPGRU,              " Blocking Reason
    ANZLE TYPE LAGP_ANZLE,             " No.of storage units in stor.bin
    MAXLE TYPE LAGP_MAXLE,             " Max No.of S.U in storage bin
    BTANR TYPE LAGP_BTANR,             " Trans ord no last stk transfer
    BTAPS TYPE LAGP_BTAPS,             " Item in transfer order
  END OF TYPE_S_LAGP.

* Structure to hold Transfer order item
TYPES:
  BEGIN OF TYPE_S_LTAP,
    LGNUM TYPE LGNUM,                  " Warehouse NO./Warehouse Complex
    TANUM TYPE TANUM,                  " Transfer Order Number
    TAPOS TYPE TAPOS,                  " Transfer order item
    MATNR TYPE MATNR,                  " Material Number
    CHARG TYPE CHARG_D,                " Batch Number
    BESTQ TYPE BESTQ,                  " Stock Category in the WM System
    MAKTX TYPE MAKTX,                  " Material Description
  END OF TYPE_S_LTAP.

* Structure to hold Final Data
TYPES:
  BEGIN OF TYPE_S_FINAL,
    LGNUM TYPE LGNUM,                  " Warehouse No./Warehouse Complex
    LGTYP TYPE LGTYP,                  " Storage Type
    MAKTX TYPE MAKTX,                  " Material Description
    MATNR TYPE MATNR,                  " Material Number
    LGPLA TYPE LGPLA,                  " Storage Bin
    BESTQ TYPE BESTQ,                  " Stock Category in the WM System
    CHARG TYPE CHARG_D,                " Batch Number
    SKZUA TYPE LAGP_SKZUA,             " Block Indicator:Stock Removal
    SKZUE TYPE LAGP_SKZUE,             " Blocking Indicator:for putaways
    SPGRU TYPE LVS_SPGRU,              " Blocking Reason
    ANZLE TYPE LAGP_ANZLE,             " No.of storage units in sto. bin
    MAXLE TYPE LAGP_MAXLE,             " Max No.of stor.units in sto bin
  END OF TYPE_S_FINAL.

*----------------------------------------------------------------------*
* Declaration of Work areas for internal tables                        *
*----------------------------------------------------------------------*
DATA:
* Structure to hold Storage bins
  WA_LAGP TYPE TYPE_S_LAGP,
* Structure to hold Transfer order item
  WA_LTAP TYPE TYPE_S_LTAP,
* Structure to hold final data
  WA_FINAL TYPE TYPE_S_FINAL,
* Structure for field catalogue
  WA_FCAT   TYPE SLIS_FIELDCAT_ALV,
* Structure for layout
  WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
* Structure for events
  WA_EVENTS TYPE SLIS_ALV_EVENT.

*----------------------------------------------------------------------*
* Internal table declarations                                          *
*----------------------------------------------------------------------*
DATA:
* Table to hold Material data for storage type
  T_LAGP LIKE STANDARD TABLE OF WA_LAGP,
* Table to hold Storage bin data
  T_LTAP LIKE STANDARD TABLE OF WA_LTAP,
* Table to hold final data
  T_FINAL LIKE STANDARD TABLE OF WA_FINAL,
* Table to hold storage bin between 50 TO 75
  T_ITAB1 LIKE STANDARD TABLE OF WA_FINAL,
* Table to hold storage bin between 25 TO 50
  T_ITAB2 LIKE STANDARD TABLE OF WA_FINAL,
* Table to hold storage bin between 0 TO 25
  T_ITAB3 LIKE STANDARD TABLE OF WA_FINAL,
* Internal table to hold the fields names to be displayed
  T_FCAT   TYPE SLIS_T_FIELDCAT_ALV,
* Internal table to hold the events
  T_EVENTS TYPE SLIS_T_EVENT.

*----------------------------------------------------------------------*
*  Selection screen declarations                                       *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
SELECT-OPTIONS:
  S_LGNUM FOR LAGP-LGNUM,              " Warehouse No/Ware house complex
  S_LGTYP FOR LAGP-LGTYP,              " Storage Type
  S_MATNR FOR LTAP-MATNR,              " Material number
  S_LGPLA FOR LAGP-LGPLA,              " Storagebin
  S_BESTQ FOR LTAP-BESTQ,              " Stock category
  S_CHARG FOR LTAP-CHARG,              " Batch number
  S_SKZUA FOR LAGP-SKZUA,              " Stock removal block
  S_SKZUE FOR LAGP-SKZUE,              " Putaway block
  S_SPGRU FOR LAGP-SPGRU.              " Bin blocking reason
SELECTION-SCREEN END OF BLOCK B1.

 

* --------------------------------------------------------------------*
*                START-OF-SELECTION EVENT                             *
* --------------------------------------------------------------------*
START-OF-SELECTION.

* Fetching storage bin and Material data
  PERFORM GET_STORAGE_BINS.

* Finla Internal table data
  PERFORM APPEND_FINAL_DATA.

  IF NOT T_FINAL[] IS INITIAL.
* Displaying final data
    PERFORM CALC_BIN_OCCUPANY.

    IF T_ITAB1 IS NOT INITIAL OR
       T_ITAB2 IS NOT INITIAL OR
       T_ITAB3 IS NOT INITIAL.
* Fill field catalogue
      PERFORM FILL_FIELD_CATALOGUE.

* Display output
      PERFORM DISPLAY_OUTPUT.
    ELSE.
      MESSAGE I000 WITH
        'No storage bins found with occupancy less than 75%'.
    ENDIF.
  ELSE.
    MESSAGE I000 WITH
      'No data found for the given selection criteria'(I01).

  ENDIF.                               " IF NOT T_FINAL[] IS INITIAL.

*&---------------------------------------------------------------------*
*& Form  GET_STORAGE_BINS                                              *
*&---------------------------------------------------------------------*
* This subroutine is to fetch storage bin and Material data            *
*----------------------------------------------------------------------*
* No interface parameters are to be passed for this subroutine.        *
*----------------------------------------------------------------------*
FORM GET_STORAGE_BINS .
  DATA:
* Internal table to hold Storage bins data
  LT_LAGP_TEMP LIKE STANDARD TABLE OF WA_LAGP.
* Fetch storage bin data from LAGP
  SELECT LGNUM                         " Warehouse NO./Warehouse Complex
         LGTYP                         " Storage Type
         LGPLA                         " Storage Bin
         SKZUA                         " Blocking for Stock removal
         SKZUE                         " Blocking Indicator:for putaways
         SPGRU                         " Blocking Reason
         ANZLE                         " No. of Sto.units in storage bin
         MAXLE                         " Max No.of stor.units in sto bin
         BTANR                         " Transfer order number
         BTAPS                         " Item in transfer order
    FROM LAGP
    INTO TABLE T_LAGP
   WHERE LGNUM IN S_LGNUM
     AND LGTYP IN S_LGTYP
     AND LGPLA IN S_LGPLA
     AND SKZUA IN S_SKZUA
     AND SKZUE IN S_SKZUE
     AND SPGRU IN S_SPGRU.

  IF SY-SUBRC NE 0.
    MESSAGE I000 WITH
      'No data found for the given selection criteria'(I01).
    STOP.
  ELSE.

* Deleting duplicates comparing Warehouse number,Transfer order number
* and Transfer order item number
    LT_LAGP_TEMP[] = T_LAGP[].

    SORT LT_LAGP_TEMP BY LGNUM BTANR BTAPS.
    DELETE ADJACENT DUPLICATES FROM LT_LAGP_TEMP
                     COMPARING LGNUM BTANR BTAPS.

* Fetching Transfer order data from table LTAP
    SELECT LGNUM                       " Warehouse NO./Warehouse Complex
           TANUM                       " Transfer Order Number
           TAPOS                       " Transfer order item
           MATNR                       " Material Number
           CHARG                       " Batch Number
           BESTQ                       " Stock Category in the WM System
           MAKTX                       " Material Description
      FROM LTAP
      INTO TABLE T_LTAP
       FOR ALL ENTRIES IN LT_LAGP_TEMP
     WHERE LGNUM EQ LT_LAGP_TEMP-LGNUM
       AND TANUM EQ LT_LAGP_TEMP-BTANR
       AND TAPOS EQ LT_LAGP_TEMP-BTAPS
       AND MATNR IN S_MATNR
       AND BESTQ IN S_BESTQ
       AND CHARG IN S_CHARG.

  ENDIF.                               " IF SY-SUBRC NE 0.

ENDFORM.                               " GET_STORAGE_BINS

*&---------------------------------------------------------------------*
*& Form  APPEND_FINAL_DATA                                             *
*&---------------------------------------------------------------------*
* This subroutine is to append data to T_FINAL internal table          *
*----------------------------------------------------------------------*
*  No interface parameters are to be passed for this subroutine.       *
*----------------------------------------------------------------------*
FORM APPEND_FINAL_DATA .

* Moving data to final internal table

  SORT T_LTAP BY LGNUM TANUM TAPOS.

  LOOP AT T_LAGP INTO WA_LAGP.

    WA_FINAL-LGNUM = WA_LAGP-LGNUM.
    WA_FINAL-LGTYP = WA_LAGP-LGTYP.
    WA_FINAL-LGPLA = WA_LAGP-LGPLA.
    WA_FINAL-SKZUA = WA_LAGP-SKZUA.
    WA_FINAL-SKZUE = WA_LAGP-SKZUE.
    WA_FINAL-SPGRU = WA_LAGP-SPGRU.
    WA_FINAL-ANZLE = WA_LAGP-ANZLE.
    WA_FINAL-MAXLE = WA_LAGP-MAXLE.

    CLEAR WA_LTAP.
    READ TABLE T_LTAP INTO WA_LTAP WITH KEY LGNUM = WA_LAGP-LGNUM
                                            TANUM = WA_LAGP-BTANR
                                            TAPOS = WA_LAGP-BTAPS
                                            BINARY SEARCH.
    IF SY-SUBRC EQ 0.
      WA_FINAL-MATNR = WA_LTAP-MATNR.
      WA_FINAL-MAKTX = WA_LTAP-MAKTX.
      WA_FINAL-BESTQ = WA_LTAP-BESTQ.
      WA_FINAL-CHARG = WA_LTAP-CHARG.

      APPEND WA_FINAL TO T_FINAL.
    ELSE.

      IF S_MATNR[] IS INITIAL AND
         S_CHARG[] IS INITIAL AND
         S_BESTQ[] IS INITIAL.
        APPEND WA_FINAL TO T_FINAL.
      ENDIF.                           " IF S_MATNR IS INITIAL AND

    ENDIF.                             " IF SY-SUBRC EQ 0.
    CLEAR WA_FINAL.

  ENDLOOP.                             " LOOP AT T_LAGP INTO WA_LAGP.

ENDFORM.                               " APPEND_FINAL_DATA


*&---------------------------------------------------------------------*
*& Form  CALC_BIN_OCCUPANY                                             *
*&---------------------------------------------------------------------*
* This subroutine is to append data to final internal table            *
*----------------------------------------------------------------------*
* No interface parameters are to be passed for this subroutine.        *
*----------------------------------------------------------------------*
FORM CALC_BIN_OCCUPANY .

  DATA:
    LW_STORAGE    TYPE P DECIMALS 2,   " Occupancy of a Bin
    LW_PERCENTAGE TYPE P DECIMALS 2.   " Occupancy percentage

* Sorting final internal table by Material and Storage bin
  SORT T_FINAL BY MATNR LGPLA.

  LOOP AT T_FINAL INTO WA_FINAL.

    IF WA_FINAL-MAXLE EQ 0.
      LW_STORAGE = 0.
      LW_PERCENTAGE = 0.
    ELSE.
      LW_STORAGE    = WA_FINAL-ANZLE / WA_FINAL-MAXLE.
      LW_PERCENTAGE = LW_STORAGE * 100.
    ENDIF.                             " IF WA_FINAL-MAXLE EQ 0.

    IF LW_PERCENTAGE GE 50 AND  LW_PERCENTAGE LT 75.
      APPEND WA_FINAL TO T_ITAB1.
    ELSEIF LW_PERCENTAGE LT 50 AND LW_PERCENTAGE GE 25.
      APPEND WA_FINAL TO T_ITAB2.
    ELSEIF LW_PERCENTAGE LT 25.
      APPEND WA_FINAL TO T_ITAB3.
    ENDIF.                             " IF LW_PERCENTAGE GT 50 AND

  ENDLOOP.                             " LOOP AT T_FINAL INTO WA_FINAL.

ENDFORM.                               " CALC_BIN_OCCUPANY

*&---------------------------------------------------------------------*
*& Form  DISPLAY_OUTPUT                                                *
*&---------------------------------------------------------------------*
* This subroutine displays output                                      *
*----------------------------------------------------------------------*
*  No interface parameters are to be passed for this subroutine.       *
*----------------------------------------------------------------------*
FORM DISPLAY_OUTPUT .
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID.


  PERFORM APPEND_ALV_BLOCK_LIST TABLES T_ITAB1
                                 USING 'T_ITAB1'.

  PERFORM APPEND_ALV_BLOCK_LIST TABLES T_ITAB2
                                 USING 'T_ITAB2'.

  PERFORM APPEND_ALV_BLOCK_LIST TABLES T_ITAB3
                                 USING 'T_ITAB3'.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXCEPTIONS
      PROGRAM_ERROR = 1
      OTHERS        = 2.
  IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.                               " IF SY-SUBRC NE 0.

ENDFORM.                               " DISPLAY_OUTPUT

*&---------------------------------------------------------------------*
*& Form  APPEND_ALV_BLOCK_LIST                                         *
*&---------------------------------------------------------------------*
*  This subroutine Appends the blocks to ALV list                      *
*----------------------------------------------------------------------*
*      -->PT_ITAB   Output table with contents                         *
*      -->PV_TABLE  Output table name                                  *
*----------------------------------------------------------------------*
FORM APPEND_ALV_BLOCK_LIST  TABLES   PT_ITAB STRUCTURE WA_FINAL
                             USING   VALUE(PV_TABLE).

  IF PT_ITAB[] IS NOT INITIAL.
    REFRESH: T_EVENTS[].
    CLEAR: WA_EVENTS.
    WA_EVENTS-NAME = SLIS_EV_TOP_OF_LIST.
    WA_EVENTS-FORM = PV_TABLE.
    APPEND WA_EVENTS TO T_EVENTS.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                  = WA_LAYOUT
        IT_FIELDCAT                = T_FCAT
        I_TABNAME                  = PV_TABLE
        IT_EVENTS                  = T_EVENTS
      TABLES
        T_OUTTAB                   = PT_ITAB
      EXCEPTIONS
        PROGRAM_ERROR              = 1
        MAXIMUM_OF_APPENDS_REACHED = 2
        OTHERS                     = 3.
    IF SY-SUBRC NE 0.
      MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.                             " IF SY-SUBRC NE 0.
  ENDIF.                               " IF PT_ITAB[] IS NOT INITIAL.

ENDFORM.                               " APPEND_ALV_BLOCK_LIST

*&---------------------------------------------------------------------*
*& Form  T_ITAB1                                                       *
*&---------------------------------------------------------------------*
* Top of list event - for ITAB1                                        *
*----------------------------------------------------------------------*
* No interface parameters need to be passed to this subroutine         *
*----------------------------------------------------------------------*
FORM T_ITAB1.

  WRITE: / 'Storage bins between 50%  -  75%  Full'(T02).

ENDFORM.                                                    " T_ITAB1

*&---------------------------------------------------------------------*
*& Form  T_ITAB2                                                       *
*&---------------------------------------------------------------------*
* Top of list event - for ITAB2                                        *
*----------------------------------------------------------------------*
* No interface parameters need to be passed to this subroutine         *
*----------------------------------------------------------------------*
FORM T_ITAB2.

  WRITE: / 'Storage bins between 25%  -  50%  Full'(T03).

ENDFORM.                                                    " T_ITAB2

*&---------------------------------------------------------------------*
*&      Form  T_ITAB3                                                  *
*&---------------------------------------------------------------------*
* Top of list event - for ITAB3                                        *
*----------------------------------------------------------------------*
* No interface parameters need to be passed to this subroutine         *
*----------------------------------------------------------------------*
FORM T_ITAB3.

  WRITE: / 'Storage bins between 0  -  25%  Full'(T04).

ENDFORM.                                                    " T_ITAB3
*&---------------------------------------------------------------------*
*& Form  FILL_FIELD_CATALOGUE                                          *
*&---------------------------------------------------------------------*
* This subroutine is to fill field catalog                             *
*----------------------------------------------------------------------*
*  No interface parameters are to be passed for this subroutine.       *
*----------------------------------------------------------------------*
FORM FILL_FIELD_CATALOGUE .
  REFRESH T_FCAT[].
  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'LGNUM'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'WhN'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'LGTYP'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'TY.'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'MAKTX'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'Material description'.
  APPEND WA_FCAT TO T_FCAT.


  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'MATNR'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'Material'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'LGPLA'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'Stor.bin'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'BESTQ'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'C'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'CHARG'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'Batch'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'SKZUA'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'RB'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'SKZUE'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'PB'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'SPGRU'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'BR'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'ANZLE'.
  WA_FCAT-TABNAME      = 'T_FINAL'.
  WA_FCAT-REPTEXT_DDIC = 'No.st.Un'.
  APPEND WA_FCAT TO T_FCAT.

  CLEAR WA_FCAT.
  WA_FCAT-FIELDNAME    = 'MAXLE'.
  WA_FCAT-TABNAME      = 'T_FINAL'
  WA_FCAT-REPTEXT_DDIC = 'Max.SU'.
  APPEND WA_FCAT TO T_FCAT.

ENDFORM.                               " FILL_FIELD_CATALOGUE

Regards,

Rajitha.

Read only

0 Likes
1,377

Hi

i got but it shows an error in start-of-selection event,

like message I000 here it shows an error

Read only

Former Member
0 Likes
1,377

Hi Surendra,

Error is because of Warehouse number does not exist something like that in my report.

You just follow the subroutines

  • Form DISPLAY_OUTPUT

  • Form APPEND_ALV_BLOCK_LIST

  • Form T_ITAB1

  • Form T_ITAB1

  • Form T_ITAB3

  • Form FILL_FIELD_CATALOGUE

This report displays output in 3 blocks and also displays some text between the list.

Follow using the above mentioned function modules and append your own Internal tables to the function module .

Regards,

Rajitha.

Read only

0 Likes
1,377

Hi Rajitha

i want to do in grid display can u send

Read only

Former Member
0 Likes
1,377

Hi Surendra ,

It is not possible with GRID Display.

Regards,

Rajitha.