Showing posts with label web dynpro abap basics. Show all posts
Showing posts with label web dynpro abap basics. Show all posts

Saturday, April 30

WD4A-Navigate from one view to another and back to previous view

Web dynpro framework provides ways to navigate from one view to another view in very easy steps. There is something called plugs in web dynpro both in web dynpro java and web dynpro ABAP, so it is a web dynpro feature. There are two types of plugs, inbound and outbound plugs. Inbound plug handles the incoming navigation and outbound plug makes sure that navigation goes out of the current view thourgh it. To connect these two plugs,a navigation linkis available in web dynpro.

Scenario : we have 2 views V1 and V2. V1 has a inbound plug and a outbound plug and V2 has a inbound and a outbound plug. We want to navigate from V1 to V2 and back from V2 to V1.

We need to connect inbound plug of V1 with the outbound plug of V2 and then connect inbound plug of V2 with the outbound plug of V1 using navigation links. Then onclick of a button or any action we wite the following code in the action handelar.

Related Articles :

Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP
WD4A - Validate Inputs in a web dynpro ABAP Application



Wednesday, April 27

WD4A - How to Calculate next 12 months from current month in web dynpro ABAP

Scenario- based on current date and month, user wants to select any month from the next 12 months. So as a developer you want to display in a list the next 12 months. For this you need to calculate next 12 months from the current date. Below written code does this and stores the next 12 months in a internal table. Later this internal table is bound with a context node to display next 12 months in a table or in a list (as user wishes) on the screen.

Technology used - Web Dynpro ABAP.
Programming language - ABAP.
Aim - calculate and store next 12 months from the current month in a internal table.

code is given below.

  types : BEGIN OF ty_to_date,
  name(20type c,
  value(20type c,
  END OF ty_to_date.
data : it_to_date type table of ty_to_date,
      wa_to_date type ty_to_date.

 data : date(12type c.

data: year(4type c,
      month(2type c,
      day(2type c.



data: imonths like sy-datum.

move sy-datum to imonths.



do 12 times.
  imonths+4(2) = imonths+4(2) + 1.
  imonths+6(2) = '01'.
  if imonths+4(2) = 13.
    imonths+4(2) = '01'.
    imonths(4) = imonths(4) + 1.
  endif.

  year = imonths(4).
month = imonths+4(2).
day = imonths+6(2).
CONCATENATE month '.' year INTO date.
  wa_to_date-name  = date.
  wa_to_date-value  = date.
  append wa_to_date to it_to_date.
enddo.


Bind the internal table to a Context Node to display list of next 12 months in a table or somwehere on the web dynpro ABAP Application screen.
  target_node->Bind_Table( it_to_date ).

Target node has the same structure as the structure of the ty_to_date created above.

Related Articles :

Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - Validate Inputs in a web dynpro ABAP Application

Tuesday, April 26

WD4A - Validate Inputs in a web dynpro ABAP Application

 - The structure of web dynpro component is shown below.




Actions created in View V1 are shown below.





Implementation of each action created above is written below.
method onactiongo .* implicitly available data objects
*   wd_Context type ref to if_wd_context_node.
*   wd_This    type ref to if_v1.
data: message_node type ref to if_wd_context_node.data: input_node type ref to if_wd_context_node,
      text_area_input 
type string.

input_node = wd_context->get_child_node( 
'NODE1' ).

message_node = wd_context->get_child_node( 
'MESSAGES' ).

message_node->invalidate( ).
endmethod.
-----------------------------------------------------------------------------
method onactiongoval .* just default handling
endmethod.
-----------------------------------------------------------------------------
method onactionset_ctxt .
  
data: node_1 type ref to if_wd_context_node.

  node_1 = wd_context->get_child_node( 
'NODE1' ).
  node_1->set_attribute( name = 
'DATE' value = '20041225' ).endmethod.
-----------------------------------------------------------------------------
method onactionset_value .
  wd_this->correct_value = 
'ABC'.endmethod.


Methods Created in Component Controller are shown below.












Implementation of each method shown above is written below.-----------------------------------------------------------------------------
method supply_messages .

  
data:   context type ref to if_wd_context,
          
component type ref to if_wd_component,
          exception_manager 
type ref to cl_wdr_message_manager,
          context_is_valid 
type abap_bool.
  
data:   text1 type          if_v1=>element_messages,
          texts 
type table of if_v1=>element_messages,
          messages 
type string_table.

  
component = wd_comp_controller->wd_get_api( ).
  exception_manager ?= 
component->get_message_manager( ).
  context = wd_context->get_context( ).
  context_is_valid = exception_manager->if_wd_validation~is_context_valid(
                              context = context ).
  
if context_is_valid = abap_false.
    messages = exception_manager->if_wd_validation~get_messages_for_context(
                              context = context ).
    
loop at messages into text1-text.
      
append text1 to texts.
    
endloop.
    node->bind_elements( texts ).
  
endif.endmethod.
-----------------------------------------------------------------------------
method supply_multinode .** data declaration
  
data:
    itab_multinode            
type if_v1=>elements_multinode,
    stru_multinode            
like line of itab_multinode.** @TODO compute values
** e.g. call a data providing FuBa
  
call method cl_wd_flight_model=>get_sflight_by_carrid
    
exporting
      i_carrid   = 
''
    
importing
      et_sflight = itab_multinode.
*
** bind all the elements
  node->bind_table(
    new_items =  itab_multinode
    set_initial_elements = abap_true ).
endmethod.
-----------------------------------------------------------------------------
method supply_node2 .data: flight type if_v1=>element_node2.

flight-price = 
'12.34'.
flight-
currency = 'EUR'.

node->bind_structure( flight ).
endmethod.

This is how the output will look like.


































Related Articles :

Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP

Saturday, March 12

Basics of Web Dynpro ABAP

Basics
Web Dynpro applications  can be created and edited in the web dynpro explorer in the ABAP development environment

It has been fully integrated into the ABAP Workbench so there is no separate transaction code. we use the object list selection to display  or create Web Dynpro component.

When we try to create a new web dynpro component, the system asks for creation of web dynpro component or a web dynpro component interface.


Component
The first step when we create a web dynpro application is to create a we dynpro component. It can have many views and those views can be embedded in windows.

Web Dynpro View
View is the smallest unit of a web dynpro application visible to the user. Various  UI elements like text fields, radio buttons, checkboxes, buttons. Links etc can be put on the view. View also has a context and a controller. Context holds temporarily ie during the session of the application.

Creating a View
View can be created  in the web dynpro explorer in the object list. In order to see the view in the browser, it has to be embedded in a window. The web dynpro design time does not enbed it in the window automatically even if the component has only one window.

View Editor
Once the view is created, it can be modified by using the layout tab of the view. So graphically UI elements can be removed or replaced. Their properties can be changed.

Context data is stored in a tree format. It has got nodes and attributes. Node is a collection of elements. No of elements inside the node  depends upon the cardinality of the node. Attributes present in the node are present in each element belonging  to that node.

Attributes Flagged as "Nullable"
Some data types like numeric or time etc are output by a default value null. For a num4c type the default output value is “0000” and for time it is 00:00:00. This type of behavior is undesirable for some situations. To solve this, we can do the following
First, you must use the method
IF_WD_CONTEXT_NODE_INFO=>SET_NULLABLE( ). This will flag the value in the node as nullable.
all attributes or individual attributes can be set nullable.
Secondly, actual value can be set to “null”. For this purpose, the
interface IF_WD_CONTEXT_NODE provides the method set_attribute_null(
'”Node_Name”' ). 

Related Articles :


ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP
WD4A - Validate Inputs in a web dynpro ABAP Application