Sunteți pe pagina 1din 5

CALL VIEW MAINTANENCE – Function Module

My latest project is a program that should verify whether there are any sales orders
that are due for delivery but do not meet certain minimum criteria. Naturally, the
minimum requirements have to be stored in some Z table, so that we don’t have to
change the program should the requirements change. A functional consultant wrote
the specification for me, which included development of a custom transaction to
maintain that Z table. Even though it seemed quite complicated at first, after talking
to the sales folks I figured that they basically wanted to maintain either a minimum
amount (in the US dollars) or a minimum quantity (in the sales units) by material
group (VBAP-MATKL). They did not need any fancy screens, so a generated
maintenance screen would do. The only challenge was to ensure that the users
have access only to the minimum requirements for their sales organization.

After some unsuccessful online search, I resorted to debugging the SM30


transaction. This led me to the function module VIEW_MAINTENANCE_CALL. (You
might be laughing already, but only now I’ve noticed that SM30 is actually called
“Call View Maintenance”. Oh well...) so I checked out that function module and saw
the table dba_sellist in the parameter list – jackpot! Just fill in VIEWFIELD,
OPERATOR and VALUE and it will bring up the maintenance screen with only the
selected values.

The very cool thing is that it also restricts the maintenance to those values. E.g. if
the user has selected sales org Z1 but then tries to add a record with Z2, it will not
allow it (although the error message is kind of generic). Hence all that left for me to
do was to write a very short report with just a selection screen and the FM call.

My Z table has the following key fields:

MANDT

VKORG

MATKL

ZUNIT

ZUNIT is a CHAR field with the domain that limits the values to USD and our sales
units. USD can be used to enter the minimum dollar amount and sales units can be
used to enter the minimum quantity. One unfortunate thing that I found out about
such domains is that SAP is adding a blank value to the list of the allowed values.
This seems to be the standard functionality; I found no way to get rid of it in the
Dictionary except for replacing single values with another table with a foreign key,
which is a hassle (check out this thread in the SDN forum). It’s not a big issue in this
case, because I can just disallow blank units through my ABAP code, but it would be
a major annoyance should anyone decide to use just SM30. Long story short, here is
my report:
REPORT zsd_r_min_order_maintain.

DATA: action.

DATA: BEGIN OF i_sellist OCCURS 0.

INCLUDE STRUCTURE vimsellist.

DATA: END OF i_sellist.

TABLES sscrfields.

PARAMETERS: p_vkorg TYPE tvko-vkorg OBLIGATORY,

p_usd RADIOBUTTON GROUP lim, " Limit by USD

p_qty RADIOBUTTON GROUP lim. " Limit by Quantity

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN PUSHBUTTON /1(15) disp USER-COMMAND disp.

SELECTION-SCREEN PUSHBUTTON 20(15) maint USER-COMMAND maint.

INITIALIZATION.

MOVE 'Display' TO disp.

MOVE 'Maintain' TO maint.

AT SELECTION-SCREEN.

* Authority check here

IF sscrfields-ucomm = 'MAINT'.

action = 'U'.

ELSE.

action = 'S'.
ENDIF.

* Selection list

CLEAR: i_sellist.

REFRESH: i_sellist.

i_sellist-viewfield = 'VKORG'.

i_sellist-operator = 'EQ'.

i_sellist-value = p_vkorg.

i_sellist-and_or = 'AND'.

APPEND i_sellist.

IF p_usd = space.

i_sellist-operator = 'NE'.

ENDIF.

i_sellist-viewfield = 'ZUNIT'.

i_sellist-value = 'USD'.

APPEND i_sellist.

* Disallow blank unit

i_sellist-viewfield = 'ZUNIT'.

i_sellist-operator = 'NE'.

i_sellist-value = space.

APPEND i_sellist.

CALL FUNCTION 'VIEW_MAINTENANCE_CALL'

EXPORTING

action = action

view_name = 'ZSD_MIN_ORDER'
TABLES

dba_sellist = i_sellist.

In a nutshell, this program provides a simple selection screen with VKORG,


radiobutton for either dollar amount or quantity, and two pushbuttons: Display and
Maintain. Then the program fills in the action field and the selection table (i_sellilst)
according to the user’s selections. When the button is pushed, the screen goes to
the same screen as SM30 (sans the first selection screen, of course) and brings up
the values that fit the criteria. When the user clicks “back” (green arrow), he/she
gets back to my selection screen and can make different selection.

Like I said, we did not need anything fancy but, as a matter of fact, you can add
more screens and built a very nice program that would look quite sophisticated by
just correctly using this function module.

Just one last thing. At first, I forgot to fill in the field I_SELLIST-AND_OR, which
resulted in a short dump ‘The WHERE condition has an unexpected format’ (runtime
error SAPSQL_WHERE_PARENTHESES, exception CX_SY_DYNAMIC_OSQL_SYNTAX).
This exception should have been caught in the function module but I guess they’ve
missed it, so keep this in mind.

Pattern for FM VIEW_MAINTENANCE_CALL - VIEW


MAINTENANCE CALL Associated Function Group: SVIM
Released Date: Not Released CALL FUNCTION 'VIEW_MAINTENANCE_CALL' "Call Extended Table
Maintenance (View Maint) Highest Level

EXPORTING

action = "

action = " Action (Display/Maintain/Transport)

* corr_number = ' ' " e070-trkorr Correction Number for Changes Made

* generate_maint_tool_if_missing = ' ' " Flag: Create Maint. Mods. if They do Not Exist

* show_selection_popup = ' ' " Flag: Display Selection Conditions Dialog Box

view_name = " dd02v-tabname Name of the View/Table to be Edited

* no_warning_for_clientindep = ' ' " Flag: No Warning for Cross-Client Objects

* rfc_destination_for_upgrade = ' ' " rfcdes-rfcdest RFC Dest. of System for Comparison/Adjustment

* client_for_upgrade = ' ' " sy-mandt Client for Comparison/Adjustment

* variant_for_selection = ' ' " tvimv-variant Selection Conditions Variant

* complex_selconds_used = ' ' " tvdir-flag Flag: DBA_SELLIST Contains Complex Selection
Conditions
* check_ddic_mainflag = ' ' " Flag: Check Whether Maintenance is Allowed

* suppress_wa_popup = SPACE " xfeld Flag: Suppress "Specify Work Area" Dialog Box

* TABLES

* dba_sellist = " vimsellist Database Access Selection Conditions

* excl_cua_funct = " vimexclfun GUI Functions to be Deactivated Dynamically

EXCEPTIONS

CLIENT_REFERENCE = 1 " View is Chained to Another Client

FOREIGN_LOCK = 2 " View/Table is Locked by Another User

INVALID_ACTION = 3 " ACTION Contains Invalid Values

NO_CLIENTINDEPENDENT_AUTH = 4 " No Authorization for Maintaining Cross-Client


Tables/Views

NO_DATABASE_FUNCTION = 5 " No Data Capture/Disposal Function Module

NO_EDITOR_FUNCTION = 6 " Editor Function Module Missing

NO_SHOW_AUTH = 7 " No Display Authorization

NO_TVDIR_ENTRY = 8 " View/Table is Not in TVDIR

NO_UPD_AUTH = 9 " No Maintenance or Display Authorization

ONLY_SHOW_ALLOWED = 10 " Display but Not Maintenance Authorization

SYSTEM_FAILURE = 11 " System Lock Error

UNKNOWN_FIELD_IN_DBA_SELLIST = 12 " Selection Table Contains Unknown Fields

VIEW_NOT_FOUND = 13 " View/Table Not Found in DDIC

MAINTENANCE_PROHIBITED = 14 " View/Table Cannot be Maintained acc. to DDIC

. " VIEW_MAINTENANCE_CALL

S-ar putea să vă placă și