Application Development 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: 

A report need in Grid display

Former Member
0 Kudos

  Hi Expert,

                     Need to create a report in grid display for the following method. In case of situation, we can maintain header data in single line doesn't matter but Pl don't require this method (REUSE_ALV_HIERSEQ_LIST_DISPLAY.)

My Idea:  is that possible to both header & Item data into final internal table using control break statment AT FIRST ENDAT? Pl give such idea it would be better to avoid HIERSEQ method.  Give best idea to creat grid display.

                   Header Data

                   Vednor name:                        Vendor no:           

              

                   SO No:                                    SO QTY :                                                  Part No:    

  

                Iteam Data

Item1item2item3item4item5item6
         

                  

Thanks

Savita

3 REPLIES 3

Abhijit74
Active Contributor
0 Kudos

Hello,

You can do it in following way. Lets assume that you have populated i_head and i_item. And display the output like below. Just go through the logic. Hope this will help you.

Header 1Header 2Header 3Header 4Header 5
Vednor nameVendor noSO NoSO QTYPart No

Item 1Item 2Item 3Item 4Item 5Item 6


















1) Take to field catalog one for header and one for item. In the event table take add two events Top_of_List and End_of_list.

DATA:

      i_item           TYPE STANDARD TABLE OF t_item,

      i_head          TYPE STANDARD TABLE OF t_head.

      i_item_sum   TYPE STANDARD TABLE OF t_item,

      i_head_sum  TYPE STANDARD TABLE OF t_head.

READ TABLE i_head ASSIGNING <lfs_head> INDEX 1.

  IF sy-subrc = 0 .

     w_head = <lfs_head>.

     REFRESH i_head_sum[].

     APPEND w_head TO i_head_sum.

    READ TABLE i_item ASSIGNING <lfs_item> WITH KEY vendor eq <lfs_head>-vendor.

    IF sy-subrc = 0.

      w_item =  <lfs_item>.

      APPEND w_item TO i_item_sum.

      CLEAR  w_item.

    ENDIF.

* Add events name into events internal table.

   CLEAR events.

   events-name = 'TOP_OF_LIST'.

   events-form = 'TOP_OF_LIST1'.

   APPEND events.

    events-name = 'END_OF_LIST'.

    events-form = 'HANDLE_EVENT_END_OF_LIST'.

    APPEND events.

*  Call  ALV_LIST_DISPLAY

* First  displaying the value of the item data based on the first header row but it's not possible to display header and item data in a single flow.So, We will display the data of first header row later. So, we are displaying like below.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

      EXPORTING

        i_callback_program      = sy-repid

        i_callback_user_command = 'USER_COMMAND1'

        is_layout               = w_layout

        it_fieldcat             = i_fcat_item[]

        it_sort                 = i_sort[]

        it_events               = events[]

        is_print                = ls_prnt

      TABLES

        t_outtab                = i_item[]

      EXCEPTIONS

        program_error           = 1

        OTHERS                  = 2.

* Other thing i assume that you will be capable of doing.

Now when we will call the end_of_list form there we will generate the remaining output.

FORM handle_event_end_of_list.

 

  DATA:

   lv_index TYPE sytabix.

 

  FIELD-SYMBOLS: <lfs_head> TYPE t_head,

                             <lfs_item> TYPE t_item.

   lv_index = 1.

  REFRESH i_item_sum[].

 

  LOOP AT i_head ASSIGNING <lfs_head> .

    IF lv_index = 1.

      lv_index = lv_index + 1.

      CONTINUE.

    ENDIF.

    w_head = <lfs_head>.

    REFRESH i_head_sum[].

    APPEND w_head TO i_head_sum.

    CLEAR w_head.

   LOOP AT i_item ASSIGNING <lfs_item> WHERE vendor = <lfs_head>-vendor.

       w_item =  <lfs_item>.

      APPEND w_item TO i_item_detail.

      CLEAR  w_item.

      ENDLOOP.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

        EXPORTING

*         i_interface_check  = g_flag_i_check

*         i_callback_pf_status_set = 'F_STATUS'

*         i_callback_user_command = 'USER_COMMAND1'

          i_callback_program = v_repid

          is_layout          = w_layout1

          it_fieldcat        = i_fcat_head[]

          is_print           = ls_prnt

        TABLES

          t_outtab           = i_head_sum[]

        EXCEPTIONS

          program_error      = 1

          OTHERS             = 2.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

     EXPORTING

       i_callback_program      = v_repid

*       i_callback_pf_status_set = 'F_STATUS'

*       i_callback_user_command = 'USER_COMMAND1'

       is_layout               = w_layout

       it_fieldcat             = i_fcat_item[]

       it_sort                 = i_sort[]

       is_print                = ls_prnt

     TABLES

       t_outtab                = i_item_sum[]

     EXCEPTIONS

       program_error           = 1

       OTHERS                  = 2.

    REFRESH i_item_sum.

  ENDLOOP.

ENDFORM.                    "HANDLE_EVENT_END_OF_LIST

* Displaying the first header row data in the TOP_OF_PAGE similar to header.

FORM top_of_list1.

FORMAT COLOR COL_HEADING.

  WRITE: / sy-uline(154).

  WRITE: / sy-vline,

  (14) text-001 ,

  sy-vline,

  (16) text-002 ,

  sy-vline,

  (29) text-010 ,

  sy-vline,

  (17) text-049 ,

  sy-vline,

  (18) text-012 ,

  sy-vline.

  FORMAT COLOR OFF.

  WRITE: / sy-uline(154).

  WRITE: / sy-vline ,

  (14) w_head-Header1 INTENSIFIED OFF ,

  sy-vline ,

  (16) w_head-Header2 INTENSIFIED OFF,

  sy-vline ,

  (29) w_head-Header3 INTENSIFIED OFF,

  sy-vline,

  (17) w_head-Header4 INTENSIFIED OFF,

  sy-vline ,

  (18) w_head-Header5INTENSIFIED OFF,

  sy-vline .

  WRITE: / sy-uline(154).

  SKIP 1.

  FORMAT COLOR OFF.

ENDFORM.

Thanks,

Abhijit

Former Member
0 Kudos

Hi,

Your question was although not too clear for me. If you want to combine both the header and the item data then you can use 'REUSE_ALV_GRID_DISPLAY' fm. In this you can pass the final internal table which has both the header and the item data.

I do not know your requirement. Why do you want to avoid hierarchical alv?  If you need help in that i can send you the sample code.

Regards

Purnand

0 Kudos

This message was moderated.