From d59db41abee382ab67bfcc9945aca5d08f9bd726 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 12:50:57 +0000 Subject: [PATCH 01/11] refactoring: refactor code --- .../zcl_odata_annotaion_sap.clas.xml | 2 +- src/zcl_odata_fw_controller.clas.abap | 63 +---- src/zcl_odata_fw_sadl.clas.abap | 88 +++++++ src/zcl_odata_fw_sadl.clas.xml | 60 +++++ src/zcl_odata_main.clas.abap | 186 +++++++++----- src/zcl_odata_main.clas.xml | 226 ++++++++++++++++++ src/zif_odata_constants.intf.xml | 2 +- src/zodata_act_param.tabl.xml | 2 + src/zodata_actions.tabl.xml | 4 + src/zodata_cust.fugr.xml | 30 --- src/zodata_entity.tabl.xml | 2 + src/zodata_entitys.tobj.xml | 2 +- src/zodata_namespace.tabl.xml | 2 + src/zodata_namespaces.tobj.xml | 1 - src/zodata_nav.tabl.xml | 2 + src/zodata_prop_txts.tabl.xml | 2 + src/zodata_property.tabl.xml | 2 + src/zodata_searchhlp.tabl.xml | 2 + src/zodata_searchhlps.tobj.xml | 1 - src/zodata_v_actionsv.tobj.xml | 1 - src/zodata_v_actparav.tobj.xml | 1 - src/zodata_v_entityv.tobj.xml | 1 - src/zodata_v_navv.tobj.xml | 1 - src/zodata_v_proptxtv.tobj.xml | 1 - src/zodata_v_propv.tobj.xml | 1 - src/zodata_vc c.tobj.xml | 5 - 26 files changed, 519 insertions(+), 171 deletions(-) create mode 100644 src/zcl_odata_fw_sadl.clas.abap create mode 100644 src/zcl_odata_fw_sadl.clas.xml diff --git a/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml b/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml index b8ae3cd..830fb1a 100644 --- a/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml +++ b/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml @@ -4,7 +4,7 @@ ZCL_ODATA_ANNOTAION_SAP - D + E SAP Annotation namespace 1 X diff --git a/src/zcl_odata_fw_controller.clas.abap b/src/zcl_odata_fw_controller.clas.abap index cd6c262..f4eae73 100644 --- a/src/zcl_odata_fw_controller.clas.abap +++ b/src/zcl_odata_fw_controller.clas.abap @@ -38,10 +38,6 @@ CLASS zcl_odata_fw_controller DEFINITION PRIVATE SECTION. DATA mo_customizing TYPE REF TO zcl_odata_fw_cust. - "!

Get table type

- "! @parameter rv_type |

Table type

- METHODS get_table_type - RETURNING VALUE(rv_type) TYPE string. ENDCLASS. @@ -65,62 +61,11 @@ CLASS zcl_odata_fw_controller IMPLEMENTATION. ENDMETHOD. METHOD define_sadl_xml. - DATA lt_sadl_entities TYPE zodata_entity_tt. - - rv_sadl_xml = || & - ||. - DATA(lt_entities) = mo_customizing->get_entities( ). + DATA(lt_properties) = mo_customizing->get_properties( ). - LOOP AT lt_entities ASSIGNING FIELD-SYMBOL() WHERE is_complex = abap_false. - - DATA(lv_type) = get_table_type( -structure ). - - if lv_type is initial. - continue. - endif. - - rv_sadl_xml = |{ rv_sadl_xml }| & - | |. - APPEND TO lt_sadl_entities. - ENDLOOP. - - rv_sadl_xml = |{ rv_sadl_xml }| & ||. - LOOP AT lt_sadl_entities ASSIGNING . - - rv_sadl_xml = |{ rv_sadl_xml }| & - || & - | | & - | |. - DATA(lt_properties) = mo_customizing->get_properties( ). - DELETE lt_properties WHERE entity_name <> -entity_name. - - LOOP AT lt_properties ASSIGNING FIELD-SYMBOL() WHERE is_key = abap_false. - rv_sadl_xml = |{ rv_sadl_xml }| & - | |. - ENDLOOP. - rv_sadl_xml = |{ rv_sadl_xml }| & ||. - ENDLOOP. - - rv_sadl_xml = |{ rv_sadl_xml }| & || & - ||. - ENDMETHOD. - - METHOD get_table_type. - DATA lo_structure TYPE REF TO cl_abap_structdescr. - - lo_structure ?= cl_abap_elemdescr=>describe_by_name( iv_structure ). - IF NOT lo_structure->is_ddic_type( ). - return. - ENDIF. - - CASE lo_structure->get_ddic_header( )-tabtype. - WHEN 'B'. - rv_type = 'CDS'. - WHEN 'T'. - rv_type = 'DDIC'. - WHEN OTHERS. - return. - ENDCASE. + DATA(lo_sadl) = NEW zcl_odata_fw_sadl( ). + rv_sadl_xml = lo_sadl->generate_sadl_xml( it_entities = lt_entities + it_properties = lt_properties ). ENDMETHOD. ENDCLASS. diff --git a/src/zcl_odata_fw_sadl.clas.abap b/src/zcl_odata_fw_sadl.clas.abap new file mode 100644 index 0000000..77ee2a3 --- /dev/null +++ b/src/zcl_odata_fw_sadl.clas.abap @@ -0,0 +1,88 @@ +"!

SADL Config

+CLASS zcl_odata_fw_sadl DEFINITION + PUBLIC + CREATE PUBLIC. + + PUBLIC SECTION. + "!

Generate SADL XML

+ "! + "! @parameter it_entities |

Entities

+ "! @parameter it_properties |

Properties

+ "! @parameter rv_sadl_xml |

SADL XML

+ METHODS generate_sadl_xml + IMPORTING it_entities TYPE zodata_entity_tt + it_properties TYPE zodata_property_tt + RETURNING VALUE(rv_sadl_xml) TYPE string. + + PROTECTED SECTION. + + PRIVATE SECTION. + "!

Get table type

+ "! @parameter iv_structure |

Structure name

+ "! @parameter rv_type |

Table type

+ METHODS get_table_type + IMPORTING iv_structure TYPE zodata_entity-structure + RETURNING VALUE(rv_type) TYPE string. +ENDCLASS. + + +CLASS zcl_odata_fw_sadl IMPLEMENTATION. + METHOD generate_sadl_xml. + DATA lt_sadl_entities TYPE zodata_entity_tt. + + rv_sadl_xml = || & + ||. + + LOOP AT it_entities ASSIGNING FIELD-SYMBOL() WHERE is_complex = abap_false. + + DATA(lv_type) = get_table_type( -structure ). + + IF lv_type IS INITIAL. + CONTINUE. + ENDIF. + + rv_sadl_xml = |{ rv_sadl_xml }| & + | |. + APPEND TO lt_sadl_entities. + ENDLOOP. + + rv_sadl_xml = |{ rv_sadl_xml }| & ||. + LOOP AT lt_sadl_entities ASSIGNING . + + rv_sadl_xml = |{ rv_sadl_xml }| & + || & + | | & + | |. + + DATA(lt_properties) = it_properties. + DELETE lt_properties WHERE entity_name <> -entity_name. + + LOOP AT lt_properties ASSIGNING FIELD-SYMBOL() WHERE is_key = abap_false. + rv_sadl_xml = |{ rv_sadl_xml }| & + | |. + ENDLOOP. + rv_sadl_xml = |{ rv_sadl_xml }| & ||. + ENDLOOP. + + rv_sadl_xml = |{ rv_sadl_xml }| & || & + ||. + ENDMETHOD. + + METHOD get_table_type. + DATA lo_structure TYPE REF TO cl_abap_structdescr. + + lo_structure ?= cl_abap_elemdescr=>describe_by_name( iv_structure ). + IF NOT lo_structure->is_ddic_type( ). + RETURN. + ENDIF. + + CASE lo_structure->get_ddic_header( )-tabtype. + WHEN 'B'. + rv_type = 'CDS'. + WHEN 'T'. + rv_type = 'DDIC'. + WHEN OTHERS. + RETURN. + ENDCASE. + ENDMETHOD. +ENDCLASS. diff --git a/src/zcl_odata_fw_sadl.clas.xml b/src/zcl_odata_fw_sadl.clas.xml new file mode 100644 index 0000000..8d64a8b --- /dev/null +++ b/src/zcl_odata_fw_sadl.clas.xml @@ -0,0 +1,60 @@ + + + + + + ZCL_ODATA_FW_SADL + E + SADL Config + 1 + X + X + X + + + + GENERATE_SADL_XML + E + Generate SADL XML + + + GET_TABLE_TYPE + E + Get table type + + + + + GENERATE_SADL_XML + IT_ENTITIES + E + Entities + + + GENERATE_SADL_XML + IT_PROPERTIES + E + Properties + + + GENERATE_SADL_XML + RV_SADL_XML + E + SADL XML + + + GET_TABLE_TYPE + IV_STRUCTURE + E + Structure name + + + GET_TABLE_TYPE + RV_TYPE + E + Table type + + + + + diff --git a/src/zcl_odata_main.clas.abap b/src/zcl_odata_main.clas.abap index 713d236..7d6cc7b 100644 --- a/src/zcl_odata_main.clas.abap +++ b/src/zcl_odata_main.clas.abap @@ -11,12 +11,14 @@ CLASS zcl_odata_main DEFINITION "!

Constructor

"! @parameter io_dpc_object |

DPC object

- "! @parameter iv_namespace |

Namespace

+ "! @parameter iv_namespace |

Namespace

METHODS constructor IMPORTING io_dpc_object TYPE REF TO /iwbep/cl_mgw_push_abs_data iv_namespace TYPE z_odata_namespace. "!

Before processing

+ "! @raising /iwbep/cx_mgw_tech_exception |

Technical exception

+ "! @raising /iwbep/cx_mgw_busi_exception |

Business exception

METHODS before_processing RAISING /iwbep/cx_mgw_tech_exception /iwbep/cx_mgw_busi_exception. @@ -32,6 +34,10 @@ CLASS zcl_odata_main DEFINITION DATA mv_namespace TYPE z_odata_namespace. DATA mo_context TYPE REF TO /iwbep/if_mgw_context. + "!

Copy data to reference

+ "! + "! @parameter i_data |

Data

+ "! @parameter c_data |

Reference

METHODS copy_data_to_ref IMPORTING i_data TYPE any CHANGING c_data TYPE REF TO data. @@ -42,39 +48,82 @@ CLASS zcl_odata_main DEFINITION RAISING /iwbep/cx_mgw_tech_exception /iwbep/cx_mgw_busi_exception. + "!

Sort/order collection

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter c_data |

Data

+ "! @raising /iwbep/cx_mgw_tech_exception |

Error

METHODS order_collection IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset CHANGING c_data TYPE table RAISING /iwbep/cx_mgw_tech_exception. + "!

Get order by clause

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter rv_orderby_clause |

Order by clause

METHODS get_orderby_clause IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset RETURNING VALUE(rv_orderby_clause) TYPE string. + "!

Filter collection

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter c_data |

Data

+ "! @raising /iwbep/cx_mgw_tech_exception |

Tech error

+ "! @raising /iwbep/cx_mgw_busi_exception |

Business error

METHODS filter_collection IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset CHANGING c_data TYPE table RAISING /iwbep/cx_mgw_tech_exception /iwbep/cx_mgw_busi_exception. + "!

Paginate collection

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter c_data |

Data

METHODS paginate_collection IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset CHANGING c_data TYPE table. + "!

Get properties

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter r_properties |

Properties

+ "! @raising /iwbep/cx_mgw_tech_exception |

Error

METHODS get_properties IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset RETURNING VALUE(r_properties) TYPE /iwbep/if_mgw_odata_re_prop=>ty_t_mgw_odata_properties RAISING /iwbep/cx_mgw_tech_exception. + "!

Raise error

+ "! + "! @parameter i_error |

Error object

+ "! @raising /iwbep/cx_mgw_busi_exception |

Converted error

METHODS raise_error IMPORTING i_error TYPE REF TO cx_root RAISING /iwbep/cx_mgw_busi_exception. + "!

Get request header

+ "! + "! @parameter r_request_headers |

Request header

+ "! @raising /iwbep/cx_mgw_tech_exception |

Error

METHODS get_request_header RETURNING VALUE(r_request_headers) TYPE tihttpnvp RAISING /iwbep/cx_mgw_tech_exception. PRIVATE SECTION. + "!

Convert dynamic where

+ "! + "! @parameter io_tech_request_context |

Tech request

+ "! @parameter rt_dynamic_where |

Dynamic where table

+ "! @raising /iwbep/cx_mgw_busi_exception |

Business error

+ "! @raising /iwbep/cx_mgw_tech_exception |

Technical error

+ METHODS convert_dynamic_where + IMPORTING io_tech_request_context TYPE REF TO /iwbep/if_mgw_req_entityset + RETURNING VALUE(rt_dynamic_where) TYPE rsds_twhere + RAISING /iwbep/cx_mgw_busi_exception + /iwbep/cx_mgw_tech_exception. ENDCLASS. @@ -214,10 +263,8 @@ CLASS zcl_odata_main IMPLEMENTATION. ENDMETHOD. METHOD filter_collection. - DATA dynamic_where TYPE rsds_twhere. - DATA dynamic_where_line LIKE LINE OF dynamic_where. - DATA field_ranges TYPE rsds_trange. - DATA entries TYPE REF TO data. + DATA field_ranges TYPE rsds_trange. + DATA entries TYPE REF TO data. FIELD-SYMBOLS LIKE c_data. TRY. @@ -238,66 +285,43 @@ CLASS zcl_odata_main IMPLEMENTATION. ENDLOOP. ENDLOOP. ELSE. - TRY. - DATA(osql_where_clause) = io_tech_request_context->get_osql_where_clause_convert( ). - IF osql_where_clause IS INITIAL. - RETURN. - ENDIF. - REPLACE ALL OCCURRENCES OF '(' IN osql_where_clause WITH ''. - REPLACE ALL OCCURRENCES OF ')' IN osql_where_clause WITH ''. - REPLACE ALL OCCURRENCES OF | OR | IN osql_where_clause WITH | AND |. - dynamic_where_line-tablename = 'TEST'. - - ##TODO " line ist nur 72 zeichen lang. der osql string muss aufgeteilt werden. - DATA(length_osql) = strlen( osql_where_clause ). - - IF length_osql <= 72. - dynamic_where_line-where_tab = VALUE #( ( |{ osql_where_clause }| ) ). - APPEND dynamic_where_line TO dynamic_where. - ELSE. - SPLIT osql_where_clause AT 'AND' INTO TABLE DATA(split_osql). - - LOOP AT split_osql ASSIGNING FIELD-SYMBOL(). - APPEND |{ } { - COND char03( WHEN sy-tabix = lines( split_osql ) - THEN '' - ELSE 'AND' ) }| TO dynamic_where_line-where_tab. - ENDLOOP. - ENDIF. - APPEND dynamic_where_line TO dynamic_where. - - CALL FUNCTION 'FREE_SELECTIONS_WHERE_2_RANGE' - EXPORTING where_clauses = dynamic_where " Abgrenzungen in Form RSDS_TWHERE - IMPORTING field_ranges = field_ranges " Abgrenzungen in Form RSDS_TRANGE - EXCEPTIONS expression_not_supported = 1 " (Noch) nicht unterstützter logischer Ausdruck - incorrect_expression = 2 " Inkorrekter logischer Ausdruck - OTHERS = 3. - IF sy-subrc <> 0. - RETURN. + DATA(lt_dynamic_where) = convert_dynamic_where( io_tech_request_context ). + + IF lt_dynamic_where IS INITIAL. + RETURN. + ENDIF. + + CALL FUNCTION 'FREE_SELECTIONS_WHERE_2_RANGE' + EXPORTING where_clauses = lt_dynamic_where " Abgrenzungen in Form RSDS_TWHERE + IMPORTING field_ranges = field_ranges " Abgrenzungen in Form RSDS_TRANGE + EXCEPTIONS expression_not_supported = 1 " (Noch) nicht unterstützter logischer Ausdruck + incorrect_expression = 2 " Inkorrekter logischer Ausdruck + OTHERS = 3. + IF sy-subrc <> 0. + RETURN. + ENDIF. + DATA(ranges) = field_ranges[ 1 ]. + CREATE DATA entries LIKE c_data. + ASSIGN entries->* TO . + + IF sy-subrc <> 0. + RETURN. + ENDIF. + + LOOP AT ranges-frange_t ASSIGNING FIELD-SYMBOL(). + LOOP AT c_data ASSIGNING . + tabix = sy-tabix. + ASSIGN COMPONENT -fieldname OF STRUCTURE TO . + IF NOT ( sy-subrc = 0 AND IS ASSIGNED ). + CONTINUE. ENDIF. - DATA(ranges) = field_ranges[ 1 ]. - CREATE DATA entries LIKE c_data. - ASSIGN entries->* TO . - - IF sy-subrc <> 0. - RETURN. + IF IN -selopt_t. + APPEND TO . + DELETE c_data INDEX tabix. ENDIF. - - LOOP AT ranges-frange_t ASSIGNING FIELD-SYMBOL(). - LOOP AT c_data ASSIGNING . - tabix = sy-tabix. - ASSIGN COMPONENT -fieldname OF STRUCTURE TO . - IF NOT ( sy-subrc = 0 AND IS ASSIGNED ). - CONTINUE. - ENDIF. - IF IN -selopt_t. - APPEND TO . - DELETE c_data INDEX tabix. - ENDIF. - ENDLOOP. - ENDLOOP. - c_data = . - ENDTRY. + ENDLOOP. + ENDLOOP. + c_data = . ENDIF. CATCH /iwbep/cx_mgw_med_exception. ENDTRY. @@ -312,8 +336,7 @@ CLASS zcl_odata_main IMPLEMENTATION. )->get_entity_type( iv_entity_name = io_tech_request_context->get_entity_type_name( ) )->get_properties( ). CATCH /iwbep/cx_mgw_med_exception INTO DATA(error). - RAISE EXCEPTION TYPE /iwbep/cx_mgw_med_exception - EXPORTING previous = error. + RAISE EXCEPTION NEW /iwbep/cx_mgw_med_exception( previous = error ). ENDTRY. ENDMETHOD. @@ -378,7 +401,7 @@ CLASS zcl_odata_main IMPLEMENTATION. DATA(max_entries) = lines( c_data ). IF top IS NOT INITIAL AND max_entries > top. - top = top + 1. + top += 1. DELETE c_data FROM top TO max_entries. ENDIF. ENDMETHOD. @@ -417,4 +440,35 @@ CLASS zcl_odata_main IMPLEMENTATION. METHOD set_context. mo_context = io_context. ENDMETHOD. + + METHOD convert_dynamic_where. + DATA ls_dynamic_where_line LIKE LINE OF rt_dynamic_where. + + DATA(lv_osql_where_clause) = io_tech_request_context->get_osql_where_clause_convert( ). + IF lv_osql_where_clause IS INITIAL. + RETURN. + ENDIF. + REPLACE ALL OCCURRENCES OF '(' IN lv_osql_where_clause WITH ''. + REPLACE ALL OCCURRENCES OF ')' IN lv_osql_where_clause WITH ''. + REPLACE ALL OCCURRENCES OF | OR | IN lv_osql_where_clause WITH | AND |. + ls_dynamic_where_line-tablename = 'TEST'. + + ##TODO " line ist nur 72 zeichen lang. der osql string muss aufgeteilt werden. + DATA(length_osql) = strlen( lv_osql_where_clause ). + + IF length_osql <= 72. + ls_dynamic_where_line-where_tab = VALUE #( ( |{ lv_osql_where_clause }| ) ). + APPEND ls_dynamic_where_line TO rt_dynamic_where. + ELSE. + SPLIT lv_osql_where_clause AT 'AND' INTO TABLE DATA(lt_split_osql). + + LOOP AT lt_split_osql ASSIGNING FIELD-SYMBOL(). + APPEND |{ } { + COND char03( WHEN sy-tabix = lines( lt_split_osql ) + THEN '' + ELSE 'AND' ) }| TO ls_dynamic_where_line-where_tab. + ENDLOOP. + ENDIF. + APPEND ls_dynamic_where_line TO rt_dynamic_where. + ENDMETHOD. ENDCLASS. diff --git a/src/zcl_odata_main.clas.xml b/src/zcl_odata_main.clas.xml index f7c6b71..2663047 100644 --- a/src/zcl_odata_main.clas.xml +++ b/src/zcl_odata_main.clas.xml @@ -22,7 +22,233 @@ D Constructor + + CONVERT_DYNAMIC_WHERE + D + Convert dynamic where + + + COPY_DATA_TO_REF + D + Copy data to reference + + + FILTER_COLLECTION + D + Filter collection + + + GET_ORDERBY_CLAUSE + D + Get order by clause + + + GET_PROPERTIES + D + Get properties + + + GET_REQUEST_HEADER + D + Get request header + + + ORDER_COLLECTION + D + Sort/order collection + + + PAGINATE_COLLECTION + D + Paginate collection + + + RAISE_ERROR + D + Raise error + + + SET_CONTEXT + D + Set context + + + + BEFORE_PROCESSING + /IWBEP/CX_MGW_BUSI_EXCEPTION + D + Business exception + + + BEFORE_PROCESSING + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Technical exception + + + CONSTRUCTOR + IO_DPC_OBJECT + D + DPC object + + + CONSTRUCTOR + IV_NAMESPACE + D + Namespace + + + CONVERT_DYNAMIC_WHERE + /IWBEP/CX_MGW_BUSI_EXCEPTION + D + Business error + + + CONVERT_DYNAMIC_WHERE + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Technical error + + + CONVERT_DYNAMIC_WHERE + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + CONVERT_DYNAMIC_WHERE + RT_DYNAMIC_WHERE + D + Dynamic where table + + + COPY_DATA_TO_REF + C_DATA + D + Reference + + + COPY_DATA_TO_REF + I_DATA + D + Data + + + FILTER_COLLECTION + /IWBEP/CX_MGW_BUSI_EXCEPTION + D + Business error + + + FILTER_COLLECTION + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Tech error + + + FILTER_COLLECTION + C_DATA + D + Data + + + FILTER_COLLECTION + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + GET_ORDERBY_CLAUSE + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + GET_ORDERBY_CLAUSE + RV_ORDERBY_CLAUSE + D + Order by clause + + + GET_PROPERTIES + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Error + + + GET_PROPERTIES + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + GET_PROPERTIES + R_PROPERTIES + D + Properties + + + GET_REQUEST_HEADER + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Error + + + GET_REQUEST_HEADER + R_REQUEST_HEADERS + D + Request header + + + ORDER_COLLECTION + /IWBEP/CX_MGW_TECH_EXCEPTION + D + Error + + + ORDER_COLLECTION + C_DATA + D + Data + + + ORDER_COLLECTION + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + PAGINATE_COLLECTION + C_DATA + D + Data + + + PAGINATE_COLLECTION + IO_TECH_REQUEST_CONTEXT + D + Tech request + + + RAISE_ERROR + /IWBEP/CX_MGW_BUSI_EXCEPTION + D + Converted error + + + RAISE_ERROR + I_ERROR + D + Error object + + + SET_CONTEXT + IO_CONTEXT + D + Context + +
diff --git a/src/zif_odata_constants.intf.xml b/src/zif_odata_constants.intf.xml index bc5c731..b9fe112 100644 --- a/src/zif_odata_constants.intf.xml +++ b/src/zif_odata_constants.intf.xml @@ -4,7 +4,7 @@ ZIF_ODATA_CONSTANTS - D + E Odata Constants 2 1 diff --git a/src/zodata_act_param.tabl.xml b/src/zodata_act_param.tabl.xml index fa375be..faf9d49 100644 --- a/src/zodata_act_param.tabl.xml +++ b/src/zodata_act_param.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Action Parameters + D C + 1 ZODATA_ACT_PARAM diff --git a/src/zodata_actions.tabl.xml b/src/zodata_actions.tabl.xml index 8b57b18..4c61135 100644 --- a/src/zodata_actions.tabl.xml +++ b/src/zodata_actions.tabl.xml @@ -4,9 +4,13 @@ ZODATA_ACTIONS + D TRANSP X + OData actions + D C + 1 ZODATA_ACTIONS diff --git a/src/zodata_cust.fugr.xml b/src/zodata_cust.fugr.xml index f38d470..cb0ddf9 100644 --- a/src/zodata_cust.fugr.xml +++ b/src/zodata_cust.fugr.xml @@ -600,7 +600,6 @@ VIEWFRAME_ZODATA_V_PROP - Extended Table Maintenance: Upper Level VIEW_ACTION @@ -650,52 +649,42 @@ VIEW_ACTION P - Aktion mit dem View: anzeigen/ändern (S/U) VIEW_NAME P - Name des Views CORR_NUMBER P - Korrekturnummer für durchgeführte Änderungen DBA_SELLIST P - Selektionsbedingungen für den DB-Zugriff DPL_SELLIST P - Selektionsbedingungen für die Anzeige EXCL_CUA_FUNCT P - Tabelle mit dynam. zu deaktivierenden CUA-Funkt. X_HEADER P - Kontrollblocktabelle für den View X_NAMTAB P - Kontrollblocktabelle für die View-Felder NO_VALUE_FOR_SUBSET_IDENT X - für 'SUBSET'-Feld wurde kein Wert vorgegeben MISSING_CORR_NUMBER X - Korrekturnummer fehlt @@ -1396,7 +1385,6 @@ VIEWPROC_ZODATA_V_PROP X - Lower-level extended table maintenance FCODE @@ -1474,92 +1462,74 @@ FCODE P - gewünschte Funktion des Bausteins VIEW_ACTION P - Aktion mit dem View: anzeigen/ändern (S/U) VIEW_NAME P - Name des Views CORR_NUMBER P - Korrekturnummer für durchgeführte Änderungen LAST_ACT_ENTRY P - Index der Cursorposition in der Anzeigetabelle UCOMM P - letztes User-command innerhalb der Viewpflege UPDATE_REQUIRED P - Flag: Einträge verändert, Sichern erforderlich CORR_KEYTAB P - Tabelle mit den Keys der zu transport. Einträge DBA_SELLIST P - Selektionsbedingungen für den DB-Zugriff DPL_SELLIST P - Selektionsbedingungen für die Anzeige EXCL_CUA_FUNCT P - Tab. der nicht zu aktivierenden CUA-Funktionen EXTRACT P - Tab. der gerade sichtbaren Daten (Anzeigetabelle TOTAL P - Tabelle, mit allen von der DB gelesenen Daten X_HEADER P - Kontrollblocktabelle für den View X_NAMTAB P - Kontrollblocktabelle für die View-Felder NO_VALUE_FOR_SUBSET_IDENT X - für ein 'SUBSET'-Feld wurde kein Wert vorgegeben MISSING_CORR_NUMBER X - Korrekturnummer fehlt SAVING_CORRECTION_FAILED X - Fehler beim Sichern der Korrektureinträge diff --git a/src/zodata_entity.tabl.xml b/src/zodata_entity.tabl.xml index afc12f9..d8dbcfd 100644 --- a/src/zodata_entity.tabl.xml +++ b/src/zodata_entity.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Odata Entität + D C + 1 ZODATA_ENTITY diff --git a/src/zodata_entitys.tobj.xml b/src/zodata_entitys.tobj.xml index cf5f60a..461cb0b 100644 --- a/src/zodata_entitys.tobj.xml +++ b/src/zodata_entitys.tobj.xml @@ -14,7 +14,7 @@ D ZODATA_ENTITY S - Odata Entität + OData Entity diff --git a/src/zodata_namespace.tabl.xml b/src/zodata_namespace.tabl.xml index 2b4d0c7..d1af9d7 100644 --- a/src/zodata_namespace.tabl.xml +++ b/src/zodata_namespace.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Namespace Odata Customizing + D C + 1 ZODATA_NAMESPACE diff --git a/src/zodata_namespaces.tobj.xml b/src/zodata_namespaces.tobj.xml index 12f2f2e..62fb947 100644 --- a/src/zodata_namespaces.tobj.xml +++ b/src/zodata_namespaces.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_NAMESPACE S - Namespace Odata Customizing diff --git a/src/zodata_nav.tabl.xml b/src/zodata_nav.tabl.xml index 97fc3cf..2356175 100644 --- a/src/zodata_nav.tabl.xml +++ b/src/zodata_nav.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Navigation Properties + D C + 1 ZODATA_NAV diff --git a/src/zodata_prop_txts.tabl.xml b/src/zodata_prop_txts.tabl.xml index 6e5eb15..b7c05b5 100644 --- a/src/zodata_prop_txts.tabl.xml +++ b/src/zodata_prop_txts.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Property Texts + D C + 1 ZODATA_PROP_TXTS diff --git a/src/zodata_property.tabl.xml b/src/zodata_property.tabl.xml index fa3a0a1..d0af65f 100644 --- a/src/zodata_property.tabl.xml +++ b/src/zodata_property.tabl.xml @@ -8,7 +8,9 @@ TRANSP X Eigenschaften + D C + 1 ZODATA_PROPERTY diff --git a/src/zodata_searchhlp.tabl.xml b/src/zodata_searchhlp.tabl.xml index 4e062a0..cd1c3bc 100644 --- a/src/zodata_searchhlp.tabl.xml +++ b/src/zodata_searchhlp.tabl.xml @@ -8,7 +8,9 @@ TRANSP X OData search helps + D C + 1 ZODATA_SEARCHHLP diff --git a/src/zodata_searchhlps.tobj.xml b/src/zodata_searchhlps.tobj.xml index a24706c..90e36ad 100644 --- a/src/zodata_searchhlps.tobj.xml +++ b/src/zodata_searchhlps.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_SEARCHHLP S - OData search helps diff --git a/src/zodata_v_actionsv.tobj.xml b/src/zodata_v_actionsv.tobj.xml index a0e78f0..9b2fbad 100644 --- a/src/zodata_v_actionsv.tobj.xml +++ b/src/zodata_v_actionsv.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_ACTIONS V - Actions Customizing View diff --git a/src/zodata_v_actparav.tobj.xml b/src/zodata_v_actparav.tobj.xml index cf282cf..fb6a327 100644 --- a/src/zodata_v_actparav.tobj.xml +++ b/src/zodata_v_actparav.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_ACTPARA V - Action Parameters diff --git a/src/zodata_v_entityv.tobj.xml b/src/zodata_v_entityv.tobj.xml index 1e42c63..f05a315 100644 --- a/src/zodata_v_entityv.tobj.xml +++ b/src/zodata_v_entityv.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_ENTITY V - Customizing Entity diff --git a/src/zodata_v_navv.tobj.xml b/src/zodata_v_navv.tobj.xml index 82da39a..15e3e6c 100644 --- a/src/zodata_v_navv.tobj.xml +++ b/src/zodata_v_navv.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_NAV V - Pflegeview Navigation Property diff --git a/src/zodata_v_proptxtv.tobj.xml b/src/zodata_v_proptxtv.tobj.xml index ac8a53a..30cd7ea 100644 --- a/src/zodata_v_proptxtv.tobj.xml +++ b/src/zodata_v_proptxtv.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_PROPTXT V - Property Text Customizing diff --git a/src/zodata_v_propv.tobj.xml b/src/zodata_v_propv.tobj.xml index 816affe..432ba4a 100644 --- a/src/zodata_v_propv.tobj.xml +++ b/src/zodata_v_propv.tobj.xml @@ -14,7 +14,6 @@ D ZODATA_V_PROP V - Customizing View Properties diff --git a/src/zodata_vc c.tobj.xml b/src/zodata_vc c.tobj.xml index 9f8ca5a..926a5a5 100644 --- a/src/zodata_vc c.tobj.xml +++ b/src/zodata_vc c.tobj.xml @@ -10,11 +10,6 @@ 2 3 - - D - ZODATA_VC - C - ZODATA_VC From a6e0eca229caadf8787c8617084388f28948a34b Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 14:58:57 +0200 Subject: [PATCH 02/11] refactor: :recycle: fixed lint issues --- src/zcl_odata_main.clas.abap | 2 +- src/zodata_id_descrption_cmplxtype.tabl.xml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zcl_odata_main.clas.abap b/src/zcl_odata_main.clas.abap index 7d6cc7b..d7f481e 100644 --- a/src/zcl_odata_main.clas.abap +++ b/src/zcl_odata_main.clas.abap @@ -401,7 +401,7 @@ CLASS zcl_odata_main IMPLEMENTATION. DATA(max_entries) = lines( c_data ). IF top IS NOT INITIAL AND max_entries > top. - top += 1. + top = top + 1. DELETE c_data FROM top TO max_entries. ENDIF. ENDMETHOD. diff --git a/src/zodata_id_descrption_cmplxtype.tabl.xml b/src/zodata_id_descrption_cmplxtype.tabl.xml index ef295e9..8b07d40 100644 --- a/src/zodata_id_descrption_cmplxtype.tabl.xml +++ b/src/zodata_id_descrption_cmplxtype.tabl.xml @@ -7,6 +7,8 @@ D INTTAB Complex Type 4 Value Description + E + 1 From dd9d59151e2da1cda40381ed052ddb0831af67a4 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 13:17:01 +0000 Subject: [PATCH 03/11] chore: automatic after pull changes --- src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml | 2 +- src/zif_odata_constants.intf.xml | 2 +- src/zodata_entitys.tobj.xml | 2 +- src/zodata_namespaces.tobj.xml | 1 + src/zodata_searchhlps.tobj.xml | 1 + src/zodata_v_actionsv.tobj.xml | 1 + src/zodata_v_actparav.tobj.xml | 1 + src/zodata_v_entityv.tobj.xml | 1 + src/zodata_v_navv.tobj.xml | 1 + src/zodata_v_proptxtv.tobj.xml | 1 + src/zodata_v_propv.tobj.xml | 1 + src/zodata_vc c.tobj.xml | 5 +++++ 12 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml b/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml index 830fb1a..b8ae3cd 100644 --- a/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml +++ b/src/z_odata_annotations/zcl_odata_annotaion_sap.clas.xml @@ -4,7 +4,7 @@ ZCL_ODATA_ANNOTAION_SAP - E + D SAP Annotation namespace 1 X diff --git a/src/zif_odata_constants.intf.xml b/src/zif_odata_constants.intf.xml index b9fe112..bc5c731 100644 --- a/src/zif_odata_constants.intf.xml +++ b/src/zif_odata_constants.intf.xml @@ -4,7 +4,7 @@ ZIF_ODATA_CONSTANTS - E + D Odata Constants 2 1 diff --git a/src/zodata_entitys.tobj.xml b/src/zodata_entitys.tobj.xml index 461cb0b..cf5f60a 100644 --- a/src/zodata_entitys.tobj.xml +++ b/src/zodata_entitys.tobj.xml @@ -14,7 +14,7 @@ D ZODATA_ENTITY S - OData Entity + Odata Entität diff --git a/src/zodata_namespaces.tobj.xml b/src/zodata_namespaces.tobj.xml index 62fb947..12f2f2e 100644 --- a/src/zodata_namespaces.tobj.xml +++ b/src/zodata_namespaces.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_NAMESPACE S + Namespace Odata Customizing diff --git a/src/zodata_searchhlps.tobj.xml b/src/zodata_searchhlps.tobj.xml index 90e36ad..a24706c 100644 --- a/src/zodata_searchhlps.tobj.xml +++ b/src/zodata_searchhlps.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_SEARCHHLP S + OData search helps diff --git a/src/zodata_v_actionsv.tobj.xml b/src/zodata_v_actionsv.tobj.xml index 9b2fbad..a0e78f0 100644 --- a/src/zodata_v_actionsv.tobj.xml +++ b/src/zodata_v_actionsv.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_ACTIONS V + Actions Customizing View diff --git a/src/zodata_v_actparav.tobj.xml b/src/zodata_v_actparav.tobj.xml index fb6a327..cf282cf 100644 --- a/src/zodata_v_actparav.tobj.xml +++ b/src/zodata_v_actparav.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_ACTPARA V + Action Parameters diff --git a/src/zodata_v_entityv.tobj.xml b/src/zodata_v_entityv.tobj.xml index f05a315..1e42c63 100644 --- a/src/zodata_v_entityv.tobj.xml +++ b/src/zodata_v_entityv.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_ENTITY V + Customizing Entity diff --git a/src/zodata_v_navv.tobj.xml b/src/zodata_v_navv.tobj.xml index 15e3e6c..82da39a 100644 --- a/src/zodata_v_navv.tobj.xml +++ b/src/zodata_v_navv.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_NAV V + Pflegeview Navigation Property diff --git a/src/zodata_v_proptxtv.tobj.xml b/src/zodata_v_proptxtv.tobj.xml index 30cd7ea..ac8a53a 100644 --- a/src/zodata_v_proptxtv.tobj.xml +++ b/src/zodata_v_proptxtv.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_PROPTXT V + Property Text Customizing diff --git a/src/zodata_v_propv.tobj.xml b/src/zodata_v_propv.tobj.xml index 432ba4a..816affe 100644 --- a/src/zodata_v_propv.tobj.xml +++ b/src/zodata_v_propv.tobj.xml @@ -14,6 +14,7 @@ D ZODATA_V_PROP V + Customizing View Properties diff --git a/src/zodata_vc c.tobj.xml b/src/zodata_vc c.tobj.xml index 926a5a5..9f8ca5a 100644 --- a/src/zodata_vc c.tobj.xml +++ b/src/zodata_vc c.tobj.xml @@ -10,6 +10,11 @@ 2 3 + + D + ZODATA_VC + C + ZODATA_VC From ddaf246900c2083c71f2d892dff9a1751ca61541 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 14:07:19 +0000 Subject: [PATCH 04/11] refactoring: reduce method size --- src/zcl_odata_value_help.clas.abap | 453 ++++++++++++++--------------- src/zcl_odata_value_help.clas.xml | 132 +++++++++ 2 files changed, 345 insertions(+), 240 deletions(-) diff --git a/src/zcl_odata_value_help.clas.abap b/src/zcl_odata_value_help.clas.abap index 44d17d7..4850f90 100644 --- a/src/zcl_odata_value_help.clas.abap +++ b/src/zcl_odata_value_help.clas.abap @@ -1,8 +1,8 @@ -"!

Dynamic Value help

+"!

Dynamic Value help

CLASS zcl_odata_value_help DEFINITION PUBLIC INHERITING FROM zcl_odata_main - CREATE PUBLIC . + CREATE PUBLIC. PUBLIC SECTION. TYPES: @@ -12,349 +12,322 @@ CLASS zcl_odata_value_help DEFINITION description TYPE string, END OF tty_value_help, tty_t_value_help TYPE STANDARD TABLE OF tty_value_help WITH KEY search_help value. - METHODS: - /iwbep/if_mgw_appl_srv_runtime~get_entityset REDEFINITION, - /iwbep/if_mgw_appl_srv_runtime~get_entity REDEFINITION. + + METHODS /iwbep/if_mgw_appl_srv_runtime~get_entityset REDEFINITION. + METHODS /iwbep/if_mgw_appl_srv_runtime~get_entity REDEFINITION. + PROTECTED SECTION. + PRIVATE SECTION. TYPES: BEGIN OF ty_s_clause, - line(72) TYPE c, + line TYPE c LENGTH 72, END OF ty_s_clause, ty_t_clause TYPE STANDARD TABLE OF ty_s_clause WITH EMPTY KEY. - METHODS: - "!

Get customizing

- "! - "! @parameter i_filter |

Search field filter

- "! @parameter r_sh_cust |

Customizing

- "! @raising zcx_odata |

Error

- get_customizing - IMPORTING - i_filter TYPE /iwbep/t_cod_select_options - RETURNING - VALUE(r_sh_cust) TYPE zodata_searchhlp - RAISING - zcx_odata, - "!

Get texttable from table

- "! - "! @parameter i_table_name |

Table name

- "! @parameter e_checkfield |

Field to check for

- "! @parameter r_texttable |

Text table

- get_texttable - IMPORTING - i_table_name TYPE tabname - EXPORTING - e_checkfield TYPE dd08v-fieldname - RETURNING - VALUE(r_texttable) TYPE dd08v-tabname, - "!

Get values by table

- "! - "! @parameter i_customizing |

Customizing

- "! @parameter r_value_help |

Value help data

- get_data_by_table - IMPORTING - i_customizing TYPE zodata_searchhlp - RETURNING - VALUE(r_value_help) TYPE tty_t_value_help, - "!

Get values by domain

- "! - "! @parameter i_customizing |

Customizing

- "! @parameter r_value_help |

Value help data

- "! @raising zcx_odata |

Error

- get_data_by_domain - IMPORTING - i_customizing TYPE zodata_searchhlp - RETURNING - VALUE(r_value_help) TYPE tty_t_value_help - RAISING - zcx_odata, - "!

Build dynamic where condition

- "! - "! @parameter i_customizing |

Customizing

- "! @parameter r_where_cond |

Error

- build_where_condition - IMPORTING - i_customizing TYPE zodata_searchhlp - RETURNING - VALUE(r_where_cond) TYPE ty_t_clause. + "!

Get customizing

+ "! + "! @parameter i_filter |

Search field filter

+ "! @parameter r_sh_cust |

Customizing

+ "! @raising zcx_odata |

Error

+ METHODS get_customizing + IMPORTING i_filter TYPE /iwbep/t_cod_select_options + RETURNING VALUE(r_sh_cust) TYPE zodata_searchhlp + RAISING zcx_odata. + + "!

Get texttable from table

+ "! + "! @parameter i_table_name |

Table name

+ "! @parameter e_checkfield |

Field to check for

+ "! @parameter r_texttable |

Text table

+ METHODS get_texttable + IMPORTING i_table_name TYPE tabname + EXPORTING e_checkfield TYPE dd08v-fieldname + RETURNING VALUE(r_texttable) TYPE dd08v-tabname. + + "!

Get values by table

+ "! + "! @parameter i_customizing |

Customizing

+ "! @parameter r_value_help |

Value help data

+ METHODS get_data_by_table + IMPORTING i_customizing TYPE zodata_searchhlp + RETURNING VALUE(r_value_help) TYPE tty_t_value_help. + + "!

Get values by domain

+ "! + "! @parameter i_customizing |

Customizing

+ "! @parameter r_value_help |

Value help data

+ "! @raising zcx_odata |

Error

+ METHODS get_data_by_domain + IMPORTING i_customizing TYPE zodata_searchhlp + RETURNING VALUE(r_value_help) TYPE tty_t_value_help + RAISING zcx_odata. + + "!

Build dynamic where condition

+ "! + "! @parameter i_customizing |

Customizing

+ "! @parameter r_where_cond |

Error

+ METHODS build_where_condition + IMPORTING i_customizing TYPE zodata_searchhlp + RETURNING VALUE(r_where_cond) TYPE ty_t_clause. + + "!

Get table values and information

+ "! + "! @parameter is_customizing |

Customizing

+ "! @parameter ev_checkfield |

Checkfield

+ "! @parameter et_table_values |

Table data

+ "! @parameter et_texttable_values |

Texttable data

+ METHODS get_table_values_and_info + IMPORTING is_customizing TYPE zodata_searchhlp + EXPORTING ev_checkfield TYPE forfield + et_table_values TYPE ANY TABLE + et_texttable_values TYPE any. ENDCLASS. CLASS zcl_odata_value_help IMPLEMENTATION. METHOD /iwbep/if_mgw_appl_srv_runtime~get_entity. - DATA: value_hlp TYPE tty_value_help. - - io_tech_request_context->get_converted_keys( - IMPORTING - es_key_values = value_hlp " Entity Key Values - converted - ). - - me->copy_data_to_ref( - EXPORTING - i_data = value_hlp - CHANGING - c_data = er_entity - ). + DATA value_hlp TYPE tty_value_help. + + io_tech_request_context->get_converted_keys( IMPORTING es_key_values = value_hlp ). " Entity Key Values - converted + + copy_data_to_ref( EXPORTING i_data = value_hlp + CHANGING c_data = er_entity ). ENDMETHOD. METHOD /iwbep/if_mgw_appl_srv_runtime~get_entityset. - DATA: value_help TYPE tty_t_value_help, - ls_customizing TYPE zodata_searchhlp, - lt_filter_options TYPE /iwbep/s_mgw_select_option-select_options. + DATA value_help TYPE tty_t_value_help. + DATA ls_customizing TYPE zodata_searchhlp. + DATA lt_filter_options TYPE /iwbep/s_mgw_select_option-select_options. TRY. DATA(filter) = io_tech_request_context->get_filter( )->get_filter_select_options( ). - IF filter IS INITIAL - AND io_tech_request_context->get_entity_type_name( ) = zif_odata_constants=>gc_global_entities-value_help. - RAISE EXCEPTION TYPE zcx_odata - EXPORTING - textid = zcx_odata=>no_filter_passed. + IF filter IS INITIAL + AND io_tech_request_context->get_entity_type_name( ) = zif_odata_constants=>gc_global_entities-value_help. + RAISE EXCEPTION NEW zcx_odata( textid = zcx_odata=>no_filter_passed ). ELSEIF filter IS NOT INITIAL. lt_filter_options = filter[ property = 'SEARCH_HELP' ]-select_options. ELSEIF io_tech_request_context->get_entity_type_name( ) <> zif_odata_constants=>gc_global_entities-value_help. - lt_filter_options = VALUE #( ( low = io_tech_request_context->get_entity_type_name( ) - sign = 'I' - option = 'EQ' ) ). + lt_filter_options = VALUE #( ( low = io_tech_request_context->get_entity_type_name( ) + sign = 'I' + option = 'EQ' ) ). ENDIF. - ls_customizing = me->get_customizing( lt_filter_options ). + ls_customizing = get_customizing( lt_filter_options ). IF ls_customizing-tabname IS NOT INITIAL. - value_help = me->get_data_by_table( i_customizing = ls_customizing ). + value_help = get_data_by_table( i_customizing = ls_customizing ). ELSEIF ls_customizing-data_element IS NOT INITIAL. - value_help = me->get_data_by_domain( i_customizing = ls_customizing ). + value_help = get_data_by_domain( i_customizing = ls_customizing ). ENDIF. " add empty value if none exists IF NOT line_exists( value_help[ value = '' ] ). - APPEND VALUE #( value = '' description = ' ' search_help = ls_customizing-id ) TO value_help. + APPEND VALUE #( value = '' + description = ' ' + search_help = ls_customizing-id ) TO value_help. ENDIF. - me->entityset_filter_page_order( - EXPORTING - io_tech_request_context = io_tech_request_context - CHANGING - c_data = value_help - ). - - me->copy_data_to_ref( - EXPORTING - i_data = value_help - CHANGING - c_data = er_entityset - ). + entityset_filter_page_order( EXPORTING io_tech_request_context = io_tech_request_context + CHANGING c_data = value_help ). + + copy_data_to_ref( EXPORTING i_data = value_help + CHANGING c_data = er_entityset ). CATCH zcx_odata cx_sy_itab_line_not_found INTO DATA(error). - me->raise_error( error ). + raise_error( error ). ENDTRY. ENDMETHOD. METHOD get_texttable. " look if there is a texttable CALL FUNCTION 'DDUT_TEXTTABLE_GET' - EXPORTING - tabname = i_table_name " Name of Table for Text Table Search - IMPORTING - texttable = r_texttable " Text Table if it Exists. Otherwise SPACE. - checkfield = e_checkfield. " Poss. Check Field to which Text Key is Appended + EXPORTING tabname = i_table_name " Name of Table for Text Table Search + IMPORTING texttable = r_texttable " Text Table if it Exists. Otherwise SPACE. + checkfield = e_checkfield. " Poss. Check Field to which Text Key is Appended ENDMETHOD. METHOD get_customizing. - SELECT * - FROM zodata_searchhlp - INTO TABLE @DATA(search_helps) - WHERE id IN @i_filter. + SELECT * FROM zodata_searchhlp + INTO TABLE @DATA(search_helps) + WHERE id IN @i_filter. IF sy-subrc <> 0. - RAISE EXCEPTION TYPE zcx_odata - EXPORTING - textid = zcx_odata=>no_search_help_found. + RAISE EXCEPTION NEW zcx_odata( textid = zcx_odata=>no_search_help_found ). ELSEIF lines( search_helps ) > 1. - RAISE EXCEPTION TYPE zcx_odata - EXPORTING - textid = zcx_odata=>only_one_filter_id. + RAISE EXCEPTION NEW zcx_odata( textid = zcx_odata=>only_one_filter_id ). ENDIF. r_sh_cust = search_helps[ 1 ]. ENDMETHOD. METHOD get_data_by_table. - DATA: description_component TYPE string, - table_name TYPE tabname, - table TYPE REF TO data, - checkfield TYPE dd08v-fieldname, - table_ref TYPE REF TO cl_abap_tabledescr, - keys TYPE ddfields, - structure TYPE REF TO cl_abap_structdescr. + DATA description_component TYPE string. + FIELD-SYMBOLS TYPE ANY TABLE. + FIELD-SYMBOLS TYPE ANY TABLE. - FIELD-SYMBOLS: - TYPE ANY TABLE, - TYPE ANY TABLE. + description_component = i_customizing-description_field. - table_name = i_customizing-tabname. - description_component = i_customizing-description_field. - - CREATE DATA table TYPE TABLE OF (table_name). - ASSIGN table->* TO . - - if sy-subrc <> 0. - return. - endif. - - table_ref ?= cl_abap_tabledescr=>describe_by_data( ). - structure ?= table_ref->get_table_line_type( ). - - structure->get_ddic_field_list( - RECEIVING - p_field_list = keys " List of Dictionary Descriptions for the Components - EXCEPTIONS - not_found = 1 " Type could not be found - no_ddic_type = 2 " Typ is not a dictionary type - OTHERS = 3 - ). - DELETE keys WHERE keyflag <> abap_true. - - DATA(components) = structure->get_components( ). - - DATA(where_cond) = me->build_where_condition( i_customizing ). - - IF line_exists( components[ name = 'SPRAS' ] ) AND line_exists( keys[ fieldname = 'SPRAS' ] ). - SELECT * - FROM (table_name) - INTO TABLE @ - WHERE spras = @sy-langu - AND (where_cond). "#EC CI_SUBRC - ELSE. - SELECT * - FROM (table_name) - INTO TABLE @ - WHERE (where_cond)."#EC CI_SUBRC - - DATA(texttable) = get_texttable( - EXPORTING - i_table_name = table_name - IMPORTING - e_checkfield = checkfield ). + IF sy-subrc <> 0. + RETURN. ENDIF. - IF texttable IS INITIAL. - checkfield = i_customizing-data_element. - ELSE. - CREATE DATA table TYPE TABLE OF (texttable). - ASSIGN table->* TO . - if sy-subrc <> 0. - return. - endif. - - DATA: test TYPE string. - - SELECT * - FROM (texttable) - INTO TABLE @ - WHERE spras = @sy-langu - AND (test). "#EC CI_SUBRC - ENDIF. + get_table_values_and_info( EXPORTING is_customizing = i_customizing + IMPORTING ev_checkfield = DATA(lv_checkfield) + et_table_values = + et_texttable_values = ). LOOP AT ASSIGNING FIELD-SYMBOL(). APPEND INITIAL LINE TO r_value_help ASSIGNING FIELD-SYMBOL(). - ASSIGN COMPONENT checkfield OF STRUCTURE TO FIELD-SYMBOL(). + ASSIGN COMPONENT lv_checkfield OF STRUCTURE TO FIELD-SYMBOL(). - if sy-subrc <> 0. - continue. - endif. + IF sy-subrc <> 0. + CONTINUE. + ENDIF. - -search_help = i_customizing-id. - -value = . + -search_help = i_customizing-id. + -value = . IF IS ASSIGNED. LOOP AT ASSIGNING FIELD-SYMBOL(). - ASSIGN COMPONENT checkfield OF STRUCTURE TO FIELD-SYMBOL(). - if sy-subrc <> 0. - continue. - endif. - CHECK = . + ASSIGN COMPONENT lv_checkfield OF STRUCTURE TO FIELD-SYMBOL(). + IF sy-subrc <> 0. + CONTINUE. + ENDIF. + IF <> . + CONTINUE. + ENDIF. ASSIGN COMPONENT description_component OF STRUCTURE TO FIELD-SYMBOL(). - if sy-subrc <> 0. - continue. - endif. + IF sy-subrc <> 0. + CONTINUE. + ENDIF. -description = . DELETE TABLE FROM . EXIT. ENDLOOP. ELSE. ASSIGN COMPONENT description_component OF STRUCTURE TO . - if sy-subrc <> 0. - continue. - endif. + IF sy-subrc <> 0. + CONTINUE. + ENDIF. -description = . ENDIF. ENDLOOP. ENDMETHOD. + METHOD get_table_values_and_info. + DATA table_ref TYPE REF TO cl_abap_tabledescr. + DATA keys TYPE ddfields. + DATA structure TYPE REF TO cl_abap_structdescr. + DATA table_name TYPE tabname. + DATA lr_table TYPE REF TO data. + FIELD-SYMBOLS TYPE ANY TABLE. + FIELD-SYMBOLS TYPE ANY TABLE. + DATA table TYPE REF TO data. + + table_name = is_customizing-tabname. + + CREATE DATA table TYPE TABLE OF (table_name). + ASSIGN table->* TO . + + table_ref ?= cl_abap_tabledescr=>describe_by_data( ). + structure ?= table_ref->get_table_line_type( ). + + structure->get_ddic_field_list( RECEIVING p_field_list = keys " List of Dictionary Descriptions for the Components + EXCEPTIONS not_found = 1 " Type could not be found + no_ddic_type = 2 " Typ is not a dictionary type + OTHERS = 3 ). + DELETE keys WHERE keyflag <> abap_true. + + DATA(components) = structure->get_components( ). + DATA(where_cond) = build_where_condition( is_customizing ). + + IF line_exists( components[ name = 'SPRAS' ] ) AND line_exists( keys[ fieldname = 'SPRAS' ] ). + SELECT * + FROM (table_name) + INTO TABLE @et_table_values + WHERE spras = @sy-langu + AND (where_cond). "#EC CI_SUBRC + ELSE. + SELECT * + FROM (table_name) + INTO TABLE @et_table_values + WHERE (where_cond). "#EC CI_SUBRC + + DATA(lv_texttable) = get_texttable( EXPORTING i_table_name = table_name + IMPORTING e_checkfield = ev_checkfield ). + ENDIF. + + IF lv_texttable IS INITIAL. + ev_checkfield = is_customizing-data_element. + ELSE. + CREATE DATA lr_table TYPE TABLE OF (lv_texttable). + ASSIGN lr_table->* TO . + IF sy-subrc <> 0. + RETURN. + ENDIF. + + SELECT * + FROM (lv_texttable) + INTO TABLE @ + WHERE spras = @sy-langu. "#EC CI_SUBRC + + et_texttable_values = . + ENDIF. + ENDMETHOD. + METHOD get_data_by_domain. - DATA: data_element TYPE REF TO cl_abap_elemdescr. + DATA data_element TYPE REF TO cl_abap_elemdescr. data_element ?= cl_abap_typedescr=>describe_by_name( i_customizing-data_element ). IF data_element->kind <> data_element->kind_elem. - return. + RETURN. ENDIF. - data_element->get_ddic_fixed_values( - EXPORTING - p_langu = sy-langu " Current Language - RECEIVING - p_fixed_values = DATA(fixed_values) " Defaults - EXCEPTIONS - not_found = 1 " Type could not be found - no_ddic_type = 2 " Typ is not a dictionary type - OTHERS = 3 - ). + data_element->get_ddic_fixed_values( EXPORTING p_langu = sy-langu " Current Language + RECEIVING p_fixed_values = DATA(fixed_values) " Defaults + EXCEPTIONS not_found = 1 " Type could not be found + no_ddic_type = 2 " Typ is not a dictionary type + OTHERS = 3 ). IF sy-subrc <> 0. - RAISE EXCEPTION TYPE zcx_odata - EXPORTING - textid = zcx_odata=>convert_msg( ). + RAISE EXCEPTION NEW zcx_odata( textid = zcx_odata=>convert_msg( ) ). ENDIF. LOOP AT fixed_values ASSIGNING FIELD-SYMBOL(). APPEND INITIAL LINE TO r_value_help ASSIGNING FIELD-SYMBOL(). - -search_help = i_customizing-id. - -value = -low . - -description = -ddtext. + -search_help = i_customizing-id. + -value = -low. + -description = -ddtext. ENDLOOP. ENDMETHOD. METHOD build_where_condition. - DATA: cond_tab TYPE STANDARD TABLE OF hrcond. + DATA cond_tab TYPE STANDARD TABLE OF hrcond. IF i_customizing-where_data_element1 IS NOT INITIAL. APPEND VALUE #( field = i_customizing-where_data_element1 opera = 'EQ' - low = i_customizing-where_value1 ) TO cond_tab. + low = i_customizing-where_value1 ) TO cond_tab. ENDIF. IF i_customizing-where_data_element2 IS NOT INITIAL. APPEND VALUE #( field = i_customizing-where_data_element2 opera = 'EQ' - low = i_customizing-where_value2 ) TO cond_tab. + low = i_customizing-where_value2 ) TO cond_tab. ENDIF. CALL FUNCTION 'RH_DYNAMIC_WHERE_BUILD' - EXPORTING - dbtable = i_customizing-tabname " Database Table - TABLES - condtab = cond_tab " Condition Table - where_clause = r_where_cond " Where Clause - EXCEPTIONS - empty_condtab = 1 - no_db_field = 2 - unknown_db = 3 - wrong_condition = 4 - OTHERS = 5. + EXPORTING dbtable = i_customizing-tabname " Database Table + TABLES condtab = cond_tab " Condition Table + where_clause = r_where_cond " Where Clause + EXCEPTIONS empty_condtab = 1 + no_db_field = 2 + unknown_db = 3 + wrong_condition = 4 + OTHERS = 5. IF sy-subrc <> 0. - return. " maybe an exception? + RETURN. " maybe an exception? ENDIF. ENDMETHOD. - ENDCLASS. diff --git a/src/zcl_odata_value_help.clas.xml b/src/zcl_odata_value_help.clas.xml index d1b8a28..d8abd52 100644 --- a/src/zcl_odata_value_help.clas.xml +++ b/src/zcl_odata_value_help.clas.xml @@ -12,26 +12,56 @@ X
+ + BUILD_WHERE_CONDITION + D + Build dynamic where condition + BUILD_WHERE_CONDITION E Build dynamic where condition + + GET_CUSTOMIZING + D + Get customizing + GET_CUSTOMIZING E Get customizing + + GET_DATA_BY_DOMAIN + D + Get values by domain + GET_DATA_BY_DOMAIN E Get values by domain + + GET_DATA_BY_TABLE + D + Get values by table + GET_DATA_BY_TABLE E Get values by table + + GET_TABLE_VALUES_AND_INFO + D + Get table values and information + + + GET_TEXTTABLE + D + Get texttable from table + GET_TEXTTABLE E @@ -39,78 +69,180 @@ + + BUILD_WHERE_CONDITION + I_CUSTOMIZING + D + Customizing + BUILD_WHERE_CONDITION I_CUSTOMIZING E Customizing + + BUILD_WHERE_CONDITION + R_WHERE_COND + D + Error + BUILD_WHERE_CONDITION R_WHERE_COND E Error + + GET_CUSTOMIZING + I_FILTER + D + Search field filter + GET_CUSTOMIZING I_FILTER E Search field filter + + GET_CUSTOMIZING + R_SH_CUST + D + Customizing + GET_CUSTOMIZING R_SH_CUST E Customizing + + GET_CUSTOMIZING + ZCX_ODATA + D + Error + GET_CUSTOMIZING ZCX_ODATA E Error + + GET_DATA_BY_DOMAIN + I_CUSTOMIZING + D + Customizing + GET_DATA_BY_DOMAIN I_CUSTOMIZING E Customizing + + GET_DATA_BY_DOMAIN + R_VALUE_HELP + D + Value help data + GET_DATA_BY_DOMAIN R_VALUE_HELP E Value help data + + GET_DATA_BY_DOMAIN + ZCX_ODATA + D + Error + GET_DATA_BY_DOMAIN ZCX_ODATA E Error + + GET_DATA_BY_TABLE + I_CUSTOMIZING + D + Customizing + GET_DATA_BY_TABLE I_CUSTOMIZING E Customizing + + GET_DATA_BY_TABLE + R_VALUE_HELP + D + Value help data + GET_DATA_BY_TABLE R_VALUE_HELP E Value help data + + GET_TABLE_VALUES_AND_INFO + ET_TABLE_VALUES + D + Table data + + + GET_TABLE_VALUES_AND_INFO + ET_TEXTTABLE_VALUES + D + Texttable data + + + GET_TABLE_VALUES_AND_INFO + EV_CHECKFIELD + D + Checkfield + + + GET_TABLE_VALUES_AND_INFO + IS_CUSTOMIZING + D + Customizing + + + GET_TEXTTABLE + E_CHECKFIELD + D + Field to check for + GET_TEXTTABLE E_CHECKFIELD E Field to check for + + GET_TEXTTABLE + I_TABLE_NAME + D + Table name + GET_TEXTTABLE I_TABLE_NAME E Table name + + GET_TEXTTABLE + R_TEXTTABLE + D + Text table + GET_TEXTTABLE R_TEXTTABLE From 436123dd836a5e57aa457db83daf9036e420ce49 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 14:17:05 +0000 Subject: [PATCH 05/11] refactoring: optimize methods --- src/zcl_odata_value_help.clas.abap | 43 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/zcl_odata_value_help.clas.abap b/src/zcl_odata_value_help.clas.abap index 4850f90..fc6b886 100644 --- a/src/zcl_odata_value_help.clas.abap +++ b/src/zcl_odata_value_help.clas.abap @@ -82,6 +82,10 @@ CLASS zcl_odata_value_help DEFINITION EXPORTING ev_checkfield TYPE forfield et_table_values TYPE ANY TABLE et_texttable_values TYPE any. + + METHODS check_table_contains_language + IMPORTING it_table_values TYPE ANY TABLE + RETURNING VALUE(rv_contains) TYPE os_boolean. ENDCLASS. @@ -167,10 +171,6 @@ CLASS zcl_odata_value_help IMPLEMENTATION. description_component = i_customizing-description_field. - IF sy-subrc <> 0. - RETURN. - ENDIF. - get_table_values_and_info( EXPORTING is_customizing = i_customizing IMPORTING ev_checkfield = DATA(lv_checkfield) et_table_values = @@ -215,9 +215,6 @@ CLASS zcl_odata_value_help IMPLEMENTATION. ENDMETHOD. METHOD get_table_values_and_info. - DATA table_ref TYPE REF TO cl_abap_tabledescr. - DATA keys TYPE ddfields. - DATA structure TYPE REF TO cl_abap_structdescr. DATA table_name TYPE tabname. DATA lr_table TYPE REF TO data. FIELD-SYMBOLS TYPE ANY TABLE. @@ -229,19 +226,9 @@ CLASS zcl_odata_value_help IMPLEMENTATION. CREATE DATA table TYPE TABLE OF (table_name). ASSIGN table->* TO . - table_ref ?= cl_abap_tabledescr=>describe_by_data( ). - structure ?= table_ref->get_table_line_type( ). - - structure->get_ddic_field_list( RECEIVING p_field_list = keys " List of Dictionary Descriptions for the Components - EXCEPTIONS not_found = 1 " Type could not be found - no_ddic_type = 2 " Typ is not a dictionary type - OTHERS = 3 ). - DELETE keys WHERE keyflag <> abap_true. - - DATA(components) = structure->get_components( ). DATA(where_cond) = build_where_condition( is_customizing ). - IF line_exists( components[ name = 'SPRAS' ] ) AND line_exists( keys[ fieldname = 'SPRAS' ] ). + IF check_table_contains_language( ). SELECT * FROM (table_name) INTO TABLE @et_table_values @@ -330,4 +317,24 @@ CLASS zcl_odata_value_help IMPLEMENTATION. RETURN. " maybe an exception? ENDIF. ENDMETHOD. + + METHOD check_table_contains_language. + DATA lt_keys TYPE ddfields. + DATA lo_table TYPE REF TO cl_abap_tabledescr. + DATA lo_structure TYPE REF TO cl_abap_structdescr. + + lo_table ?= cl_abap_tabledescr=>describe_by_data( it_table_values ). + lo_structure ?= lo_table->get_table_line_type( ). + + lo_structure->get_ddic_field_list( RECEIVING p_field_list = lt_keys " List of Dictionary Descriptions for the Components + EXCEPTIONS not_found = 1 " Type could not be found + no_ddic_type = 2 " Typ is not a dictionary type + OTHERS = 3 ). + DELETE lt_keys WHERE keyflag <> abap_true. + + DATA(lt_components) = lo_structure->get_components( ). + IF line_exists( lt_components[ name = 'SPRAS' ] ) AND line_exists( lt_keys[ fieldname = 'SPRAS' ] ). + rv_contains = abap_true. + ENDIF. + ENDMETHOD. ENDCLASS. From 3b00c91a633bf22f48d22ab6577bf240ac4b6778 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 14:35:14 +0000 Subject: [PATCH 06/11] refactor: refactor value help odata --- src/zcl_odata_value_help.clas.abap | 71 +++++++++++++++---------- src/zcl_odata_value_help.clas.xml | 34 ++++++++++++ src/zcl_odata_value_help_dpc.clas.abap | 56 ++++++++++++++++++++ src/zcl_odata_value_help_dpc.clas.xml | 72 ++++++++++++++++++++++++++ 4 files changed, 206 insertions(+), 27 deletions(-) create mode 100644 src/zcl_odata_value_help_dpc.clas.abap create mode 100644 src/zcl_odata_value_help_dpc.clas.xml diff --git a/src/zcl_odata_value_help.clas.abap b/src/zcl_odata_value_help.clas.abap index fc6b886..426f7f7 100644 --- a/src/zcl_odata_value_help.clas.abap +++ b/src/zcl_odata_value_help.clas.abap @@ -83,9 +83,21 @@ CLASS zcl_odata_value_help DEFINITION et_table_values TYPE ANY TABLE et_texttable_values TYPE any. + "!

Check of table contains language

+ "! + "! @parameter it_table_values |

Table data

+ "! @parameter rv_contains |

Contains language

METHODS check_table_contains_language IMPORTING it_table_values TYPE ANY TABLE RETURNING VALUE(rv_contains) TYPE os_boolean. + + "!

Get text table data

+ "! + "! @parameter iv_texttable |

Text table name

+ "! @parameter et_texttable_values |

Text table data

+ METHODS get_texttable_data + IMPORTING iv_texttable TYPE tabname + EXPORTING et_texttable_values TYPE ANY TABLE. ENDCLASS. @@ -215,50 +227,39 @@ CLASS zcl_odata_value_help IMPLEMENTATION. ENDMETHOD. METHOD get_table_values_and_info. - DATA table_name TYPE tabname. - DATA lr_table TYPE REF TO data. - FIELD-SYMBOLS TYPE ANY TABLE. - FIELD-SYMBOLS TYPE ANY TABLE. + DATA lv_table_name TYPE tabname. + FIELD-SYMBOLS TYPE ANY TABLE. DATA table TYPE REF TO data. - table_name = is_customizing-tabname. + lv_table_name = is_customizing-tabname. - CREATE DATA table TYPE TABLE OF (table_name). + CREATE DATA table TYPE TABLE OF (lv_table_name). ASSIGN table->* TO . DATA(where_cond) = build_where_condition( is_customizing ). IF check_table_contains_language( ). - SELECT * - FROM (table_name) - INTO TABLE @et_table_values - WHERE spras = @sy-langu - AND (where_cond). "#EC CI_SUBRC + + zcl_odata_value_help_dpc=>read_dyn_table_with_language( EXPORTING iv_table_name = lv_table_name + it_where_condition = where_cond + IMPORTING et_table_data = ). ELSE. - SELECT * - FROM (table_name) - INTO TABLE @et_table_values - WHERE (where_cond). "#EC CI_SUBRC - DATA(lv_texttable) = get_texttable( EXPORTING i_table_name = table_name + zcl_odata_value_help_dpc=>read_dyn_table( EXPORTING iv_table_name = lv_table_name + it_where_condition = where_cond + IMPORTING et_table_data = ). + + DATA(lv_texttable) = get_texttable( EXPORTING i_table_name = lv_table_name IMPORTING e_checkfield = ev_checkfield ). ENDIF. + et_table_values = . IF lv_texttable IS INITIAL. ev_checkfield = is_customizing-data_element. ELSE. - CREATE DATA lr_table TYPE TABLE OF (lv_texttable). - ASSIGN lr_table->* TO . - IF sy-subrc <> 0. - RETURN. - ENDIF. - - SELECT * - FROM (lv_texttable) - INTO TABLE @ - WHERE spras = @sy-langu. "#EC CI_SUBRC - et_texttable_values = . + get_texttable_data( EXPORTING iv_texttable = lv_texttable + IMPORTING et_texttable_values = et_texttable_values ). ENDIF. ENDMETHOD. @@ -337,4 +338,20 @@ CLASS zcl_odata_value_help IMPLEMENTATION. rv_contains = abap_true. ENDIF. ENDMETHOD. + + METHOD get_texttable_data. + DATA lr_table TYPE REF TO data. + FIELD-SYMBOLS TYPE ANY TABLE. + + CREATE DATA lr_table TYPE TABLE OF (iv_texttable). + ASSIGN lr_table->* TO . + IF sy-subrc <> 0. + RETURN. + ENDIF. + + zcl_odata_value_help_dpc=>read_dyn_table_with_language( EXPORTING iv_table_name = iv_texttable + IMPORTING et_table_data = ). + + et_texttable_values = . + ENDMETHOD. ENDCLASS. diff --git a/src/zcl_odata_value_help.clas.xml b/src/zcl_odata_value_help.clas.xml index d8abd52..19de23b 100644 --- a/src/zcl_odata_value_help.clas.xml +++ b/src/zcl_odata_value_help.clas.xml @@ -22,6 +22,11 @@ E Build dynamic where condition + + CHECK_TABLE_CONTAINS_LANGUAGE + D + Check of table contains language + GET_CUSTOMIZING D @@ -67,6 +72,11 @@ E Get texttable from table + + GET_TEXTTABLE_DATA + D + Get text table data + @@ -93,6 +103,18 @@ E Error + + CHECK_TABLE_CONTAINS_LANGUAGE + IT_TABLE_VALUES + D + Table data + + + CHECK_TABLE_CONTAINS_LANGUAGE + RV_CONTAINS + D + Contains language + GET_CUSTOMIZING I_FILTER @@ -249,6 +271,18 @@ E Text table + + GET_TEXTTABLE_DATA + ET_TEXTTABLE_VALUES + D + Text table data + + + GET_TEXTTABLE_DATA + IV_TEXTTABLE + D + Text table name +
diff --git a/src/zcl_odata_value_help_dpc.clas.abap b/src/zcl_odata_value_help_dpc.clas.abap new file mode 100644 index 0000000..2128881 --- /dev/null +++ b/src/zcl_odata_value_help_dpc.clas.abap @@ -0,0 +1,56 @@ +"!

DPC 4 Value Help Odata

+CLASS zcl_odata_value_help_dpc DEFINITION + PUBLIC + CREATE PUBLIC. + + PUBLIC SECTION. + TYPES: + BEGIN OF ty_s_clause, + line TYPE c LENGTH 72, + END OF ty_s_clause, + ty_t_clause TYPE STANDARD TABLE OF ty_s_clause WITH EMPTY KEY. + + "!

Read dynamic table with language

+ "! + "! @parameter iv_spras |

Language

+ "! @parameter iv_table_name |

Table name

+ "! @parameter it_where_condition |

Where condition

+ "! @parameter et_table_data |

Table data

+ CLASS-METHODS read_dyn_table_with_language + IMPORTING iv_spras TYPE spras DEFAULT sy-langu + iv_table_name TYPE tabname + it_where_condition TYPE ty_t_clause OPTIONAL + EXPORTING et_table_data TYPE ANY TABLE. + + "!

Read dynamic table

+ "! + "! @parameter iv_table_name |

Table name

+ "! @parameter it_where_condition |

Where condition

+ "! @parameter et_table_data |

Table data

+ CLASS-METHODS read_dyn_table + IMPORTING iv_table_name TYPE tabname + it_where_condition TYPE ty_t_clause OPTIONAL + EXPORTING et_table_data TYPE ANY TABLE. + + PROTECTED SECTION. + + PRIVATE SECTION. +ENDCLASS. + + +CLASS zcl_odata_value_help_dpc IMPLEMENTATION. + METHOD read_dyn_table_with_language. + SELECT * + FROM (iv_table_name) + INTO TABLE @et_table_data + WHERE spras = @iv_spras + AND (it_where_condition). "#EC CI_SUBRC + ENDMETHOD. + + METHOD read_dyn_table. + SELECT * + FROM (iv_table_name) + INTO TABLE @et_table_data + WHERE (it_where_condition). "#EC CI_SUBRC + ENDMETHOD. +ENDCLASS. diff --git a/src/zcl_odata_value_help_dpc.clas.xml b/src/zcl_odata_value_help_dpc.clas.xml new file mode 100644 index 0000000..c22f7ea --- /dev/null +++ b/src/zcl_odata_value_help_dpc.clas.xml @@ -0,0 +1,72 @@ + + + + + + ZCL_ODATA_VALUE_HELP_DPC + E + DPC 4 Value Help Odata + 1 + X + X + X + + + + READ_DYN_TABLE + E + Read dynamic table + + + READ_DYN_TABLE_WITH_LANGUAGE + E + Read dynamic table with language + + + + + READ_DYN_TABLE + ET_TABLE_DATA + E + Table data + + + READ_DYN_TABLE + IT_WHERE_CONDITION + E + Where condition + + + READ_DYN_TABLE + IV_TABLE_NAME + E + Table name + + + READ_DYN_TABLE_WITH_LANGUAGE + ET_TABLE_DATA + E + Table data + + + READ_DYN_TABLE_WITH_LANGUAGE + IT_WHERE_CONDITION + E + Where condition + + + READ_DYN_TABLE_WITH_LANGUAGE + IV_SPRAS + E + Language + + + READ_DYN_TABLE_WITH_LANGUAGE + IV_TABLE_NAME + E + Table name + + + + + From 99886fdd909466cfd318ce6f7848ac0b7063aaa3 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 16:48:21 +0200 Subject: [PATCH 07/11] docs: :memo: added features see #101 --- docs/index.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/index.md b/docs/index.md index 8b1386f..cb32417 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,18 +5,18 @@ layout: home hero: name: "ABAP OData Framework" text: "A odata framework for a SAP System. " - tagline: My great project tagline + tagline: Custom reusable framework for OData services in ABAP. actions: - theme: brand text: Documentation link: /documentation/ features: - - title: Feature A - details: Lorem ipsum dolor sit amet, consectetur adipiscing elit - - title: Feature B - details: Lorem ipsum dolor sit amet, consectetur adipiscing elit - - title: Feature C - details: Lorem ipsum dolor sit amet, consectetur adipiscing elit + - title: Reusable + details: The entities created with this framework can be reused in other odata projects. + - title: Quick Service Creation + details: The service creation is very fast and easy. + - title: Focus on developer + details: The framework is focused on the developer, making the development process easier. --- From dd9da6dd48416e1edc17839bdc1734bcfd78f06f Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 16:48:43 +0200 Subject: [PATCH 08/11] docs: :sparkles: added sadl docu --- docs/.vitepress/config.mts | 5 +++-- docs/documentation/sadl/index.md | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 docs/documentation/sadl/index.md diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index ee02494..49cddbe 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -74,7 +74,7 @@ export default }, } } -); + ); function nav() { return [ @@ -85,7 +85,7 @@ function nav() { items: [ { text: 'Changelog', - link: 'https://github.com/miggi92/odata-fw/blob/master/CHANGELOG.md' + link: 'https://github.com/miggi92/odata-fw/blob/master/changelog.txt' }, { text: 'Contributing', @@ -104,6 +104,7 @@ function sidebarDocumentation() { items: [ { text: 'Creating a service', link: '/documentation/Creating-a-service' }, { text: 'DPC boilerplate code', link: '/documentation/DPC-boilerplate-code' }, + { text: 'SADL', link: '/documentation/sadl' }, { text: 'OData customizing', link: '/documentation/customizing/', collapsed: true, items: [ diff --git a/docs/documentation/sadl/index.md b/docs/documentation/sadl/index.md new file mode 100644 index 0000000..3314b7a --- /dev/null +++ b/docs/documentation/sadl/index.md @@ -0,0 +1,4 @@ +--- +title: SADL +--- +# {{ $frontmatter.title }} \ No newline at end of file From 23c7e9775fca06aa802b83125c40d43a9755f0ff Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 17:02:02 +0200 Subject: [PATCH 09/11] docs: :sparkles: updated sadl docu --- docs/documentation/DPC-boilerplate-code.md | 5 +++ docs/documentation/sadl/index.md | 47 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/documentation/DPC-boilerplate-code.md b/docs/documentation/DPC-boilerplate-code.md index 1834669..1fe2814 100644 --- a/docs/documentation/DPC-boilerplate-code.md +++ b/docs/documentation/DPC-boilerplate-code.md @@ -21,6 +21,7 @@ Implementation: ``` abap DATA(ls_data_provider) = me->mt_data_providers->get( iv_entity_name ). ls_data_provider-instance->before_processing( ). +ls_data_provider-instance->set_context( mo_context ). " for SADL features ls_data_provider-instance->/iwbep/if_mgw_appl_srv_runtime~get_entity( EXPORTING @@ -48,6 +49,8 @@ Implementation: ```abap DATA(ls_data_provider) = me->mt_data_providers->get( iv_entity_name ). ls_data_provider-instance->before_processing( ). +ls_data_provider-instance->set_context( mo_context ). " for SADL features + ls_data_provider-instance->/iwbep/if_mgw_appl_srv_runtime~get_entityset( EXPORTING iv_entity_name = iv_entity_name @@ -79,6 +82,8 @@ Implementation: METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity. DATA(ls_data_provider) = me->mt_data_providers->get( iv_entity_name ). ls_data_provider-instance->before_processing( ). + ls_data_provider-instance->set_context( mo_context ). " for SADL features + ls_data_provider-instance->/iwbep/if_mgw_appl_srv_runtime~create_deep_entity( EXPORTING iv_entity_name = iv_entity_name diff --git a/docs/documentation/sadl/index.md b/docs/documentation/sadl/index.md index 3314b7a..618a825 100644 --- a/docs/documentation/sadl/index.md +++ b/docs/documentation/sadl/index.md @@ -1,4 +1,49 @@ --- title: SADL --- -# {{ $frontmatter.title }} \ No newline at end of file +# {{ $frontmatter.title }} + +The Service Adaptation Definition Language or SADL feature was introduced with version [1.2.0](https://github.com/miggi92/odata-fw/releases/tag/v1.2.0) of this framework. +And is used for the [Analytical table](https://experience.sap.com/fiori-design-web/analytical-table-alv/) in UI5. + +## SADL XML + +The SADL XML is automatically generated by the framework. No need to add there something manually. + +## Define Keys + +Every `dimension` annoation will be a key in the SADL framework. + +Example: +```abap +DATA(lo_entity_type_inv) = model->get_entity_type( 'invoicesDocuments' ). +lo_entity_type_inv->set_semantic( /iwbep/if_ana_odata_types=>gcs_ana_odata_semantic_value-query-aggregate ). + +DATA(lo_property_inv) = lo_entity_type_inv->get_property( 'accountingArea' ). +DATA(lo_annotation_inv) = + lo_property_inv->/iwbep/if_mgw_odata_annotatabl~create_annotation( + /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ). +lo_annotation_inv->add( + iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role + iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ). + +``` + + +## Structure + +In the structure that is used for the entity you should create a property `GENERATED_KEY` in the ABAP and `GeneratedKey` in the odata customizing. +The key value is generated by the SADL framework. + +## How it knows when to use SADL? + +If you use the `if_sadl_gw_dpc_util~get_dpc` method that is shipped with the `ZCL_ODATA_MAIN` class, the framework will automatically use the SADL framework. + +```abap +if_sadl_gw_dpc_util~get_dpc( )->get_entityset( + EXPORTING + io_tech_request_context = io_tech_request_context + IMPORTING + et_data = lt_invoices + es_response_context = es_response_context ). +``` \ No newline at end of file From 2cf98d406ab5ac5901b7a7ae66e7727195600271 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 17:06:52 +0200 Subject: [PATCH 10/11] docs: :memo: updated project description #101 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6dce79b..7d5bdf4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,11 @@ ## Description -An OData ABAP Framework +An OData ABAP Framework, that focuses on a easy and fast way to create OData Services in ABAP. Changes to the OData service are done in the code for data changes and in the customizing for model changes, no need to regenerate the service after changes. +Every entity has it own class, therefore every class can be reused in entities of other services. +It also reduces the mainly unused `CRUD` methods that the `SEGW` will create for every entity. +The purpose of this framework is to create a simple Odata service within a few minutes. +Every service that uses this framework can easy be extended. ## Documentation The documentation and how to use can be found under [Documentation](https://miggi92.github.io/odata-fw/) From 38cbac5852fb70804e1d81e84690a71d4b3c81a7 Mon Sep 17 00:00:00 2001 From: Miguel Gebhardt Date: Fri, 12 Jul 2024 17:09:39 +0200 Subject: [PATCH 11/11] style: :lipstick: added external link icon --- docs/.vitepress/config.mts | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 49cddbe..794aa3f 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -30,6 +30,7 @@ export default themeConfig: { // https://vitepress.dev/reference/default-theme-config nav: nav(), + externalLinkIcon: true, editLink: { pattern: 'https://github.com/miggi92/odata-fw/edit/master/docs/:path', text: 'Edit this page on GitHub'