Sunteți pe pagina 1din 2

Creating and using Variant in Select Options with Web Dynpro for ABAP -1

Sharad Agrawal Business Card


Co pany! Valero "nergy Corporation Posted on Aug# $1% $&&' 1$!$( A) in ABAP% Web Dynpro

!ubscrib e Print Permalin k

As part of my work, I created a Webdynpro for ABAP application having the selection screen for accepting the user input. My user demanded to get the basic variant functionality in W A application same as available in ABAP reports. I searched ! " for the available solution and found the solution suggested by Mr. Anantha Athuru #https$%%wiki.sdn.sap.com%wiki%&%bo'(A)*. But this solution involves creating a dummy ABAP report having the same selection screen as W A application and store variants over there. I thought there should be some better way. !o here I am. +his e&ample application contains customer number and plant two select options on Main ,iew. +he main view also has two buttons. +he first button navigates to -!ave ,ariant view. and other button navigates to -/et ,ariants. view. +he solution can be described in following steps. 0. 1reate your application with select options. 2our component will have to have the component WD*+S","C-+OP-.O/S as 3used component3 in order to get select option functionality. 2ou may create attributes for the instance of 3select option handler class3 #.0+WD+S","C-+OP-.O/S* and range tables of customer and data selection data #type ref to data* in all views so they can be passed back and forth easily. 4. After entering the data in the selection screen, the user presses the 3!ave ,ariant3 button. +he action associated with button reads the select options to get the range tables first and fill the corresponding view attributes with them. +hen it navigates to 3!ave ,ariant3 view #passes the attribute with 5ire plug event handler method*. +he view let the user enter the input for variant name, description and /lobal indicator. 6. +he program prepares and stores the variant data in system table I" 7 #e1port to ###database*. 8sing table I" 7 places a restriction that the W A component name can.t be more than 49 characters to get the correct results, though you are free to create a new clustered table with same table fields as I" 7 # with more wide !:+5 field* or ,A:I to store variants. +he variants are stored as following in this e&ample.

Area 2./D3-*",.D* is populated with -2W.# +he first 49 characters of user defined key #./D3-S*-0D* contains the W component name. +he last 4 characters are used to store the uni;ue variant se;uence number. +he first 0< characters of I" 7=P/MI contains the variant name, the 0> th character contains -%. if variant

is global variant and rest 4> characters will contain the variant description. +he field 8!?:A contains the name of the user who created the variant. +he program checks if there is no already e&isting variant this the same name. +he range tables for customer and plant are referencing to data. +hey are made dereference and store the data in range internal tables #... type range of @8"":, type range of W?:@!A because referenced data can.t be e&ported to database*.

+he both tables are e&ported to database to I <. +he retrieval process takes the following steps. "avigate to 3/et ,ariant3 view

-2W. with key prepared in previous steps.

:ead all the records from table I" 7 for area -2W. and key having a pattern of 49 characters of W component name. Bnly retain the records only that are either created by user or global.

/et the variant name from first 0< characters of I" 7=P/MI and description from 0C=<9 characters of same field.

field, /lobal indicator from 0> th character

!how the results in a table and let user choose one variant. Bnce the variant is chosen, import from database the range tables using the I and area from I" 7 record. Populate the referenced range tables #type ref to data* from customer and plant range table. "avigate to Main ,iew and set the range tables for select option. In ne&t blog, I will provide the code and detail of the !aving ,ariant functionality.

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