Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

In most of developments of module pool,we come across such functionality.

In one of my development i had a table control which has around 40 fields.My functional team wants functionality like we had it in se16.i.e when user selects certain row then he should be able to see complete row in detail form(vertical form).

Here you go,

I have created button on screen whose fct code is TC_9001_DTL.

Now go to PAI for table control TC_9001.

ie MODULE tc_9001_user_command.


*&SPWIZARD: INPUT MODULE FOR TC 'TC_9001'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE tc_9001_user_command INPUT.

   ok_code = sy-ucomm.

   PERFORM user_ok_tc USING    'TC_9001'

                               'GT_FINAL'

                               'ZMARK'

                      CHANGING ok_code.

   sy-ucomm = ok_code.

ENDMODULE.                    "TC_9001_USER_COMMAND INPUT

Now in subroutine user_ok_tc,

*&---------------------------------------------------------------------*

*&      Form  USER_OK_TC                                               *

*&---------------------------------------------------------------------*

FORM user_ok_tc USING    p_tc_name TYPE dynfnam

                          p_table_name

                          p_mark_name

                 CHANGING p_ok      LIKE sy-ucomm.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

   DATA: l_ok              TYPE sy-ucomm,

         l_offset          TYPE i.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

*&SPWIZARD: Table control specific operations                          *

*&SPWIZARD: evaluate TC name and operations                            *

   SEARCH p_ok FOR p_tc_name.

   IF sy-subrc <> 0.

     EXIT.

   ENDIF.

   l_offset = STRLEN( p_tc_name ) + 1.

   l_ok = p_ok+l_offset.

*&SPWIZARD: execute general and TC specific operations                 *

   CASE l_ok.

     WHEN 'INSR'.                      "insert row

       PERFORM fcode_insert_row USING    p_tc_name

                                         p_table_name.

       CLEAR p_ok.

     WHEN 'DELE'.                      "delete row

       PERFORM fcode_delete_row USING    p_tc_name

                                         p_table_name

                                         p_mark_name.

       CLEAR p_ok.

     WHEN 'P--' OR                    "top of list

          'P-'  OR                    "previous page

          'P+'  OR                    "next page

          'P++'.                      "bottom of list

       PERFORM compute_scrolling_in_tc USING p_tc_name

                                             l_ok.

       CLEAR p_ok.

*     WHEN 'L--'.                       "total left

*       PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

*

*     WHEN 'L-'.                        "column left

*       PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

*

*     WHEN 'R+'.                        "column right

*       PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

*

*     WHEN 'R++'.                       "total right

*       PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

*

     WHEN 'MARK'.                      "mark all filled lines

       PERFORM fcode_tc_mark_lines USING p_tc_name

                                         p_table_name

                                         p_mark_name   .

       CLEAR p_ok.

     WHEN 'DMRK'.                      "demark all filled lines

       PERFORM fcode_tc_demark_lines USING p_tc_name

                                           p_table_name

                                           p_mark_name .

       CLEAR p_ok.

       "Processing for displaying table row data

     WHEN 'DTL'.

       PERFORM view_dtl_screen.

ENDFORM.                              " USER_OK_TC


Now i have written code in view_dtl_screen as follows:-

*&---------------------------------------------------------------------*

*&      Form  VIEW_DTL_SCREEN

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

FORM view_dtl_screen .

"Type Declaration for Displaying Row Details of Table Control

TYPES : BEGIN OF gty_rowdtl,

           fld_name(100)      TYPE  c,

           fld_val(220)        TYPE  c,

         END OF gty_rowdtl.

*here gt_final and gs_final are the internal table and work area for table control.

*gt_rowdtl and gs_rowdtl are of type gty_rowdtl.

LOOP AT gt_final INTO gs_final WHERE zmark IS NOT INITIAL.

CLEAR : gs_rowdtl.

     gs_rowdtl-fld_name   =    lc_row1.

     gs_rowdtl-fld_val    =    gs_final-zcapexp."acc treatment

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtl-fld_name   =    lc_row2.

     gs_rowdtl-fld_val    =    gs_final-zgrpind."grp indicator

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtl-fld_name   =    lc_row3.

     gs_rowdtl-fld_val    =    gs_final-zpspid."project defn

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtl-fld_name   =    lc_row4.

     gs_rowdtl-fld_val    =    gs_final-zpost1."project description

     APPEND gs_rowdtl TO gt_rowdtl.

     CLEAR : gs_rowdtl.

     gs_rowdtl-fld_name   =    lc_row5.

     gs_rowdtl-fld_val    =    gs_final-zposid."wbs element

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtl-fld_name   =    lc_row6.

     gs_rowdtl-fld_val    =    gs_final-zzcapexp."wbs type.

Endloop.

TYPE-POOLS : slis.

   DATA lt_fieldcat         TYPE            slis_t_fieldcat_alv,

           ls_fieldcat            TYPE            slis_fieldcat_alv,

           lt_exclude            TYPE            slis_t_extab,

           ls_exclude           LIKE LINE OF    lt_exclude.

   CLEAR ls_fieldcat.

   ls_fieldcat-fieldname     =    'FLD_NAME'.

   ls_fieldcat-seltext_s     =    text-065.

   ls_fieldcat-outputlen     =    50.

   ls_fieldcat-key          =    gc_x.

   APPEND ls_fieldcat TO lt_fieldcat.

   CLEAR ls_fieldcat.

   ls_fieldcat-fieldname     =    'FLD_VAL'.

   ls_fieldcat-seltext_s     =    text-066.

   ls_fieldcat-outputlen     =    50.

   APPEND ls_fieldcat TO lt_fieldcat.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&ETA'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&SC'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&SC+'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&OUP'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&ODN'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&ILT'.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_exclude-fcode      =    '&OL0'.

   APPEND ls_exclude TO lt_exclude.

   CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

     EXPORTING

       i_title              = text-067

       i_selection          = gc_blank

       i_allow_no_selection = gc_x

       i_zebra              = gc_x

       i_tabname            = 'GT_ROWDTL'

       it_fieldcat          = lt_fieldcat

       it_excluding         = lt_exclude

     TABLES

       t_outtab             = gt_rowdtl.

ENDFORM.                    " VIEW_DTL_SCREEN


In this way we will get all fields of a row in detail format.

I have attached screen shots

In image 1.bmp there is button at bottom.If we click on it we will get screen as untitled.bmp

Thanks and Regards,

Abdul

1 Comment