define table zsignature {
key client : abap.clnt not null;
key organisation : abap.char(8) not null;
key pos : abap.char(8) not null;
key username : xubname not null;
signature : abap.string(0);
}
@EndUserText.label: 'Signature Maintain View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
define root view entity Z_C_SIGNATURE_MAINTAIN
provider contract transactional_query
as projection on Z_I_SIGNATURE
{
key Organisation,
key Pos,
key Username,
Signature
}
@EndUserText.label: 'Signature Read View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.query.implementedBy: 'ABAP:ZCL_SIGNATURE_READ'
@Metadata.allowExtensions: true
define root view entity Z_C_SIGNATURE_READ
provider contract transactional_query
as projection on Z_I_SIGNATURE
{
key Organisation,
key Pos,
key Username,
Signature
}
METHOD if_rap_query_provider~select.
DATA: lt_objects TYPE objec_t,
lt_signature TYPE TABLE OF z_c_signature_read.
DATA(lo_paging) = io_request->get_paging( ).
TRY.
"Filter not needed, because we all calculate fields in Backend
DATA(lo_filter) = io_request->get_filter( )->get_as_ranges( ).
CATCH cx_rap_query_filter_no_range.
ENDTRY.
CALL FUNCTION 'HR_STRUCTURE_GET'
EXPORTING
root_plvar = '01'
root_otype = 'US'
root_objid = sy-uname
pathid = 'US-BP-OO'
IMPORTING
result_objects = lt_objects
EXCEPTIONS
plvar_not_found = 1
root_not_found = 2
path_not_found = 3
internal_error = 4
OTHERS = 5.
DATA(ls_o) = VALUE #( lt_objects[ otype = 'O' ] OPTIONAL ).
DATA(ls_s) = VALUE #( lt_objects[ otype = 'S' ] OPTIONAL ).
DATA(ls_us) = VALUE #( lt_objects[ otype = 'US' ] OPTIONAL ).
"First check if there is a Signature for specific User
IF ls_us IS NOT INITIAL.
SELECT SINGLE * FROM z_i_signature WHERE username = @ls_us-realo INTO @DATA(ls_signature).
ENDIF.
"Second check combination position & organisation
IF ls_signature IS INITIAL AND ls_s IS NOT INITIAL AND ls_o IS NOT INITIAL.
SELECT SINGLE * FROM z_i_signature WHERE pos = @ls_s-realo AND organisation = @ls_o-realo INTO @ls_signature.
ENDIF.
"Third one check for organisation
IF ls_signature IS INITIAL AND ls_o IS NOT INITIAL.
SELECT SINGLE * FROM z_i_signature WHERE organisation = @ls_o-realo INTO @ls_signature.
ENDIF.
ls_signature-Signature = replace( val = ls_signature-Signature sub = '${User}' with = ls_us-stext ).
ls_signature-Signature = replace( val = ls_signature-Signature sub = '${Position}' with = ls_s-stext ).
APPEND CORRESPONDING #( ls_signature ) TO lt_signature.
io_response->set_total_number_of_records( 1 ).
io_response->set_data( lt_signature ).
ENDMETHOD.
@Metadata.layer: #CUSTOMER
annotate view Z_C_SIGNATURE_READ
with
{
@UI.facet: [
{
label: 'Signature',
id : 'Signature',
purpose: #STANDARD,
type : #IDENTIFICATION_REFERENCE,
position: 10,
targetQualifier: 'Signature'
}]
@EndUserText.label: 'Organisation (O)'
@UI.selectionField: [{ position: 10 }]
@UI.lineItem: [{ position: 10 }]
Organisation;
@EndUserText.label: 'Position (S)'
@UI.selectionField: [{ position: 20 }]
@UI.lineItem: [{ position: 20 }]
Pos;
@EndUserText.label: 'User (US)'
@UI.selectionField: [{ position: 30 }]
@UI.lineItem: [{ position: 30 }]
Username;
@EndUserText.label: 'Signature'
@UI.identification: [{ position: 10, qualifier: 'Signature' }]
Signature;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |