Skip to content

Commit

Permalink
fixes downport
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev committed Feb 18, 2024
1 parent 6723f56 commit ca456ce
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 126 deletions.
178 changes: 54 additions & 124 deletions src/z2ui5_cl_demo_app_057.clas.abap
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
class Z2UI5_CL_DEMO_APP_057 definition
public
create public .
CLASS z2ui5_cl_demo_app_057 DEFINITION
PUBLIC
CREATE PUBLIC .

public section.
PUBLIC SECTION.

interfaces Z2UI5_IF_APP .
interfaces IF_SERIALIZABLE_OBJECT .
INTERFACES z2ui5_if_app .
INTERFACES if_serializable_object .

types:
BEGIN OF ty_s_tab,
TYPES:
BEGIN OF ty_s_tab,
selkz TYPE abap_bool,
product TYPE string,
create_date TYPE string,
create_by TYPE string,
storage_location TYPE string,
quantity TYPE i,
END OF ty_s_tab .
types:
ty_t_table TYPE STANDARD TABLE OF ty_s_tab WITH EMPTY KEY .
TYPES:
ty_t_table TYPE STANDARD TABLE OF ty_s_tab WITH EMPTY KEY .

DATA mt_table TYPE ty_t_table .
DATA mv_check_download TYPE abap_bool .

data MT_TABLE type TY_T_TABLE .
data MV_CHECK_DOWNLOAD type ABAP_BOOL .
PROTECTED SECTION.

DATA client TYPE REF TO Z2UI5_if_client.
DATA client TYPE REF TO z2ui5_if_client.

DATA:
BEGIN OF app,
Expand All @@ -33,120 +34,49 @@ public section.
get TYPE z2ui5_if_types=>ty_s_get,
END OF app.

METHODS Z2UI5_on_init.
METHODS Z2UI5_on_event.
METHODS Z2UI5_on_render.
METHODS Z2UI5_on_render_main.
METHODS z2ui5_on_init.
METHODS z2ui5_on_event.
METHODS z2ui5_on_render.
METHODS z2ui5_on_render_main.

METHODS Z2UI5_set_data.
METHODS z2ui5_set_data.

PRIVATE SECTION.

CLASS-METHODS hlp_get_csv_by_tab
IMPORTING
val TYPE STANDARD TABLE
RETURNING
VALUE(rv_row) TYPE string.

CLASS-METHODS hlp_get_base64
IMPORTING
val TYPE string
RETURNING
VALUE(result) TYPE string.

ENDCLASS.



CLASS Z2UI5_CL_DEMO_APP_057 IMPLEMENTATION.


METHOD hlp_get_base64.

TRY.
CALL METHOD ('CL_WEB_HTTP_UTILITY')=>encode_base64
EXPORTING
unencoded = val
RECEIVING
encoded = result.

CATCH cx_sy_dyn_call_illegal_class.

DATA(classname) = 'CL_HTTP_UTILITY'.
CALL METHOD (classname)=>encode_base64
EXPORTING
unencoded = val
RECEIVING
encoded = result.

ENDTRY.

ENDMETHOD.


METHOD hlp_get_csv_by_tab.

IF val IS INITIAL.
RETURN.
ENDIF.

DATA(lo_struc) = CAST cl_abap_structdescr( cl_abap_structdescr=>describe_by_data( val[ 1 ] ) ).
DATA(lt_components) = lo_struc->get_components( ).

rv_row = ``.
LOOP AT lt_components INTO DATA(lv_name) FROM 2.
rv_row = rv_row && lv_name-name && `;`.
ENDLOOP.
rv_row = rv_row && cl_abap_char_utilities=>cr_lf.



LOOP AT val assigning FIELD-SYMBOL(<row>).

DATA(lv_index) = 2.
DO.
ASSIGN COMPONENT lv_index OF STRUCTURE <row> TO FIELD-SYMBOL(<field>).
IF sy-subrc <> 0.
EXIT.
ENDIF.
rv_row = rv_row && <field>.
lv_index = lv_index + 1.
rv_row = rv_row && `;`.
ENDDO.

rv_row = rv_row && cl_abap_char_utilities=>cr_lf.
ENDLOOP.

ENDMETHOD.
CLASS z2ui5_cl_demo_app_057 IMPLEMENTATION.


METHOD Z2UI5_if_app~main.
METHOD z2ui5_if_app~main.

me->client = client.
app-get = client->get( ).

IF app-check_initialized = abap_false.
app-check_initialized = abap_true.
Z2UI5_on_init( ).
z2ui5_on_init( ).
ENDIF.

IF app-get-event IS NOT INITIAL.
Z2UI5_on_event( ).
z2ui5_on_event( ).
ENDIF.

Z2UI5_on_render( ).
z2ui5_on_render( ).

CLEAR app-get.

ENDMETHOD.


METHOD Z2UI5_on_event.
METHOD z2ui5_on_event.

CASE app-get-event.

WHEN 'BUTTON_START'.
Z2UI5_set_data( ).
z2ui5_set_data( ).

WHEN `BUTTON_DOWNLOAD`.
mv_check_download = abap_true.
Expand All @@ -159,47 +89,47 @@ CLASS Z2UI5_CL_DEMO_APP_057 IMPLEMENTATION.
ENDMETHOD.


METHOD Z2UI5_on_init.
METHOD z2ui5_on_init.

app-view_main = `MAIN`.

ENDMETHOD.


METHOD Z2UI5_on_render.
METHOD z2ui5_on_render.

CASE app-view_main.
WHEN 'MAIN'.
Z2UI5_on_render_main( ).
z2ui5_on_render_main( ).
ENDCASE.

ENDMETHOD.


METHOD Z2UI5_on_render_main.
METHOD z2ui5_on_render_main.

DATA(view) = z2ui5_cl_xml_view=>factory( ).

view = view->page( id = `page_main`
title = 'abap2UI5 - List Report Features'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
)->header_content(
)->link(
text = 'Demo' target = '_blank'
href = 'https://twitter.com/abap2UI5/status/1661723127595016194'
)->link(
text = 'Source_Code' target = '_blank' href = z2ui5_cl_demo_utility=>factory( client )->app_get_url_source_code( )
)->get_parent( ).
view = view->page( id = `page_main`
title = 'abap2UI5 - List Report Features'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
)->header_content(
)->link(
text = 'Demo' target = '_blank'
href = 'https://twitter.com/abap2UI5/status/1661723127595016194'
)->link(
text = 'Source_Code' target = '_blank' href = z2ui5_cl_demo_utility=>factory( client )->app_get_url_source_code( )
)->get_parent( ).

IF mv_check_download = abap_true.
mv_check_download = abap_false.

DATA(lv_csv) = hlp_get_csv_by_tab( mt_table ).
DATA(lv_base64) = hlp_get_base64( lv_csv ).
DATA(lv_csv) = z2ui5_cl_util=>itab_get_csv_by_itab( mt_table ).
data(lv_csv_x) = z2ui5_cl_util=>conv_get_xstring_by_string( lv_csv ).
DATA(lv_base64) = z2ui5_cl_util=>conv_encode_x_base64( lv_csv_x ).

view->_generic( ns = `html` name = `iframe` t_prop = value #( ( n = `src` v = `data:text/csv;base64,` && lv_base64 ) ( n = `hidden` v = `hidden` ) ) ).
* ->_cc_plain_xml( `<html:iframe src= hidden="hidden" />`).
view->_generic( ns = `html` name = `iframe` t_prop = VALUE #( ( n = `src` v = `data:text/csv;base64,` && lv_base64 ) ( n = `hidden` v = `hidden` ) ) ).

ENDIF.

Expand All @@ -211,7 +141,7 @@ CLASS Z2UI5_CL_DEMO_APP_057 IMPLEMENTATION.
header_title->snapped_content( ns = 'f' ).

DATA(lo_box) = page->header( )->dynamic_page_header( pinnable = abap_true
)->flex_box( alignitems = `Start` justifycontent = `SpaceBetween` )->flex_box( alignItems = `Start` ).
)->flex_box( alignitems = `Start` justifycontent = `SpaceBetween` )->flex_box( alignitems = `Start` ).


lo_box->get_parent( )->hbox( justifycontent = `End` )->button(
Expand All @@ -223,13 +153,13 @@ CLASS Z2UI5_CL_DEMO_APP_057 IMPLEMENTATION.

DATA(tab) = cont->table( items = client->_bind( val = mt_table ) ).

tab->header_toolbar(
)->toolbar(
)->toolbar_spacer(
)->button(
icon = 'sap-icon://download'
press = client->_event( 'BUTTON_DOWNLOAD' )
).
tab->header_toolbar(
)->toolbar(
)->toolbar_spacer(
)->button(
icon = 'sap-icon://download'
press = client->_event( 'BUTTON_DOWNLOAD' )
).

DATA(lo_columns) = tab->columns( ).
lo_columns->column( )->text( text = `Product` ).
Expand All @@ -250,7 +180,7 @@ CLASS Z2UI5_CL_DEMO_APP_057 IMPLEMENTATION.
ENDMETHOD.


METHOD Z2UI5_set_data.
METHOD z2ui5_set_data.

mt_table = VALUE #(
( product = 'table' create_date = `01.01.2023` create_by = `Peter` storage_location = `AREA_001` quantity = 400 )
Expand Down
3 changes: 2 additions & 1 deletion src/z2ui5_cl_demo_app_083.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ CLASS z2ui5_cl_demo_app_083 IMPLEMENTATION.

WHEN `FILTER_UPDATE`.
IF mv_value IS NOT INITIAL.
DATA(ls_range) = z2ui5_cl_util=>filter_get_range_by_token( mv_value ).
DATA ls_range TYPE z2ui5_cl_util_api=>ty_s_range.
ls_range = z2ui5_cl_util=>filter_get_range_by_token( mv_value ).
INSERT ls_range INTO TABLE ms_filter-product.
ENDIF.

Expand Down
5 changes: 4 additions & 1 deletion src/z2ui5_cl_demo_app_130.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ CLASS z2ui5_cl_demo_app_130 IMPLEMENTATION.

WHEN 'CALL_POPUP_VARIANT'.

mt_variants_pop = CORRESPONDING #( mt_variants ).
LOOP AT mt_variants REFERENCE INTO DATA(lr_fields).
APPEND INITIAL LINE TO mt_variants_pop REFERENCE INTO DATA(field).
field->* = CORRESPONDING #( lr_fields->* ).
ENDLOOP.

render_popup_varaint( client ).

Expand Down

0 comments on commit ca456ce

Please sign in to comment.