Skip to Content

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 = syucomm.

   PERFORM user_ok_tc USING    ‘TC_9001’

                               ‘GT_FINAL’

                               ‘ZMARK’

                      CHANGING ok_code.

   syucomm = 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 syucomm.

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

   DATA: l_ok              TYPE syucomm,

         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 sysubrc <> 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_rowdtlfld_name   =    lc_row1.

     gs_rowdtlfld_val    =    gs_finalzcapexp.“acc treatment

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtlfld_name   =    lc_row2.

     gs_rowdtlfld_val    =    gs_finalzgrpind.“grp indicator

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtlfld_name   =    lc_row3.

     gs_rowdtlfld_val    =    gs_finalzpspid.“project defn

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtlfld_name   =    lc_row4.

     gs_rowdtlfld_val    =    gs_finalzpost1.“project description

     APPEND gs_rowdtl TO gt_rowdtl.

     CLEAR : gs_rowdtl.

     gs_rowdtlfld_name   =    lc_row5.

     gs_rowdtlfld_val    =    gs_finalzposid.“wbs element

     APPEND gs_rowdtl TO gt_rowdtl.

     gs_rowdtlfld_name   =    lc_row6.

     gs_rowdtlfld_val    =    gs_finalzzcapexp.“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_fieldcatfieldname     =    ‘FLD_NAME’.

   ls_fieldcatseltext_s     =    text065.

   ls_fieldcatoutputlen     =    50.

   ls_fieldcatkey          =    gc_x.

   APPEND ls_fieldcat TO lt_fieldcat.

   CLEAR ls_fieldcat.

   ls_fieldcatfieldname     =    ‘FLD_VAL’.

   ls_fieldcatseltext_s     =    text066.

   ls_fieldcatoutputlen     =    50.

   APPEND ls_fieldcat TO lt_fieldcat.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&ETA’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&SC’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&SC+’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&OUP’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&ODN’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&ILT’.

   APPEND ls_exclude TO lt_exclude.

   CLEAR : ls_exclude.

   ls_excludefcode      =    ‘&OL0’.

   APPEND ls_exclude TO lt_exclude.

   CALL FUNCTION ‘REUSE_ALV_POPUP_TO_SELECT’

     EXPORTING

       i_title              = text067

       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

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply