SAP RAP Unmanaged Application
SAP RAP Unmanaged Application
MANOJKUMAR KOTTI
Manojkumar Kotti
Table of Contents
1|Page
Manojkumar Kotti
@[Link] : #NOT_EXTENSIBLE
@[Link] : #TRANSPARENT
@[Link] : #A
@[Link] : #RESTRICTED
salesdocumenttype : [Link](4);
orderreason : [Link](3);
salesorganization : [Link](4);
distributionchannel : [Link](2);
division : [Link](2);
salesoffice : [Link](4);
salesgroup : [Link](3);
@[Link] : 'zmk_vbak_t.currency'
netprice : [Link](13,2);
currency : [Link];
local_created_by : abp_creation_user;
local_created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;
2|Page
Manojkumar Kotti
@[Link] : #NOT_EXTENSIBLE
@[Link] : #TRANSPARENT
@[Link] : #A
@[Link] : #RESTRICTED
@[Link] : 'Sales'
@[Link] : false
material : [Link](18);
plant : [Link](4);
@[Link] : 'zmk_vbap_t.quantityunits'
quantity : [Link](13,3);
quantityunits : [Link](3);
local_created_by : abp_creation_user;
local_created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;
3|Page
Manojkumar Kotti
Step3: Create Interface view for the Header Table and add composition to child
(Items) interface view
@[Link]: #NOT_REQUIRED
@[Link]: true
salesdocumenttype as SalesDocumentType,
orderreason as OrderReason,
salesorganization as SalesOrganization,
distributionchannel as DistributionChannel,
division as Division,
salesoffice as SalesOffice,
salesgroup as SalesGroup,
@[Link]: 'Currency'
netprice as NetPrice,
currency as Currency,
@[Link]: true
local_created_by as LocalCreatedBy,
@[Link]: true
local_created_at as LocalCreatedAt,
@[Link]: true
local_last_changed_by as LocalLastChangedBy,
@[Link]: true
local_last_changed_at as LocalLastChangedAt,
/* Associations */
_salesItem
4|Page
Manojkumar Kotti
Step4: Create Interface view for the Item Table and add association to parent (Header)
interface view
@[Link]: [#NONE]
@[Link]: #NOT_REQUIRED
@[Link]: true
@[Link]:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
material as Material,
plant as Plant,
@[Link]: 'Quantityunits'
quantity as Quantity,
quantityunits as Quantityunits,
@[Link]: true
local_created_by as LocalCreatedBy,
@[Link]: true
local_created_at as LocalCreatedAt,
@[Link]: true
local_last_changed_by as LocalLastChangedBy,
@[Link]: true
local_last_changed_at as LocalLastChangedAt,
/* Associations */
_salesHeader
5|Page
Manojkumar Kotti
Step5: Create Consumption View for Header and mark it as Root view and redirect to
composition child
@[Link]: #NOT_REQUIRED
@[Link]: true
@[Link]: true
@[Link]: true
as projection on ZMK_SALESHDR_UMG_I
key SalesDocument,
SalesDocumentType,
OrderReason,
SalesOrganization,
DistributionChannel,
Division,
@[Link]: true
SalesOffice,
SalesGroup,
@[Link]: 'Currency'
NetPrice,
Currency,
LocalCreatedBy,
LocalCreatedAt,
LocalLastChangedBy,
LocalLastChangedAt,
/* Associations */
6|Page
Manojkumar Kotti
Step6: Create Consumption view for the item table and redirect to parent association
@[Link]: #NOT_REQUIRED
@[Link]: true
@[Link]: true
@[Link]: true
as projection on ZMK_SALESITM_UMG_I
key SalesDocument,
key SalesItemnumber,
@[Link]: true
Material,
Plant,
@[Link]: 'Quantityunits'
Quantity,
Quantityunits,
LocalCreatedBy,
LocalCreatedAt,
LocalLastChangedBy,
LocalLastChangedAt,
/* Associations */
7|Page
Manojkumar Kotti
@UI: { headerInfo: {
value: 'SalesDocument' } } }
@[Link]: [{
id: 'SalesHeader',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
position: 10
},
id: 'SalesItems',
purpose: #STANDARD,
type: #LINEITEM_REFERENCE,
position: 20,
targetElement: '_salesItem'
selectionField: [ { position: 10 } ] }
SalesDocument;
8|Page
Manojkumar Kotti
selectionField: [ { position: 20 } ] }
SalesDocumentType;
selectionField: [ { position: 30 } ] }
OrderReason;
SalesOrganization;
selectionField: [ { position: 50 } ] }
DistributionChannel;
selectionField: [ { position: 60 } ] }
Division;
selectionField: [ { position: 70 } ] }
SalesOffice;
selectionField: [ { position: 80 } ] }
SalesGroup;
NetPrice;
Currency;
LocalCreatedBy;
9|Page
Manojkumar Kotti
LocalCreatedAt;
LocalLastChangedBy;
LocalLastChangedAt;
10 | P a g e
Manojkumar Kotti
@UI: { headerInfo: {
value: 'SalesItemnumber' } } }
@[Link]: [{
id: 'SalesItems',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
position: 10
}]
SalesDocument;
SalesItemnumber;
Material;
Plant;
11 | P a g e
Manojkumar Kotti
Quantity;
@[Link]: true
Quantityunits;
@[Link]: true
LocalCreatedBy;
@[Link]: true
LocalCreatedAt;
@[Link]: true
LocalLastChangedBy;
@[Link]: true
LocalLastChangedAt;
12 | P a g e
Manojkumar Kotti
strict ( 2 );
with draft;
update;
delete;
SalesDocument = salesdocument;
SalesDocumentType = salesdocumenttype;
OrderReason = orderreason;
SalesOrganization = salesorganization;
13 | P a g e
Manojkumar Kotti
DistributionChannel = distributionchannel;
Division = division;
SalesOffice = salesoffice;
SalesGroup = salesgroup;
NetPrice = netprice;
Currency = currency;
LocalCreatedBy = local_created_by;
LocalCreatedAt = local_created_at;
LocalLastChangedBy = local_last_changed_by;
LocalLastChangedAt = local_last_changed_at;
update;
delete;
SalesDocument = salesdocument;
SalesItemnumber = salesitemnumber;
Material = material;
Plant = plant;
Quantity = quantity;
Quantityunits = quantityunits;
14 | P a g e
Manojkumar Kotti
LocalCreatedBy = local_created_by;
LocalCreatedAt = local_created_at;
LocalLastChangedBy = local_last_changed_by;
LocalLastChangedAt = local_last_changed_at;
15 | P a g e
Manojkumar Kotti
@[Link] : #EXTENSIBLE_ANY
@[Link] : #TRANSPARENT
@[Link] : #A
@[Link] : #RESTRICTED
salesdocumenttype : [Link](4);
orderreason : [Link](3);
salesorganization : [Link](4);
distributionchannel : [Link](2);
division : [Link](2);
salesoffice : [Link](4);
salesgroup : [Link](3);
@[Link] : 'zmk_vbak_umg_d.currency'
netprice : [Link](13,2);
currency : [Link];
localcreatedby : abp_creation_user;
localcreatedat : abp_creation_tstmpl;
locallastchangedby : abp_locinst_lastchange_user;
locallastchangedat : abp_locinst_lastchange_tstmpl;
16 | P a g e
Manojkumar Kotti
@[Link] : #EXTENSIBLE_ANY
@[Link] : #TRANSPARENT
@[Link] : #A
@[Link] : #RESTRICTED
material : [Link](18);
plant : [Link](4);
@[Link] : 'zmk_vbap_umg_d.quantityunits'
quantity : [Link](13,3);
quantityunits : [Link](3);
localcreatedby : abp_creation_user;
localcreatedat : abp_creation_tstmpl;
locallastchangedby : abp_locinst_lastchange_user;
locallastchangedat : abp_locinst_lastchange_tstmpl;
17 | P a g e
Manojkumar Kotti
ENDCLASS.
ENDCLASS.
ENDCLASS.
ENDCLASS.
PRIVATE SECTION.
18 | P a g e
Manojkumar Kotti
IMPORTING keys_rba FOR READ SalesOrderHdr\_Salesitem FULL result_requested RESULT result LINK association_links.
ENDCLASS.
METHOD get_instance_authorizations.
ENDMETHOD.
METHOD get_global_authorizations.
ENDMETHOD.
METHOD create.
IF sy-subrc NE 0.
DATA(lo_util) = zmk_sales_util_umg=>get_instance( ).
19 | P a g e
Manojkumar Kotti
IF lv_created EQ abap_true.
salesdocument = ls_sales_hdr-salesdocument
number = 001
ENDIF.
ELSE.
salesdocument = ls_sales_hdr-salesdocument
number = 001
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD update.
20 | P a g e
Manojkumar Kotti
IF sy-subrc EQ 0.
DATA(lo_util) = zmk_sales_util_umg=>get_instance( ).
IF lv_created EQ abap_true.
APPEND VALUE #(
%key = ls_entities-%key
%msg = new_message(
id = 'ZMK_SALES_MSG'
number = 001
severity = if_abap_behv_message=>severity-success )
) TO reported-salesorderhdr.
ENDIF.
ELSE.
21 | P a g e
Manojkumar Kotti
salesdocument = ls_sales_hdr-salesdocument
number = 001
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD delete.
END OF ty_sales_hdr,
BEGIN OF ty_sales_item,
END OF ty_sales_item.
DATA(lo_util) = zmk_sales_util_umg=>get_instance( ).
CLEAR ls_sales_hdr.
ls_sales_hdr = ls_key-salesdocument.
22 | P a g e
Manojkumar Kotti
salesdocument = ls_key-salesdocument
number = 001
ENDLOOP.
ENDMETHOD.
METHOD read.
INTO @DATA(ls_hdr).
IF sy-subrc = 0.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD lock.
ENDMETHOD.
METHOD rba_Salesitem.
23 | P a g e
Manojkumar Kotti
target-salesdocument = ls_item-salesdocument
ENDLOOP.
ENDLOOP.
ENDMETHOD.
METHOD cba_Salesitem.
IF sy-subrc NE 0.
DATA(lo_util) = zmk_sales_util_umg=>get_instance( ).
IF lv_created EQ abap_true.
salesdocument = ls_sales_itm-salesdocument
salesdocument = ls_sales_itm-salesdocument
number = 001
24 | P a g e
Manojkumar Kotti
ENDIF.
ELSE.
salesdocument = ls_sales_itm-salesdocument
salesdocument = ls_sales_itm-salesdocument
salesitemnumber = ls_sales_itm-salesitemnumber
number = 002
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
25 | P a g e
Manojkumar Kotti
ENDCLASS.
METHOD update.
ELSE.
" Fill Return Parameter for Framework
APPEND VALUE #( %cid = ls_entities-%cid_ref
salesdocument = ls_sales_itm-salesdocument
salesitemnumber = ls_sales_itm-salesitemnumber ) TO failed-salesorderitm.
" Report Error
APPEND VALUE #( %cid = ls_entities-%cid_ref
salesdocument = ls_sales_itm-salesdocument
salesitemnumber = ls_sales_itm-salesitemnumber
%msg = new_message( id = 'ZMK_SALES_MSG'
number = 001
v1 = 'Duplicate Sales Order'
severity = if_abap_behv_message=>severity-error ) ) TO reported-salesorderitm.
ENDIF.
ENDIF.
ENDLOOP.
26 | P a g e
Manojkumar Kotti
ENDMETHOD.
METHOD delete.
TYPES : BEGIN OF ty_sales_hdr,
salesdocument TYPE zsorder,
END OF ty_sales_hdr,
BEGIN OF ty_sales_item,
salesdocument TYPE zsorder,
salesitemnumber TYPE int2,
END OF ty_sales_item.
ENDMETHOD.
METHOD read.
ENDMETHOD.
METHOD rba_Salesheader.
ENDMETHOD.
ENDCLASS.
ENDCLASS.
27 | P a g e
Manojkumar Kotti
METHOD finalize.
ENDMETHOD.
METHOD check_before_save.
ENDMETHOD.
METHOD save.
" Save Data to Buffer
DATA(lo_util) = zmk_sales_util_umg=>get_instance( ).
lo_util->get_hdr_value( IMPORTING ex_sales_hdr = DATA(ls_sales_hdr) ).
lo_util->get_itm_value( IMPORTING ex_sales_itm = DATA(ls_sales_itm) ).
lo_util->get_hdr_t_deletion( IMPORTING ex_sales_docs = DATA(lt_sales_header) ).
lo_util->get_itm_t_deletion( IMPORTING ex_sales_info = DATA(lt_sales_items) ).
lo_util->get_deletion_flags( IMPORTING ex_so_hdr_del = DATA(lv_so_hdr_del) ).
" If lv_so_header is flagged then delete both header and item entries
" If lv_so_header is not flagged then look for the respective sales order and item and then delete entry
" Delete Logic
IF lv_so_hdr_del = abap_true.
" Delete header and all items for sales documents in lt_sales_header
LOOP AT lt_sales_header INTO DATA(ls_del_hdr).
DELETE FROM zmk_vbak_t WHERE salesdocument = @ls_del_hdr-salesdocument.
DELETE FROM zmk_vbap_t WHERE salesdocument = @ls_del_hdr-salesdocument.
ENDLOOP.
ELSE.
" Delete individual headers if present in lt_sales_header
LOOP AT lt_sales_header INTO ls_del_hdr.
DELETE FROM zmk_vbak_t WHERE salesdocument = @ls_del_hdr-salesdocument.
ENDLOOP.
ENDMETHOD.
METHOD cleanup.
zmk_sales_util_umg=>get_instance( )->cleanup_buffer( ).
ENDMETHOD.
METHOD cleanup_finalize.
ENDMETHOD.
ENDCLASS.
28 | P a g e
Manojkumar Kotti
Step13: Transactional Buffer – Manually created custom utility class to save data in
transactional buffer
PUBLIC
FINAL
CREATE PRIVATE .
PUBLIC SECTION.
END OF ty_sales_hdr,
BEGIN OF ty_sales_item,
END OF ty_sales_item.
29 | P a g e
Manojkumar Kotti
cleanup_buffer.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
METHOD set_hdr_value.
gs_sales_hdr_buff = im_sales_hdr.
ex_created = abap_true.
ENDIF.
ENDMETHOD.
METHOD get_hdr_value.
ex_sales_hdr = gs_sales_hdr_buff.
ENDMETHOD.
30 | P a g e
Manojkumar Kotti
METHOD get_instance.
IF mo_instance IS INITIAL.
ENDIF.
ro_instance = mo_instance.
ENDMETHOD.
METHOD set_itm_value.
gs_sales_itm_buff = im_sales_itm.
ex_created = abap_true.
ENDIF.
ENDMETHOD.
METHOD get_itm_value.
ex_sales_itm = gs_sales_itm_buff.
ENDMETHOD.
METHOD cleanup_buffer.
CLEAR : gs_sales_hdr_buff,
gs_sales_itm_buff,
gt_sales_hdr_t_buff,
gt_sales_itm_t_buff,
gv_so_delete.
ENDMETHOD.
METHOD set_hdr_deletion_flag.
gv_so_delete = im_so_delete.
ENDMETHOD.
31 | P a g e
Manojkumar Kotti
METHOD get_deletion_flags.
ex_so_hdr_del = gv_so_delete.
ENDMETHOD.
METHOD set_hdr_t_deletion.
ENDMETHOD.
METHOD set_itm_t_deletion.
ENDMETHOD.
METHOD get_hdr_t_deletion.
ex_sales_docs = gt_sales_hdr_t_buff.
ENDMETHOD.
METHOD get_itm_t_deletion.
ex_sales_info = gt_sales_itm_t_buff.
ENDMETHOD.
ENDCLASS.
32 | P a g e
Manojkumar Kotti
Step14: Create Behavior definition with Implementation type as Projection for the root
consumption view
projection;
strict ( 2 );
use draft;
use create;
use update;
use delete;
use update;
use delete;
33 | P a g e
Manojkumar Kotti
Step15: Create Service Definition with reference to the root Interface view
expose ZMK_SALESHDR_UMG_C;
expose ZMK_SALESITM_UMG_C;
34 | P a g e
Manojkumar Kotti
Output:
List Page View
35 | P a g e