ALV REPORT WITH MULTIPLE BLOCKS

To print two blocks in a single ALV report, I have taken the sample and modified to my requirement.  I am having the following problems in this code.
      1.  Columnwise total not appearing.
      2.  Amount and numbers in all the columns are 
          left justified instead of right justified.
The code written is given below.  Kindly check the same and suggest for corrections.
--- SAMPLE 1--
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
       EXPORTING
            i_callback_program      = sy-cprog
            i_callback_user_command = 'USER_COMMAND'.
  PERFORM list_append TABLES IT_CTV
                       USING '1'
                             'IT_CTV'.
  PERFORM list_append TABLES IT_APP
                       USING '2'
                             'IT_APP'.
  PERFORM f_list_display.
      FORM USER_COMMAND                                             *
FORM user_command USING i_ucomm     LIKE sy-ucomm
                        is_selfield TYPE slis_selfield.     "#EC CALLED
ENDFORM.                               " USER_COMMAND
      Form  list_append
FORM list_append TABLES ut_table
                 USING  u_no      TYPE char1
                        u_tabname TYPE slis_tabname.
  DEFINE m_fieldcat.
    ls_fieldcat-fieldname = &1.
    ls_fieldcat-ref_tabname = &2.
    append ls_fieldcat to lt_fieldcat.
  END-OF-DEFINITION.
  DEFINE m_sort.
    ls_sort-fieldname = &1.
    ls_sort-up        = 'X'.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.
  DATA :
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
    ls_sort     TYPE slis_sortinfo_alv,
    lt_sort     TYPE slis_t_sortinfo_alv. " Sort table
  DATA:
    lt_events TYPE slis_t_event,
    ls_event  TYPE slis_alv_event,
    ls_layout TYPE slis_layout_alv.
  ls_layout-group_change_edit = 'X'.
  ls_layout-colwidth_optimize = 'X'.
  ls_layout-zebra             = 'X'.
  ls_layout-cell_merge        = 'X'.
  ls_layout-detail_popup      = 'X'.
  ls_layout-get_selinfos      = 'X'.
  ls_layout-max_linesize      = '300'.
  CASE u_no.
    WHEN '1'.
      ls_fieldcat-SELTEXT_L = ' REGION'.
      ls_fieldcat-DO_SUM = 'X'.
      m_fieldcat  'BZIRK' 'IT_CTV'.
      ls_fieldcat-SELTEXT_L = ' CTV STOCK'.
      m_fieldcat  'CTVST' 'IT_CTV'.
      ls_fieldcat-SELTEXT_L = ' CTV VALUE'.
      m_fieldcat  'CTVVL' 'IT_CTV'.
      m_sort  'BZIRK'.
      ls_fieldcat-DO_SUM = 'X'.
    WHEN '2'.
      ls_fieldcat-SELTEXT_L = ' REGION'.
      m_fieldcat  'BZIRK' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' RFG STK'.
      m_fieldcat  'RFGST' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' RFG VAL'.
      m_fieldcat  'RFGVL' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' WM STK'.
      m_fieldcat  'WMCST' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' WM VAL'.
      m_fieldcat  'WMCVL' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' MCCS STK'.
      m_fieldcat  'MOVST' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' MCCS VAL'.
      m_fieldcat  'MOVVL' 'IT_APP'.
      ls_fieldcat-SELTEXT_L = ' APP STK'.
      m_fieldcat  'APPST' 'IT_APP'.
     ls_fieldcat-SELTEXT_L = ' APP VAL'.
     m_fieldcat  'APPVL' 'IT_APP'.
      m_sort  'BZIRK'.
  ENDCASE.
ls_fieldcat-COL_POS = 1.
ls_fieldcat-FIELDNAME = 'BZIRK'.
ls_fieldcat-DO_SUM = 'X'.
ls_fieldcat-FIX_COLUMN = 'X'.
APPEND ls_fieldcat TO lT_fieldcat.
  IF u_no CA '13'.
    MOVE        'TOP_OF_PAGE'        TO ls_event-name.
    CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
    APPEND ls_event TO lt_events.
  ELSE.
    MOVE        'TOP_OF_LIST'        TO ls_event-name.
    CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
    APPEND ls_event TO lt_events.
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
       EXPORTING
            it_fieldcat                = lt_fieldcat
            is_layout                  = ls_layout
            i_tabname                  = u_tabname
            it_events                  = lt_events
            it_sort                    = lt_sort
       TABLES
            t_outtab                   = ut_table
       EXCEPTIONS
            program_error              = 1
            maximum_of_appends_reached = 2
            OTHERS                     = 3.
  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.                               " LIST_APPEND
      Form  f_list_display
FORM f_list_display.
  DATA ls_print TYPE slis_print_alv.
  ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
  ls_print-no_print_listinfos = 'X'.   " Display no listinfos
  ls_print-reserve_lines      = 2.     " Lines reserved for end of page
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
       EXPORTING
            i_interface_check = ' '
            is_print          = ls_print
       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.                               " F_LIST_DISPLAY
Thanks in advance.
A S VINCENT

Hai Vincent
Check the following Code
*& Report  ZALV_BLOCK                                               *
REPORT  ZALV_BLOCK NO STANDARD PAGE HEADING
                                MESSAGE-ID ZZ.
*..Type Definitions for ALV Report
TYPE-POOLS SLIS.
Table Declarations.                                        *
TABLES: MARA,        "Material Master
        MARC,        "Plant Data for Material
        MARD,        "Storage Location Data for Material
        VBAP,        "Sales Document: Item Data
        VBUP.        "Sales Document: Item Status
Internal table to store sales orders.......
DATA: BEGIN OF IT_VBAP OCCURS 0,
        VBELN LIKE VBAP-VBELN,    "Sales Document
        POSNR LIKE VBAP-POSNR,    "Sales Document Item
        KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                   "                        Units
      END OF IT_VBAP.
internal table to store final data
DATA: BEGIN OF IT_FINAL OCCURS 0,
        WERKS LIKE MARD-WERKS,    "Plant
        MATNR LIKE MARD-MATNR,    "Material Number
        LGORT LIKE MARD-LGORT,    "Storage Location
        LABST LIKE MARD-LABST,    "Valuated stock with unrestricted use
        INSME LIKE MARD-INSME,    "Stock in quality inspection
        RETME LIKE MARD-RETME,    "Blocked Stock Returns
        UMLME LIKE MARD-UMLME,    "Stock in transfer
        MAKTX LIKE MAKT-MAKTX,    "Material description
        VBELN LIKE VBAP-VBELN,    "Sales Document
        POSNR LIKE VBAP-POSNR,    "Sales Document Item
        KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                   "                        Units
      END OF IT_FINAL.
ALV Type declaration                                                 *
*..Field Catalog for Basic List.
DATA : IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
       WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV.
*..Events For Basic List.
DATA : IT_EVENTS TYPE SLIS_T_EVENT,
       WA_EVENTS TYPE SLIS_ALV_EVENT.
*..Layout For Basic List
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
*..Sort Table For Basic List
DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
           DATA DECLARATIONS                                         *
DATA: V_FLAG,
      VINDEX TYPE SY-TABIX,
      TOTAL TYPE VBAP-KWMENG.     "Open order quantity
*..To Store Program Name
DATA: V_REPID  TYPE SYREPID.
*..To know whether basic list contains any data
Selection Screen.                                                    *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
                S_WERKS FOR MARC-WERKS,
                S_LGORT FOR MARD-LGORT.
SELECTION-SCREEN END OF BLOCK B1.
Event:Initialization                                                 *
INITIALIZATION.
  V_REPID = SY-REPID.
AT Selection Screen.                                                 *
AT SELECTION-SCREEN.
  PERFORM VALIDATIONS.
Event: Start-of-Selection                                            *
START-OF-SELECTION.
     To get data from vbap into internal table IT_VBAP
  PERFORM FETCH_OPEN_DATA.
      To get data into final internal table IT_FINAL
  IF V_FLAG = 'X'.
    PERFORM FETCH_FINAL_DATA.
  ENDIF.
  IF V_FLAG = ''.
    MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
    EXIT.
  ELSE.
  --Setting the FIELD CATALOG for ALV
    PERFORM FILL_FIELDCAT_HEADER.
*-----Setting the LAYOUT for ALV
    PERFORM GET_LAYOUT.
*-----Getting the ALV Events
    PERFORM GET_EVENT.
*---- To Sort the list
    PERFORM DO_SORT.
  ENDIF.
Event: End-of-Selection                                            *
END-OF-SELECTION.
*--Generating the ALV LIST DISPLAY
  PERFORM DISPLAY_LIST.
                         FORM DEFINITIONS                            *
*&      Form  VALIDATIONS
      To validate data in selection screen
-->  p1        text
<--  p2        text
FORM VALIDATIONS.
  PERFORM VALIDATE_MATNR.
  PERFORM VALIDATE_WERKS.
  PERFORM VALIDATE_LGORT.
  IF NOT ( ( MARA-MATNR IS INITIAL ) AND
          ( MARC-WERKS IS INITIAL ) AND
          ( MARD-LGORT IS INITIAL ) ).
    SELECT SINGLE MATNR
                  WERKS
                  LGORT
                  FROM MARD
      INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
      WHERE MATNR = MARA-MATNR
        AND WERKS = MARC-WERKS
        AND LGORT = MARD-LGORT.
  ENDIF.
ENDFORM.                    " VALIDATIONS
*&      Form  VALIDATE_MATNR
      To validate MATNR
-->  p1        text
<--  p2        text
FORM VALIDATE_MATNR.
  IF NOT S_MATNR[] IS INITIAL.
    SELECT MATNR
           UP TO 1 ROWS
           INTO (MARD-MATNR)
           FROM MARA
           WHERE MATNR IN S_MATNR.
    ENDSELECT.
  ENDIF.
  IF SY-SUBRC NE 0.
    MESSAGE E000 WITH TEXT-001.
  ENDIF.
ENDFORM.                    " VALIDATE_MATNR
*&      Form  VALIDATE_WERKS
      To validate plant
-->  p1        text
<--  p2        text
FORM VALIDATE_WERKS.
  IF NOT S_WERKS[] IS INITIAL.
    SELECT WERKS
           UP TO 1 ROWS
           INTO (MARD-WERKS)
           FROM MARC
           WHERE WERKS IN S_WERKS.
    ENDSELECT.
  ENDIF.
  IF SY-SUBRC NE 0.
    MESSAGE E000 WITH TEXT-002.
  ENDIF.
ENDFORM.                    " VALIDATE_WERKS
*&      Form  VALIDATE_LGORT
      To validate storage
-->  p1        text
<--  p2        text
FORM VALIDATE_LGORT.
  IF NOT S_LGORT[] IS INITIAL.
    SELECT LGORT
           UP TO 1 ROWS
           INTO (MARD-LGORT)
           FROM MARD
           WHERE LGORT IN S_LGORT.
    ENDSELECT.
  ENDIF.
  IF SY-SUBRC NE 0.
    MESSAGE E000 WITH TEXT-003.
  ENDIF.
ENDFORM.                    " VALIDATE_LGORT
*&      Form  FETCH_OPEN_DATA
      To get data into internal table IT_VBAP
-->  p1        text
<--  p2        text
FORM FETCH_OPEN_DATA.
  IF NOT ( ( MARA-MATNR IS INITIAL ) AND
           ( MARC-WERKS IS INITIAL ) AND
           ( MARD-LGORT IS INITIAL ) ).
    SELECT VBELN
           POSNR
           KWMENG
           INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
           FROM VBAP
           WHERE MATNR IN S_MATNR
             AND WERKS IN S_WERKS
             AND LGORT IN S_LGORT.
  ENDIF.
  LOOP AT IT_VBAP.
    SELECT * FROM VBUP
             INTO VBUP
             WHERE VBELN = IT_VBAP-VBELN
               AND POSNR = IT_VBAP-POSNR
               AND LFSTA NE 'C'.
    ENDSELECT.
  ENDLOOP.
  IF SY-SUBRC NE 0.
    REFRESH IT_VBAP.
    MESSAGE E000 WITH TEXT-004.
    EXIT.
  ELSE.
    V_FLAG = 'X'.
  ENDIF.
      To get sum of all quantities as open order quantity
  LOOP AT IT_VBAP.
    TOTAL = TOTAL + IT_VBAP-KWMENG.
  ENDLOOP.
ENDFORM.                    " FETCH_OPEN_DATA
*&      Form  FETCH_FINAL_DATA
     To get data into final internal table IT_FINAL
-->  p1        text
<--  p2        text
FORM FETCH_FINAL_DATA.
  SELECT A~MATNR
         A~WERKS
         A~LGORT
         MAKTX
         LABST
         INSME
         RETME
         UMLME
         VBELN
         POSNR
         KWMENG
         INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
         FROM MARD AS A
         INNER JOIN MAKT AS B
         ON AMATNR = BMATNR
          AND SPRAS = 'E'
         INNER JOIN VBAP AS C
         ON AMATNR = CMATNR
         FOR ALL ENTRIES IN IT_VBAP
         WHERE VBELN = IT_VBAP-VBELN
           AND POSNR = IT_VBAP-POSNR
           AND KWMENG = IT_VBAP-KWMENG
           AND A~MATNR IN S_MATNR
           AND A~WERKS IN S_WERKS
           AND A~LGORT IN S_LGORT.
  IF SY-SUBRC NE 0.
    V_FLAG = SPACE.
    MESSAGE E001 WITH 'No data found IN the selection criteria'.
    EXIT.
  ELSE.
    V_FLAG = 'X'.
  ENDIF.
ENDFORM.                    " FETCH_FINAL_DATA
*&      Form  FILL_FIELDCAT_HEADER
      text
-->  p1        text
<--  p2        text
FORM FILL_FIELDCAT_HEADER .
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     I_PROGRAM_NAME               = V_REPID
     I_INTERNAL_TABNAME           = 'IT_FINAL'
  I_STRUCTURE_NAME             =
  I_CLIENT_NEVER_DISPLAY       = 'X'
     I_INCLNAME                   = V_REPID
  I_BYPASSING_BUFFER           =
  I_BUFFER_ACTIVE              =
    CHANGING
      CT_FIELDCAT                  = IT_FIELDCAT
   EXCEPTIONS
     INCONSISTENT_INTERFACE       = 1
     PROGRAM_ERROR                = 2
     OTHERS                       = 3
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
    CASE WA_FIELDCAT-FIELDNAME.
      WHEN 'KWMENG'.
       WA_FIELDCAT-COL_POS = '11'.
       WA_FIELDCAT-OUTPUTLEN = '22'.
       WA_FIELDCAT-SELTEXT_L = 'Net Value'.
        WA_FIELDCAT-DO_SUM    = 'X'.
    ENDCASE.
    MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
  ENDLOOP.
ENDFORM.                    " FILL_FIELDCAT_HEADER
*&      Form  GET_LAYOUT
      text
-->  p1        text
<--  p2        text
FORM GET_LAYOUT .
  WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM.                    " GET_LAYOUT
*&      Form  GET_EVENT
      text
-->  p1        text
<--  p2        text
FORM GET_EVENT .
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      I_LIST_TYPE     = 0
    IMPORTING
      ET_EVENTS       = IT_EVENTS
    EXCEPTIONS
      LIST_TYPE_WRONG = 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.
  LOOP AT IT_EVENTS INTO WA_EVENTS.
    CASE WA_EVENTS-NAME.
      WHEN 'TOP_OF_PAGE'.
        WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
      WHEN 'USER_COMMAND'.
        WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
    ENDCASE.
    MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
  ENDLOOP.
ENDFORM.                    " GET_EVENT
      FORM FILL_LIST_HEADER                                         *
FORM FILL_LIST_HEADER.
  WRITE:2'Report :' ,   SY-REPID,
       : 85 '         Intelligroup Asia Pvt Ltd' CENTERED,
       : 159 'Date  :' ,SY-DATUM,
       :/2'User   :',   SY-UNAME,
       : 82 '               Hyderabad         ' CENTERED ,
       : 159 'Pg.No :' ,SY-PAGNO,
       :/86 '           Stock Report    ' CENTERED.
  SKIP 2.
ENDFORM.                    "FILL_LIST_HEADER
*&      Form  DISPLAY_LIST
      text
-->  p1        text
<--  p2        text
FORM DISPLAY_LIST .
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
  I_INTERFACE_CHECK              = ' '
  I_BYPASSING_BUFFER             =
  I_BUFFER_ACTIVE                = ' '
     I_CALLBACK_PROGRAM             = V_REPID
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  I_STRUCTURE_NAME               =
     IS_LAYOUT                      = WA_LAYOUT
     IT_FIELDCAT                    = IT_FIELDCAT
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
     IT_SORT                        = IT_SORT[]
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
     IT_EVENTS                      = IT_EVENTS
  IT_EVENT_EXIT                  =
  IS_PRINT                       =
  IS_REPREP_ID                   =
  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         =
    TABLES
      T_OUTTAB                       = IT_FINAL
   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_LIST
*&      Form  do_sort
      text
-->  p1        text
<--  p2        text
FORM DO_SORT .
*-- Populating the sort table
  IT_SORT-FIELDNAME = 'MATNR'.
  IT_SORT-TABNAME = 'IT_FINAL'.
  IT_SORT-UP = 'X'.
it_sort-subtot = 'X'.
  APPEND IT_SORT.
ENDFORM.                    " do_sort
Thanks & Regards
Sreenivasulu P

Similar Messages

  • ALV REPORT WITH MULTIPLE BLOCKS - COLUM TOTAL

    Hi friends,
    In the following code, I am not getting the column total.
    --- SAMPLE 1--
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
           EXPORTING
                i_callback_program      = sy-cprog
                i_callback_user_command = 'USER_COMMAND'.
      PERFORM list_append TABLES IT_CTV
                           USING '1'
                                 'IT_CTV'.
      PERFORM list_append TABLES IT_APP
                           USING '2'
                                 'IT_APP'.
      PERFORM f_list_display.
          FORM USER_COMMAND                                             *
    FORM user_command USING i_ucomm     LIKE sy-ucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
    ENDFORM.                               " USER_COMMAND
          Form  list_append
    FORM list_append TABLES ut_table
                     USING  u_no      TYPE char1
                            u_tabname TYPE slis_tabname.
      DEFINE m_fieldcat.
        ls_fieldcat-fieldname = &1.
        ls_fieldcat-ref_tabname = &2.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
    DATA: GT_ZSUM TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
      DEFINE m_sort.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv. " Sort table
      DATA:
        lt_events TYPE slis_t_event,
        ls_event  TYPE slis_alv_event,
        ls_layout TYPE slis_layout_alv.
      ls_layout-group_change_edit = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-zebra             = 'X'.
      ls_layout-cell_merge        = 'X'.
      ls_layout-detail_popup      = 'X'.
      ls_layout-get_selinfos      = 'X'.
      ls_layout-max_linesize      = '300'.
      CASE u_no.
        WHEN '1'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          m_fieldcat  'BZIRK' 'IT_CTV'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' CTV STOCK'.
          m_fieldcat  'CTVST' 'IT_CTV'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' CTV VALUE'.
          m_fieldcat  'CTVVL' 'IT_CTV'.
          ls_fieldcat-DO_SUM = 'X'.
          m_sort  'BZIRK'.
        WHEN '2'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          m_fieldcat  'BZIRK' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' RFG STK'.
          m_fieldcat  'RFGST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' RFG VAL'.
          m_fieldcat  'RFGVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' WM STK'.
          m_fieldcat  'WMCST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' WM VAL'.
          m_fieldcat  'WMCVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' MCCS STK'.
          m_fieldcat  'MOVST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' MCCS VAL'.
          m_fieldcat  'MOVVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' APP STK'.
          m_fieldcat  'APPST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' APP VAL'.
          m_fieldcat  'APPVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-DO_SUM = 'X'.
         m_sort  'BZIRK'.
      ENDCASE.
    ls_fieldcat-COL_POS = 1.
    ls_fieldcat-FIELDNAME = 'BZIRK'.
    ls_fieldcat-DO_SUM = 'X'.
    ls_fieldcat-FIX_COLUMN = 'X'.
    APPEND ls_fieldcat TO lT_fieldcat.
      IF u_no CA '13'.
        MOVE        'TOP_OF_PAGE'        TO ls_event-name.
        CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ELSE.
        MOVE        'TOP_OF_LIST'        TO ls_event-name.
        CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                it_fieldcat                = lt_fieldcat
                is_layout                  = ls_layout
                i_tabname                  = u_tabname
                it_events                  = lt_events
                it_sort                    = lt_sort
           TABLES
                t_outtab                   = ut_table
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 2
                OTHERS                     = 3.
      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.                               " LIST_APPEND
          Form  f_list_display
    FORM f_list_display.
      DATA ls_print TYPE slis_print_alv.
      ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
      ls_print-no_print_listinfos = 'X'.   " Display no listinfos
      ls_print-reserve_lines      = 2.     " Lines reserved for end of page
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
           EXPORTING
                i_interface_check = ' '
                is_print          = ls_print
           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.                               " F_LIST_DISPLAY
          FORM top_of_page1                                             *
    FORM top_of_page1.                                          "#EC CALLED
      WRITE 'SALES REPORT'.
      PERFORM TOP_LIST1.
    ENDFORM.
          FORM top_of_list2                                             *
    FORM top_of_list2.                                          "#EC CALLED
      WRITE 'STOCK REPORT'.
      PERFORM top_of_page.
    ENDFORM.
    *-----END OF SAMPLE 1 -
    Could any help me.
    Thanx in advance.
    Regards,
    A S VINCENT

    Hai Vincent
    Check & Run the follow ABAP Code
    *& Report  ZALV_Block                                               *
    REPORT  ZALV_block NO STANDARD PAGE HEADING
                                    MESSAGE-ID ZZ.
    *..Type Definitions for ALV Report
    TYPE-POOLS SLIS.
    Table Declarations.                                        *
    TABLES: MARA,        "Material Master
            MARC,        "Plant Data for Material
            MARD,        "Storage Location Data for Material
            VBAP,        "Sales Document: Item Data
            VBUP.        "Sales Document: Item Status
    Internal table to store sales orders.......
    DATA: BEGIN OF IT_VBAP OCCURS 0,
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_VBAP.
    internal table to store final data
    DATA: BEGIN OF IT_FINAL OCCURS 0,
            WERKS LIKE MARD-WERKS,    "Plant
            MATNR LIKE MARD-MATNR,    "Material Number
            LGORT LIKE MARD-LGORT,    "Storage Location
            LABST LIKE MARD-LABST,    "Valuated stock with unrestricted use
            INSME LIKE MARD-INSME,    "Stock in quality inspection
            RETME LIKE MARD-RETME,    "Blocked Stock Returns
            UMLME LIKE MARD-UMLME,    "Stock in transfer
            MAKTX LIKE MAKT-MAKTX,    "Material description
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_FINAL.
    ALV Type declaration                                                 *
    *..Field Catalog for Basic List.
    DATA : IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV.
    *..Events For Basic List.
    DATA : IT_EVENTS TYPE SLIS_T_EVENT,
           WA_EVENTS TYPE SLIS_ALV_EVENT.
    *..Layout For Basic List
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *..Sort Table For Basic List
    DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
               DATA DECLARATIONS                                         *
    DATA: V_FLAG,
          VINDEX TYPE SY-TABIX,
          TOTAL TYPE VBAP-KWMENG.     "Open order quantity
    *..To Store Program Name
    DATA: V_REPID  TYPE SYREPID.
    *..To know whether basic list contains any data
    Selection Screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
                    S_WERKS FOR MARC-WERKS,
                    S_LGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK B1.
    Event:Initialization                                                 *
    INITIALIZATION.
      V_REPID = SY-REPID.
    AT Selection Screen.                                                 *
    AT SELECTION-SCREEN.
      PERFORM VALIDATIONS.
    Event: Start-of-Selection                                            *
    START-OF-SELECTION.
         To get data from vbap into internal table IT_VBAP
      PERFORM FETCH_OPEN_DATA.
          To get data into final internal table IT_FINAL
      IF V_FLAG = 'X'.
        PERFORM FETCH_FINAL_DATA.
      ENDIF.
      IF V_FLAG = ''.
        MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
        EXIT.
      ELSE.
      --Setting the FIELD CATALOG for ALV
        PERFORM FILL_FIELDCAT_HEADER.
    *-----Setting the LAYOUT for ALV
        PERFORM GET_LAYOUT.
    *-----Getting the ALV Events
        PERFORM GET_EVENT.
    *---- To Sort the list
        PERFORM DO_SORT.
      ENDIF.
    Event: End-of-Selection                                            *
    END-OF-SELECTION.
    *--Generating the ALV LIST DISPLAY
      PERFORM DISPLAY_LIST.
                             FORM DEFINITIONS                            *
    *&      Form  VALIDATIONS
          To validate data in selection screen
    -->  p1        text
    <--  p2        text
    FORM VALIDATIONS.
      PERFORM VALIDATE_MATNR.
      PERFORM VALIDATE_WERKS.
      PERFORM VALIDATE_LGORT.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
              ( MARC-WERKS IS INITIAL ) AND
              ( MARD-LGORT IS INITIAL ) ).
        SELECT SINGLE MATNR
                      WERKS
                      LGORT
                      FROM MARD
          INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
          WHERE MATNR = MARA-MATNR
            AND WERKS = MARC-WERKS
            AND LGORT = MARD-LGORT.
      ENDIF.
    ENDFORM.                    " VALIDATIONS
    *&      Form  VALIDATE_MATNR
          To validate MATNR
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_MATNR.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR
               UP TO 1 ROWS
               INTO (MARD-MATNR)
               FROM MARA
               WHERE MATNR IN S_MATNR.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-001.
      ENDIF.
    ENDFORM.                    " VALIDATE_MATNR
    *&      Form  VALIDATE_WERKS
          To validate plant
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_WERKS.
      IF NOT S_WERKS[] IS INITIAL.
        SELECT WERKS
               UP TO 1 ROWS
               INTO (MARD-WERKS)
               FROM MARC
               WHERE WERKS IN S_WERKS.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-002.
      ENDIF.
    ENDFORM.                    " VALIDATE_WERKS
    *&      Form  VALIDATE_LGORT
          To validate storage
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_LGORT.
      IF NOT S_LGORT[] IS INITIAL.
        SELECT LGORT
               UP TO 1 ROWS
               INTO (MARD-LGORT)
               FROM MARD
               WHERE LGORT IN S_LGORT.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-003.
      ENDIF.
    ENDFORM.                    " VALIDATE_LGORT
    *&      Form  FETCH_OPEN_DATA
          To get data into internal table IT_VBAP
    -->  p1        text
    <--  p2        text
    FORM FETCH_OPEN_DATA.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
               ( MARC-WERKS IS INITIAL ) AND
               ( MARD-LGORT IS INITIAL ) ).
        SELECT VBELN
               POSNR
               KWMENG
               INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
               FROM VBAP
               WHERE MATNR IN S_MATNR
                 AND WERKS IN S_WERKS
                 AND LGORT IN S_LGORT.
      ENDIF.
      LOOP AT IT_VBAP.
        SELECT * FROM VBUP
                 INTO VBUP
                 WHERE VBELN = IT_VBAP-VBELN
                   AND POSNR = IT_VBAP-POSNR
                   AND LFSTA NE 'C'.
        ENDSELECT.
      ENDLOOP.
      IF SY-SUBRC NE 0.
        REFRESH IT_VBAP.
        MESSAGE E000 WITH TEXT-004.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
          To get sum of all quantities as open order quantity
      LOOP AT IT_VBAP.
        TOTAL = TOTAL + IT_VBAP-KWMENG.
      ENDLOOP.
    ENDFORM.                    " FETCH_OPEN_DATA
    *&      Form  FETCH_FINAL_DATA
         To get data into final internal table IT_FINAL
    -->  p1        text
    <--  p2        text
    FORM FETCH_FINAL_DATA.
      SELECT A~MATNR
             A~WERKS
             A~LGORT
             MAKTX
             LABST
             INSME
             RETME
             UMLME
             VBELN
             POSNR
             KWMENG
             INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
             FROM MARD AS A
             INNER JOIN MAKT AS B
             ON AMATNR = BMATNR
              AND SPRAS = 'E'
             INNER JOIN VBAP AS C
             ON AMATNR = CMATNR
             FOR ALL ENTRIES IN IT_VBAP
             WHERE VBELN = IT_VBAP-VBELN
               AND POSNR = IT_VBAP-POSNR
               AND KWMENG = IT_VBAP-KWMENG
               AND A~MATNR IN S_MATNR
               AND A~WERKS IN S_WERKS
               AND A~LGORT IN S_LGORT.
      IF SY-SUBRC NE 0.
        V_FLAG = SPACE.
        MESSAGE E001 WITH 'No data found IN the selection criteria'.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
    ENDFORM.                    " FETCH_FINAL_DATA
    *&      Form  FILL_FIELDCAT_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_FIELDCAT_HEADER .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = V_REPID
         I_INTERNAL_TABNAME           = 'IT_FINAL'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                  = IT_FIELDCAT
       EXCEPTIONS
         INCONSISTENT_INTERFACE       = 1
         PROGRAM_ERROR                = 2
         OTHERS                       = 3
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
        CASE WA_FIELDCAT-FIELDNAME.
          WHEN 'KWMENG'.
           WA_FIELDCAT-COL_POS = '11'.
           WA_FIELDCAT-OUTPUTLEN = '22'.
           WA_FIELDCAT-SELTEXT_L = 'Net Value'.
            WA_FIELDCAT-DO_SUM    = 'X'.
        ENDCASE.
        MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " FILL_FIELDCAT_HEADER
    *&      Form  GET_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_LAYOUT .
      WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  GET_EVENT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_EVENT .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = IT_EVENTS
        EXCEPTIONS
          LIST_TYPE_WRONG = 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.
      LOOP AT IT_EVENTS INTO WA_EVENTS.
        CASE WA_EVENTS-NAME.
          WHEN 'TOP_OF_PAGE'.
            WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
          WHEN 'USER_COMMAND'.
            WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
        ENDCASE.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " GET_EVENT
          FORM FILL_LIST_HEADER                                         *
    FORM FILL_LIST_HEADER.
      WRITE:2'Report :' ,   SY-REPID,
           : 85 '         Intelligroup Asia Pvt Ltd' CENTERED,
           : 159 'Date  :' ,SY-DATUM,
           :/2'User   :',   SY-UNAME,
           : 82 '               Hyderabad         ' CENTERED ,
           : 159 'Pg.No :' ,SY-PAGNO,
           :/86 '           Stock Report    ' CENTERED.
      SKIP 2.
    ENDFORM.                    "FILL_LIST_HEADER
    *&      Form  DISPLAY_LIST
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_LIST .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = V_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
         IS_LAYOUT                      = WA_LAYOUT
         IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
         IT_SORT                        = IT_SORT[]
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
         IT_EVENTS                      = IT_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      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         =
        TABLES
          T_OUTTAB                       = IT_FINAL
       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_LIST
    *&      Form  do_sort
          text
    -->  p1        text
    <--  p2        text
    FORM DO_SORT .
    *-- Populating the sort table
      IT_SORT-FIELDNAME = 'MATNR'.
      IT_SORT-TABNAME = 'IT_FINAL'.
      IT_SORT-UP = 'X'.
    it_sort-subtot = 'X'.
      APPEND IT_SORT.
    ENDFORM.                    " do_sort
    Thanks & Regards
    Sreenivasulu P

  • Printing page numbers in an ALV report with multiple grids

    Hi,
    I have developed a report using OO ALV GRID. The output is having multiple grids navigated using a menu button appended to the standard tool bar
    (Ref report: BCALV_GRID_07). On navigation, we are able to display specific titles when each grid is displayed.
    When we print those individual pages (the grids), we are able to print the page numbers and the title for the first grid but when we display the next grid and print, we are unable to initialise the page number
    and print specific title. The page numbers continues from the last printing.
    I am looking at identifying the grid when the print event - PRINT_TOP_OF_PAGE is triggered so that a grid specific title can be printed and also page number initialised.
    Any suggestions is highly appreciated.
    Thanks.
    Mani.

    You cannot have one event for all the grids as you cannot identify for which grid the event has fired. You need to activate the event for each of the grid and handle the code independently.
    regards,
    Ravi
    Note - Please mark the helpful answers

  • Report with multiple Detail Area

    Hi All,
    Please see the Report pointed to the link below:
    [Report with multiple Detail Area|http://us.share.geocities.com/felix5ac/fairway.jpg]
    Some Explanations:
    ========================
    (1) The line with "ABCDEFGH..." is variable data coming from the database in the Detail Area
    (2) The lines with "WBLNX'" "123, 123.12", 
                             "WBLNX'"
       are variable data associated with the same Heading: "ABCDEFGH..."
    (2b) There can be multiple lines of data in the detail area (i.e. 1 or more "ABCDEFGH..." and the associated WBLNX and numbers...)
    (3) Item Code Descriptions ==> is a Header Info
    (4) ARL ... and FPHI... ==> are variable data and lines in these area can be 1 line; it can be 4 lines; it can be 10 lines...
    (5) Lines FROM "Artwork Procedures..." to the the end of the page are static.
    QUESTION:
    ===================
    How do I best design these Report with the multiple detail areas? Again, please see link of the Report above...
    Thanks and Best regards,
    Felix

    Hi Felix
    You can place the less detailed fields in the regular sections of the report and wherever you require multiple lines you can use the subreports.
    Hope this helps.
    Regards
    Nikhil

  • Create a Procedural ALV Report with editable fields and save the changes

    Hi,
    I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDIT_02
    BCALV_TEST_GRID_EDIT_04_FORMS
    BCALV_TEST_GRID_EDITABLE
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_03
    BCALV_EDIT_04
    BCALV_EDIT_05
    BCALV_EDIT_06
    BCALV_EDIT_07
    BCALV_EDIT_08
    BCALV_FULLSCREEN_GRID_EDIT
    But all these are using OO Concepts.
    Please help.
    Regards,
    Smruthi

    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) TYPE c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
    fieldcatalog-edit             = 'X'
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-info_fieldname =      'LINE_COLOR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = gd_repid
                i_callback_pf_status_set = 'STATUS'
                i_callback_top_of_page   = 'TOP-OF-PAGE'
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           TABLES
                t_outtab                = it_ekko
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
      LOOP AT it_ekko INTO wa_ekko.
        ld_color = ld_color + 1.
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
        MODIFY it_ekko FROM wa_ekko.
      ENDLOOP.
    ENDFORM.                    " DATA_RETRIEVAL
          FORM top-of-page                                              *
    FORM top-of-page.
      WRITE:/ 'This is First Line of the Page'.
    ENDFORM.
          FORM status                                                   *
    FORM status USING rt_extab TYPE slis_t_extab.  .
      SET PF-STATUS 'ALV'.
    ENDFORM.
          FORM USER_COMMAND                                          *
    -->  RF_UCOMM                                                      *
    -->  RS                                                            *
    FORM user_command USING rf_ucomm LIKE sy-ucomm
                             rs TYPE slis_selfield.            
      DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      CALL METHOD ref1->check_changed_data.
      CASE rf_ucomm.
    when 'SAVE'.
    get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
    endcase.
    endform.
    ENDFORM.
    here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
    create a custom PF status and create push buttons and assign your ok codes in your PF status.
    if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
    Hope this will help you.
    Regards,
    phani.

  • Print or download ALV report with sort options

    Dear friends,
    How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
    Regards,
    Praveen Lobo

    Hi Praveen,
    Use this code, its working:-
    *FOR SORTING DATA
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *          SORT W.R.T. CUSTOMER NAME
      wa_sort-spos = 1.
      wa_sort-fieldname = 'NAME1'. "field customer name
      wa_sort-tabname = 'IT_KNA1'. "internal table with records
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    "this will sort the ALV o/p for customer with same name
    "now the name will not be repeated
    "records with same name will be grouped
    *          DISPLAY RECORDS IN ALV GRID
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = sy-repid "report id
        it_fieldcat                       = it_field "field catalog
        it_sort                           = it_sort "sort info
      TABLES
        t_outtab                          = it_kna1 "internal table
      EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir
    Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM

  • Bursting a report with multiple queries

    Hi,
    I need to set-up bursting in BIP for a report with multiple queries. The output format is pdf and delivery is through e-mail. Since the queries need to be linked, I'm trying to do this using data template. I've set-up split and burst based on a field (store_id) from the first query which is used as a bind variable in the subsequent queries. So I'd ideally want the report to be split based on store_id. The report works fine if I use a parameter for store_id and view the output by store_id. When I try to schedule the report for bursting, it generates and e-mails the reports but only the last report appears to have correct data output while the others have only the output from the first query (and all other queries appear to return nothing in the report).
    Any suggestions on what could be the issue here? Thanks!
    Here is the data template for the report:
    <dataTemplate name="Report" description="Report" dataSourceRef="ReportDB">
    <dataQuery>
    <sqlStatement name="STORE_VENDOR">
    <![CDATA[SELECT STORE.STORE_ID Q1_STORE_ID, VENDOR.VENDOR_ID Q1_VENDOR_ID, VENDOR.VENDOR_DESC Q1_VENDOR_DESC, PERSON.NAME Q1_NAME
                   FROM STORE, SERVICE_TICKET, VENDOR, ROLE, ROLE_TYPE, PERSON, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = VENDOR.SOURCE_ID AND SERVICE_TICKET.VENDOR_ID = VENDOR.VENDOR_ID)
                   AND (STORE.SOURCE_ID = ROLE.SOURCE_ID AND STORE.STORE_ID = ROLE.STORE_ID)
                   AND (ROLE.SOURCE_ID = ROLE_TYPE.SOURCE_ID AND ROLE.ROLE_TYPE_ID = ROLE_TYPE.TYPE_ID AND ROLE_TYPE.TYPE_DESC = 'PIC')
                   AND (ROLE.SOURCE_ID = PERSON.SOURCE_ID AND ROLE.PERSON_ID = PERSON.PERSON_ID)
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   GROUP BY STORE.STORE_ID, VENDOR.VENDOR_ID, VENDOR.VENDOR_DESC, PERSON.NAME
                   ORDER BY STORE.STORE_ID]]>
    </sqlStatement>
    <sqlStatement name="WO">
    <![CDATA[SELECT STORE.STORE_ID Q3_STORE_ID, 'Nightly Cleaning' Q3_NIGHTLY_CLEANING, 'Nightly Cleaning' Q3_DESCRIPTION, SERVICE_TICKET.TICKET_ID Q3_TICKET_ID, TO_CHAR(SERVICE_TICKET.END_DATE, 'MM/DD/YYYY') Q3_END_DATE, 'Excellent' Q3_QUALITY_RATING_1, 'Satisfactory' Q3_QUALITY_RATING_2, 'Unsatisfactory' Q3_QUALITY_RATING_3
                   FROM SERVICE_TICKET, STORE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4']]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_1">
    <![CDATA[SELECT STORE.STORE_ID Q4_STORE_ID, ZONE.ZONE_DESC Q4_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q4_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q4_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q4_WO_END_DATE, 'Excellent' Q4_QUALITY_RATING_1, 'Satisfactory' Q4_QUALITY_RATING_2, 'Unsatisfactory' Q4_QUALITY_RATING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'ABC'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_2">
    <![CDATA[SELECT STORE.STORE_ID Q5_STORE_ID, ZONE.ZONE_DESC Q5_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q5_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q5_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q5_WO_END_DATE, 'Excellent' Q5_QUALITY_RATING_1, 'Satisfactory' Q5_QUALITY_RATING_2, 'Unsatisfactory' Q5_QUALITY_RATING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'XYZ'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
    </sqlStatement>
    <sqlStatement name="SERVC_TYPE_3">
    <![CDATA[SELECT STORE.STORE_ID Q6_STORE_ID, ZONE.ZONE_DESC Q6_ZONE_DESC, 'Excellent' Q6_QUALITY_RATING_1, 'Satisfactory' Q6_QUALITY_RATING_2, 'Unsatisfactory' Q6_QUALITY_RATING_3, 'One' Q6_QTY_MISSING_1, 'Two' Q6_QTY_MISSING_2, '3 or More' Q6_QTY_MISSING_3
                   FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
                   WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
                   AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
                   AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
                   AND SERVICE_TYPE.TYPE_DESC = 'PQR'
                   AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
                   AND STORE.STORE_ID = :Q1_STORE_ID
                   AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
                   AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
                   ORDER BY SERVICE_TYPE.TYPE_ID]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
         <group name="G_STORE_VENDOR" source="STORE_VENDOR">
              <element name="Q1_STORE_ID" value="Q1_STORE_ID"/>
              <element name="Q1_VENDOR_ID" value="Q1_VENDOR_ID"/>
              <element name="Q1_VENDOR_DESC" value="Q1_VENDOR_DESC"/>
              <element name="Q1_NAME" value="Q1_NAME"/>
         </group>     
         <group name="G_WO" source="WO">
              <element name="Q3_NIGHTLY_CLEANING" value="Q3_NIGHTLY_CLEANING"/>
              <element name="Q3_DESCRIPTION" value="Q3_DESCRIPTION"/>
              <element name="Q3_TICKET_ID" value="Q3_TICKET_ID"/>
              <element name="Q3_END_DATE" value="Q3_END_DATE"/>
              <element name="Q3_QUALITY_RATING_1" value="Q3_QUALITY_RATING_1"/>
              <element name="Q3_QUALITY_RATING_2" value="Q3_QUALITY_RATING_2"/>
              <element name="Q3_QUALITY_RATING_3" value="Q3_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_1" source="SERVC_TYPE_1">
              <element name="Q4_ZONE_DESC" value="Q4_ZONE_DESC"/>
              <element name="Q4_SERVICE_COST" value="Q4_SERVICE_COST"/>
              <element name="Q4_TICKET_ID" value="Q4_TICKET_ID"/>
              <element name="Q4_WO_END_DATE" value="Q4_WO_END_DATE"/>
              <element name="Q4_QUALITY_RATING_1" value="Q4_QUALITY_RATING_1"/>
              <element name="Q4_QUALITY_RATING_2" value="Q4_QUALITY_RATING_2"/>
              <element name="Q4_QUALITY_RATING_3" value="Q4_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_2" source="SERVC_TYPE_2">
              <element name="Q5_ZONE_DESC" value="Q5_ZONE_DESC"/>
              <element name="Q5_SERVICE_COST" value="Q5_SERVICE_COST"/>
              <element name="Q5_TICKET_ID" value="Q5_TICKET_ID"/>
              <element name="Q5_WO_END_DATE" value="Q5_WO_END_DATE"/>
              <element name="Q5_QUALITY_RATING_1" value="Q5_QUALITY_RATING_1"/>
              <element name="Q5_QUALITY_RATING_2" value="Q5_QUALITY_RATING_2"/>
              <element name="Q5_QUALITY_RATING_3" value="Q5_QUALITY_RATING_3"/>
         </group>     
         <group name="G_SERVC_TYPE_3" source="SERVC_TYPE_3">
              <element name="Q6_ZONE_DESC" value="Q6_ZONE_DESC"/>
              <element name="Q6_QUALITY_RATING_1" value="Q6_QUALITY_RATING_1"/>
              <element name="Q6_QUALITY_RATING_2" value="Q6_QUALITY_RATING_2"/>
              <element name="Q6_QUALITY_RATING_3" value="Q6_QUALITY_RATING_3"/>
              <element name="Q6_QTY_MISSING_1" value="Q6_QTY_MISSING_1"/>
              <element name="Q6_QTY_MISSING_2" value="Q6_QTY_MISSING_2"/>
              <element name="Q6_QTY_MISSING_3" value="Q6_QTY_MISSING_3"/>
         </group>
    </dataStructure>
    </dataTemplate>

    Hello user6428199,
    When you use ":Q1_STORE_ID" in your queries, BI Publisher looks for a report parameter named Q1_STORE_ID. Change all your report queries to get data for all the store_id's available. As you are bursting the report using the store_id as the bursting key, BI Publisher will split the report based on the stored_id and delivers content based on it. No matter how many queries you may have, BI Publisher will loop through all the store_id's available and all the queries will return data for that particular id in a report.
    Thanks,
    Machaan

  • Report with Multiple queries too slow in BI Publisher 11g

    Hi, I have a report in 11g where i need to create multiple queries to show them in report. I tried to combine everything in one query, but i found that the query is too huge and hard to understand and maintain. I created 3 data sets and linked them together. In SQL dev, the main query is returning about 315 records and first detail query returns less than 100 records and second detail query is returning one record which is BLOB. Each query returns data within a couple of seconds from SQL Developer. The entire report from BI Publisher should be just 21 page PDF output. Did anyone face performance issues while running reports with multiple queries in 11g? I ran reports that have single query which returned 10K pages PDF and never had an issue while everthing is in one query. This is the first time Iam attempting to create multiple queries. Can someone help me understand what i might be doing wrong or missing here. Thank you.

    Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
    Per the BI Publisher guide,
    Following are recommended guidelines for building data models:
    Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
    You should only use multiquery data models in the following scenarios:
    To perform functions that the query type, such as a SQL query, does not support directly.
    To support complex views (for example, distributed queries or GROUP BY queries).
    To simulate a view when you do not have or want to use a view.
    Thanks,
    Bipuser

  • ALV Reporting with drill down capabillities

    I'm creating a abap custom report using the ALV.  I want to drill down to CJ03 which is projects.  I know how to do it in regular custom reporting, but I don't seem to be able to get it to work using the ALV.  Can anyone help?
    Thanks.
    Linda

    Hi Linda,
    Take a look at this sample program. The logic to handle any interaction with the user is in my "PORCESS_USER_COMMANDS" routine.
    This is defined in the "I_CALLBACK_USER_COMMAND" parameter in the ALV FM.
    Hope this helps.
    Cheers,
    Pat.
    [code]
    Modification History
    Date      | Author    | Chg Req #     | Description
    15.08.2001| Pat Yee   | $TMP          | Program Creation
    This program is an example of how the ALV Display works.
    It will display Customer Data.
    This report will also show how to display an ALV report with different
    colored lines and icons
    REPORT zpat.
    Include Programs
    INCLUDE <icon>.
    Database Tables
    TABLES: kna1.                  "Customer Master
    Types
    TYPE-POOLS: kkblo.
    Structures
    Structure to hold the Color Information
    DATA: BEGIN OF st_color,
            color(3) TYPE c,
          END OF st_color.
    Structure to hold the Icon Information
    DATA: BEGIN OF st_icon,
            icon(4) TYPE c,
          END OF st_icon.
    ALV Field Catalog Structure
    DATA: st_fieldcat   TYPE slis_fieldcat_alv.
    ALV Layout Structure
    DATA: st_layout     TYPE slis_layout_alv.
    Internal Tables
    Output Table
    DATA: BEGIN OF tbl_kna1 OCCURS 0.
            INCLUDE STRUCTURE st_icon.   "Icon Structure
            INCLUDE STRUCTURE kna1.      "Customer Master Structure
            INCLUDE STRUCTURE st_color.  "Color Structure
    DATA: END OF tbl_kna1.
    ALV Field Catalog Table
    DATA: tbl_fieldcat  TYPE slis_t_fieldcat_alv.
    Variables
    DATA: fieldname(30) TYPE c,
          g_repid       LIKE sy-repid.
    Start of Selection
    START-OF-SELECTION.
      g_repid = sy-repid.
      PERFORM get_data.
    End of Selection
    END-OF-SELECTION.
      PERFORM do_fancy_stuff.
      PERFORM get_layout.
      PERFORM get_fieldcat.
      PERFORM create_report.
    *&      Form  CREATE_REPORT
          Learn to read the subroutine name!
    FORM create_report.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_interface_check       = ' '
                i_callback_program      = g_repid
                i_callback_user_command = 'PROCESS_USER_COMMANDS'
                it_fieldcat             = tbl_fieldcat
                i_default               = 'X'
                i_save                  = ' '
                is_layout               = st_layout
           TABLES
                t_outtab                = tbl_kna1
           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.                               " CREATE_REPORT
    *&      Form  GET_FIELDCAT
          Build the Field Catalog
    FORM get_fieldcat.
    Here the field catalog is created. To display more fields simply
    'uncomment' the additional lines and add the field name. Also note
    that the field catalog is much more powerful than this. You can
    intensify fields, change the colour, assign reference fields, etc.
    Look at type slis_fieldcat_alv for more options.
      PERFORM write_fieldcat USING 'ICON'  'TBL_KNA1' '    ' 'X' 1 '2' 'X'
      PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '
      PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '
                                   'X'.
      PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '
      PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '
      PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '
      PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '
      PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '
      PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '
      PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.
    ENDFORM.                               " GET_FIELDCAT
    *&      Form  WRITE_FIELDCAT
          Write the Field Catalog data to the Field Catalog Table
         -->name   Field name
         -->tab    Table name
         -->st     Structure Name
         -->key    Is this field a Key?
         -->pos    Position Number
         -->length Field Length
         -->icon   Display as Icon
         -->hot    Hotspot
    FORM write_fieldcat USING name tab st key pos length icon hot.
      st_fieldcat-fieldname   = name.
      st_fieldcat-tabname     = tab.
      st_fieldcat-ref_tabname = st.
      st_fieldcat-key         = key.
      st_fieldcat-col_pos     = pos.
      st_fieldcat-outputlen   = length.
      st_fieldcat-icon        = icon.
      st_fieldcat-hotspot     = hot.
      APPEND st_fieldcat TO tbl_fieldcat.
      CLEAR st_fieldcat.
    ENDFORM.                               " WRITE_FIELDCAT
    *&      Form  PROCESS_USER_COMMANDS
          Interactive Reporting Commands
    FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
                                     selfield TYPE slis_selfield.
    This subroutine is called when there is user interaction in the output
    In this case if the user double clicks the Customer Number then the
    program will call transaction XD03 and display the Customer Master
    Data
      CASE syst-ucomm.
        WHEN '&IC1'.
    get cursor field fieldname.
          READ TABLE tbl_kna1 INDEX selfield-tabindex.
          SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
          CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                               " PROCESS_USER_COMMANDS
    *&      Form  GET_LAYOUT
      set the layout of the ALV.
      add color to the row?
    FORM get_layout.
      st_layout-info_fieldname    = 'COLOR'.
      st_layout-colwidth_optimize = 'X'.
      st_layout-get_selinfos      = 'X'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  get_data
          Get some data to play with
    FORM get_data.
      SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
             UP TO 30 ROWS.
    ENDFORM.                    " get_data
    *&      Form  do_fancy_stuff
          Do some fancy pants stuff for example changing the color of
          lines and adding icons
    FORM do_fancy_stuff.
    Here we will demonstrate changing the color of ALV Record lines as
    well as displaying Icons
      LOOP AT tbl_kna1.
    All records where NAME1 begins with 'M', will be displayed in Bluish
    Green
        IF tbl_kna1-name1(1) EQ 'M'.
          tbl_kna1-color = 'C41'.  "Bluish Green
          MODIFY tbl_kna1 TRANSPORTING color.
        ENDIF.
    All records with no TELF1 will be displayed in White and have a
    Warning Icon
        IF tbl_kna1-telf1 IS INITIAL.
          tbl_kna1-color = 'C00'.  "White
          tbl_kna1-icon  = '@AH@'. "Warning Icon
          MODIFY tbl_kna1 TRANSPORTING icon color.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " do_fancy_stuff[/code]

  • Report with multiple dimensions in Row and Column with EvEXP

    Hi
    We are currently running BPC 7.0 SP3 and try to create the report(or schedule) with more 2 x 2 dimensions in the row and column.
    e.g.
    row dimension : Outer row is Entity, Inner row is Account
    column dimension : Outer column is Time, Inner row is Category
    We created the report with  2 x 2 dimensions like above e.g. with EvEXP and EvNXP, NOT EvDRE
    based on default dynamic template:Template13.xlt(Nested Row, 2 x 1 dimensions defined by EvEXP and EvNXP formula).
    However, when expanding the dimension with double click these dimensions or change CV of the report with  2 x 2 dimensions defined by EvEXP and EvNXP formula,
    error occurs on EvEXP and EvNXP formula and can't retrieve the result correctly.
    [Question]
    Can't we create the report with more 2 x 2 dimensions in the row and column using EvEXP and EvNXP function ?
    We understand that we can make the report with more 2 x 2 dimensions in the row and column if using EvDRE.
    Thank You in advance
    Kenya

    Thank you for your advice.
    I understand that we should use EvDRE when creating the report with multiple dimension in the row/column because EvEXP have some erros, poor performance, etc.
    Then, we have two questions.
    1)
    >plus they had some errors in the designs.
    what kind of errors they have as an example?
    2)
    >If you must build the EVEXP and EVNXP, I would suggest building the template from scratch
    We built the simple template with just 2 x 2 dimension from scratch.
    But this report doesn't work well when double-click the dimension or changing CV...
    Would you please check the following template?
    <https://sapmats-de.sap-ag.de/download/download.cgi?id=RCZE1ME4YSORY3DCDO4NNMANZLBL1L5ZBUOB2F71YVNVS8XDJW>
    It would be greatly appreciated if you could give me your advice for the template.
    Thank you again
    And my best regards,
    Kenya

  • Report with multiple tabs

    Hi,
    I have a report with multiple tabs in selection screen. Say material number is mandatory in the first tab. But we don't need material number in the second tab. But if I want to go to the 2nd tab, i get the error message 'Please enter the material number'. Can this be avoided?
    Thanks in advance.

    Hi Paromita,
    If I understand your problem correctly then, here is the summary of your problem -
    a) There are multiple tabs on selection screen. Out of which the first tab has a mandatory field i.e., Material Number. And then there are other tabs.
    b) So, unless and until you provide the value in first tab for the material number(which is a mandatory field), you cannot navigate to the second tab or any other tab for that matter.
    So, ideally the second and rest of other tabs are mutually dependent on the first tab's information as it has a mandatory field. Unless and until you make the first tab inactive it will not let you enter data in the second tab and so on.
    So, to ideally enable input in second tab, make the first tab inactive. Try this and let me know if it works.
    BR,
    Ravi

  • Publication for Deski report with multiple data providers

    Hi,
    Has anyone been able to get a publication working that uses a Deski report with multiple data providers as the source? I'm trying to get a publication working that uses dynamic recipients and personalization. When I try to schedule the publication, I get the error "Object not found". 
    Thanks,
    Debbie

    Debbie,
    That's standard.
    It's useful for emulating outer joins in reports.
    Say you've got a sales report where you want to display all 12 months of the year in a crosstab whatever month you run in.
    We're only in May at the moment though. With one data provider (SALES), you'll get a crosstab with just up to May for your months.
    If you create a separate data provider called MONTHS to return the months in the current year, you will then have a merged dimension of YearMonth in both.
    In your crosstab if you just use YearMonth you'll get just the five months. If you qualify it with its data provider name (in our case MONTHS), you'll see the full twelve months shown.
    I hope that clears it up for your.
    Regards,
    Mark

  • ALV Hierarchical With multiple boxes

    Hello.
    I have an alv hierarchical with multiple boxes.
    Can I  insert a buttom in Gui status of alv that allows me to  expand  all the boxes of  hierarchy?
    Regards
    Angela

    Hi Narendra,
    Try this program:
    TABLES : sflight.
    TYPE-POOLS: slis.
    DATA : w_repid LIKE sy-repid.
    w_repid = sy-repid.
    DATA: BEGIN OF it_sflight OCCURS 0,
    checkbox(1),
    carrid LIKE sflight-carrid,
    END OF it_sflight.
    *layout
    DATA: wa_layout TYPE slis_layout_alv.
    *field catalog
    DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
    wa_fieldcatalog TYPE slis_fieldcat_alv.
    START-OF-SELECTION.
    SELECT carrid FROM sflight
    INTO CORRESPONDING FIELDS OF TABLE it_sflight.
    END-OF-SELECTION.
    CLEAR it_fieldcatalog.
    REFRESH it_fieldcatalog.
    wa_fieldcatalog-fieldname = 'CHECKBOX'.
    wa_fieldcatalog-outputlen = '3'.
    wa_fieldcatalog-col_pos = '1'.
    wa_fieldcatalog-seltext_m = 'Chk'.
    wa_fieldcatalog-checkbox = 'X'.
    wa_fieldcatalog-edit = 'X'.
    APPEND wa_fieldcatalog TO it_fieldcatalog.
    CLEAR wa_fieldcatalog.
    wa_fieldcatalog-fieldname = 'CARRID'.
    wa_fieldcatalog-outputlen = '10'.
    wa_fieldcatalog-col_pos = '2'.
    wa_fieldcatalog-seltext_m = 'Carrid'.
    APPEND wa_fieldcatalog TO it_fieldcatalog.
    CLEAR wa_fieldcatalog.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = w_repid
    is_layout = wa_layout
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = it_fieldcatalog
    TABLES
    t_outtab = it_sflight
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    *& Form USER_COMMAND
    FORM user_command USING p_ucomm TYPE sy-ucomm
    p_selfld TYPE slis_selfield.
    CASE p_ucomm.
    WHEN '&DATA_SAVE'.
    DATA ref1 TYPE REF TO cl_gui_alv_grid.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = ref1.
    CALL METHOD ref1->check_changed_data.
    LOOP AT it_sflight WHERE checkbox = 'X'.
    DELETE it_sflight INDEX sy-tabix.
    ENDLOOP.
    p_selfld-refresh = 'X'.
    ENDCASE.
    ENDFORM. "user_command
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • BI+ Reporting With Multiple Data Sources

    Hi -
    We've been using BI+ Reports with multiple data sources on separate grids. We are wondering if there is a better way to ensure the user has their point of view bar in sync between the the data sources. In our case, both Data Sources are separate HFM applications with all the dimensions identical except the account which is defined on the report. We are not using Metadata Management.
    I'm aware of the "Merge Equivalent Prompts" in the Preferences > Financial Reporting window, but this does not always ensure the users have the same point of view.
    What practice are other companies using to make sure the user runs the reports accurately with both point of view bars pulling the same entity/year/period.
    Thanks in advance.

    Thanks for your answer, however my question - I know it looks quite messy - is not directly related to data templates, my problem is that at the moment I am using a stored procedure following - almost exactly - what another procedure does in oracle EBS to call a BI publisher report.
    1. This procedure populates some temporary table with the xml data where the concurrent request picks it up and uses it to populate the BI publisher template.
    2. However I can't go and specify the XML location in my data template as this is not an option for us (i.e. reading the xml from the temporary table), so I am looking for another way to populate the BI publisher template (Note: I can't as well include the SQL queries in my Data template).
    Thanks ;)

  • ALV report with dynamic columns, and repeated structure rows

    Hey Guys,
    I've done some ALV programming, but most of the reports were straight forward. This one is a little interesting. So here go the questions...
    Q1: Regarding Columns:
    What is the best way to code a report with columns being dynamic. This is one of the parameters the user is going to enter in his input.
    Q2: Regarding Rows:
    I want to repeat a structure(say it contains f1, f2, f3) multiple time in rows. What is the best way to do it? The labels for these fields have to appear in the first column.
    Below is the visual representation of the questions.
    Jan 06  , Feb 06, Mar 06....(dynamic)
       material 1
    Current Stock
    current required
    $Value of stock
       material 2
    Current Stock
    current required
    $Value of stock
       material 3
    Current Stock
    current required
    $Value of stock
    Thanks for your help.
    Sumit.

    Hi Sumit,
    Just check this sample from one of the SAP site
    ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
    Applies To:
    ABAP / ALV Grid
    Article Summary
    ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
    Code Sample
    REPORT zcdf_dynamic_table.
    * Dynamic ALV Grid with Cell Coloring.
    * Build a field catalog dynamically and provide the ability to color
    * the cells.
    * To test, copy this code to any program name and create screen 100
    * as described in the comments. After the screen is displayed, hit
    * enter to exit the screen.
    * Tested in 4.6C and 6.20
    * Charles Folwell - [email protected] - Feb 2, 2005
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    START-OF-SELECTION.
    * Build field catalog based on your criteria.
    wa_fieldcat-fieldname = 'FIELD1'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 1'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    wa_fieldcat-fieldname = 'FIELD2'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 2'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Before adding cell color table, save fieldcatalog to pass
    * to ALV call. The ALV call needs a fieldcatalog without
    * the internal table for cell coloring.
    t_fieldcat2[] = t_fieldcat1[].
    * Add cell color table.
    * CALENDAR_TYPE is a structure in the dictionary with a
    * field called COLTAB of type LVC_T_SCOL. You can use
    * any structure and field that has the type LVC_T_SCOL.
    wa_fieldcat-fieldname = 'T_CELLCOLORS'.
    wa_fieldcat-ref_field = 'COLTAB'.
    wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Create dynamic table including the internal table
    * for cell coloring.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fieldcat1
    IMPORTING
    ep_table = r_dyn_table
    EXCEPTIONS
    generate_subpool_dir_full = 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.
    * Get access to new table using field symbol.
    ASSIGN r_dyn_table->* TO <t_dyn_table>.
    * Create work area for new table.
    CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
    * Get access to new work area using field symbol.
    ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    * Get data into table from somewhere. Field names are
    * known at this point because field catalog is already
    * built. Read field names from the field catalog or use
    * COMPONENT <number> in a DO loop to access the fields. A
    * simpler hard coded approach is used here.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'ABC'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'XYZ'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'TUV'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'DEF'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    * Color cells based on your criteria. In this example, a test on
    * FIELD2 is used to decide on color.
    LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    * Get access to internal table used to color cells.
    ASSIGN COMPONENT 'T_CELLCOLORS'
    OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
    CLEAR wa_cellcolors.
    wa_cellcolors-fname = 'FIELD2'.
    IF <w_field> = 'DEF'.
    wa_cellcolors-color-col = '7'.
    ELSE.
    wa_cellcolors-color-col = '5'.
    ENDIF.
    APPEND wa_cellcolors TO <t_cellcolors>.
    MODIFY <t_dyn_table> FROM <wa_dyn_table>.
    ENDLOOP.
    * Display screen. Define screen 100 as empty, with next screen
    * set to 0 and flow logic of:
    * PROCESS BEFORE OUTPUT.
    * MODULE initialization.
    * PROCESS AFTER INPUT.
    CALL SCREEN 100.
    * MODULE initialization OUTPUT
    MODULE initialization OUTPUT.
    * Set up for ALV display.
    IF r_dock_ctnr IS INITIAL.
    CREATE OBJECT r_dock_ctnr
    EXPORTING
    side = cl_gui_docking_container=>dock_at_left
    ratio = '90'.
    CREATE OBJECT r_alv_grid
    EXPORTING i_parent = r_dock_ctnr.
    * Set ALV controls for cell coloring table.
    wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
    * Display.
    CALL METHOD r_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = wa_is_layout
    CHANGING
    it_outtab = <t_dyn_table>
    it_fieldcatalog = t_fieldcat2.
    ELSE. "grid already prepared
    * Refresh display.
    CALL METHOD r_alv_grid->refresh_table_display
    EXPORTING
    i_soft_refresh = ' '
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    ENDIF.
    ENDMODULE. " initialization OUTPUT
    Regards
    vijay

Maybe you are looking for

  • 2013 Mac Pro external drive options...?

    So I have my new Mac Pro and it is pretty good....! I have a 500GB drive which is just so dam fast, but it is only 500GB.... and I'm coming from a 2010 Pro with 6TB of storage via a Drobo FireWire 800 RAID (still bummed that a pro machine shipped in

  • Can I access Webi queries and Xcelsius dashboards from SAP portal?

    Hello, Can I access Webi queries and Xcelsius dashboards from SAP portal?  And how? Thanks

  • Deemed exports

    Hi Do we need to maintain excise bed condition types education cess cond type s& he edu cess type vat/cst in deemed exports pricing procedure regards how the steps will be will they be statistical bed etc regards

  • Oracle database application table connector no logs

    How do I enable the loggin level to DEBUG for Database Application table (9.0.4.1 with patch p7306669_90410_Generic ) I am using JBOSS403SP1 I have set this <category name="ADAPTER.DBADAPTERLOGGER"><priority value="DEBUG" /></category> int the log4j.

  • Block in Billing Plan

    Hi I need to generate an output type whenever a sales order is created or changed if there is a change in the billing block in the Billing plan for prepaid SO. Can anybody please let me know in which structure the value lies ? KOMPBV1-FAKSP is not ap