1. 程式人生 > >WDA-Web Dynpro的POWL(個人物件工作清單)

WDA-Web Dynpro的POWL(個人物件工作清單)

POWL(Personal Object Worklist) for Web Dynpro

轉載地址:https://blogs.sap.com/2013/02/15/powlpersonal-object-worklist-for-web-dynpro/

 

FollowRSS feed

Summary

This document illustrates how to make personnel object work list, Feeder class and how to integrate POWL with WD ABAP. 

Author: Rohan Sanjay Uphade 

Company: NTT DATA India EAS Ltd. 

Created on: 12 December 2012 

Author Bio

Rohan is SAP certified Consultant and works in NTT DATA, He has work experience in SAP ABAP , Dynamic programming,

WebDynpro ABAP, POWL , Smart forms , Adobe forms and so on.

 

Main Steps Involve in creating POWL Feature.

  1. Create Feeder class
  2. Implement Feeder class method
  3. Define Application id, Type, Role and queries
  4. Integrate POWL with our WebDynpro application
  5. Test POWL

 

1. Create Feeder class.

  • For our example, we need to create tables for Data selection
  • Create a table name:  YEMPLOYEE, presented in Fig. 2.
  • Create Table entries for above table for references.
  • Create Table Type    : YTT_YEMPLOYEE ,presented in Fig.3

       

   Fig. 2 Database table used for our example

          

          Fig. 3 Table type for database table YEMPLOYEE.

 

  • Now go to T.Code: SE24 and create a class with following interface, presented in Fig.4
  • Class Name          : YPOWL_CLASS.
  • Interface Name     : IF_POWL_FEEDER.

          

          Fig. 4 YPOWL_CLASS   is made and is using the interface IF_POWL_FEEDER.

  • Now create attribute for same class, presented in Fig.5
  • Attribute Name:

   MT_RESULT                      Type      YTT_YEMPLOYEE.

   MT_FIELDCAT                   Type      POWL_FIELDCAT_TTY

   MT_SELCRITERIA              Type      POWL_SELCRIT_TTY

   MT_CRITERIA_DEFAULT   Type      RSPARAMS_TT

                                 

          Fig. 5 Attribute for YPOWL_CLASS   is made.

  •   Implemented Feeder class has various methods as shown in Fig 6.

          

   Fig.6 Interface Implemented methods.

   NOTE:  It is not necessary to use all methods provided by interface from the start.

   There are 2 mandatory methods and 6 optional ones.

   GET_OBJECTS and GET_OBJECT_DEFINITION are two mandatory methods, rest are optional.

 

  Method description: 

               1.GET_ACTIONS: In this method, we can define the buttons and their action which can be handle in                    

                    Method HANDLE_ACTION. Method GET_ACTION properties defined in structure POWL_ACTDESCR_STY like text, tooltip, index etc.

             

               2.GET_ACTION_CONF: In this method, one can fire a confirmation dialog window  on the click of button, it will ask user whether to delete

                    the entries or not or similar.

              

               3.GET_SEL_CRITERIA: In these method selection criteria is defined for this particular feeder.  I.E Fields which appear in POWL selection screen.

    • Structure use: POWL_SELCRIT_STY

              

               4.GET_FIELD_CATALOG: This method describes the field catalog to be used for query results table and the UI properties of the particular fields.

    • Various properties can be set here: Column position, column header, column visible, column color etc.
    • Structure use: POWL_FIELDCAT_STY.

              

               5.GET_OBJECT_DEFINITION: This method is used to define the container (e.g. specify field types) where the selected data gets stored.

              

               6.GET_OBJECTS: This method is used to retrieve data from the backend system. Data retrieval can be done via simple select query or by

                    using a function module. Selected data is passed to E_RESULTS which is exporting parameter of this method

              

               7.GET_DETAIL_COMP:Enable the detail component feature.

              

               8.HANDLE_ACTION: In this, all the actions for the buttons are defined and also we can control enable/disable property of buttons here.

                    Control can be  transferred from class to portal via firing a event using :

    • E_portal_actions-fire_wdevent = abap_true. 

 

2. Implement Feeder class method.

     NOTE: Please implement/Activate all method of feeder class, otherwise system will generate dump saying ‘Implementation is missing’.

  • Method GET_ACTIONS
METHOD IF_POWL_FEEDER~GET_ACTIONS.
DATA:WA_POWL_ACTIONS TYPE POWL_ACTDESCR_STY,
IT_POWL_ACTIONS TYPE TABLE OF POWL_ACTDESCR_STY.
WA_POWL_ACTIONS-ACTIONID = ‘POWL_LEAD_SEL’.
*WA_POWL_ACTIONS-CARDINALITY   = C_FEEDER_ACTION_SEL_REQ.
*WA_POWL_ACTIONS-PLACEMENT     = C_FEEDER_ACTION_TOOLBAR.
WA_POWL_ACTIONS-ENABLED       = ‘X’.
WA_POWL_ACTIONS-PLACEMENTINDX = 1.
*WA_POWL_ACTIONS-
WA_POWL_ACTIONS-TEXT = ‘TEST’.
APPEND WA_POWL_ACTIONS TO IT_POWL_ACTIONS.
E_ACTIONS_CHANGED =   ‘X’.
C_ACTION_DEFS = IT_POWL_ACTIONS.
ENDMETHOD.

 

  • Method GET_ ACTION_CONF
  • Method GET_SEL_CRITERIA

     

METHOD IF_POWL_FEEDER~GET_SEL_CRITERIA.

     DATA: LS_SELCRIT TYPE POWL_SELCRIT_STY,
      LS_CRITERIA_DEFAULT  TYPE RSPARAMS,
      LS_DEFAULT TYPE RSPARAMS.
      IF MT_SELCRITERIA IS INITIAL.
         LS_SELCRIT TO MT_SELCRITERIA.
         LS_SELCRIT-SELNAME = ‘SALARY’.
         LS_SELCRIT-KIND = ‘S’.
         LS_SELCRIT-PARAM_TYPE = ‘I’.
         LS_SELCRIT-SELOPT_TYPE = ‘A’.
         LS_SELCRIT-ALLOW_ADMIN_CHANGE = ‘X’.
         LS_SELCRIT-DATATYPE = ‘YEMPLOYEE-SALARY’.
         APPEND LS_SELCRIT TO MT_SELCRITERIA.
         CLEAR LS_SELCRIT.
                E_SELCRIT_DEFS_CHANGED = ‘X’.
         E_DEFAULT_VAL_CHANGED  = ‘X’.
         C_SELCRIT_DEFS         = MT_SELCRITERIA.
         C_DEFAULT_VALUES       = MT_CRITERIA_DEFAULT.
      ELSE.
         C_SELCRIT_DEFS = MT_SELCRITERIA.
         C_DEFAULT_VALUES = MT_CRITERIA_DEFAULT.
         E_SELCRIT_DEFS_CHANGED = ‘X’.
     ENDIF.
     CLEAR C_DEFAULT_VALUES.
     CLEAR C_DEFAULT_VALUES.

ENDMETHOD.
  • Method GET_FIELD_CATALOG
METHOD IF_POWL_FEEDER~GET_FIELD_CATALOG.
   DATA: LS_FIELDCAT       TYPE POWL_FIELDCAT_STY,
         LS_DFIES          TYPE DFIES,
         LS_FCAT           TYPE LVC_S_FCAT,
         L_SEQNR           TYPE INT4.

   DEFINE ADD_COLPOS.
   ADD 1 TO L_SEQNR.
   LS_FIELDCAT-COLPOS = L_SEQNR.
   ENDOFDEFINITION.

   IF MT_FIELDCAT IS INITIAL.
* 1. MANDT
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘MANDT’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-COL_VISIBLE = ‘ ‘.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 1.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘EMP_ID’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘EMP_ID’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘EMP_NAME’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘DESIGNATION’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘MANAGER’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
   CLEAR LS_FIELDCAT.
   LS_FIELDCAT-COLID = ‘SALARY’.
   ADD_COLPOS.
   LS_FIELDCAT-HEADER_BY_DDIC = ‘X’.
   LS_FIELDCAT-FIXED = ‘X’.
   LS_FIELDCAT-H_ALIGN = ‘L’.
   LS_FIELDCAT-ALLOW_SORT  = ‘X’.
   LS_FIELDCAT-COL_VISIBLE = ‘X’.
   LS_FIELDCAT-EDITABLE = ‘ ‘.
   LS_FIELDCAT-WIDTH = 4.
   INSERT LS_FIELDCAT INTO TABLE MT_FIELDCAT.
  ELSE.
   C_FIELDCAT = MT_FIELDCAT.
  ENDIF.
ENDMETHOD.

 

  • Method GET_ OBJECT_DEFINITION
 METHOD IF_POWL_FEEDER~GET_OBJECT_DEFINITION.
   E_OBJECT_DEF ?= CL_ABAP_TABLEDESCR=>DESCRIBE_BY_DATA( ME->MT_RESULT ).
 ENDMETHOD.

 

  • Method GET_OBJECTS
METHOD IF_POWL_FEEDER~GET_OBJECTS.
DATA: R_EMP_ID   TYPE RANGE OF YEMPLOYEE-EMP_ID,
R_EMP_NAME TYPE RANGE OF YEMPLOYEE-EMP_NAME,
R_SALARY   TYPE RANGE OF YEMPLOYEE-SALARY,
X_BOOK_ID  LIKE LINE OF  R_EMP_ID,
X_EMP_NAME   LIKE LINE OF  R_EMP_NAME,
X_SALARY    LIKE LINE OF  R_SALARY.
FIELD-SYMBOLS: <LFS_PARAMS> TYPE RSPARAMS,
<LF_RESULT> TYPE YEMPLOYEE.
“FILL THE RANGE TABLES
LOOP AT I_SELCRIT_VALUES ASSIGNING <LFS_PARAMS>.
CASE <LFS_PARAMS>-SELNAME.
WHEN ‘EMP_ID’.
MOVE-CORRESPONDING <LFS_PARAMS> TO X_BOOK_ID.
INSERT X_BOOK_ID INTO TABLE R_EMP_ID.
WHEN ‘EMP_NAME’.
MOVE-CORRESPONDING <LFS_PARAMS> TO X_EMP_NAME.
INSERT X_EMP_NAME INTO TABLE R_EMP_NAME.
WHEN ‘SALARY’.
MOVE-CORRESPONDING <LFS_PARAMS> TO X_SALARY.
INSERT X_SALARY INTO TABLE R_SALARY.
ENDCASE.
ENDLOOP.
REFRESH ME->MT_RESULT.
SELECT * FROM YEMPLOYEE  INTO TABLE ME->MT_RESULT
WHERE EMP_ID   IN R_EMP_ID
AND EMP_NAME IN R_EMP_NAME
AND SALARY   IN R_SALARY.

E_RESULTS = ME->MT_RESULT.
ENDMETHOD.

 

  • Method GET_OBJECTS
METHOD IF_POWL_FEEDER~GET_DETAIL_COMP.
E_DETAIL_COMP = ‘YEMPLOYEE_POWL_WD’.
ENDMETHOD.

 

  • Method GET_DETAIL_COMP
 METHOD IF_POWL_FEEDER~GET_DETAIL_COMP.
       E_DETAIL_COMP = ‘YEMPLOYEE_POWL_WD’.
 ENDMETHOD.

 

  • Method HANDLE_ACTION
METHOD IF_POWL_FEEDER~HANDLE_ACTION.
DATA: LS_PARAMETER TYPE POWL_NAMEVALUE_STY.
DATA : X_RESULT TYPE YEMPLOYEE ,
V_INDEX TYPE RSTABIX,
V_INDX(2) TYPE C.
CASE I_ACTIONID.
WHEN ‘POWL_LEAD_SEL’.
CLEAR:X_RESULT,V_INDX.
READ TABLE  C_SELECTED INTO V_INDEX INDEX 1.
IF SY-SUBRC = 0.
V_INDX = V_INDEX-TABIX.
READ TABLE C_RESULT_TAB INTO X_RESULT INDEX V_INDX.
IF SY-SUBRC = 0.
E_PORTAL_ACTIONS-FIRE_WDEVENT = ABAP_TRUE.
LS_PARAMETER-KEY = ‘EMP_ID’.
LS_PARAMETER-VALUE = X_RESULT-EMP_ID.
APPEND LS_PARAMETER TO E_PORTAL_ACTIONS-PARAMETERS.
LS_PARAMETER-KEY = ‘EMP_NAME’.
LS_PARAMETER-VALUE = X_RESULT-EMP_NAME.
APPEND LS_PARAMETER TO E_PORTAL_ACTIONS-PARAMETERS.
LS_PARAMETER-KEY = ‘SALARY’.
LS_PARAMETER-VALUE = X_RESULT-SALARY.
APPEND LS_PARAMETER TO E_PORTAL_ACTIONS-PARAMETERS.
ENDIF.
ENDIF.
ENDCASE.
ENDMETHOD.

 

3. Define Application id, Type ,Role and queries

  • After a feeder is developed, it needs to be made visible to the roles. Basically, this means we need to register the feeder under a specific APPLID, define a POWER List type and introduce it to the roles .

 

  Step 1.Create an Application ID

    • Transaction code: FPB_MAINTAIN_HIER
    • Click on Change->Display button and then on New Entries button
    • Give  application id name:YEMPLOYEE_APPLID
    • Presses SAVE , it will ask for transport request. Give/Create transport request and save it.
    • Now u can see your entry (YEMPLOYEE_APPLID) in the list as shown below figure.

               

          

      Step 2.Create a POWL TYPE

    • Transaction code: POWL_TYPE
    • Click on New Entries button.
    • Give Type name : YEMPLOYEE_TYPE
    • Enter description and feeder class name as shown in below figure.
    • Presses SAVE, it will ask for transport request, add it to same request created for APPLID.
    • Now u can see your entry (YEMPLOYEE_TYPE) in the list.

    

      Step 3.Role assignment for POWL TYPE

  Here we connect the APPLID with the POWL Type and make it visible to the role.

    • Transaction code: POWL_TYPER
    • Click on New Entries button and enter details as shown in figure.
    • NOTE:Role is Optional field and can be specified only if a role dependent mapping is required
    • Press SAVE, it will ask for transport request. Give/Create transport request and save it.

 

       Step 4.Query for POWL

  Here we define default queries for power list. A query id is made which is connected to POWL type.

  NOTE: you can define one or more queries. 

    • Transaction code :POWL_QUERY
    • Click on New Entries button and enter details as shown in figure.

    • Press SAVE, and give transport request.
    • After this, we can create/see the query parameters and the query settings with the help of the corresponding buttons:
    • On clicking Query Parameter, you could see following screen, with field declare in feeder class.
    • On clicking Query setting, one can enable different feature like quick search for fields.

 

  Step 5.Map APPLID & QUERYID for POWL

  Here if several queries are defined then sequence of tabs can be controlled via this transaction.

    • Transaction code :POWL_QUERYR
    • Click on New Entries button and enter details as shown in figure.
    • And tick the checkbox Activate.
    • Press SAVE, and give transport request

 

4. Integrate POWL with WD application

    • Transaction code :SE80
    • Create a Web Dynpro component YEMPLOYEE_POWL_WD and save it.
    • Define Component usage. POWL_UI_COMP,as shown in below figure.

 

    • Goto Views, Define POWL Component usage in properties tab of MAIN VIEW
    • Now, Define a view Container, Label and Text view inside the MAIN VIEW (POWL VIEW).
    • FOR CONTEXT NODE: Create node with single attribute EMP_NAME & bind it toTEXT_NAME
    • Now Go to Windows, in the properties tab of Windows, define the usage ofPOWL_UI_COMP component.

 

    • In WINDOWS, View container(VC_UI) embed the view Powl_Master of Powl_UI_Comp component as shown in fig.
    • Now click on Outbound Plug tab of window, give PLUG NAME & PARAMETER NAME.

    PARAMETER NAME                 TYPE

    APPLID                                    STRING

    FORALLQ                                 POWL_XFLAG_TY

    QNAME                                    POWL_QUERY_TY

    QSELPARA                              STRING

    REFRESHQ                              POWL_XFLAG_TY

    SRVGROUP                              POWL_XFLAG_TY

 

    • Click SAVE and go to WINDOW tab and create navigation link for OUT.

 

    • Define the mapping of Outbound plug of windows with Default plug of view Powl_Master as shown:

 

    • In the methods Tab of Windows , write the code in Handle Default Event handler to fire the outbound plug to Powl_Master View :
METHOD HANDLEDEFAULT .
DATA: LV_INBOX_QUERY TYPE STRING,
LT_QUERY_PARAMS TYPE RSPARAMS_TT,
LWA_PARAM TYPE RSPARAMS.
DATA LV_QNAME TYPE POWL_QUERY_TY.

LV_QNAME = ‘YEMPLOYEE_QUERY1’.
CALL FUNCTION ‘POWL_ENCODE_SELPARA’
EXPORTING
I_SELPARA = LT_QUERY_PARAMS
I_ESCAPE = ‘\IMPORTING
E_SELPARA_STRING = LV_INBOX_QUERY.

WD_THIS->FIRE_OUT_PLG(
APPLID =   ‘YEMPLOYEE_APPLID’ 
QNAME =   LV_QNAME                  
FORALLQ = ‘X’                         
QSELPARA = LV_INBOX_QUERY           
REFRESHQ = ‘X’                         
*     REFRESHA = ‘X’                       
SRVGROUP = ‘X’ ).
ENDMETHOD.

 

5. Test POWL.

     Now create WD application and activate the whole program and run the application.

  • Initial Screen

          Here, You can

    • Define New query (Define New query)
    • Change Query (Change Search condition)
    • Personalize (Set Layout , Remove query , Set default query etc)
  • AFTER DEFINING NEW QUERY

Best Regards,