0% found this document useful (0 votes)
90 views

ABAP RAP Application to Create a PO Using Unmanned Scenario

pdf

Uploaded by

Damini Gadde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

ABAP RAP Application to Create a PO Using Unmanned Scenario

pdf

Uploaded by

Damini Gadde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

RAP Application to create Purchase order- UnManaged Scenario


1. Create Database Tables
2. Create CDS Views
3. Create the Projection Views
4. Create the Behavior Definitions
5. Behavior Implementation to perform CRUD operations
6. Create the Metadata Extensions
7. Create the Service Definition
8. Create the Service Binding
9. Check the service URLS for metadata and Purchase order details
10. Preview the Purchase order Application
11. Add the Input Help for the Field to show the list of possible values
12. Improve the UI User Experience
13. Perform the CRUD Operations
14. Perform the Action

1. Create Database Tables:

Create a Database Table for Purchase Order Header table


@EndUserText.label : 'Table for Purchase Order Header'
@AbapCatalog.enhancement.category : #EXTENSIBLE_ANY
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #ALLOWED
define table ztb_po_head {

key client : abap.clnt not null;


key po_num : ebeln not null;
doc_cat : bstyp;
type : abap.char(2);
comp_code : bukrs;
org : ekorg;
status : abap.char(1);
vendor : lifnr;
plant : werks_d;
create_by : abp_creation_user;
created_date_time : abp_creation_tstmpl;
changed_date_time : abp_locinst_lastchange_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;

Email: [email protected] 1|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Populate and check the table data.

Create a Database Table for Purchase Order Items table


@EndUserText.label : 'Table for Purchase Order Items'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztb_po_items {

key client : abap.clnt not null;


@AbapCatalog.foreignKey.screenCheck : true
key po_num : ebeln not null
with foreign key [1..*,1] ztb_po_head
where client = ztb_po_items.client
and po_num = ztb_po_items.po_num;
key po_item : ebelp not null;
item_text : abap.char(40);
material : abap.char(40);
plant : werks_d;
stor_loc : lgort_d;
@Semantics.quantity.unitOfMeasure : 'ztb_po_items.uom'
qty : abap.quan(13,3);
uom : abap.unit(3);
@Semantics.amount.currencyCode : 'ztb_po_items.price_unit'
product_price : abap.curr(10,2);
price_unit : abap.cuky;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_time;

Populate and check the table Data

Email: [email protected] 2|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

2. Create CDS Views

Create a CDS Root View Entity for Purchase Order Header Table
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS View for PO Head'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
define root view entity ZI_PO_HEAD
as select from ztb_po_head
//association [0..*] to ZI_PO_ITMS as _PO_items on $projection.PoNum =
_PO_items.PoNum
composition [0..*] of ZI_PO_ITMS as _PO_items
{
key po_num as PoNum,
doc_cat as DocCat,
type as Type,
comp_code as CompCode,
org as Org,
status as Status,
vendor as Vendor,
plant as Plant,
create_by as CreateBy,
created_date_time as CreatedDateTime,
changed_date_time as ChangedDateTime,
local_last_changed_by as LocalLastChangedBy,
_PO_items // Make association public
}

Create a CDS View Entity for Purchase Order Items table


@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Data Definition for Items Table'
@Metadata.ignorePropagatedAnnotations: false
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
@Metadata.allowExtensions: true
define view entity ZI_PO_ITMS as select from ztb_po_items
association to parent ZI_PO_HEAD as _po_hd on $projection.PoNum = _po_hd.PoNum
{
key po_num as PoNum,
key po_item as PoItem,
item_text as ItemText,
material as Material,
plant as Plant,
stor_loc as StorLoc,
@Semantics.quantity.unitOfMeasure: 'uom'
qty as Qty,
uom as Uom,
@Semantics.amount.currencyCode: 'PriceUnit'
product_price as ProductPrice,

Email: [email protected] 3|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

price_unit as PriceUnit,
local_last_changed_by as LocalLastChangedBy,
local_last_changed_at as LocalLastChangedAt,
_po_hd
}

3. Create the Projection Views


Create a Projection root view for Purchase order Header
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Projection view for PO Head'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
@Search.searchable: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}

@UI:{ headerInfo: {
typeName: 'Purchase Order',
typeNamePlural: 'Purchase Orders',
title: {
type: #STANDARD,
value: 'PoNum'
}
} }
define root view entity ZC_PO_HEAD provider contract transactional_query
as projection on ZI_PO_HEAD
{
@Search.defaultSearchElement: true
key PoNum,
DocCat,
Type,
CompCode,
Org,
Status,
/* @Consumption.valueHelpDefinition: [{

entity: {
name: 'ZI_VEND',
element: 'Vendor'
}}] */
Vendor,
Plant,
CreateBy,
CreatedDateTime,
ChangedDateTime,
LocalLastChangedBy,
/* Associations */
_PO_items : redirected to composition child ZC_PO_ITEMS

Email: [email protected] 4|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Create a Projection view for Purchase order Items


@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Projection view for PO Items'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZC_PO_ITEMS as projection on ZI_PO_ITMS
{
key PoNum,
key PoItem,
ItemText,
Material,
Plant,
StorLoc,
@Semantics.quantity.unitOfMeasure: 'uom'
Qty,
Uom,
@Semantics.amount.currencyCode: 'PriceUnit'
ProductPrice,
PriceUnit,
LocalLastChangedBy,
LocalLastChangedAt,
/* Associations */
_po_hd : redirected to parent ZC_PO_HEAD
}

Email: [email protected] 5|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

4. Create the Behavior Definitions

Create a Behavior Definition for Purchase Order Header


Also, add the Action – Change status to change the Purchase Order status
unmanaged implementation in class zbp_i_po_head unique;
//strict ( 2 );

define behavior for ZI_PO_HEAD alias PO_HD


lock master
//authorization master ( instance )
//etag master <field_name>
{
create;
update;
delete;
field ( readonly :update ) PoNum;
field ( mandatory ) DocCat, CompCode, Org, Status, Vendor;
action ( features : instance ) Change_status result [1] $self;
association _PO_items { create; }
mapping for ztb_po_head
{
PoNum = po_num;
DocCat = doc_cat;
Type = type;
CompCode = comp_code;
Org = org;
Status = status;
Vendor = vendor;
CreateBy = create_by;
CreatedDateTime = created_date_time;
ChangedDateTime = changed_date_time;
LocalLastChangedBy = local_last_changed_by;
}
}

define behavior for ZI_PO_ITMS alias PO_IT


implementation in class zbp_i_po_items unique
lock dependent by _po_hd
// authorization dependent by _po_hd
//etag master <field_name>
{
create;
update;
delete;
field ( readonly : update ) PoNum, PoItem;
field ( mandatory ) ItemText, Material, Uom, Plant, StorLoc, Qty, ProductPrice,
PriceUnit;
association _po_hd;
mapping for ztb_po_items
{
PoNum = po_num;
PoItem = po_item;
ItemText = item_text;
Material = Material;

Email: [email protected] 6|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Uom = Uom;
Plant = Plant;
StorLoc = stor_loc;
Qty = Qty;
ProductPrice = product_price;
PriceUnit = price_unit;
LocalLastChangedAt = local_last_changed_at;
LocalLastChangedBy = local_last_changed_by;
}
}

Create a Behavior definition for the Purchase Order Header Projection View
projection;
//strict ( 2 ); //Uncomment this line in order to enable strict mode 2. The strict
mode has two variants (strict(1), strict(2)) and is prerequisite to be future proof
regarding syntax and to be able to release your BO.

define behavior for ZC_PO_HEAD //alias <alias_name>


{
use create;
use update;
use delete;

use action Change_status;

use association _PO_items { create; }


}

define behavior for ZC_PO_ITEMS //alias <alias_name>


{
use create;
use update;
use delete;

use association _po_hd;


}

Email: [email protected] 7|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

5. Behavior Implementation to perform CRUD operations

Behavior implementation class for the Purchase Order Header


Also add the logic for the Action - Change status.
Global class-
CLASS zbp_i_po_head DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zi_po_head.
ENDCLASS.

CLASS zbp_i_po_head IMPLEMENTATION.


ENDCLASS.

Local Class-
CLASS lhc_PO_HD DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.

METHODS get_instance_features FOR INSTANCE FEATURES


IMPORTING keys REQUEST requested_features FOR po_hd RESULT result.

METHODS create FOR MODIFY


IMPORTING entities FOR CREATE po_hd.

METHODS update FOR MODIFY


IMPORTING entities FOR UPDATE po_hd.

METHODS delete FOR MODIFY


IMPORTING keys FOR DELETE po_hd.

METHODS read FOR READ


IMPORTING keys FOR READ po_hd RESULT result.

METHODS lock FOR LOCK


IMPORTING keys FOR LOCK po_hd.

METHODS rba_Po_items FOR READ


IMPORTING keys_rba FOR READ po_hd\_Po_items FULL result_requested RESULT result
LINK association_links.

METHODS cba_Po_items FOR MODIFY


IMPORTING entities_cba FOR CREATE po_hd\_Po_items.

METHODS Change_status FOR MODIFY


IMPORTING keys FOR ACTION po_hd~Change_status RESULT result.

ENDCLASS.

CLASS lhc_PO_HD IMPLEMENTATION.

METHOD get_instance_features.

READ ENTITIES OF zi_po_head IN LOCAL MODE


ENTITY po_hd
FIELDS ( PoNum Status )

Email: [email protected] 8|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

WITH CORRESPONDING #( keys )


RESULT DATA(lt_po_result)
FAILED failed.

result =
VALUE #( FOR ls_po IN lt_po_result
( %key = ls_po-%key
%features-%action-Change_status = COND #( WHEN ls_po-status = 'B'
THEN if_abap_behv=>fc-o-
disabled
ELSE if_abap_behv=>fc-o-
enabled )
) ).

ENDMETHOD.

METHOD create.

DATA : ls_po_hd TYPE ztb_po_head.

READ TABLE entities ASSIGNING FIELD-SYMBOL(<lfs_po_hd>) INDEX 1.


IF sy-subrc EQ 0.
ls_po_hd = CORRESPONDING #( <lfs_po_hd> MAPPING FROM ENTITY USING CONTROL ).
ENDIF.

INSERT ztb_po_head FROM @ls_po_hd.


IF sy-subrc IS INITIAL.
mapped-po_hd = VALUE #( BASE mapped-po_hd
( %cid = <lfs_po_hd>-%cid
PoNum = ls_po_hd-po_num
) ).
ELSE.

APPEND VALUE #( %cid = <lfs_po_hd>-%cid


PoNum = <lfs_po_hd>-PoNum )
TO failed-po_hd.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity = if_abap_behv_message=>severity-
error )
%key-PoNum = <lfs_po_hd>-PoNum
%cid = <lfs_po_hd>-%cid
%create = 'X'
PoNum = <lfs_po_hd>-PoNum )
TO reported-po_hd.

ENDIF.

ENDMETHOD.

METHOD update.

Email: [email protected] 9|P ag e


Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

DATA : ls_po TYPE zi_po_head,


ls_po_hd TYPE ztb_po_head.

READ TABLE entities ASSIGNING FIELD-SYMBOL(<lfs_po_hd>) INDEX 1.


IF sy-subrc EQ 0.
SELECT SINGLE * FROM ztb_po_head WHERE po_num EQ @<lfs_po_hd>-PoNum INTO
@ls_po_hd.
* ls_po_hd = CORRESPONDING #( <lfs_po_hd> MAPPING FROM ENTITY USING CONTROL ).
IF <lfs_po_hd>-CompCode IS NOT INITIAL.
ls_po_hd-comp_code = <lfs_po_hd>-CompCode.
ENDIF.
IF <lfs_po_hd>-DocCat IS NOT INITIAL.
ls_po_hd-doc_cat = <lfs_po_hd>-DocCat.
ENDIF.
*
IF <lfs_po_hd>-Org IS NOT INITIAL.
ls_po_hd-org = <lfs_po_hd>-Org.
ENDIF.
**
IF <lfs_po_hd>-Plant IS NOT INITIAL.
ls_po_hd-plant = <lfs_po_hd>-Plant.
ENDIF.
**
IF <lfs_po_hd>-PoNum IS NOT INITIAL.
ls_po_hd-po_num = <lfs_po_hd>-PoNum.
ENDIF.
*
IF <lfs_po_hd>-Status IS NOT INITIAL.
ls_po_hd-status = <lfs_po_hd>-Status.
ENDIF.
*
IF <lfs_po_hd>-Type IS NOT INITIAL.
ls_po_hd-type = <lfs_po_hd>-Type.
ENDIF.
*
IF <lfs_po_hd>-Vendor IS NOT INITIAL.
ls_po_hd-vendor = <lfs_po_hd>-Vendor.
ENDIF.
*
ENDIF.

UPDATE ztb_po_head FROM @ls_po_hd .


IF sy-subrc IS INITIAL.
mapped-po_hd = VALUE #( BASE mapped-po_hd
( %cid = <lfs_po_hd>-%cid_ref
PoNum = ls_po_hd-po_num
) ).
ELSE.

APPEND VALUE #( %cid = <lfs_po_hd>-%cid_ref


PoNum = <lfs_po_hd>-PoNum )
TO failed-po_hd.

APPEND VALUE #( %msg = new_message( id = '00'

Email: [email protected] 10 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

number = '001'
v1 = 'Invalid Details'
severity = if_abap_behv_message=>severity-
error )
%key-PoNum = <lfs_po_hd>-PoNum
%cid = <lfs_po_hd>-%cid_ref
%update = 'X'
PoNum = <lfs_po_hd>-PoNum )
TO reported-po_hd.

ENDIF.

ENDMETHOD.

METHOD delete.

READ TABLE keys ASSIGNING FIELD-SYMBOL(<lfs_keys>) INDEX 1.


IF sy-subrc EQ 0.
DELETE FROM ztb_po_head WHERE po_num EQ @<lfs_keys>-PoNum.
IF sy-subrc NE 0.
APPEND VALUE #( %cid = <lfs_keys>-%cid_ref
PoNum = <lfs_keys>-PoNum )
TO failed-po_hd.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity =
if_abap_behv_message=>severity-error )
%key-PoNum = <lfs_keys>-PoNum
%cid = <lfs_keys>-%cid_ref
%delete = 'X'
PoNum = <lfs_keys>-PoNum )
TO reported-po_hd.
ENDIF.
ENDIF.

ENDMETHOD.

METHOD read.

SELECT * FROM ztb_po_head


FOR ALL ENTRIES IN @keys
WHERE po_num = @keys-PoNum
INTO CORRESPONDING FIELDS OF TABLE @result.

ENDMETHOD.

METHOD lock.
ENDMETHOD.

METHOD rba_Po_items.
ENDMETHOD.

METHOD cba_Po_items.

Email: [email protected] 11 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

DATA : ls_po_items TYPE ztb_po_items.

READ TABLE entities_cba ASSIGNING FIELD-SYMBOL(<lfs_po_items>) INDEX 1.


IF sy-subrc EQ 0.
DATA(lv_po) = <lfs_po_items>-PoNum.
ENDIF.

READ TABLE <lfs_po_items>-%target ASSIGNING FIELD-SYMBOL(<lfs_items>) INDEX 1.


IF sy-subrc EQ 0.
DATA(ls_items) = CORRESPONDING ztb_po_items( <lfs_items> MAPPING FROM ENTITY
USING CONTROL ).
ENDIF.

INSERT ztb_po_items FROM @ls_items.


IF sy-subrc IS INITIAL.

INSERT VALUE #( %cid = <lfs_po_items>-%cid_ref


PoNum = lv_po
PoItem = ls_items-po_item
) INTO TABLE mapped-po_it.

ELSE.
APPEND VALUE #( %cid = <lfs_po_items>-%cid_ref
PoNum = lv_po
PoItem = ls_items-po_item
) TO failed-po_it.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity = if_abap_behv_message=>severity-
error )
%key-PoNum = lv_po
%key-PoItem = ls_items-po_item
%cid = <lfs_po_items>-%cid_ref
PoNum = lv_po
PoItem = ls_items-po_item
) TO reported-po_it.

ENDIF.

ENDMETHOD.

METHOD Change_status.

DATA : ls_po_hd TYPE ztb_po_head.

MODIFY ENTITIES OF zi_po_head IN LOCAL MODE


ENTITY po_hd
UPDATE FROM VALUE #( FOR key IN keys
( PoNum = key-PoNum
Status = 'B'

Email: [email protected] 12 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

%control-Status = if_abap_behv=>mk-on ) )
FAILED failed
REPORTED reported.

READ ENTITIES OF zi_po_head IN LOCAL MODE


ENTITY po_hd
ALL FIELDS WITH
CORRESPONDING #( keys )
RESULT DATA(pos).

result = VALUE #( FOR po IN pos


( %tky = po-%tky
%param = po ) ).

* READ TABLE keys INTO DATA(key) INDEX 1.


* SELECT SINGLE * FROM ztb_po_head WHERE po_num = @key-PoNum INTO @ls_po_hd.
* ls_po_hd-status = 'B'.
*
* UPDATE ztb_po_head FROM @ls_po_hd.

ENDMETHOD.

ENDCLASS.

CLASS lsc_ZI_PO_HEAD DEFINITION INHERITING FROM cl_abap_behavior_saver.


PROTECTED SECTION.

METHODS finalize REDEFINITION.

METHODS check_before_save REDEFINITION.

METHODS save REDEFINITION.

METHODS cleanup REDEFINITION.

METHODS cleanup_finalize REDEFINITION.

ENDCLASS.

CLASS lsc_ZI_PO_HEAD IMPLEMENTATION.

METHOD finalize.
ENDMETHOD.

METHOD check_before_save.
ENDMETHOD.

METHOD save.
ENDMETHOD.

METHOD cleanup.
ENDMETHOD.

METHOD cleanup_finalize.

Email: [email protected] 13 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

ENDMETHOD.

ENDCLASS.

Behavior implementation class for the Purchase Order Items


Global Class-
CLASS zbp_i_po_items DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zi_po_head.
ENDCLASS.

CLASS zbp_i_po_items IMPLEMENTATION.


ENDCLASS.

Local Class-
CLASS lhc_PO_IT DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.

METHODS update FOR MODIFY


IMPORTING entities FOR UPDATE po_it.

METHODS delete FOR MODIFY


IMPORTING keys FOR DELETE po_it.

METHODS read FOR READ


IMPORTING keys FOR READ po_it RESULT result.

METHODS rba_Po_hd FOR READ


IMPORTING keys_rba FOR READ po_it\_Po_hd FULL result_requested RESULT result
LINK association_links.
METHODS create FOR MODIFY
IMPORTING entities FOR CREATE po_it.

ENDCLASS.

CLASS lhc_PO_IT IMPLEMENTATION.

METHOD update.

DATA : ls_po_items TYPE ztb_po_items,


lt_po_items TYPE TABLE of ztb_po_items.

* READ TABLE entities ASSIGNING FIELD-SYMBOL(<lfs_po_it>) INDEX 1.


* IF sy-subrc EQ 0.
SELECT * FROM ztb_po_items FOR ALL ENTRIES IN @entities WHERE po_num =
@entities-PoNum INTO table @lt_po_items.
* ls_po_items = CORRESPONDING #( <lfs_po_it> MAPPING FROM ENTITY USING CONTROL
).
* ENDIF.

LOOP AT entities ASSIGNING FIELD-SYMBOL(<lfs_po_it>).


READ TABLE lt_po_items ASSIGNING FIELD-SYMBOL(<lfs_items>)
WITH KEY po_num = <lfs_po_it>-PoNum po_item = <lfs_po_it>-PoItem BINARY
SEARCH.

Email: [email protected] 14 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

IF sy-subrc eq 0.
IF <lfs_po_it>-Material IS NOT INITIAL.
<lfs_items>-material = <lfs_po_it>-Material.
ENDIF.
IF <lfs_po_it>-ItemText IS NOT INITIAL.
<lfs_items>-item_text = <lfs_po_it>-ItemText.
ENDIF.
IF <lfs_po_it>-Plant IS NOT INITIAL.
<lfs_items>-plant = <lfs_po_it>-Plant.
ENDIF.
IF <lfs_po_it>-ProductPrice IS NOT INITIAL.
<lfs_items>-product_price = <lfs_po_it>-ProductPrice.
ENDIF.
IF <lfs_po_it>-PriceUnit IS NOT INITIAL.
<lfs_items>-price_unit = <lfs_po_it>-PriceUnit.
ENDIF.
IF <lfs_po_it>-Qty IS NOT INITIAL.
<lfs_items>-qty = <lfs_po_it>-Qty.
ENDIF.
IF <lfs_po_it>-Uom IS NOT INITIAL.
<lfs_items>-uom = <lfs_po_it>-Uom.
ENDIF.
IF <lfs_po_it>-StorLoc IS NOT INITIAL.
<lfs_items>-stor_loc = <lfs_po_it>-StorLoc.
ENDIF.
endif.

ENDLOOP.

UPDATE ztb_po_items FROM TABLE @lt_po_items.


IF sy-subrc IS INITIAL.
* mapped-po_it = VALUE #( BASE mapped-po_it
* ( %cid = <lfs_po_it>-%cid_ref
* PoNum = ls_po_items-po_num
* ) ).

INSERT VALUE #( %cid = <lfs_po_it>-%cid_ref


PoNum = <lfs_po_it>-PoNum
PoItem = <lfs_po_it>-PoItem
) INTO TABLE mapped-po_it.
ELSE.

APPEND VALUE #( %cid = <lfs_po_it>-%cid_ref


PoNum = <lfs_po_it>-PoNum
PoItem = <lfs_po_it>-PoItem )
TO failed-po_it.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity = if_abap_behv_message=>severity-
error )
%key-PoNum = <lfs_po_it>-PoNum
%key-PoItem = <lfs_po_it>-PoItem
%cid = <lfs_po_it>-%cid_ref

Email: [email protected] 15 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

%update = 'X'
PoNum = <lfs_po_it>-PoNum
PoItem = <lfs_po_it>-PoItem )
TO reported-po_it.

ENDIF.

ENDMETHOD.

METHOD delete.

READ TABLE keys ASSIGNING FIELD-SYMBOL(<lfs_keys>) INDEX 1.


IF sy-subrc EQ 0.
DELETE FROM ztb_po_items WHERE po_num EQ @<lfs_keys>-PoNum AND po_item EQ
@<lfs_keys>-PoItem.
IF sy-subrc NE 0.
APPEND VALUE #( %cid = <lfs_keys>-%cid_ref
PoNum = <lfs_keys>-PoNum
PoItem = <lfs_keys>-PoItem )
TO failed-po_it.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity =
if_abap_behv_message=>severity-error )
%key-PoNum = <lfs_keys>-PoNum
%key-PoItem = <lfs_keys>-PoItem
%cid = <lfs_keys>-%cid_ref
%delete = 'X'
PoNum = <lfs_keys>-PoNum
PoItem = <lfs_keys>-PoItem )
TO reported-po_it.
ENDIF.
ENDIF.

ENDMETHOD.

METHOD read.
ENDMETHOD.

METHOD rba_Po_hd.
ENDMETHOD.

METHOD create.
DATA : ls_po_items TYPE ztb_po_items.

READ TABLE entities ASSIGNING FIELD-SYMBOL(<lfs_po_items>) INDEX 1.


IF sy-subrc EQ 0.
ls_po_items = CORRESPONDING #( <lfs_po_items> MAPPING FROM ENTITY USING CONTROL
).
ENDIF.

INSERT ztb_po_items FROM @ls_po_items.


IF sy-subrc IS NOT INITIAL.

Email: [email protected] 16 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

mapped-po_it = VALUE #( BASE mapped-po_it


( %cid = <lfs_po_items>-%cid
PoNum = ls_po_items-po_num
PoItem = ls_po_items-po_item
) ).

ELSE.
APPEND VALUE #( %cid = <lfs_po_items>-%cid
PoNum = <lfs_po_items>-PoNum
PoItem = <lfs_po_items>-PoItem )
TO failed-po_it.

APPEND VALUE #( %msg = new_message( id = '00'


number = '001'
v1 = 'Invalid Details'
severity = if_abap_behv_message=>severity-
error )
%key-PoNum = <lfs_po_items>-PoNum
%key-PoItem = <lfs_po_items>-PoItem
%cid = <lfs_po_items>-%cid
%create = 'X'
PoNum = <lfs_po_items>-PoNum
PoItem = <lfs_po_items>-PoItem )
TO reported-po_it.
ENDIF.

ENDMETHOD.

ENDCLASS.

Email: [email protected] 17 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

6. Create the Metadata Extensions

Create a Metadata extension for the Purchase order Header


@Metadata.layer: #CUSTOMER
@UI:{ headerInfo: {
typeName: 'Purchase Order',
typeNamePlural: 'Purchase Orders',
title: {
type: #STANDARD,
value: 'PoNum'
}
} }
annotate entity ZC_PO_HEAD with
{
@UI.facet: [{
id: 'POHd',
purpose: #STANDARD,
position: 10,
type:#IDENTIFICATION_REFERENCE,
// type:#COLLECTION,
label: 'Purchase Order Header'
},
/*

{
id: 'BasicInfo',
purpose:#STANDARD,
parentId: 'POHd',
position:10,
targetQualifier: 'BasicGroup',
type:#FIELDGROUP_REFERENCE,
label:'Basic Details'
},

{
id: 'OrgInfo',
purpose:#STANDARD,
parentId: 'POHd',
position:20,
targetQualifier: 'OrgGroup',
type:#FIELDGROUP_REFERENCE,
label:'Organization Details'

},

{
id: 'MorDet',
purpose:#STANDARD,
parentId: 'POHd',
position:30,
targetQualifier: 'MoreDet',
type:#FIELDGROUP_REFERENCE,
label:'More Details'

Email: [email protected] 18 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

},

{
id:'Header1',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD',
position: 10
}, */

{
id: 'POItems',
purpose: #STANDARD,
type:#LINEITEM_REFERENCE,
position: 20,
targetElement: '_PO_items',
label: 'Purchase Order Items'
}
]

@UI.lineItem: [{ position: 10,label: 'Purchase Order'}]


@UI.selectionField: [{ position: 10 }]
@UI.identification: [{ position: 10,label: 'Purchase Order' }]
// @UI.fieldGroup: [{ position: 10, label: 'Purchase Order',qualifier: 'BasicGroup'
}]
//@UI.dataPoint:{ title:'Purchase Order', qualifier: 'HD' }
PoNum;

@UI.lineItem: [{ position: 30,label: 'Order Type', importance: #HIGH }]


@UI.identification: [{ position: 30,label: 'Order Type' }]
// @UI.fieldGroup: [{ position: 30, label: 'Order Type',qualifier: 'BasicGroup' }]
Type;

@UI.lineItem: [{ position: 40,label: 'Company Code', importance: #HIGH }]


@UI.identification: [{ position: 40,label: 'Company Code' }]
// @UI.fieldGroup: [{ position: 40, label: 'Company Code',qualifier: 'OrgGroup' }]
CompCode;

// @UI.fieldGroup: [{ position: 50, label: 'Organization',qualifier: 'OrgGroup' }]


@UI.lineItem: [{ position: 50,label: 'Organization', importance: #HIGH }]
@UI.identification: [{ position: 50,label: 'Organization' }]
// @UI.fieldGroup: [{ position: 50, label: 'Organization',qualifier: 'OrgGroup' }]
Org;

@UI.lineItem: [{ position: 60, label: 'Vendor' }]


@UI.selectionField: [{ position: 30 }]
@UI.identification: [{ position: 60, label: 'Vendor' }]
// @UI.fieldGroup: [{ position: 60, label: 'Vendor',qualifier: 'OrgGroup' }]
// @Consumption.valueHelpDefinition: [{entity:{ name: 'ZI_VEND', element:'Vendor'
}}]
Vendor;

@UI.lineItem: [{ position: 70, label: 'Plant' }]

Email: [email protected] 19 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

@UI.selectionField: [{ position: 70 }]
@UI.identification: [{ position: 70, label: 'Plant' }]
// @UI.fieldGroup: [{ position: 70, label: 'Plant',qualifier: 'OrgGroup' }]
Plant;

@UI.lineItem: [{ position: 80,label: 'Status'},{ type: #FOR_ACTION, dataAction:


'Change_status' ,
label: 'Change
Status'}]
@UI.identification: [{ position: 80,label: 'Purchase Status' }]
// @UI.fieldGroup: [{ position: 80, label: 'Purchase Status',qualifier:
'BasicGroup' }]
Status;

@UI.identification: [{ position: 90,label: 'Creation Date' }]


// @UI.fieldGroup: [{ position: 90, label: 'Creation Date',qualifier: 'MoreDet' }]
CreatedDateTime;

Create a Metadata extension for the Purchase order Items


@Metadata.layer: #CORE
@UI.headerInfo:{
title:
{
//value: 'PoItem'},
//description:{
label: 'PurchaseItemInfo',
type: #STANDARD,
value: 'PoItem'}
}
annotate entity ZC_PO_ITEMS
with
{
@UI.facet: [{
id: 'ItemID',
purpose: #STANDARD,
position: 10,
type:#IDENTIFICATION_REFERENCE,
// type:#COLLECTION,
label: 'Item Information'
} /*,

id: 'BasicInfo',
purpose:#STANDARD,
parentId: 'ItemID',
position:10,
targetQualifier: 'BasicGroup',
type:#FIELDGROUP_REFERENCE,
label:'Item Details'

Email: [email protected] 20 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

} /*,

{
id:'Header1',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD1',
position: 10
} ,

{
id:'Header2',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD2',
position: 20
} */
]

@UI.lineItem: [{ position: 10,label: 'Purchase Order'}]


// @UI.fieldGroup: [{ position: 10, label: 'Purchase Order',qualifier:
'BasicGroup' }]
@UI.identification: [{ position: 10,label: 'Purchase Order' }]
// @UI.dataPoint:{ title:'Purchase Order', qualifier: 'HD1' }
PoNum;

@UI.lineItem: [{ position: 20,label: 'Item Number'}]


@UI.identification: [{ position: 20,label: 'Item Number' }]
// @UI.fieldGroup: [{ position: 20, label: 'Item Number',qualifier: 'BasicGroup'
}]
// @UI.dataPoint:{ title:'Item Number', qualifier: 'HD2' }
PoItem;

@UI.lineItem: [{ position: 30,label: 'Short text'}]


@UI.identification: [{ position: 30,label: 'Short text' }]
// @UI.fieldGroup: [{ position: 30, label: 'Short text',qualifier: 'BasicGroup' }]
ItemText;

@UI.lineItem: [{ position: 40,label: 'Material'}]


@UI.identification: [{ position: 40,label: 'Material' }]
// @UI.fieldGroup: [{ position: 40, label: 'Material',qualifier: 'BasicGroup' }]
Material;

@UI.lineItem: [{ position: 50,label: 'Plant'}]


@UI.identification: [{ position: 50,label: 'Plant' }]
// @UI.fieldGroup: [{ position: 50, label: 'Plant',qualifier: 'BasicGroup' }]
Plant;

@UI.lineItem: [{ position: 60,label: 'Material Group'}]


@UI.identification: [{ position: 60,label: 'Purchase Order Item' }]
// @UI.fieldGroup: [{ position: 60, label: 'Stroage Location',qualifier:
'BasicGroup' }]
StorLoc;

Email: [email protected] 21 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

@UI.lineItem: [{ position: 70,label: 'Order Quantity'}]


@UI.identification: [{ position: 70,label: 'Order Quantity' }]
// @UI.fieldGroup: [{ position: 70, label: 'Order Quantity',qualifier:
'BasicGroup' }]
Qty;

@UI.lineItem: [{ position: 80,label: 'Order Unit'}]


@UI.identification: [{ position: 80,label: 'Order Unit' }]
// @UI.fieldGroup: [{ position: 80, label: 'Order Unit',qualifier: 'BasicGroup' }]
Uom;

@UI.lineItem: [{ position: 90,label: 'Product Price'}]


@UI.identification: [{ position: 90,label: 'Product Price' }]
// @UI.fieldGroup: [{ position: 90, label: 'Product Price',qualifier: 'BasicGroup'
}]
ProductPrice;

@UI.lineItem: [{ position: 100,label: 'Price Unit'}]


@UI.identification: [{ position: 100,label: 'Price Unit' }]
// @UI.fieldGroup: [{ position: 100, label: 'Price Unit',qualifier: 'BasicGroup'
}]
PriceUnit;

7. Create the Service Definition

Create a Service definition and expose the Purchase order header and items projection views
@EndUserText.label: 'Service definition for PO'
define service ZUI_PO_HD_ITEMS {
expose ZC_PO_HEAD as PO_Hd;
expose ZC_PO_ITEMS as PO_Items;
}

Email: [email protected] 22 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

8. Create the Service Binding

Create a Service Binding for the service definition, activate it and publish it.

9. Check the service URLS for metadata and Purchase order details
Click on Service URL-To check the metadata of Purchase order Header and items
URL:https://0e4e7bd0-339a-47c7-aae6-a8f0cb52cf77.abap-
web.us10.hana.ondemand.com/sap/opu/odata/sap/ZUI_PO_HD_ITEMS/$metadata?sap-client=100
Metadata for Purchase order header

Metadata for Purchase order Items

Email: [email protected] 23 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

To check the data for the Purchase order header -


https://0e4e7bd0-339a-47c7-aae6-a8f0cb52cf77.abap-
web.us10.hana.ondemand.com/sap/opu/odata/sap/ZUI_PO_HD_ITEMS/PO_Hd?sap-client=100

To check the data for the Purchase order items -


https://0e4e7bd0-339a-47c7-aae6-a8f0cb52cf77.abap-
web.us10.hana.ondemand.com/sap/opu/odata/sap/ZUI_PO_HD_ITEMS/PO_Items?sap-client=100

Email: [email protected] 24 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

10. Preview the Purchase order Application

Now, select the Entity set in service binding and click on Preview

Click on go, now it shows the purchase order details

Select the purchase order, it’s navigate to the header and items details.

Email: [email protected] 25 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Select the item, it’s navigates to items details

11. Add the Input Help for the Field to show the list of possible values

Now add the input help check for the Vendor field, as there were no values for the vendor.

Create a database table for Vendor


@EndUserText.label : 'Vendor Table'
@AbapCatalog.enhancement.category : #EXTENSIBLE_CHARACTER_NUMERIC
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztb_vendor {

key client : abap.clnt not null;


key vendor : lifnr not null;
vendordesc : abap.char(81);

Email: [email protected] 26 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Populate and check the table data

Create a CDS View Entity for the Vendor Table


@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Vendor'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZI_VEND as select from ztb_vendor
{
key vendor as Vendor,
vendordesc as VendorDesc

Now, add the annotation to the vendor field in the Purchase order projection view to get the input list of
vendors.

Email: [email protected] 27 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Now, Vendor field has the input help list

12. Improve the UI User Experience


Add the purchase order Number with label in the Header information.
Group the related details with heading in purchase order information

Changes in the metadata extension of purchase order header


@Metadata.layer: #CUSTOMER
@UI:{ headerInfo: {
typeName: 'Purchase Order',
typeNamePlural: 'Purchase Orders',
title: {
type: #STANDARD,
value: 'PoNum'
}
} }
annotate entity ZC_PO_HEAD with
{
@UI.facet: [{
id: 'POHd',

Email: [email protected] 28 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

purpose: #STANDARD,
position: 10,
//type:#IDENTIFICATION_REFERENCE,
type:#COLLECTION,
label: 'Purchase Order Header'
},

{
id: 'BasicInfo',
purpose:#STANDARD,
parentId: 'POHd',
position:10,
targetQualifier: 'BasicGroup',
type:#FIELDGROUP_REFERENCE,
label:'Basic Details'
},

{
id: 'OrgInfo',
purpose:#STANDARD,
parentId: 'POHd',
position:20,
targetQualifier: 'OrgGroup',
type:#FIELDGROUP_REFERENCE,
label:'Organization Details'

},

{
id: 'MorDet',
purpose:#STANDARD,
parentId: 'POHd',
position:30,
targetQualifier: 'MoreDet',
type:#FIELDGROUP_REFERENCE,
label:'More Details'

},

{
id:'Header1',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD',
position: 10
},

{
id: 'POItems',
purpose: #STANDARD,
type:#LINEITEM_REFERENCE,
position: 20,
targetElement: '_PO_items',

Email: [email protected] 29 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

label: 'Purchase Order Items'


}
]

@UI.lineItem: [{ position: 10,label: 'Purchase Order'}]


@UI.selectionField: [{ position: 10 }]
// @UI.identification: [{ position: 10,label: 'Purchase Order' }]
@UI.fieldGroup: [{ position: 10, label: 'Purchase Order',qualifier: 'BasicGroup' }]
@UI.dataPoint:{ title:'Purchase Order', qualifier: 'HD' }
PoNum;

@UI.lineItem: [{ position: 30,label: 'Order Type', importance: #HIGH }]


// @UI.identification: [{ position: 30,label: 'Order Type' }]
@UI.fieldGroup: [{ position: 30, label: 'Order Type',qualifier: 'BasicGroup' }]
Type;

@UI.lineItem: [{ position: 40,label: 'Company Code', importance: #HIGH }]


//@UI.identification: [{ position: 40,label: 'Company Code' }]
@UI.fieldGroup: [{ position: 40, label: 'Company Code',qualifier: 'OrgGroup' }]
CompCode;

// @UI.fieldGroup: [{ position: 50, label: 'Organization',qualifier: 'OrgGroup' }]


@UI.lineItem: [{ position: 50,label: 'Organization', importance: #HIGH }]
//@UI.identification: [{ position: 50,label: 'Organization' }]
@UI.fieldGroup: [{ position: 50, label: 'Organization',qualifier: 'OrgGroup' }]
Org;

@UI.lineItem: [{ position: 60, label: 'Vendor' }]


@UI.selectionField: [{ position: 30 }]
//@UI.identification: [{ position: 60, label: 'Vendor' }]
@UI.fieldGroup: [{ position: 60, label: 'Vendor',qualifier: 'OrgGroup' }]
// @Consumption.valueHelpDefinition: [{entity:{ name: 'ZI_VEND', element:'Vendor'
}}]
Vendor;

@UI.lineItem: [{ position: 70, label: 'Plant' }]


@UI.selectionField: [{ position: 70 }]
//@UI.identification: [{ position: 70, label: 'Plant' }]
@UI.fieldGroup: [{ position: 70, label: 'Plant',qualifier: 'OrgGroup' }]
Plant;

@UI.lineItem: [{ position: 80,label: 'Status'},{ type: #FOR_ACTION, dataAction:


'Change_status' ,
label: 'Change
Status'}]
//@UI.identification: [{ position: 80,label: 'Purchase Status' }]
@UI.fieldGroup: [{ position: 80, label: 'Purchase Status',qualifier: 'BasicGroup'
}]
Status;

//@UI.identification: [{ position: 90,label: 'Creation Date' }]


@UI.fieldGroup: [{ position: 90, label: 'Creation Date',qualifier: 'MoreDet' }]
CreatedDateTime;
}

Email: [email protected] 30 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Add the purchase order and item number with labels in header information.
Group the item details.

Changes in the metadata extension of purchase order Items


@Metadata.layer: #CORE
@UI.headerInfo:{
title:
{
//value: 'PoItem'},
//description:{
label: 'PurchaseItemInfo',
type: #STANDARD,
value: 'PoItem'}
}
annotate entity ZC_PO_ITEMS
with
{
@UI.facet: [{
id: 'ItemID',
purpose: #STANDARD,
position: 10,
//type:#IDENTIFICATION_REFERENCE,
type:#COLLECTION,
label: 'Item Information'
},

id: 'BasicInfo',
purpose:#STANDARD,
parentId: 'ItemID',
position:10,
targetQualifier: 'BasicGroup',
type:#FIELDGROUP_REFERENCE,
label:'Item Details'

},

Email: [email protected] 31 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

{
id:'Header1',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD1',
position: 10
},

{
id:'Header2',
purpose: #HEADER,
type:#DATAPOINT_REFERENCE,
targetQualifier:'HD2',
position: 20
}
]

@UI.lineItem: [{ position: 10,label: 'Purchase Order'}]


@UI.fieldGroup: [{ position: 10, label: 'Purchase Order',qualifier: 'BasicGroup'
}]
//@UI.identification: [{ position: 10,label: 'Purchase Order' }]
@UI.dataPoint:{ title:'Purchase Order', qualifier: 'HD1' }
PoNum;

@UI.lineItem: [{ position: 20,label: 'Item Number'}]


// @UI.identification: [{ position: 20,label: 'Item Number' }]
@UI.fieldGroup: [{ position: 20, label: 'Item Number',qualifier: 'BasicGroup' }]
@UI.dataPoint:{ title:'Item Number', qualifier: 'HD2' }
PoItem;

@UI.lineItem: [{ position: 30,label: 'Short text'}]


// @UI.identification: [{ position: 30,label: 'Short text' }]
@UI.fieldGroup: [{ position: 30, label: 'Short text',qualifier: 'BasicGroup' }]
ItemText;

@UI.lineItem: [{ position: 40,label: 'Material'}]


// @UI.identification: [{ position: 40,label: 'Material' }]
@UI.fieldGroup: [{ position: 40, label: 'Material',qualifier: 'BasicGroup' }]
Material;

@UI.lineItem: [{ position: 50,label: 'Plant'}]


// @UI.identification: [{ position: 50,label: 'Plant' }]
@UI.fieldGroup: [{ position: 50, label: 'Plant',qualifier: 'BasicGroup' }]
Plant;

@UI.lineItem: [{ position: 60,label: 'Material Group'}]


// @UI.identification: [{ position: 60,label: 'Purchase Order Item' }]
@UI.fieldGroup: [{ position: 60, label: 'Stroage Location',qualifier:
'BasicGroup' }]
StorLoc;

@UI.lineItem: [{ position: 70,label: 'Order Quantity'}]


// @UI.identification: [{ position: 70,label: 'Order Quantity' }]
@UI.fieldGroup: [{ position: 70, label: 'Order Quantity',qualifier: 'BasicGroup'
}]

Email: [email protected] 32 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Qty;

@UI.lineItem: [{ position: 80,label: 'Order Unit'}]


// @UI.identification: [{ position: 80,label: 'Order Unit' }]
@UI.fieldGroup: [{ position: 80, label: 'Order Unit',qualifier: 'BasicGroup' }]
Uom;

@UI.lineItem: [{ position: 90,label: 'Product Price'}]


// @UI.identification: [{ position: 90,label: 'Product Price' }]
@UI.fieldGroup: [{ position: 90, label: 'Product Price',qualifier: 'BasicGroup'
}]
ProductPrice;

@UI.lineItem: [{ position: 100,label: 'Price Unit'}]


// @UI.identification: [{ position: 100,label: 'Price Unit' }]
@UI.fieldGroup: [{ position: 100, label: 'Price Unit',qualifier: 'BasicGroup' }]
PriceUnit;

Email: [email protected] 33 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

13. Perform the CRUD Operations

Create- Now, create the Purchase Order with Items

Give the Header information and click on save

Email: [email protected] 34 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Purchase order Header got created

Now, create the item- click on create button.


Give item information and click on save.

Email: [email protected] 35 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Purchase order Item got created.

Now, go to the initial page, it shows the new Purchase order.

Purchase Order Header and Items details

Email: [email protected] 36 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Update- Now, edit the Purchase Order Header and Items details

It comes in Edit Mode

Email: [email protected] 37 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Change the details

New Details got updated

Email: [email protected] 38 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Delete- Now, delete the Item

Item got deleted

Email: [email protected] 39 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Now, delete the Purchase order

Purchase order got deleted

Update- Now, edit the Purchase order item details

Email: [email protected] 40 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Change the item details

Purchase order item details got changed

Email: [email protected] 41 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Add the new item to purchase order

Give the new item details

Email: [email protected] 42 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Click on save.

New item got created.

Email: [email protected] 43 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

New item got added to purchase order

14. Perform the Action

Action- Change status to change the purchase order status

Purchase order status got changed from A to B.

Email: [email protected] 44 | P a g e
Prepared by Yogi Pavan - SAP ABAP Consultant Linkedin – Bandi Yogi Pavan Kumar Reddy

Email: [email protected] 45 | P a g e

You might also like