Skip to Content
Author's profile photo Former Member

Add a Selection Screen to a Table Maintenance Dialog

When end users will maintain a z-table with 100+ rows, it helps to be able to restrict the selection by any number of selection criteria.  This document attempts to define a “best practice” method for calling a table maintenance dialog from a selection screen.

Current Table Maintenance

The standard way to show a table maintenance dialog is via SM30, Call View Maintenance

/wp-content/uploads/2013/08/sm30_265731.png

or a custom parameter transaction that calls SM30 for a specific table, with parameters VIEWNAME and UPDATE = ‘X’.

Neither of these provide an initial selection screen.  Entries can be restricted by checking the “Enter conditions” radiobutton, but users are more familiar with selection screens than with the dialog box that pops up.  Therefore it is good UI to use a selection screen instead of the “Enter conditions” radiobutton.

Example Selection Screen Definition

In this example, an executable report has been created with selection screen.

REPORT  z_maintain_mytable.

DATA mytable    TYPE z_mytable.

DATA selections TYPE TABLE OF vimsellist.

DATA selection  TYPE vimsellist.

SELECT-OPTIONS: so_selop1 FOR mytablemyfield1,

                 so_selop2 FOR mytablemyfield2.

PARAMETERS: p_param1 TYPE z_mytablemyfield3,

             p_param2 TYPE z_mytablemyfield4.

sel_screen.PNG

Calling Function Modules

When the user clicks execute, the program needs to read their selections and call the table maintenance dialog.  The following code shows how this is easily done by using function modules ‘VIEW_RANGETAB_TO_SELLIST’ and ‘VIEW_MAINTENANCE_CALL’.

START-OF-SELECTION.

  DEFINE addsel.

    CALL FUNCTION ‘VIEW_RANGETAB_TO_SELLIST’

      EXPORTING

        fieldname          = &1

        append_conjunction = ‘AND’

      TABLES

        sellist            = selections

        rangetab           = &2[].

  END-OF-DEFINITION.

  DEFINE addparam.

    IF &2 IS NOT INITIAL.

      CLEAR selection.

      selectionviewfield = &1.

      selectionvalue = &2.

      selectionand_or = ‘AND’.

      selectionoperator = ‘EQ’.

      APPEND selection TO selections.

    ENDIF.

  END-OF-DEFINITION.

  add_sel ‘MYFIELD1’ so_selop1.

  add_sel ‘MYFIELD2’ so_selop2.

  add_par MYFIELD3′ p_param1.

  add_par MYFIELD4′ p_param2.

  CALL FUNCTION ‘VIEW_MAINTENANCE_CALL’

    EXPORTING

      action                = ‘U’ “for Update

      view_name             = ‘Z_MYTABLE’

      complex_selconds_used = ‘X’

    TABLES

      dba_sellist           = selections

    EXCEPTIONS

      OTHERS                = 1.

  IF sysubrc = 1.

    MESSAGE ID symsgid TYPE symsgty NUMBER symsgno

               WITH symsgv1 symsgv2 symsgv3 symsgv4.

  ENDIF.

Horray!  That is all. In only 46 lines (plus two for every select-option or parameter), this will bring the user to from the selection-screen to the table maintenance screen.

tab_maint.PNG

This is a collaborative document.  If there are better ways of achieving this functionality don’t hesitate to chime in and contribute!

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Varun Kumar Sahu
      Varun Kumar Sahu

      Nice one. A very good way to add selection screen.

      Regards,

      Varun Kumar Sahu

      Author's profile photo Shakeeluddin Khaja
      Shakeeluddin Khaja

      Thanks for sharing . useful Information.

      Regards.

      Author's profile photo Former Member
      Former Member

      Excellent article, thank you!

      Regards,

      Martin

      Author's profile photo Praveen Nenawa
      Praveen Nenawa

      Hi ,

      Just a Function module to do the job ....
      Nice one to know .

      😳

      Author's profile photo Michael Fallenbüchel
      Michael Fallenbüchel

      Great work! But not perfect.

      Let's say you have a table with a field type QUAN 13,3.

      Now you do your selection in the dynamic selection screen for this field from 1 to 5.

      ABAP will dump, saying "ASSIGN_OFFSET_NOTALLOWED".

      "Part of the source field "<VALUE>" was assigned to a field symbol,

      but this is not allowed for fields of type "P"."

      Any one has a solution for this?

      Author's profile photo Former Member
      Former Member

      Hi Michael,

      I'm dealing with the same problem. For me it seems to be a bug in form TRANSLATE_SELLIST_TO_WHERETAB of program SAPLSVIX.

      I tried many things but have no solution yet how to fill DBA_SELLIST.

      I'm still working...

      Author's profile photo Michael Fallenbüchel
      Michael Fallenbüchel

      Correct, the mistake is in TRANSLATE_SELLIST_TO_WHERETAB.

      I already made a call at SAP, first they told me VIEW_MAINTENANCE_CALL is not released, I told them it is (see help "The function moduel has been released"), nothing more since last contact yesterday.

      If there are any updates I will let you know...

      Author's profile photo Former Member
      Former Member
      Author's profile photo Former Member
      Former Member

      Dear Michael,

      i am also getting same error.Please tell me how you solve this.Please do needful.

      Thanks & Regards,

      Avinash

      Author's profile photo Michael Fallenbüchel
      Michael Fallenbüchel

      Hi Ramu,

      you need to implement note 2007905

      Then I have added some coding (function  RS_DS_CONV_IN_2_EX) "in between" to convert my selection values to internal format (decimal point, ...)

      Hope this helps

      Michael

      Author's profile photo Former Member
      Former Member

      HI michael

      Thank You for reply.and how to edit the values of selection screen like key fields.for example i enter the value in selection screen in output if i am trying to edit the values getting following error.

             Specify the key within the work area

      Regards,

      Ramu

      Author's profile photo Former Member
      Former Member

      Hello Eric,

      Sorry for seeing this too late 🙁

      I had a different take on this problem & had documented it as a WiKi - Using selection-screen in Table Maintenance Generator - ABAP Development - SCN Wiki.

      BR,

      Suhas

      Author's profile photo Former Member
      Former Member

      Hello Suhas,

      I use function FREE_SELECTIONS_DIALOG to create dynamic selections for a pool of different tables of our application.

      Then I convert export parameter EX_FIELD_RANGES to DBA_SELLIST to call VIEW_MAINTENACE_CALL.

      For the conversion I use VIEW_RANGETAB_TO_SELLIST and some code of my own, depending on field type.

      But that doesn't work for fields of type P.

      BR

      Frank

      Author's profile photo Michael Fallenbüchel
      Michael Fallenbüchel

      Same here:

      1. FREE_SELECTIONS_INIT

      2. FREE_SELECTIONS_DIALOG

      3. VIEW_RANGETAB_SO_SELLIST

      4. VIEW_MAINTENANCE_CALL

      Author's profile photo Former Member
      Former Member

      Hello Gentlemen,

      I don't use the VIEW_MAINTENANCE_CALL function. I use the TMG event AA and call the selection-screen in there.

      I already made a call at SAP, first they told me VIEW_MAINTENANCE_CALL is not released

      Interesting, i thought that the FM is "released". But if you see the date it is blank 😯

      /wp-content/uploads/2014/02/2014_02_18_151605_390788.jpg

      Something fishy is going on there 😛

      BR,

      Suhas

      Author's profile photo Raymond Giuseppi
      Raymond Giuseppi

      For it means "has always been released" or "released in time so old that no one in Walldorf remembers" .

      You can also check in documentation at help.sap.com that SAP suggest their usage (From Middle level entry - BC Extended Applications Function Library - SAP Library for ERP 6.0 to Middle level entry for good old 4.0)

      Regards,

      Raymond

      Author's profile photo Former Member
      Former Member

      Hello All,

      Just to clarify, when i said -

      I don't use the VIEW_MAINTENANCE_CALL function

      i meant for this scenario. I have used this FM many times & it has always worked like a charm 🙂

      BR,

      Suhas

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for the feedback everyone!  I'm learning a ton.

      I like how Suhas' method uses the standard events instead of slapping an executable report on the front end.  Perhaps we can combine our document and wiki and determine a best practice.

      My only concern with his method is the filtering on the application server and not the database - is that the right choice in this scenario?  And does VIEW_MAINTENANCE_CALL do the same thing?

      Author's profile photo Y.C. Cheng
      Y.C. Cheng

      Thank you very much!

      Regards,