<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Havish on Medium]]></title>
        <description><![CDATA[Stories by Havish on Medium]]></description>
        <link>https://medium.com/@havish7728?source=rss-c9e5bebeb9f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9FksUfVo6CaL3N3zp2e2tg.jpeg</url>
            <title>Stories by Havish on Medium</title>
            <link>https://medium.com/@havish7728?source=rss-c9e5bebeb9f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:41:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@havish7728/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Complete RAP Application Using Unmanaged Implementation in ABAP (Step-by-Step)]]></title>
            <link>https://havish7728.medium.com/building-a-complete-rap-application-using-unmanaged-implementation-in-abap-step-by-step-7ec64ad5aca3?source=rss-c9e5bebeb9f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ec64ad5aca3</guid>
            <category><![CDATA[sap-fiori]]></category>
            <category><![CDATA[sap]]></category>
            <category><![CDATA[abap]]></category>
            <category><![CDATA[rap]]></category>
            <category><![CDATA[odata]]></category>
            <dc:creator><![CDATA[Havish]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 17:28:24 GMT</pubDate>
            <atom:updated>2026-03-16T17:36:35.216Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>ABAP RESTful Application Programming Model (RAP)</strong> is SAP’s modern framework for building enterprise-ready services and applications.<br>In this article, we will build a <strong>complete RAP application using Unmanaged Implementation</strong>, covering CDS views, behavior definitions, implementation classes, service definition, and service binding step by step.</p><h3>Project Flow of the RAP Application</h3><p>The RAP application in this example follows a layered architecture. Each component plays a specific role in exposing the database table as an OData service and generating a Fiori Elements application.</p><p>The development flow of the project is as follows:</p><ol><li><strong>Create Database Table</strong><br> Create a custom table Z0028EKKO that stores Purchase Order information such as PO Number, Company Code, Document Category, and Document Type.</li><li><strong>Create Root CDS View (Interface Layer)</strong><br> Define the root view entity Z0028_EKKO_RV on top of the database table. This represents the core data model of the RAP business object.</li><li><strong>Create Projection CDS View (Consumption Layer)</strong><br> Create the projection view Z0028_EKKO_PV based on the root view. This layer exposes the entity to the service layer and contains UI annotations for Fiori Elements.</li><li><strong>Create Behavior Definition for Root View</strong><br> Define the transactional capabilities such as <strong>create, update, and delete</strong> and specify that the implementation will be <strong>unmanaged</strong>.</li><li><strong>Generate Behavior Implementation Class</strong><br> Activate the behavior definition to generate the implementation class ZBP_0028_EKKO_RV, where CRUD operations are implemented manually.</li><li><strong>Create Behavior Definition for Projection View</strong><br> Expose the root behavior operations (create, update, delete) in the projection layer.</li><li><strong>Create Service Definition</strong><br> Define the service ZIS_SO_EKKO and expose the projection entity Z0028_EKKO_PV.</li><li><strong>Create Service Binding (OData V2 — UI)</strong><br> Create and publish the service binding to generate the OData service and enable Fiori Elements preview.</li><li><strong>Preview the Fiori Application</strong><br> Once the service binding is published, the RAP service automatically generates a <strong>Fiori Elements List Report and Object Page</strong> based on the UI annotations.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXoHDyXA50171fp2VijphQ.png" /></figure><h3>1. Root CDS View (Interface Layer)</h3><p>The <strong>Root CDS View</strong> represents the <strong>core data model in the RAP architecture</strong>. It directly exposes the database table structure and acts as the <strong>foundation for business objects</strong>. All transactional operations such as <strong>create, update, and delete</strong> are defined on this root entity.</p><p>In this example, a root view entity is created on top of the custom database table <strong>Z0028EKKO</strong>, which stores purchase order–related information.</p><h3>Root CDS View Definition</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED<br>@EndUserText.label: &#39;Ekko root view&#39;<br>@Metadata.ignorePropagatedAnnotations: true</pre><pre>define root view entity Z0028_EKKO_RV <br>as select from z0028ekko<br>{<br>    key ebeln as Ebeln,<br>        bukrs as Bukrs,<br>        bstyp as Bstyp,<br>        bsart as Bsart<br>}</pre><h3>Explanation of Key Annotations</h3><p><strong>@AccessControl.authorizationCheck: #NOT_REQUIRED</strong></p><p>This annotation disables CDS access control checks. It is commonly used during development or when authorization logic is not required.</p><p><strong>@EndUserText.label</strong></p><p>Provides a user-friendly description of the CDS entity. This label appears in development tools and service metadata.</p><p><strong>@Metadata.ignorePropagatedAnnotations: true</strong></p><p>Prevents annotations from underlying sources such as database tables or other CDS views from automatically propagating to this CDS entity.</p><p><strong>define root view entity</strong></p><p>Declares the CDS as a <strong>root entity</strong> in RAP. Root entities represent the <strong>main business objects that support transactional operations</strong>.</p><h3>Field Mapping</h3><p>The following fields from the database table <strong>Z0028EKKO</strong> are exposed through the CDS view:</p><ul><li><strong>EBELN → Ebeln</strong> (Purchase Order Number — Key Field)</li><li><strong>BUKRS → Bukrs</strong> (Company Code)</li><li><strong>BSTYP → Bstyp</strong> (Document Category)</li><li><strong>BSART → Bsart</strong> (Document Type)</li></ul><p>The field <strong>EBELN</strong> is defined as the <strong>primary key</strong>, which uniquely identifies each purchase order record.</p><h3>Role in RAP Architecture</h3><p>This root CDS view plays a critical role in the RAP model. It serves as:</p><ul><li>The <strong>transactional data source</strong></li><li>The <strong>basis for behavior definition</strong></li><li>The <strong>foundation for projection views</strong></li></ul><p>All business logic such as <strong>create, update, and delete operations</strong> will ultimately operate on this root entity.</p><h3>2. Root Projection View with UI Metadata</h3><p>In the RAP architecture, the <strong>Projection View</strong> acts as the <strong>consumption layer</strong>. While the <strong>Root CDS View</strong> represents the core data model, the projection view exposes only the required fields for the <strong>service layer and UI applications</strong>.</p><p>This layer is also where <strong>UI annotations</strong> are typically added for <strong>Fiori Elements applications</strong>, such as:</p><ul><li>List report columns</li><li>Object page sections</li><li>Header information</li></ul><p>The projection view is built on top of the <strong>Root CDS View (</strong><strong>Z0028_EKKO_RV)</strong> and represents the business object that will be exposed through the service.</p><h3>Projection View Definition</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED<br>@EndUserText.label: &#39;Ekko Projection View&#39;<br>@Metadata.ignorePropagatedAnnotations: true</pre><pre>@UI.headerInfo: {<br>  typeName: &#39;PO&#39;,<br>  typeNamePlural: &#39;POs&#39;,<br>  title: { type: #STANDARD, value: &#39;Ebeln&#39; }<br>}</pre><pre>define root view entity Z0028_EKKO_PV<br>  provider contract transactional_query<br>  as projection on Z0028_EKKO_RV<br>{</pre><pre>  @UI.facet: [{<br>      id: &#39;PO&#39;,<br>      type: #IDENTIFICATION_REFERENCE,<br>      label: &#39;PO Information&#39;,<br>      position: 10,<br>      targetQualifier: &#39;PO&#39;<br>  }]</pre><pre>  @EndUserText.label: &#39;PO Number&#39;<br>  @UI.lineItem: [{ position: 10 }]<br>  @UI.identification: [{ position: 10, qualifier: &#39;PO&#39; }]<br>  key Ebeln,</pre><pre>  @EndUserText.label: &#39;Company Code&#39;<br>  @UI.lineItem: [{ position: 20 }]<br>  @UI.identification: [{ position: 20, qualifier: &#39;PO&#39; }]<br>  Bukrs,</pre><pre>  @EndUserText.label: &#39;Document Category&#39;<br>  @UI.lineItem: [{ position: 30 }]<br>  @UI.identification: [{ position: 30, qualifier: &#39;PO&#39; }]<br>  Bstyp,</pre><pre>  @EndUserText.label: &#39;Document Type&#39;<br>  @UI.lineItem: [{ position: 40 }]<br>  @UI.identification: [{ position: 40, qualifier: &#39;PO&#39; }]<br>  Bsart</pre><pre>}</pre><h3>Key Elements Explained</h3><h3>provider contract transactional_query</h3><p>This specifies that the projection view supports <strong>transactional operations</strong>, including:</p><ul><li>Create</li><li>Update</li><li>Delete</li></ul><p>Because of this provider contract, the entity can be used in <strong>transactional RAP services</strong>.</p><h3>Projection on Root View</h3><pre>as projection on Z0028_EKKO_RV</pre><p>This statement indicates that the projection view is built on top of the <strong>Root CDS View</strong>.</p><ul><li>The <strong>root view</strong> manages the <strong>core data model</strong>.</li><li>The <strong>projection view</strong> controls how the data is <strong>exposed to the service and UI layer</strong>.</li></ul><p>This layered architecture keeps the <strong>data model independent from UI concerns</strong>.</p><h3>UI Header Configuration</h3><p>The annotation:</p><pre>@UI.headerInfo</pre><p>defines the <strong>Object Page header</strong> in a Fiori Elements application.</p><p>In this example:</p><ul><li><strong>typeName</strong> defines the singular name of the business object.</li><li><strong>typeNamePlural</strong> defines the plural label shown in the UI.</li><li><strong>title</strong> determines which field is displayed as the main title on the Object Page.</li></ul><p>Here, the <strong>Purchase Order number (Ebeln)</strong> appears as the header title.</p><h3>UI Facet</h3><p>The annotation:</p><pre>@UI.facet</pre><p>is used to define <strong>sections inside the Object Page</strong>.</p><p>In this example, a section called <strong>“PO Information”</strong> is created.</p><p>Important properties used here include:</p><ul><li><strong>id</strong> — Unique identifier for the facet</li><li><strong>type</strong> — Defines the facet type</li><li><strong>label</strong> — Name displayed in the UI</li><li><strong>position</strong> — Determines the order of sections</li><li><strong>targetQualifier</strong> — Links the facet to fields that use the same qualifier</li></ul><h3>List Report Configuration</h3><p>The annotation:</p><pre>@UI.lineItem</pre><p>controls which fields appear as <strong>columns in the List Report table</strong>.</p><p>In this example, the List Report displays the following columns:</p><ul><li>Purchase Order Number (Ebeln)</li><li>Company Code (Bukrs)</li><li>Document Category (Bstyp)</li><li>Document Type (Bsart)</li></ul><p>The <strong>position attribute</strong> determines the column order in the table.</p><h3>Object Page Fields</h3><p>The annotation:</p><pre>@UI.identification</pre><p>defines which fields appear inside the <strong>Object Page section</strong>.</p><p>All fields use the qualifier <strong>PO</strong>, which connects them to the <strong>PO Information facet</strong> defined earlier.</p><p>This means that the following fields appear inside the <strong>PO Information section</strong> of the Object Page:</p><ul><li>Purchase Order Number</li><li>Company Code</li><li>Document Category</li><li>Document Type</li></ul><h3>Role of the Projection View in RAP</h3><p>The projection view serves as the <strong>consumption interface for the RAP service</strong>.</p><p>Its responsibilities include:</p><ul><li>Exposing required fields to the <strong>service layer</strong></li><li>Defining <strong>UI annotations for Fiori Elements applications</strong></li><li>Controlling which elements of the root entity are <strong>accessible externally</strong></li></ul><p>This separation ensures a <strong>clean architecture</strong>, where the <strong>data model remains independent of UI-specific configurations</strong>.</p><h3>3. Behavior Definition for Root View</h3><p>In the RAP architecture, the <strong>Behavior Definition</strong> defines how a business object behaves. It specifies which operations are allowed on the entity and how locking, authorization, and field control are handled.</p><p>In this example, the behavior definition is created for the <strong>Root CDS View </strong><strong>Z0028_EKKO_RV</strong>. Since the application uses <strong>Unmanaged RAP</strong>, the RAP framework will not automatically generate database operations. Instead, all CRUD logic must be implemented manually in a behavior implementation class.</p><h3>Behavior Definition</h3><pre>unmanaged implementation in class zbp_0028_ekko_rv unique;<br>strict ( 2 );</pre><pre>define behavior for Z0028_EKKO_RV<br>lock master<br>authorization master ( instance )<br>{</pre><pre>  field ( readonly : update ) ebeln;<br>  create;<br>  update;<br>  delete;</pre><pre>}</pre><h3>Unmanaged Implementation</h3><p>The statement</p><p>unmanaged implementation in class zbp_0028_ekko_rv unique;</p><p>indicates that the business logic will be implemented manually in the ABAP class <strong>ZBP_0028_EKKO_RV</strong>.</p><p>In unmanaged RAP:</p><ul><li>The framework does not automatically handle database operations.</li><li>Developers must implement <strong>create, update, and delete logic manually</strong>.</li><li>The implementation is written in the <strong>behavior implementation class</strong>.</li></ul><h3>Strict Mode</h3><p>strict ( 2 );</p><p>Strict mode enables RAP syntax validation and enforces best practices. Version <strong>2</strong> applies stronger checks to ensure that the behavior definition follows RAP development standards.</p><h3>Lock Handling</h3><p>lock master</p><p>This statement enables locking at the <strong>root entity level</strong>. It ensures that concurrent updates on the same record are handled properly and prevents data inconsistencies.</p><h3>Authorization Handling</h3><p>authorization master ( instance )</p><p>This enables <strong>instance-level authorization checks</strong> for the root entity. Authorization logic can later be implemented to control access to specific records.</p><h3>Supported Operations</h3><p>The behavior definition allows the following operations:</p><ul><li><strong>create</strong> — allows creating new records</li><li><strong>update</strong> — allows modifying existing records</li><li><strong>delete</strong> — allows removing records from the database</li></ul><p>These operations will later be implemented in the behavior implementation class.</p><h3>Field Control</h3><p>The statement</p><p>field ( readonly : update ) ebeln;</p><p>ensures that the <strong>EBELN field cannot be modified during an update operation</strong>.</p><p>This is typically done for key fields such as <strong>Purchase Order Number</strong>, which should remain constant once the record has been created.</p><p>This means:</p><ul><li>EBELN can be provided during <strong>create</strong></li><li>EBELN cannot be changed during <strong>update</strong></li></ul><h3>Role of Behavior Definition in RAP</h3><p>The Behavior Definition acts as a <strong>contract between the RAP framework and the implementation logic</strong>. It tells the framework:</p><ul><li>which operations are allowed on the entity</li><li>which fields are editable or read-only</li><li>how locking should be handled</li><li>which class contains the implementation logic</li></ul><p>For <strong>unmanaged RAP</strong>, this layer is essential because it connects the RAP business object to the <strong>custom ABAP class where CRUD operations are implemented</strong>.</p><h3>4. Behavior Implementation Class — Implementing Create, Update, and Delete</h3><p>In <strong>Unmanaged RAP</strong>, the framework does not automatically perform database operations. Instead, developers must implement the CRUD logic manually inside the <strong>Behavior Implementation Class</strong>.</p><p>The class responsible for handling these operations is automatically generated when the behavior definition is activated. In this example, the implementation class is <strong>ZBP_0028_EKKO_RV</strong>, and the handler class <strong>LHC_Z0028_EKKO_RV</strong> inherits from CL_ABAP_BEHAVIOR_HANDLER.</p><p>When creating the behavior implementation class in ADT, the system may generate the class template with <strong>managed implementation methods</strong>. Since this example uses <strong>Unmanaged RAP</strong>, the generated template must be adjusted accordingly.</p><p>Make sure the behavior definition specifies:</p><pre>unmanaged implementation in class zbp_0028_ekko_rv unique;</pre><p>This ensures that the RAP framework expects <strong>manual implementation of CRUD operations</strong> inside the behavior implementation class.</p><p>If the implementation type is <strong>managed</strong>, the framework automatically handles database operations. However, in <strong>unmanaged implementation</strong>, developers must explicitly write the logic for:</p><ul><li>Create</li><li>Update</li><li>Delete</li></ul><p>inside the behavior handler class.</p><p>This class contains methods that handle different RAP operations such as <strong>create, update, delete, read, authorization checks, and locking</strong>.</p><h3>Behavior Handler Class Definition</h3><pre>CLASS lhc_Z0028_EKKO_RV DEFINITION INHERITING FROM cl_abap_behavior_handler.<br>  PRIVATE SECTION.</pre><pre>    METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION<br>      IMPORTING keys REQUEST requested_authorizations FOR z0028_ekko_rv RESULT result.</pre><pre>    METHODS create FOR MODIFY<br>      IMPORTING entities FOR CREATE z0028_ekko_rv.</pre><pre>    METHODS update FOR MODIFY<br>      IMPORTING entities FOR UPDATE z0028_ekko_rv.</pre><pre>    METHODS delete FOR MODIFY<br>      IMPORTING keys FOR DELETE z0028_ekko_rv.</pre><pre>    METHODS read FOR READ<br>      IMPORTING keys FOR READ z0028_ekko_rv RESULT result.</pre><pre>    METHODS lock FOR LOCK<br>      IMPORTING keys FOR LOCK z0028_ekko_rv.</pre><pre>ENDCLASS.</pre><p>This class defines all the operations supported by the business object.</p><p>Key responsibilities of the handler class include:</p><ul><li>Handling <strong>create requests</strong></li><li>Handling <strong>update requests</strong></li><li>Handling <strong>delete operations</strong></li><li>Managing <strong>record locking</strong></li><li>Performing <strong>authorization checks</strong></li></ul><h3>Create Operation Implementation</h3><p>The <strong>create method</strong> inserts new records into the database table.</p><pre>METHOD create.<br>  LOOP AT entities INTO DATA(wa_ent).</pre><pre>    DATA(ls_po) = VALUE z0028ekko(<br>      Ebeln = wa_ent-%data-Ebeln<br>      Bukrs = wa_ent-%data-Bukrs<br>      Bstyp = wa_ent-%data-Bstyp<br>      Bsart = wa_ent-%data-Bsart<br>    ).</pre><pre>    INSERT z0028ekko FROM @ls_po.</pre><pre>  ENDLOOP.<br>ENDMETHOD.</pre><p>Explanation:</p><ul><li>The <strong>entities</strong> parameter contains the records sent from the UI or service.</li><li>%data contains the values of the fields being created.</li><li>A structure <strong>ls_po</strong> is constructed using the VALUE expression.</li><li>The record is inserted into the table <strong>Z0028EKKO</strong> using the INSERT statement.</li></ul><p>This method allows multiple records to be created in a single request by looping through the incoming entities.</p><h3>Update Operation Implementation</h3><p>The <strong>update method</strong> modifies existing records in the database.</p><p>One common issue in unmanaged RAP updates is that fields not sent from the UI may appear as <strong>initial values</strong> in %data. To prevent overwriting existing data with blank values, the %control structure is used to identify which fields were actually modified.</p><pre>METHOD update.</pre><pre>  DATA: lt_update TYPE TABLE OF z0028ekko.</pre><pre>  LOOP AT entities INTO DATA(wa_ent).</pre><pre>    SELECT SINGLE *<br>      FROM z0028ekko<br>      INTO @DATA(ls_db)<br>      WHERE ebeln = @wa_ent-%data-ebeln.</pre><pre>    IF sy-subrc = 0.</pre><pre>      IF wa_ent-%control-bukrs = if_abap_behv=&gt;mk-on.<br>        ls_db-bukrs = wa_ent-%data-bukrs.<br>      ENDIF.</pre><pre>      IF wa_ent-%control-bstyp = if_abap_behv=&gt;mk-on.<br>        ls_db-bstyp = wa_ent-%data-bstyp.<br>      ENDIF.</pre><pre>      IF wa_ent-%control-bsart = if_abap_behv=&gt;mk-on.<br>        ls_db-bsart = wa_ent-%data-bsart.<br>      ENDIF.</pre><pre>      APPEND ls_db TO lt_update.</pre><pre>    ENDIF.</pre><pre>  ENDLOOP.</pre><pre>  MODIFY z0028ekko FROM TABLE @lt_update.</pre><pre>ENDMETHOD.</pre><p>Explanation:</p><ul><li>The existing record is first read from the database.</li><li>%control identifies which fields were changed by the user.</li><li>Only those fields are updated in the structure.</li><li>The final records are collected in an internal table.</li><li>The MODIFY statement updates all records in a single database operation.</li></ul><p>This approach ensures that <strong>unchanged fields are not overwritten with initial values</strong>.</p><h3>Delete Operation Implementation</h3><p>The <strong>delete method</strong> removes records from the database.</p><pre>METHOD delete.<br>  LOOP AT keys INTO DATA(wa_keys).</pre><pre>    DELETE FROM z0028ekko<br>      WHERE ebeln = @wa_keys-Ebeln.</pre><pre>  ENDLOOP.<br>ENDMETHOD.</pre><p>Explanation:</p><ul><li>The <strong>keys</strong> parameter contains the primary keys of records to be deleted.</li><li>Each key is processed in a loop.</li><li>The corresponding database record is deleted using the DELETE statement.</li></ul><h3>Additional Methods</h3><p>The handler class also contains methods for:</p><p><strong>Authorization Handling</strong></p><p>get_instance_authorizations</p><p>This method can be used to implement instance-level authorization logic.</p><p><strong>Read Operation</strong></p><p>read</p><p>This method can be implemented to manually fetch records if required.</p><p><strong>Lock Handling</strong></p><p>lock</p><p>This method is used to manage record locking to prevent concurrent modifications.</p><p>In this example, these methods are currently left empty but can be extended depending on application requirements.</p><h3>Saver Class</h3><p>In unmanaged RAP, the <strong>Saver Class</strong> inherits from CL_ABAP_BEHAVIOR_SAVER and handles transactional processing.</p><pre>CLASS lsc_Z0028_EKKO_RV DEFINITION INHERITING FROM cl_abap_behavior_saver.<br>  PROTECTED SECTION.</pre><pre>    METHODS finalize REDEFINITION.<br>    METHODS check_before_save REDEFINITION.<br>    METHODS save REDEFINITION.<br>    METHODS cleanup REDEFINITION.<br>    METHODS cleanup_finalize REDEFINITION.</pre><pre>ENDCLASS.</pre><p>These methods control different phases of the RAP save sequence, such as validation and cleanup.</p><p>In this example, they are left empty because the database operations are handled directly inside the handler methods.</p><h3>Summary</h3><p>The <strong>Behavior Implementation Class</strong> is where the actual business logic of an unmanaged RAP application resides. It handles database operations manually and ensures that the data processing aligns with the behavior definition.</p><p>The implementation shown above demonstrates how to build a simple RAP business object capable of performing <strong>create, update, and delete operations</strong> while maintaining data integrity.</p><h3>5. Behavior Definition for Projection View</h3><p>After defining the behavior for the <strong>Root CDS View</strong>, the next step in the RAP architecture is creating the <strong>Behavior Definition for the Projection View</strong>.</p><p>The projection behavior definition acts as the <strong>consumption layer behavior</strong>. It does not implement any logic itself; instead, it exposes the operations defined in the <strong>root behavior</strong> to the service layer.</p><p>In other words, the projection behavior simply <strong>reuses the operations defined in the root entity</strong>.</p><h3>Projection Behavior Definition</h3><pre>projection;<br>strict ( 2 );</pre><pre>define behavior for Z0028_EKKO_PV<br>{<br>  use create;<br>  use update;<br>  use delete;<br>}</pre><h3>Understanding the Components</h3><h3>Projection Keyword</h3><p>projection;</p><p>This keyword indicates that the behavior definition belongs to a <strong>projection view</strong> rather than the root entity.</p><p>Projection behaviors do not implement business logic themselves. They only <strong>expose the capabilities defined in the root behavior</strong>.</p><h3>Strict Mode</h3><p>strict ( 2 );</p><p>Strict mode enforces RAP development standards and syntax checks. Version <strong>2</strong> enables stronger validations and ensures compatibility with the RAP programming model.</p><h3>Reusing Root Behavior Operations</h3><p>The use keyword is used to expose operations defined in the <strong>root behavior definition</strong>.</p><p>The following operations are reused:</p><ul><li><strong>use create</strong> — allows creation of new records</li><li><strong>use update</strong> — allows modification of existing records</li><li><strong>use delete</strong> — allows deletion of records</li></ul><p>These operations will ultimately trigger the implementation logic written in the <strong>behavior implementation class of the root entity</strong>.</p><h3>Why Projection Behavior is Required</h3><p>In RAP architecture, there is a clear separation between:</p><ul><li><strong>Data Model Layer</strong> → Root CDS View</li><li><strong>Consumption Layer</strong> → Projection View</li><li><strong>Business Logic Layer</strong> → Behavior Implementation</li></ul><p>The projection behavior definition ensures that the <strong>consumption layer can access the transactional capabilities of the root entity</strong> while maintaining this layered architecture.</p><h3>Role in the RAP Flow</h3><p>At this stage, the RAP model contains:</p><ol><li><strong>Root CDS View</strong> — represents the business object data model</li><li><strong>Projection CDS View</strong> — exposes the entity for consumption and UI annotations</li><li><strong>Root Behavior Definition</strong> — defines allowed operations and links to the implementation class</li><li><strong>Behavior Implementation Class</strong> — implements the actual CRUD logic</li><li><strong>Projection Behavior Definition</strong> — exposes those operations to the service layer</li></ol><p>The next step is to expose the projection entity through a <strong>Service Definition</strong> so that it can be consumed by applications such as <strong>Fiori Elements</strong>.</p><h3>6. Service Definition</h3><p>After defining the data model, behaviors, and implementation logic, the next step in the RAP architecture is to expose the business object through a <strong>Service Definition</strong>.</p><p>The service definition determines which entities are exposed as part of the <strong>OData service</strong>. In RAP, it usually exposes the <strong>Projection View</strong>, because this view represents the consumption layer and contains UI annotations.</p><p>In this example, the projection entity <strong>Z0028_EKKO_PV</strong> is exposed through the service definition.</p><h3>Service Definition</h3><pre>@EndUserText.label: &#39;Service Defintion for EKKO PV&#39;<br>define service ZIS_SO_EKKO {<br>  expose Z0028_EKKO_PV;<br>}</pre><h3>Explanation</h3><p>The annotation:</p><p>@EndUserText.label</p><p>provides a readable description of the service definition.</p><p>The statement:</p><p>expose Z0028_EKKO_PV;</p><p>exposes the <strong>Projection View</strong> as part of the service. This makes the entity available for consumption by external applications such as <strong>Fiori Elements, SAPUI5 applications, or other OData consumers</strong>.</p><p>The service definition does not implement any logic. It only determines <strong>which entities are part of the service interface</strong>.</p><p>At this stage, the business object is defined but not yet accessible externally. To make it available as an OData service, a <strong>Service Binding</strong> must be created.</p><h3>7. Service Binding</h3><p>A <strong>Service Binding</strong> connects the service definition to a specific <strong>communication protocol</strong>, such as OData. It also generates the runtime artifacts required for the service.</p><p>In this example, the service binding is created using <strong>OData V2 — UI</strong>, which is commonly used for <strong>Fiori Elements applications</strong>.</p><h3>Service Binding Configuration</h3><p>Service Binding Name: <strong>ZIS_SO_EKKO_UI</strong></p><p>Protocol: <strong>OData V2 — UI</strong></p><p>Service Definition: <strong>ZIS_SO_EKKO</strong></p><p>After creating the service binding, it must be <strong>activated and published</strong>.</p><h3>Steps to Activate the Service</h3><ol><li>Create a <strong>Service Binding</strong> in ADT.</li><li>Select protocol <strong>OData V2 — UI</strong>.</li><li>Link the binding to the service definition <strong>ZIS_SO_EKKO</strong>.</li><li>Activate the service binding.</li><li>Click <strong>Publish</strong>.</li></ol><p>Once published, the system generates the <strong>OData service endpoint</strong> and preview applications.</p><h3>Testing the Service</h3><p>After publishing the binding, the following options become available:</p><ul><li><strong>Preview in Fiori Elements List Report</strong></li><li><strong>Access the OData metadata</strong></li><li><strong>Test CRUD operations through the UI</strong></li></ul><p>The Fiori preview automatically generates a <strong>List Report and Object Page</strong> based on the UI annotations defined earlier in the <strong>Projection View</strong>.</p><h3>Final RAP Flow Recap</h3><p>The complete RAP flow implemented in this example follows these steps:</p><ol><li><strong>Root CDS View (</strong><strong>Z0028_EKKO_RV)</strong><br>Defines the core business object and database mapping.</li><li><strong>Projection CDS View (</strong><strong>Z0028_EKKO_PV)</strong><br>Exposes the entity for consumption and contains UI annotations.</li><li><strong>Behavior Definition (Root View)</strong><br>Defines transactional capabilities such as create, update, and delete.</li><li><strong>Behavior Implementation Class</strong><br>Implements the actual database logic for unmanaged RAP.</li><li><strong>Projection Behavior Definition</strong><br>Reuses operations from the root behavior.</li><li><strong>Service Definition (</strong><strong>ZIS_SO_EKKO)</strong><br>Exposes the projection entity as part of an OData service.</li><li><strong>Service Binding (OData V2 — UI)</strong><br>Publishes the service so it can be consumed by applications such as Fiori Elements.</li></ol><p>This layered architecture ensures a <strong>clear separation between data modeling, business logic, and service exposure</strong>, which is a key design principle of the <strong>ABAP RESTful Application Programming Model (RAP)</strong>.</p><p><strong>Fiori Preview of the RAP Application</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMbxG0urHycwgXqeI8IENw.png" /><figcaption>Fiori Elements List Report generated from the RAP service, displaying Purchase Orders with Company Code, Document Category, and Document Type, with support for Create and Delete operations.</figcaption></figure><p>This example demonstrates how a complete RAP application can be built using unmanaged implementation. By separating the architecture into CDS views, behavior definitions, implementation classes, and service exposure, RAP provides a clean and scalable way to build modern SAP applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ec64ad5aca3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating Adobe Forms using RAP and Exposing PDF via OData in SAP ABAP]]></title>
            <link>https://havish7728.medium.com/generating-adobe-forms-using-rap-and-exposing-pdf-via-odata-in-sap-abap-4cfa31563ebb?source=rss-c9e5bebeb9f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cfa31563ebb</guid>
            <category><![CDATA[sap-adobe-forms]]></category>
            <category><![CDATA[s4-hana]]></category>
            <category><![CDATA[abap]]></category>
            <category><![CDATA[rap]]></category>
            <category><![CDATA[sap]]></category>
            <dc:creator><![CDATA[Havish]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 07:18:10 GMT</pubDate>
            <atom:updated>2026-03-16T17:35:47.653Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern SAP S/4HANA development, <strong>RAP (RESTful ABAP Programming Model)</strong> is widely used for building scalable applications and exposing business data via <strong>OData services</strong>. A common requirement in enterprise applications is generating <strong>PDF documents such as invoices, sales orders, or delivery notes</strong> directly from RAP services.</p><p>This article explains how to <strong>generate an Adobe Form PDF using RAP and expose it through OData</strong>, allowing users to open the PDF directly from a Fiori application or browser.</p><p>The example uses <strong>Sales Order data from VBAK and VBAP</strong>.</p><h3>Architecture / Flow</h3><p>The solution follows this architecture:</p><ol><li>Create <strong>Adobe Form (SFP)</strong> to design the PDF layout.</li><li>Fetch data in the <strong>Adobe Form Interface</strong>.</li><li>Create a <strong>Global Class</strong> to generate the PDF.</li><li>Create a project in <strong>SEGW</strong> and redefine <strong>GET_STREAM </strong>method in OData to return the PDF stream.</li><li>Create a <strong>Root CDS View</strong> with a generated PDF link.</li><li>Create a <strong>Projection View</strong>.</li><li>Create <strong>Metadata Extension</strong>.</li><li>Create <strong>Service Definition and Service Binding</strong>.</li><li>Access the <strong>PDF via OData URL</strong>.</li></ol><h3>Step 1— Creating the Adobe Form Interface</h3><p>Next, create the <strong>interface for the Adobe Form</strong> which will fetch the data from SAP tables.</p><p>Interface Name:</p><pre>ZADOBE_SALES_DATA</pre><h3>Import Parameter</h3><pre>I_VBELN</pre><p>This parameter receives the <strong>Sales Order Number</strong>.</p><h3>Code Initialization</h3><p>In the interface, data is fetched from <strong>VBAK and VBAP</strong>.</p><pre>select single VBELN<br>       ERDAT<br>       VBTYP<br>       AUART<br>from vbak<br>into wa_vbak<br>where vbeln = i_vbeln.</pre><pre>if sy-subrc = 0.</pre><pre>  select VBELN<br>         POSNR<br>         MATNR<br>         MATKL<br>         ZWERT<br>         ZMENG<br>         ZIEME<br>         WAERK<br>  from vbap<br>  into table it_vbap<br>  where vbeln = i_vbeln.</pre><pre>endif.</pre><h3>Explanation</h3><ol><li>The first <strong>SELECT SINGLE</strong> statement fetches the <strong>Sales Order header data</strong> from the <strong>VBAK table</strong>.</li><li>If the record exists (SY-SUBRC = 0), the second <strong>SELECT statement</strong> fetches the <strong>item details</strong> from the <strong>VBAP table</strong>.</li></ol><p>These variables are then used inside the <strong>Adobe Form layout</strong> to populate the PDF fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GeZ9UiHmaO5U6xODN615nw.png" /></figure><h3>Step 2— Creating the Adobe Form (SFP)</h3><p>The first step is designing the <strong>Adobe Form layout</strong> that will display the Sales Order information.</p><p>Transaction used: <strong>SFP</strong></p><p>Form Name:</p><pre>ZADOBE_SALES_DATA</pre><p>The form displays the following fields:</p><h3>Header Fields (VBAK)</h3><ul><li>VBELN — Sales Document</li><li>ERDAT — Created On</li><li>VBTYP — Document Category</li><li>AUART — Sales Document Type</li></ul><h3>Item Fields (VBAP)</h3><ul><li>POSNR — Item</li><li>MATNR — Material</li><li>MATKL — Material Group</li><li>ZWERT — Net Value</li><li>ZMENG — Target Quantity</li><li>ZIEME — Unit of Measure</li><li>WAERK — Currency</li></ul><p>The layout was designed using <strong>Adobe LiveCycle Designer</strong> inside SFP.</p><p>The header section shows <strong>sales order information</strong>, while the table section displays <strong>item details</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrBpqAfEDBuAjiwaGYKkYw.png" /></figure><h3>Step 3 — Creating a Global Class to Generate the Adobe Form PDF</h3><p>After designing the Adobe Form and fetching the data through the form interface, the next step is to <strong>generate the PDF programmatically using ABAP</strong>.</p><p>In RAP-based applications, this is typically done through a <strong>Global ABAP Class</strong> which calls the Adobe Form function module and returns the <strong>PDF as XSTRING</strong>. This PDF can then be exposed through <strong>OData GET_STREAM</strong>.</p><h3>Creating the Global Class</h3><p>Create a <strong>global class</strong> (for example):</p><pre>Z0028_CL_SALES_OF</pre><p>Inside the class, create a <strong>static method</strong> that:</p><ol><li>Accepts the <strong>Sales Order number (VBELN)</strong></li><li>Calls the <strong>Adobe Form Function Module</strong></li><li>Generates the <strong>PDF output</strong></li><li>Returns the <strong>PDF content</strong></li></ol><h3>Method Implementation</h3><p>Below is the method used to generate the PDF.</p><pre>METHOD get_of.</pre><pre>  DATA:lv_docs   TYPE sfpdocparams,<br>       fm_name   TYPE funcname,<br>       lv_output TYPE sfpoutputparams,<br>       lv_out    TYPE fpformoutput.</pre><pre>  CALL FUNCTION &#39;FP_FUNCTION_MODULE_NAME&#39;<br>    EXPORTING<br>      i_name     = &#39;ZADOBE_SALES_DATA&#39;<br>    IMPORTING<br>      e_funcname = fm_name.</pre><pre>  lv_output-getpdf = &#39;X&#39;.</pre><pre>  CALL FUNCTION &#39;FP_JOB_OPEN&#39;<br>    CHANGING<br>      ie_outputparams = lv_output.</pre><pre>  IF sy-subrc &lt;&gt; 0.<br>* Implement suitable error handling here<br>  ENDIF.</pre><pre>  CALL FUNCTION fm_name<br>    EXPORTING<br>      /1bcdwb/docparams  = lv_docs<br>      i_vbeln            = i_vbeln<br>    IMPORTING<br>      /1bcdwb/formoutput = lv_out.</pre><pre>  IF sy-subrc &lt;&gt; 0.<br>* Implement suitable error handling here<br>  ENDIF.</pre><pre>  CALL FUNCTION &#39;FP_JOB_CLOSE&#39;.</pre><pre>  IF sy-subrc &lt;&gt; 0.<br>* Implement suitable error handling here<br>  ENDIF.</pre><pre>  re_pdf_content = lv_out-pdf.</pre><pre>ENDMETHOD.</pre><h3>Explanation of the Code</h3><h3>1. Getting the Generated Function Module</h3><pre>CALL FUNCTION &#39;FP_FUNCTION_MODULE_NAME&#39;</pre><p>Every Adobe Form automatically generates a <strong>function module</strong>.<br>This function call retrieves the <strong>technical name of the generated function module</strong>.</p><p>Example:</p><pre>/1BCDWB/SF00000012</pre><p>This allows the program to dynamically call the form.</p><h3>2. Opening the Adobe Form Processing Job</h3><pre>CALL FUNCTION &#39;FP_JOB_OPEN&#39;</pre><p>This initializes the <strong>Adobe Form processing environment</strong>.</p><p>The parameter:</p><pre>lv_output-getpdf = &#39;X&#39;</pre><p>ensures the system returns the <strong>PDF as binary data</strong> instead of printing it.</p><h3>3. Calling the Adobe Form</h3><pre>CALL FUNCTION fm_name</pre><p>This dynamically calls the <strong>generated Adobe Form function module</strong>.</p><p>Parameters passed:</p><p>ParameterPurpose/1BCDWB/DOCPARAMSDocument parametersI_VBELNSales order number/1BCDWB/FORMOUTPUTOutput containing PDF</p><p>The returned structure <strong>LV_OUT</strong> contains the <strong>generated PDF</strong>.</p><h3>4. Closing the Adobe Form Job</h3><pre>CALL FUNCTION &#39;FP_JOB_CLOSE&#39;</pre><p>This closes the Adobe Form processing session.</p><h3>5. Returning the PDF</h3><pre>re_pdf_content = lv_out-pdf.</pre><p>The PDF is returned as <strong>XSTRING</strong>, which will later be used in the <strong>OData GET_STREAM method</strong>.</p><h3>Result of This Step</h3><p>At this stage:</p><ul><li>The <strong>Adobe Form can be generated programmatically</strong></li><li>The method returns the <strong>PDF as XSTRING</strong></li><li>This method can now be used inside <strong>OData services</strong></li></ul><p>In the next step, we will use this method inside the <strong>OData GET_STREAM method</strong> to allow users to <strong>download the PDF directly from the browser</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L832YY0SQgUB8763V-wXQA.png" /></figure><h3>Step 4 — Redefining GET_STREAM Method to Return the PDF</h3><p>After generating the Adobe Form PDF using a global class, the next step is to <strong>expose the PDF through an OData service</strong> so that it can be opened directly in a browser or Fiori application.</p><p>In SAP Gateway, binary content such as <strong>PDF, images, or files</strong> is returned using the <strong>GET_STREAM method</strong>.</p><p>This method allows the OData service to send <strong>media content instead of JSON/XML data</strong>.</p><h3>Creating the OData Service</h3><p>Transaction used:</p><pre>SEGW</pre><p>Create a new project.</p><p>Example:</p><pre>Z0028_AF</pre><h3>Entity Type</h3><pre>Z0028_AF_RAP</pre><p>Property:</p><pre>VBELN</pre><h3>Entity Set</h3><pre>Z0028_AF_RAP_SET</pre><h3>Redefining the GET_STREAM Method</h3><p>Navigate to:</p><pre>Runtime Artifacts<br> → ZCL_Z0028_AF_DPC_EXT<br> → /IWBEP/IF_MGW_APPL_SRV_RUNTIME<br> → GET_STREAM</pre><p>Right-click and <strong>Redefine Method</strong>.</p><h3>GET_STREAM Method Implementation</h3><p>Below is the implementation used to generate and return the Adobe Form PDF.</p><pre>METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.</pre><pre>  DATA: lv_doc          TYPE vbeln,<br>        lv_form_content TYPE xstring.</pre><pre>  lv_doc = it_key_tab[ name = &#39;vbeln&#39; ]-value.</pre><pre>  lv_form_content =<br>        z0028_cl_sales_of=&gt;get_of(<br>            i_vbeln = lv_doc ).</pre><pre>  set_header(<br>    is_header = VALUE #(<br>        name  = &#39;Content-Disposition&#39;<br>        value = |inline; filename={ lv_doc }.pdf|<br>    )<br>  ).</pre><pre>  copy_data_to_ref(<br>    EXPORTING<br>      is_data = VALUE /iwfnd/if_mgw_core_runtime=&gt;ty_s_media_resource(<br>          mime_type = &#39;application/pdf&#39;<br>          value     = lv_form_content<br>      )<br>    CHANGING<br>      cr_data = er_stream ).</pre><pre>ENDMETHOD.</pre><h3>Code Explanation</h3><h3>1. Reading the Sales Order from the URL</h3><pre>lv_doc = it_key_tab[ name = &#39;vbeln&#39; ]-value.</pre><p>The <strong>Sales Order number</strong> is extracted from the OData request.</p><p>Example URL:</p><pre>/sap/opu/odata/sap/Z0028_AF/Z0028_AF_RAP_SET(&#39;0000000022&#39;)/$value</pre><p>Here:</p><pre>0000000022</pre><p>is read from <strong>IT_KEY_TAB</strong>.</p><h3>2. Calling the Adobe Form Generation Method</h3><pre>lv_form_content =<br>      z0028_cl_sales_of=&gt;get_of(<br>          i_vbeln = lv_doc ).</pre><p>This calls the <strong>global class method created earlier</strong> which:</p><ol><li>Calls the Adobe Form</li><li>Generates the PDF</li><li>Returns the <strong>PDF as XSTRING</strong></li></ol><h3>3. Setting the HTTP Header</h3><pre>set_header(<br>  is_header = VALUE #(<br>      name  = &#39;Content-Disposition&#39;<br>      value = |inline; filename={ lv_doc }.pdf|<br>  )<br>).</pre><p>This header instructs the browser to:</p><ul><li><strong>Open the PDF inline</strong></li><li>Use the filename:</li></ul><pre>0000000022.pdf</pre><h3>4. Returning the PDF Stream</h3><pre>copy_data_to_ref</pre><p>This converts the <strong>XSTRING PDF data</strong> into a <strong>media resource</strong> that the OData service can return.</p><pre>mime_type = &#39;application/pdf&#39;</pre><h3>Testing the Service</h3><p>After activating the service in:</p><pre>/IWFND/MAINT_SERVICE</pre><p>You can open the PDF directly in the browser.</p><p>Example URL:</p><pre>/sap/opu/odata/sap/Z0028_AF/Z0028_AF_RAP_SET(&#39;0000000022&#39;)/$value</pre><p>Result:</p><p>The <strong>Sales Order PDF generated by the Adobe Form opens in the browser</strong>.</p><h3>Result of This Step</h3><p>At this stage:</p><ul><li>Adobe Form is <strong>generated dynamically</strong></li><li>PDF is <strong>returned via OData</strong></li><li>The document can be <strong>opened directly in a browser</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZ_URGisKNp6sDAfHBueZQ.png" /></figure><h3>Step 5 — Creating the Root CDS View with the PDF Link</h3><p>After exposing the Adobe Form through <strong>OData GET_STREAM</strong>, the next step is to make the <strong>PDF accessible from RAP</strong>.</p><p>This is achieved by creating a <strong>Root CDS View</strong> that:</p><ul><li>Retrieves Sales Order data from <strong>VBAK</strong></li><li>Displays a <strong>Preview button</strong></li><li>Dynamically generates a <strong>PDF link</strong></li></ul><p>This link will open the <strong>Adobe Form PDF directly from the browser or Fiori application</strong>.</p><h3>Creating the Root CDS View</h3><p>Create a <strong>Root View Entity</strong>.</p><p>Example:</p><pre>ZIS_SO_VBAK</pre><p>This CDS view reads data from the <strong>VBAK table</strong> and constructs the <strong>PDF access URL</strong>.</p><h3>Root CDS View Code</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED<br>@EndUserText.label: &#39;Sales order header&#39;<br>@Metadata.ignorePropagatedAnnotations: true<br>define root view entity ZIS_SO_VBAK<br>  as select from vbak<br>{</pre><pre>  key vbeln,<br>      erdat,<br>      vbtyp,<br>      auart,<br>      &#39;Preview File&#39; as ShowPDF,<br>      concat(&#39;/sap/opu/odata/SAP/Z0028_AF_SRV/Z0028_AF_RAP_SET(&#39;&#39;&#39;,concat(vbeln,&#39;&#39;&#39;)/$value&#39;)) as Link<br>}</pre><h3>Explanation of the CDS View</h3><h3>Authorization Check</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED</pre><p>This disables authorization checks for the CDS view.</p><h3>Label Annotation</h3><pre>@EndUserText.label: &#39;Sales order header&#39;</pre><p>Defines the <strong>description of the CDS view</strong> that appears in development tools.</p><h3>Ignore Propagated Annotations</h3><pre>@Metadata.ignorePropagatedAnnotations: true</pre><p>This ensures only annotations defined in this CDS view are used.</p><h3>Creating the Preview Column</h3><pre>&#39;Preview File&#39; as ShowPDF</pre><p>This creates a <strong>virtual column</strong> that will later appear as a <strong>button or label in the UI</strong>.</p><h3>Generating the Dynamic PDF Link</h3><p>The most important part of this CDS view is the <strong>dynamic link generation</strong>.</p><pre>concat(&#39;/sap/opu/odata/SAP/Z0028_AF_SRV/Z0028_AF_RAP_SET(&#39;&#39;&#39;,concat(vbeln,&#39;&#39;&#39;)/$value&#39;)) as Link</pre><p>This builds the <strong>OData URL dynamically for each Sales Order</strong>.</p><p>Example generated link:</p><pre>/sap/opu/odata/SAP/Z0028_AF_SRV/Z0028_AF_RAP_SET(&#39;50000001&#39;)/$value</pre><p>When this URL is opened:</p><ul><li>The <strong>GET_STREAM method is triggered</strong></li><li>The <strong>Adobe Form PDF is generated</strong></li><li>The <strong>PDF opens in the browser</strong></li></ul><h3>Example Result</h3><p>VBELNERDATAUARTShowPDFLink5000000112.03.2026ORPreview File/sap/opu/…</p><p>Clicking the link opens the <strong>Sales Order PDF</strong>.</p><h3>Result of This Step</h3><p>At this stage:</p><ul><li>RAP CDS View contains <strong>Sales Order data</strong></li><li>A <strong>dynamic link to the Adobe Form PDF</strong> is generated</li><li>Each Sales Order can open <strong>its own PDF document</strong></li></ul><h3>Step 6 — Creating the Projection View for RAP</h3><p>After creating the <strong>Root CDS View</strong>, the next step in RAP development is to create a <strong>Projection View</strong>.</p><p>The Projection View acts as a <strong>consumption layer</strong>. It exposes only the fields required by the <strong>service layer or UI application</strong> while keeping the root entity as the <strong>data source</strong>.</p><p>This step is essential because <strong>RAP services should always expose projection views instead of the root entity directly</strong>.</p><h3>Creating the Projection View</h3><p>Create a <strong>Projection View Entity</strong>.</p><p>Example:</p><pre>ZIS_SO_VBAK_PO</pre><p>This view will project the fields from the <strong>Root CDS View (ZIS_SO_VBAK)</strong>.</p><h3>Projection View Code</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED<br>@EndUserText.label: &#39;Projection View for ZIS_SO_VBAK&#39;<br>@Metadata.ignorePropagatedAnnotations: true<br>@Metadata.allowExtensions: true<br>define root view entity ZIS_SO_VBAK_PO<br>  provider contract transactional_query<br>  as projection on ZIS_SO_VBAK<br>{<br>  key vbeln,<br>      erdat,<br>      vbtyp,<br>      auart,<br>      ShowPDF,<br>      Link<br>}</pre><h3>Explanation of the Projection View</h3><h3>Authorization Annotation</h3><pre>@AccessControl.authorizationCheck: #NOT_REQUIRED</pre><p>This disables authorization checks for this CDS view.</p><h3>Label Annotation</h3><pre>@EndUserText.label: &#39;Projection View for ZIS_SO_VBAK&#39;</pre><p>This defines the description for the projection view.</p><h3>Allow Metadata Extensions</h3><pre>@Metadata.allowExtensions: true</pre><p>This enables the CDS view to be <strong>extended using Metadata Extensions</strong>, which is important for adding <strong>UI annotations later</strong>.</p><h3>Provider Contract</h3><pre>provider contract transactional_query</pre><p>This defines the <strong>behavior of the projection view</strong> in RAP.</p><p>transactional_query means</p><ul><li>The view supports <strong>data queries</strong></li><li>It can later be extended for <strong>transactional operations</strong></li></ul><h3>Projection Source</h3><pre>as projection on ZIS_SO_VBAK</pre><p>This tells the system that the projection view <strong>consumes data from the root CDS view</strong>.</p><h3>Result of This Step</h3><p>After creating the projection view:</p><ul><li>The <strong>Root CDS View handles the data logic</strong></li><li>The <strong>Projection View exposes the data to RAP</strong></li><li>The <strong>PDF link and preview field become available to the service layer</strong></li></ul><h3>Step 7 — Creating the Metadata Extension for UI Annotations</h3><p>After creating the <strong>Projection View</strong>, the next step is to define how the data should appear in the <strong>UI (Fiori Elements or RAP Preview)</strong>.</p><p>Instead of placing UI annotations directly inside the CDS view, SAP recommends using a <strong>Metadata Extension</strong>. This keeps the <strong>data model clean</strong> and separates <strong>UI logic from business logic</strong>.</p><h3>Creating the Metadata Extension</h3><p>Create a <strong>Metadata Extension</strong> for the projection view:</p><pre>ZIS_SO_VBAK_PO</pre><p>This extension defines:</p><ul><li>Header information for the application</li><li>Fields displayed in the list report</li><li>A <strong>clickable PDF link</strong> to open the Adobe Form</li></ul><h3>Metadata Extension Code</h3><pre>@Metadata.layer: #CORE </pre><pre>@UI.headerInfo:{<br>typeName: &#39;Sales Order&#39;,<br>typeNamePlural: &#39;Sale Orders&#39;,<br>title:{<br>type:#STANDARD,<br>label:&#39;Document&#39;,<br>value:&#39;Vbeln&#39;<br>}<br>}<br>annotate entity ZIS_SO_VBAK_PO<br>with<br>{</pre><pre>@UI:{ lineItem: [{ position : 10}] }<br>vbeln;</pre><pre>@UI:{ lineItem: [{ position : 20}]}<br>erdat;</pre><pre>@UI:{ lineItem: [{ position : 30}]}<br>vbtyp;</pre><pre>@UI:{ lineItem: [{ position : 40}]}<br>auart;</pre><pre>@UI.lineItem:[<br>    { position: 50, type: #WITH_URL, url:&#39;Link&#39;, label: &#39;PDF&#39; }<br>]<br>ShowPDF;</pre><pre>//@UI:{ lineItem: [{ position : 60}]}<br>//Link;<br>    <br>}</pre><h3>Explanation of the Metadata Extension</h3><h3>Metadata Layer</h3><pre>@Metadata.layer: #CORE</pre><p>This indicates that the annotations belong to the <strong>core layer</strong> of the application.</p><h3>Header Information for the UI</h3><pre>@UI.headerInfo</pre><p>This defines how the object appears in the <strong>application header</strong>.</p><pre>typeName: &#39;Sales Order&#39;<br>typeNamePlural: &#39;Sale Orders&#39;</pre><p>Defines the name of the business object.</p><pre>title:{<br>type:#STANDARD,<br>label:&#39;Document&#39;,<br>value:&#39;Vbeln&#39;<br>}</pre><p>This displays the <strong>Sales Order number as the main title</strong>.</p><h3>List Report Fields</h3><p>The following annotations define the columns in the <strong>Fiori List Report</strong>.</p><h3>Sales Order Number</h3><pre>@UI:{ lineItem: [{ position : 10}] }<br>vbeln;</pre><h3>Created Date</h3><pre>@UI:{ lineItem: [{ position : 20}]}<br>erdat;</pre><h3>Document Category</h3><pre>@UI:{ lineItem: [{ position : 30}]}<br>vbtyp;</pre><h3>Sales Document Type</h3><pre>@UI:{ lineItem: [{ position : 40}]}<br>auart;</pre><h3>Creating the PDF Button</h3><p>The most important annotation is for the <strong>PDF preview link</strong>.</p><pre>@UI.lineItem:[<br>    { position: 50, type: #WITH_URL, url:&#39;Link&#39;, label: &#39;PDF&#39; }<br>]<br>ShowPDF;</pre><p>This creates a <strong>clickable link in the UI</strong>.</p><h3>How it works</h3><ul><li>The column <strong>ShowPDF</strong> appears as <strong>PDF</strong></li><li>The annotation uses the <strong>Link field as the URL</strong></li><li>Clicking the link opens the <strong>Adobe Form PDF</strong></li></ul><p>Example generated URL:</p><pre>/sap/opu/odata/SAP/Z0028_AF_SRV/Z0028_AF_RAP_SET(&#39;50000001&#39;)/$value</pre><p>This triggers the <strong>GET_STREAM method</strong> created earlier.</p><h3>Why the Link Field is Hidden</h3><p>The Link field is commented out:</p><pre>//@UI:{ lineItem: [{ position : 60}]}<br>//Link;</pre><p>Reason:</p><ul><li>The link is <strong>only used internally</strong></li><li>Users should see <strong>only the PDF button</strong>, not the raw URL</li></ul><h3>Step 8 — Creating the Service Definition</h3><p>After creating the <strong>Projection View and Metadata Extension</strong>, the next step is to expose the data model through a <strong>RAP Service Definition</strong>.</p><p>The <strong>Service Definition</strong> determines which CDS entities are exposed to the service layer and eventually consumed by <strong>Fiori applications or external clients</strong>.</p><h3>Creating the Service Definition</h3><p>Create a <strong>Service Definition</strong>.</p><p>Example name:</p><pre>ZIS_SO_VBAK</pre><p>This service will expose the <strong>Projection View (ZIS_SO_VBAK_PO)</strong> created earlier.</p><h3>Service Definition Code</h3><pre>@EndUserText.label: &#39;Service Defintion for VBAK PV&#39;<br>define service ZIS_SO_VBAK {<br>  expose ZIS_SO_VBAK_PO;<br>}</pre><h3>Explanation</h3><h3>Label Annotation</h3><pre>@EndUserText.label: &#39;Service Defintion for VBAK PV&#39;</pre><p>Defines a description for the service definition that appears in development tools.</p><h3>Exposing the Projection View</h3><pre>expose ZIS_SO_VBAK_PO;</pre><p>This statement exposes the <strong>Projection View entity</strong> to the service.</p><p>Only entities listed here will be available in the <strong>Service Binding and OData service</strong>.</p><h3>Result of This Step</h3><p>After activating the Service Definition:</p><ul><li>The <strong>Projection View becomes available for service binding</strong></li><li>The RAP service can now expose the <strong>Sales Order data along with the PDF preview functionality</strong></li></ul><p>However, the service is still <strong>not accessible externally</strong>. The final step is to create a <strong>Service Binding</strong>, which publishes the service as an <strong>OData service</strong>.</p><h3>Final Step — Creating the Service Binding</h3><p>Create a <strong>Service Binding</strong> and bind the service definition:</p><pre>ZIS_SO_VBAK</pre><p>Binding Type:</p><pre>OData V2</pre><p>Steps:</p><ol><li>Create Service Binding</li><li>Select <strong>OData V2</strong></li><li>Bind the service definition</li><li>Activate the binding</li><li>Click <strong>Preview</strong></li></ol><h3>Final Result</h3><p>After completing all steps:</p><ul><li>RAP application displays <strong>Sales Orders</strong></li><li>Each row contains a <strong>PDF button</strong></li><li>Clicking the button opens the <strong>Adobe Form generated PDF</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9U0trix31NjbI3c80da8jA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohbqqeX-1S3I_Rq64y1gGA.png" /></figure><h3>Conclusion</h3><p>This implementation demonstrates how to integrate <strong>Adobe Forms with RAP and OData</strong> in SAP S/4HANA.</p><p>Key highlights of the solution:</p><ul><li>Adobe Form designed using <strong>SFP</strong></li><li>PDF generated using <strong>ABAP class</strong></li><li><strong>GET_STREAM method</strong> used to return binary PDF</li><li>CDS View dynamically generates <strong>PDF links</strong></li><li>RAP <strong>Projection View and Metadata Extensions</strong> control the UI</li><li>Service Definition and Binding expose the functionality</li></ul><p>The result is a <strong>fully integrated RAP application</strong> where users can generate and view <strong>Sales Order PDFs directly from the UI</strong>.</p><p>This completes the <strong>full end-to-end implementation of Adobe Forms with RAP and OData</strong>.</p><p>Special thanks to <a href="https://medium.com/u/e8d6b9f05f08">Surya teja Vulli</a> for helping me out!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cfa31563ebb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>