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

Friday, April 22

How to Develop Portal Applications


Apart from standard components and services provided by SAP, Developers can develop custom components and custom services for providing custom content and custom processing. These services and components can make use of hundreds of standard SAP provided components and services like creating navigation links, transforming XML content and client side eventing.
When we develop a portal application, we must know beforehand that what are portal administrators going to use it for. There are 2 steps one must follow to create a portal application:

·         Run NWDS and use enterprise portal perspective.
·         Create an enterprise portal project and add components and services, create a PAR file and upload it on the portal.

We can use any of the following technology to build a portal application:

Portal Runtime: Portal runs on portal runtime. PRT also provide infrastructure to develop portal components which provide HTML for display purpose. Also PRT is used for creating portal services which provide functionality to components and other services.

Web Dynpro: Web dynpro comes in 2 flavours, web dynpro ABAP and web dynpro Java. One can build UI using web dynpro and deploy it on portal. This is the preferred method of creating portal applications.

I shall explain web dynpro ABAP and web dynpro Java development in detail later in upcoming porsts on this blog.
In order to develop applications in portal, you need to know basic things like HTML and servlet programming and JSP.
Tasks that can be performed in portal application perspective are:
·         Perspective configuration
·         Portal application project creation
·         Importing JAR and PAR files
·         Check Web services
·         Working with NWDI


Perspective configuration

Once the portal application is created, developer needs to upload its PAR file to the portal from NWDS EP perspective. For this, EP perspective must know the installation information of the portal to which Portal application is to be uploaded.
In NWDS go to Window ® Preferences ® SAP Enterprise Portal  ® Application Development Studio. There are various checkboxes available to configure the EP Plug-in. Select the checkboxes, as needed.

Portal application project creation

Create a new portal application project
Select the menu File ® New ® Project…  ® Portal Applications ® Create a Portal Application Project Specify the project name etc. That’s it.
Create a new portal service
Select the menu File  ® New  ® Other…
select Portal Application ® Create a new Portal Application Object, click Next
Select the project in which you want to create the service,  click Next.
Select Portal Service to be created, click Next.
Enter the service name etc.
 That’s it.

Create new portal component
Select the menu File  ® New  ® Other…
Select Portal Application ® Create a new Portal Application Object, click Next
Select project in which you would like to create the component,  click Next.
Select Portal Component ® AbstractPortalComponent, click Next.
Enter the component name etc. That’s it.