a simple web dynpro application to locate employee’s ...€¦ · a simple web dynpro application...

14
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0, ABAP. For more information, visit the Web Dynpro ABAP homepage . For more information, visit the ABAP homepage . Summary This article contains how to call Google map from the Web Dynpro for ABAP so that it can be used to locate employee. Author: Raju Borda Company: Tata consultancy services Created on: 28 June 2010 Author Bio Raju Borda is working as Developer in TCS in all areas of ABAP development including Web Dynpro for ABAP, SOA and integration technologies.

Upload: others

Post on 18-Oct-2020

6 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 1

A Simple Web Dynpro Application

to Locate Employee’s Location

into Google Map

Applies to:

SAP Net Weaver 7.0, ABAP. For more information, visit the Web Dynpro ABAP homepage.

For more information, visit the ABAP homepage.

Summary

This article contains how to call Google map from the Web Dynpro for ABAP so that it can be used to locate employee.

Author: Raju Borda

Company: Tata consultancy services

Created on: 28 June 2010

Author Bio

Raju Borda is working as Developer in TCS in all areas of ABAP development including Web Dynpro for ABAP, SOA and integration technologies.

Page 2: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 2

Table of Contents

Introduction ................................................................................................................................................... 3

Create the Web Dynpro component ........................................................................................................... 3 Step 1:.......................................................................................................................................................................... 3

Step 2:.......................................................................................................................................................................... 4

Step 3:.......................................................................................................................................................................... 5

Step 4:.......................................................................................................................................................................... 6

Step 5:.......................................................................................................................................................................... 7

Step 6:.......................................................................................................................................................................... 8

Build the URL to locate employee .............................................................................................................. 9

Step 7........................................................................................................................................................................... 9

Step 8......................................................................................................................................................................... 10

Test the Application ................................................................................................................................. 11

Step 9:........................................................................................................................................................................ 11

Step 10:...................................................................................................................................................................... 12

Related Content .......................................................................................................................................... 13

Disclaimer and Liability Notice ..................................................................................................................... 14

Page 3: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 3

Introduction

This article is all about creating a simple Web Dynpro for ABAP application to locate Employee’s location into

Google map.

Create the Web Dynpro component

Step 1:

Go to Se80 create a Web Dynpro comp name ZTEST_LOCATE_EMP.

Page 4: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 4

Step 2:

Create a node into your main windo with name EMP. Dictionary strcuture as PA0006.Click on the button

“ADD attriubute from structure” and select the perner from it.

Page 5: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 5

Step 3:

Go to layout tab into MAIN view and create an input field with name EMP_ID.

Page 6: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 6

Step 4:

Double click on the EMP_ID.

You can see the value property for it. Bind this to the context attribute you have created.

Page 7: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 7

Step 5:

Create a Button with name LOCATE.

Page 8: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 8

Step 6:

Double click on it, you can see on action property. Just click on the create button right side of it.

Create a ACTION name LOCATE .no need to give any outbound plug name.

Page 9: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 9

Build the URL to locate employee

Step 7

When you create an action it automatically a Method name ONACTION<your acion name>.

Here it is ONACTIONLOCATE

Page 10: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 10

Step 8.

Put the below code inside your method:

data : v_pernr type pa0006-pernr.

data : v_street type pa0006-STRAS.

data : v_city type pa0006-ORT01.

data : lr_node type ref to if_wd_context_node.

data: lo_window_manager type ref to if_wd_window_manager.

data: lo_api_component type ref to if_wd_component.

data: lo_window type ref to if_wd_window.

data: ld_url type string.

DATA : FINAL_URL TYPE STRING.

lr_node = wd_context->get_child_node( 'EMP' ).

lr_node->GET_ATTRIBUTE( exporting NAME = 'PERNR'

IMPORTING VALUE = V_PERNR ).

select SINGLE STRAS ORT01 from pa0006 into (v_street,v_city) where

PERNR eq v_pernr.

IF SY-SUBRC EQ 0.

CONDENSE V_CITY.

CONDENSE V_STREET.

CONCATENATE

'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='

V_CITY V_STREET INTO FINAL_URL SEPARATED BY SPACE.

ENDIF.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

*FINAL_URL = 'www.google.com'.

ld_url = FINAL_URL.

CALL METHOD lo_window_manager->CREATE_EXTERNAL_WINDOW

EXPORTING URL = ld_url

RECEIVING WINDOW = lo_window.

lo_window->open( ).

Page 11: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 11

Test the Application

Step 9:

Create a Web Dynpro application

Page 12: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 12

Step 10:

Execute the application and give the perner which have the address data updated in PA0006. Take pernr 00000003 if you don’t get any.

Page 13: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 13

Related Content

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/0122113f-0d01-0010-d8b3-fe8ba6d9d088

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/f08ab239-d69a-2c10-119b-c623b74be4af

For more information, visit the Web Dynpro ABAP homepage.

Page 14: A Simple Web Dynpro Application to Locate Employee’s ...€¦ · A Simple Web Dynpro Application to Locate Employee’s Location into Google Map Applies to: SAP Net Weaver 7.0,

A Simple Web Dynpro Application to Locate Employee’s Location into Google Map

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 14

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not

supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,

and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and

services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this

document.