Sunday, February 26, 2012
Please follow the steps to fill the Drop Down by Index with values
  • Create Web Dynpro component and Save 

  • Go to View -> Context -> Create node COUNTRIES with cardinality 0..n. 

  • Go to Layout -> Create DropDownByIndex UI element and Label UI element for Drop down box. 



  • Bind the context attribute to DropDown in the shown way. 
  • Go to Methods tab -> WDDOINIT -> Write the below code. 
  • Activate Web Dynpro Component 
  • Create Web Dynpro Application 
  • Execute the WebDynrpo application. 
Supply Function is used to repopulate child nodes when the lead selection in the parent node changes.
Supply function is called automatically by the Web Dynpro Runtime when an attempt is made to read an empty node collection. This situation occurs for following condition.
  • The node is never populated before.
  • The lead selection of the parent node is changed.
  • Application coding has explicitly invalidated the element collection.
Few examples where we can use Supply function.
  1. Lets say we have two drop down boxes. For every selected entry from first drop down box, if you want to set different kind of values, Supply function can be useful. 
  2. Lets say we have two tables. For every selected row from first Table, if you have multiple elements to be shown in table, Supply function can be useful. 
Steps to use Supply Function

  • Create Web Dynpro component and Save. 
  • Go to Component Controller context ->Create one root node(EMP_INFO) under context node as shown below for Employee information table. Set cardinality to 0..n


  •  Create one child node e.g IT0006_DATA under EMP_INFO root node where EMP_INFO is the source of supply for the node IT0006_DATA. Cardinality 0...n and Supply function GET_ADD_DATA should be mentioned. 


  • Go to view VIEW1 ->Context. Map component controller context to view context by drag and drop method. 

  •  Go to view layout ->Set ROOTUIELEMENTCONTAINER layout to MatrixLayout type.
  • Create EMP_INFO table UI Element ->Set table caption and Table Layout data property to MatrixHeadData. Create binding as shown in the print screen.  
  •   Create IT0006_DATA table UI Element ->Set table caption and Table Layout data property to MatrixHeadData. Create binding as shown in the print screen.

  •  Save and Go to COMPONENTCONTROLLER - >Methods - >WDDOINIT. Write the below code 
METHOD wddoinit.
  DATA lo_nd_emp_info TYPE REF TO if_wd_context_node.

  DATA lt_emp_info TYPE wd_this->elements_emp_info.

* navigate from  to  via lead selection
  lo_nd_emp_info = wd_context->get_child_node( name = wd_this->wdctx_emp_info ).
  SELECT *
    FROM pa0002
    INTO CORRESPONDING FIELDS OF TABLE lt_emp_info
    UP TO 50 ROWS.

  lo_nd_emp_info->bind_table( new_items = lt_emp_info set_initial_elements = abap_true ).

ENDMETHOD.
  •   COMPONENTCONTROLLER - >Methods - >WDDOINIT. Write the below code 
METHOD get_add_data .
* General Notes
* =============
* A common scenario for a supply method is to aquire key
* informations from the parameter  and then
* to invoke a data provider.
* A free navigation thru the context, especially to nodes on
* the same or deeper hierachical level is strongly discouraged,
* because such a strategy may easily lead to unresolvable
* situations!!

*  if necessary, get static attributes of parent element
  DATA ls_parent_attributes TYPE wd_this->element_emp_info.
  parent_element->get_static_attributes(
    IMPORTING
      static_attributes = ls_parent_attributes ).

  DATA lo_nd_it0006_data TYPE REF TO if_wd_context_node.

  DATA lt_it0006_data TYPE wd_this->elements_it0006_data.

* navigate from  to  via lead selection
  lo_nd_it0006_data = wd_context->path_get_node( path = `EMP_INFO.IT0006_DATA` ).
  SELECT *
    FROM pa0006
    INTO CORRESPONDING FIELDS OF TABLE lt_it0006_data
    WHERE pernr EQ ls_parent_attributes-pernr.
  lo_nd_it0006_data->bind_table( new_items = lt_it0006_data set_initial_elements = abap_true ).

ENDMETHOD.
  •  Activate the Web Dynpro Component
  • Create Web Dynpro application 
  • Execute the Web Dynpro application.

Tuesday, February 21, 2012
Transaction Recorder: Transaction recorder is used to record a series of transactions and their screens.
Recording Features
  • Data transfer programs that use batch input or CALL TRANSACTION
  • Batch input sessions
  • Test data
  • Function modules
Steps in Transaction recording.
  • Go to transaction SHDB and Click on New Recording button.
  •  Give Recording name and Transaction code to be record.
  • Execute the transaction in the usual way.
  • When you have finished processing the transaction, the system displays an overview of the transaction and your input. Save and Click on BACK button.
  • Select the recording and click on Program button to create program for the recording.
  • Generate the program to read from the file. 
  •  Give the title for the program & click on Source code button. 
  • Change the source wherever required. 
  • REPORT ztest_bdc NO STANDARD PAGE HEADING LINE-SIZE 255.
    INCLUDE bdcrecx1.
    PARAMETERS: dataset(132) LOWER CASE DEFAULT 'IT0006_DATA'.
    ***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
    *
    *   If it is nessesary to change the data section use the rules:
    *   1.) Each definition of a field exists of two lines
    *   2.) The first line shows exactly the comment
    *       '* data element: ' followed with the data element
    *       which describes the field.
    *       If you don't have a data element use the
    *       comment without a data element name
    *   3.) The second line shows the fieldname of the
    *       structure, the fieldname must consist of
    *       a fieldname and optional the character '_' and
    *       three numbers and the field length in brackets
    *   4.) Each field must be type C.
    *
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    DATA: BEGIN OF record,
    * data element: PERNR_D
            pernr_001(038),
    * data element: TIMRE
            timr6_002(001),
    * data element: CHOIC
            choic_003(035),
    * data element: SUBTY
            subty_004(004),
    * data element: BEGDA
            begda_020(010),
    * data element: ENDDA
            endda_021(010),
    * data element: ANSSA
            anssa_022(004),
    * data element: PAD_CONAM
            name2_023(040),
    * data element: PAD_STRAS
            stras_024(060),
    * data element: PSTLZ_HR
            pstlz_025(010),
    * data element: PAD_ORT01
            ort01_026(040),
    * data element: LAND1
            land1_027(003),
    * data element: TELNR
            telnr_028(014),
          END OF record.
    
    *** End generated data section ***
    
    START-OF-SELECTION.
    
      PERFORM open_dataset USING dataset.
      PERFORM open_group.
    
      DO.
    
        READ DATASET dataset INTO record.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
    
        PERFORM bdc_dynpro      USING 'SAPMP50A'           '1000'.
        PERFORM bdc_field       USING 'BDC_OKCODE'         '=INS'.
        PERFORM bdc_field       USING 'RP50G-PERNR'        record-pernr_001.
        PERFORM bdc_field       USING 'RP50G-TIMR6'        record-timr6_002.
        PERFORM bdc_field       USING 'BDC_CURSOR'         'RP50G-SUBTY'.
        PERFORM bdc_field       USING 'RP50G-CHOIC'        record-choic_003.
        PERFORM bdc_field       USING 'RP50G-SUBTY'        record-subty_004.
    
        PERFORM bdc_dynpro      USING 'MP000600'           '2001'.
        PERFORM bdc_field       USING 'BDC_CURSOR'         'P0006-TELNR'.
        PERFORM bdc_field       USING 'BDC_OKCODE'         'UPD'.
        PERFORM bdc_field       USING 'P0006-BEGDA'        record-begda_020.
        PERFORM bdc_field       USING 'P0006-ENDDA'        record-endda_021.
        PERFORM bdc_field       USING 'P0006-ANSSA'        record-anssa_022.
        PERFORM bdc_field       USING 'P0006-NAME2'        record-name2_023.
        PERFORM bdc_field       USING 'P0006-STRAS'        record-stras_024.
        PERFORM bdc_field       USING 'P0006-PSTLZ'        record-pstlz_025.
        PERFORM bdc_field       USING 'P0006-ORT01'        record-ort01_026.
        PERFORM bdc_field       USING 'P0006-LAND1'        record-land1_027.
        PERFORM bdc_field       USING 'P0006-TELNR'        record-telnr_028.
        PERFORM bdc_transaction USING 'PA30'.
      ENDDO.
    
      PERFORM close_group.
      PERFORM close_dataset USING dataset.
    
  • Save and Activate the program.



  • Execute the program. 
  • The program Creates Address infotype record.
Saturday, February 18, 2012
If domain is defined with Value Table, drop down list does not get populated with values automatically.
Steps to get the values in drop down list (DropDownByKey).
  • Create Web Dynpro component and save as local object.
  • Go to Context tab -> Create node and attribute inside the node. 
  • Go to Layout tab -> Place UI element DropDownByKey by using Create container form so that UI element is automatically bound to Context attribute. 
  • Go to method tab -> Write the below code in WDDOINIT method. Here we have to call SET_ATTRIBUTE_VALUE_SET of interface IF_WD_CONTEXT_NODE_INFO to set the fixed values for an attribute which is bound to DropDownByKey UI element.
    method wddoinit .
    "Reference variables
      data:
            lo_nd_emp_det      type ref to if_wd_context_node,
            lo_nd_emp_det_info type ref to if_wd_context_node_info,
            lo_el_emp_det      type ref to if_wd_context_element.
    
      types:
            begin of ty_p0002,
              pernr      type pa0002-pernr,
              nachn      type pa0002-nachn,
              vorna      type pa0002-vorna,
            end of ty_p0002,
            ty_value_set type wdr_context_attr_value.
      data:
          ls_p0002       type ty_p0002,
          ls_value_set   type ty_value_set.
    
      data:
            lt_p0002     type standard table of ty_p0002,
            lt_value_set type standard table of ty_value_set.
    
    "Navigate from  to  via lead selection
      lo_nd_emp_det = wd_context->get_child_node( name = wd_this->wdctx_emp_det ).
    "Get node info
      lo_nd_emp_det_info = lo_nd_emp_det->get_node_info( ).
    "Select the all employee details
       select pernr
              nachn
              vorna
         from pa0002
         into table lt_p0002
         up to 100 rows.
    "Put Employee lines into value set
        loop at lt_p0002 into ls_p0002.
          ls_value_set-value = ls_p0002-pernr.
          concatenate ls_p0002-vorna ls_p0002-nachn into ls_value_set-text separated by space.
          append ls_value_set to lt_value_set.
          clear  ls_value_set.
        endloop.
    " Assign value set
        call method lo_nd_emp_det_info->set_attribute_value_set
          exporting
            name      = 'PERNR'
            value_set = lt_value_set.
    
    endmethod.
    
  • Save and Activate Web Dynpro component. 
  • Create Web Dynpro Application ->Execute.
Friday, February 17, 2012
Presently Web Dynpro ABAP engine is fillin Drop down by Key for certain domains, for others not. 
  • For domains, that have direct values assigned everything is filled automatically. 

  • If domain has values indirectly through value table, no values are filled. 
Steps to get the values in drop down list using Domains
  • Create web dynpro component and save in local directly. 

  •  Go to CONTEXT tab insert attribute actio TYPE ACTIO or mention the field PSPAR-ACTIO directly if the domain is assigned to field.

  •  Go to LAYOUT tab ->Create UI element DropDownbyKey and Bind the context attribute ACTIO to drop down UI element.


  •  If you mention label for drop down box, you should mention Lable for attribute of LABEL UI element.


  •  Save and activate all. 
  •  Create web dynpro application and execute. 

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.