Está en la página 1de 15

5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

2nd March 2017 ABAP for HANA - Facil y Sencillo

[https://4.bp.blogspot.com/-7RvJtpIgUeg/WLdPl-
VFJRI/AAAAAAAAPhM/TYtyowujnWsBnu1S6BdzsIlbAYFXDfujACEw/s1600/SAP%2BABAP%2BCoding.jpg]

Para comenzar la iniciación en SAP ABAP para HANA, vamos a implementar algunos
conceptos básicos que mejoran nuestras soluciones ABAP. Estos son:

Eclipse IDE como ambiente de desarrollo.


Vistas CDS como conexión a la fuente de datos y lógica de relaciones.
Servicios OData para exponer los datos.
Programa/Reporte ALV con código mejorado para mostrar los datos de la vista CDS.
El sistema SAP en la maquina virtual tiene un modelo de datos de Procurement pre
cargado. En este tutorial básico vamos a usar solo las tablas SNWD_AD (Business
Partners Direcciones) y SNWD_BPA (Business Partners información complementaria).

[https://1.bp.blogspot.com/-4zkqtCBOAwo/WLdRpqzbObI/AAAAAAAAPh8/UCF97Q6g2xkX6rvXORxUAUrk1caxXmX2ACLcB/s1
600/Procurement%2BData%2BModel_short.png]

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 1/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

Pre requisitos:

SAP NW AS ABAP and BW 7.50 SP02 : Maquina Vitual [http://raulcaraballoit.blogspot.com/2017/01/sap-nw-as-abap-


and-bw-750-sp02-maquina.html]

Paso a Paso:

* Core Data Service View *


En Eclipse IDE abrir la perspectiva ABAP.

[https://3.bp.blogspot.com/-6G1_vlJGUa0/WLdPhof5CHI/AAAAAAAAPh4/YV6qVIs_No4gtyD16IgSngb5dfR3k_TjQCEw/s1600/0
0.png]

Conectarse al proyecto ABAP y crear un nuevo ABAP Repository Object en el paquete


ZTEST.

[https://2.bp.blogspot.com/-
lkyu6biJsQc/WLdPho9leAI/AAAAAAAAPh4/P-KkzMxtM08Cagxypz5lmNLG2PlLNeskQCEw/s1600/01.png]

Seleccionar Data Definition desde la carpeta Core Data Services y presionar Next.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 2/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://2.bp.blogspot.com/-
T3rGwqaAAjw/WLdPhguNRkI/AAAAAAAAPh4/aAV6R7D9jZs-fezZeOxsAitGY2GPc2HlQCEw/s1600/02.png]

Colocar el nombre ZCDS_CLIENT, introduzca una descripción y presiona Next.

[https://4.bp.blogspot.com/-
NBMtaZjm8iY/WLdPiLXfMRI/AAAAAAAAPh4/xHsuf99ZufklnZDQcTT1IZAoy9zRQe4iQCEw/s1600/03.png]

Seleccionar el transporte "Test Request", y presionar Finish.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 3/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://2.bp.blogspot.com/-7gwDWyaADcg/WLdPiKRuIQI/AAAAAAAAPh4/Tk3nyh8rZkMjA8pL_0yQCYXAlqVPdzOeQCEw/s160
0/04.png]

En la vista CDS creada insertar este código.

@AbapCatalog.sqlViewName: 'ZV_CDS_CLI_INF'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'CLIENT INFO'

define view zcds_client as select from snwd_ad as ad

join snwd_bpa as bpa

on ad.client = bpa.client and ad.node_key = bpa.address_guid

key ad.client as client_id,

key ad.node_key as addres_key,

ad.building as building,

ad.city as city,

ad.country as country,

bpa.company_name as company_name,

bpa.node_key as company_key,

bpa.bp_role as company_role,

bpa.currency_code as company_currency
http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 4/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

Guardar y Activar tu vista CDS.

[https://2.bp.blogspot.com/-
GAABA8qq0zY/WLdPiUkcf0I/AAAAAAAAPh4/jdazeqmzitYK2HeHgV8sKtAnwqsFC289QCEw/s1600/05.png]

Botón derecho en la vista CDS / Open With / Data Preview.

[https://3.bp.blogspot.com/-u-
D0rNw24ko/WLdPiiJsXZI/AAAAAAAAPh4/lMrh0rjrijU7Ijv87Vp4wEmf6dRHErISgCEw/s1600/06.png]

Revisa el resultado. Es posible que eclipse no muestre la tabla con los valores pero
puedes ver el numero de filas consultadas como un caso de prueba.

[https://1.bp.blogspot.com/-6Fe3AT307Fc/WLdPilul9EI/AAAAAAAAPh4/N8gPesD1N5I1wTQvJtVtkVFLdQHy4yDtACEw/s1600/0
7.png]

* OData Service *

Ahora vamos a crear un servicio OData usando nuestra vista CDS como fuente de datos.
1. Click en Run ABAP Development Object…
2. Ingresar segw.
3. Seleccionar la transacción SEGW y presionar OK.
http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 5/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

Si tienes algún problema para usar esta transacción desde eclipse, puedes usar SAP
GUI como alternativa.

[https://3.bp.blogspot.com/-
qPuIe4ec55U/WLgyvxz0u0I/AAAAAAAAPi8/5zV8Ft8XDY8lsRNoMspnXT3E_wFbtx1LwCEw/s1600/08.png]

1. Presionar en Create Project.


2. Colocar los valores como lo muestra la siguiente imagen.
3. Presionar OK.

[https://3.bp.blogspot.com/-
h2J_xTzh9nY/WLgywGWmvWI/AAAAAAAAPjA/hgi1JUfA9qwRv-OAbg5c4friZJTdvAqwwCEw/s1600/09.png]

Abrir el proyecto creado y clic derecho en Data Model. Seleccionar Import / DDIC
Structure.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 6/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://1.bp.blogspot.com/-3AlG6lcGT2M/WLgywBqsZFI/AAAAAAAAPjE/h6cDs1WoSIIIZzMFI3nk-
uJqHoECn0RXQCEw/s1600/10.png]

Usar los siguientes valores:


Name: ClientInfo
Seleccionar Entity Type
ABAP Structure: ZV_CDS_CLI_INF
Check en Create Default Entity Set
Presionar Next

[https://1.bp.blogspot.com/-
BYwtCv8eZdg/WLgywPxEwhI/AAAAAAAAPjI/OUhl4UMkcZIY6-_blzkjKBzqOO9iUXOhwCEw/s1600/11.png]

Desde Data Source Parameter(s), seleccionar todos los campos excepto CLIENT_ID y
presionar Next.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 7/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://2.bp.blogspot.com/-
dS2xbMxrP2M/WLgywUeLGII/AAAAAAAAPkc/F0Srmh2BLOMYdvy9CzDh7rDFjALYpxo2QCEw/s1600/12.png]

Seleccionar ADDRES_KEY y COMPANY_KEY como key values. Presionar Finish.

[https://1.bp.blogspot.com/-5dpPM9o0hiM/WLgywaiv0zI/AAAAAAAAPkc/0wuoabrrTOo-
0quBRqxvhTahuWiSjaB9ACEw/s1600/13.png]

1. Seleccionar ClientInfoSet entity.


2. Presionar Generate Runtime Object.
3. El sistema muestra los valores por defecto para algunos de los objectos que serán
creados (No cambiarlos).
4. Presionar OK.

[https://4.bp.blogspot.com/-9k2hCNA7oHc/WLgywi1suFI/AAAAAAAAPkc/RfL-
ep1iNiYAG8jjJSPZLnXG0CCIYomBwCEw/s1600/14.png]

Seleccionar el paquete ZTEST y guardar.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 8/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://2.bp.blogspot.com/-4oUlVHkH580/WLgywgNBkTI/AAAAAAAAPkc/y4fyvDu8t1ccsuvZu3lXC45EdGpWFJBegCEw/s1600/
15.png]

Seleccionar el request "Test Request" y presionar OK.

[https://3.bp.blogspot.com/-Scf4126z-
os/WLgyw33XNLI/AAAAAAAAPkc/1KTo-fLYKzIgRMRKJFXIZUSvo3SEnNaXQCEw/s1600/16.png]

Debes ver varios Success mensajes.

[https://2.bp.blogspot.com/-
DPRWvwWp91c/WLgyw1fNdLI/AAAAAAAAPkc/1mJqePhkcgk-MVVdeqFcrwx7LYf5CMmSgCEw/s1600/17.png]

En Service Implementation, botón derecho en ClientInfoSet y seleccionar Map to Data


Source.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 9/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://1.bp.blogspot.com/-806pEZxz-
RQ/WLgyxNHIo6I/AAAAAAAAPkc/hTJobp57XlMRuOcltBVx_8LV29hJ6F-hgCEw/s1600/18.png]

Seleccionar los siguientes valores:


Target: Local
Type: Business Entity
Name: CDS~ZCDS_CLIENT
Presionar OK

[https://1.bp.blogspot.com/-0Ez2pTHkOB0/WLgyxFVjcQI/AAAAAAAAPkc/oS7dRc0yU4M7d8BkcDWvlezWywFpGPTYgCEw/s16
00/19.png]

1. Introduzca los valores para los Element como se muestra en la siguiente imagen.
2. Presionar Save.
3. Presionar Generate Runtime Object.

[https://3.bp.blogspot.com/-VV_Nsu4Qlr4/WLgyxPa-
hhI/AAAAAAAAPkc/Uc3X3aWjtkwu4jK0-LZ_q8Gk68m5OVYAgCEw/s1600/20.png]

1. Doble clic en Service Maintenance.


2. Seleccionar GW_HUB.
3. Presionar Register.
http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 10/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://3.bp.blogspot.com/-wRa3rlyOhf0/WLgyxUIMTAI/AAAAAAAAPkc/gibAFnNpSpgZc-
GHTN5OTrtIz1ATTY3_wCEw/s1600/21.png]

Para registrar tu proyecto como un servicio, tu información debe verse como se


muestra en la siguiente imagen y el paquete sera ZTEST. Presionar OK.

[https://3.bp.blogspot.com/-
swjAam4iQPk/WLgyxUEEYKI/AAAAAAAAPkc/kufhtq9tygoJtGcMuNauUYbgRrklC9UIgCEw/s1600/22.png]

1. Revisar que registration status se vea en verde.


2. Presionar el botón Maintain.

[https://4.bp.blogspot.com/-
NnQdZJ8DIkk/WLgyxXEnzmI/AAAAAAAAPkc/GpYPpXaia8UtiMj_ZzBdIJJAo4WBrvWhACEw/s1600/23.png]

1. Seleccionar el servicio.
2. Clic en SAP Gateway Client.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 11/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://4.bp.blogspot.com/-
sdnS2kFft74/WLgyxvGUDkI/AAAAAAAAPkc/-WaPGqWDVng-5paMOqP8C6r7H6YL0_1TgCEw/s1600/24.png]

1. Presionar Execute.
2. Revisar los resultados.

[https://2.bp.blogspot.com/-
lUBh4mfnnMA/WLgyxgaOQOI/AAAAAAAAPkc/BcH5_R5A9AQ2ViULNCsfe40aOPEKqxF1wCEw/s1600/25.png]

Tu servicio OData esta funcionando!!!

* ABAP Program : ALV Report *


Tu puedes usar tu vista CDS en tus programas ABAP también. En eclipse IDE, crea un
nuevo ABAP Program en el paquete ZTEST.

[https://1.bp.blogspot.com/-
JAozCCnmHCA/WLgyx9C1aoI/AAAAAAAAPkc/QqfUV1z7hpMFTgV4CCi1HoUvjkXMZixXACEw/s1600/26.png]

Colocar el nombre ZR_CLIENT_ALV y agregar una descripción. Presionar Next.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 12/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://3.bp.blogspot.com/-
a0eEFS24nwU/WLgyx3PqquI/AAAAAAAAPkc/m_Jws-waBKgWGg26ooJrIOUm4YSsNLNJgCEw/s1600/27.png]

Seleccionar "Test Request" y presionar Finish.

[https://2.bp.blogspot.com/-rWcHY8Y04cA/WLgyx-
kprLI/AAAAAAAAPkc/C6_8wq129PMNV84tAHpoxL3jrGcaZe6EwCEw/s1600/28.png]

Agregar el siguiente código:


cl_salv_gui_table_ida=>create_for_cds_view( iv_cds_view_name = ‘zcds_client’ )-
>fullscreen( )->display( ).
Guardar y activar el programa.
Presionar F8 para correr el programa.

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 13/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

[https://1.bp.blogspot.com/-
feoJeSlAcug/WLgyyAL4iRI/AAAAAAAAPkc/BJ9eFxymi0QaYXsEYc9Cty4EV0kh0dcLQCEw/s1600/29.png]

El Programa/Reporte esta funcionando.

[https://3.bp.blogspot.com/-
NgHt6io65mw/WLgyyNkmB9I/AAAAAAAAPkc/G9XiMC7PQ_0WIrFdWSZNbzJP4uWNdFRuwCEw/s1600/30.png]

[https://raulcaraballoit.wordpress.com/2017/02/07/abap-for-hana-basic-easy/]

Publicado 2nd March 2017 por Raúl Caraballo


Etiquetas: ABAP, ALV, CDS, eclipse, hana, OData, Raul Caraballo, sap, SAP 7.5, Service

0 Añadir un comentario

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 14/15
5/12/2018 ABAP for HANA - Facil y Sencillo | Innovators at Heart

Introduce tu comentario...

Comentar como: Fernando (Goo Cerrar sesión

Publicar Vista previa Avisarme

http://raulcaraballoit.blogspot.com/2017/03/abap-for-hana-facil-y-sencillo.html 15/15

También podría gustarte