Skip to content

Commit

Permalink
Merge pull request #9 from hhelibeb/improve-custom-fields-description
Browse files Browse the repository at this point in the history
improve custom fields description
  • Loading branch information
hhelibeb authored Oct 22, 2020
2 parents 03e0be0 + 3ce1bc6 commit 1d281b8
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 21 deletions.
27 changes: 19 additions & 8 deletions src/zafl_viewer.prog.abap
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,24 @@ FORM display.

DATA: lr_functions TYPE REF TO cl_salv_functions.

IF zcl_afl_utilities=>get_distinct_count( tab_data = gt_log field_name = 'FNAME' ) = 1.
SELECT SINGLE cust_name1, cust_name2, cust_name3 FROM zafl_config
INTO @DATA(config).
ENDIF.

IF config IS INITIAL.
config = VALUE #(
cust_name1 = 'CUST_FIELD1'
cust_name2 = 'CUST_FIELD2'
cust_name3 = 'CUST_FIELD3'
).
ENDIF.

PERFORM set_column USING '' lr_cols 'GUID' 'GUID' .
PERFORM set_column USING 'X' lr_cols 'FNAME' 'Function Module' .
PERFORM set_column USING '' lr_cols 'CUST_FIELD1' 'CUST_FIELD1' .
PERFORM set_column USING '' lr_cols 'CUST_FIELD2' 'CUST_FIELD2' .
PERFORM set_column USING '' lr_cols 'CUST_FIELD3' 'CUST_FIELD3' .
PERFORM set_column USING '' lr_cols 'CUST_FIELD1' config-cust_name1.
PERFORM set_column USING '' lr_cols 'CUST_FIELD2' config-cust_name2.
PERFORM set_column USING '' lr_cols 'CUST_FIELD3' config-cust_name3.
PERFORM set_column USING '' lr_cols 'STATUS' 'Status Code' .
PERFORM set_column USING '' lr_cols 'TIMESTAMP' 'Timestamp' .
PERFORM set_column USING '' lr_cols 'TIME_COST' 'Time Cost' .
Expand All @@ -201,12 +214,10 @@ FORM display.
PERFORM set_column USING 'X' lr_cols 'TABLE_OUT' 'Tables Out' .



DATA(lr_events) = gr_alv->get_event( ).
*... §6.1 register to the event USER_COMMAND

SET HANDLER gr_events->on_user_command FOR lr_events.

*... §6.3 register to the event LINK_CLICK
SET HANDLER gr_events->on_link_click FOR lr_events.


Expand All @@ -217,10 +228,10 @@ ENDFORM.
FORM set_column USING i_hotspot TYPE xfeld
pr_cols TYPE REF TO cl_salv_columns
VALUE(fname)
VALUE(text).
VALUE(text).

DATA: lr_column TYPE REF TO cl_salv_column_table.
* Change the properties of the Columns KUNNR

TRY.
lr_column ?= pr_cols->get_column( fname ).
lr_column->set_long_text( CONV #( text ) ).
Expand Down
65 changes: 65 additions & 0 deletions src/zafl_viewer.prog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,35 @@
<ENTRY>时间</ENTRY>
<LENGTH>14</LENGTH>
</item>
<item>
<ID>I</ID>
<KEY>T02</KEY>
<ENTRY>开始日期</ENTRY>
<LENGTH>20</LENGTH>
</item>
<item>
<ID>I</ID>
<KEY>T03</KEY>
<ENTRY>结束日期</ENTRY>
<LENGTH>18</LENGTH>
</item>
<item>
<ID>I</ID>
<KEY>T04</KEY>
<ENTRY>开始时间</ENTRY>
<LENGTH>20</LENGTH>
</item>
<item>
<ID>I</ID>
<KEY>T05</KEY>
<ENTRY>结束时间</ENTRY>
<LENGTH>18</LENGTH>
</item>
<item>
<ID>R</ID>
<ENTRY>ABAP FM Log Viewer</ENTRY>
<LENGTH>70</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>P_DEND</KEY>
Expand All @@ -1964,6 +1993,42 @@
<ENTRY>开始时间</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_CF1</KEY>
<ENTRY>Custom Field1</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_CF2</KEY>
<ENTRY>Custom Field2</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_CF3</KEY>
<ENTRY>Custom Field3</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_FM</KEY>
<ENTRY>函数模块</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_GUID</KEY>
<ENTRY>GUID</ENTRY>
<LENGTH>38</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>S_STATUS</KEY>
<ENTRY>状态</ENTRY>
<LENGTH>38</LENGTH>
</item>
</TEXTPOOL>
</item>
</I18N_TPOOL>
Expand Down
55 changes: 42 additions & 13 deletions src/zcl_afl_utilities.clas.abap
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
CLASS zcl_afl_utilities DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

CLASS-METHODS re_process
IMPORTING
!guid TYPE guid .
CLASS-METHODS is_prd
RETURNING VALUE(result) TYPE abap_bool.

class ZCL_AFL_UTILITIES definition
public
final
create public .

public section.

class-methods RE_PROCESS
importing
!GUID type GUID .
class-methods IS_PRD
returning
value(RESULT) type ABAP_BOOL .
class-methods GET_DISTINCT_COUNT
importing
!TAB_DATA type ANY TABLE
!FIELD_NAME type CLIKE
returning
value(COUNT) type INT4 .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
Expand All @@ -20,6 +26,29 @@ ENDCLASS.
CLASS ZCL_AFL_UTILITIES IMPLEMENTATION.


METHOD get_distinct_count.

TYPES: BEGIN OF ty_temp,
field TYPE string,
END OF ty_temp.
DATA: count_table TYPE HASHED TABLE OF ty_temp WITH UNIQUE KEY field,
count_wa LIKE LINE OF count_table.

LOOP AT tab_data ASSIGNING FIELD-SYMBOL(<wa>).
ASSIGN COMPONENT field_name OF STRUCTURE <wa> TO FIELD-SYMBOL(<field>).
IF sy-subrc <> 0.
RETURN.
ELSE.
count_wa-field = <field>.
INSERT count_wa INTO TABLE count_table.
ENDIF.
ENDLOOP.

count = lines( count_table ).

ENDMETHOD.


METHOD is_prd.

DATA: role TYPE t000-cccategory.
Expand Down
73 changes: 73 additions & 0 deletions src/zcl_afl_utilities.clas.testclasses.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
*"* use this source file for your ABAP unit test classes
CLASS ltc_get_distinct_count DEFINITION FINAL FOR TESTING
DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS: setup.
METHODS: empty_input FOR TESTING.
METHODS: general_input FOR TESTING.
METHODS: error_input FOR TESTING.
ENDCLASS.

CLASS ltc_get_distinct_count IMPLEMENTATION.

METHOD setup.

ENDMETHOD.
METHOD empty_input.

DATA: test_table TYPE STANDARD TABLE OF sflight.

DATA(count) = zcl_afl_utilities=>get_distinct_count( tab_data = test_table field_name = 'CARRID' ).
cl_abap_unit_assert=>assert_equals(
act = count
exp = 0
msg = |exp: 0, act:{ count }|
).

ENDMETHOD.
METHOD general_input.

DATA: test_table TYPE STANDARD TABLE OF sflight.

test_table = VALUE #(
( seatsmax = '1' )
( seatsmax = '55332' )
( seatsmax = '3' )
( seatsmax = '4' )
( seatsmax = '5' )
( seatsmax = '6' )
( seatsmax = '7' )
( seatsmax = '8' )
( seatsmax = '9' )
( seatsmax = '5' )
( seatsmax = '5' )
( seatsmax = '2' )
( seatsmax = '5' )
( seatsmax = '1' )
( seatsmax = '9' )
( seatsmax = '9' )
( seatsmax = '6' )
).

DATA(count) = zcl_afl_utilities=>get_distinct_count( tab_data = test_table field_name = 'SEATSMAX' ).
cl_abap_unit_assert=>assert_equals(
act = count
exp = 10
msg = |exp: 10, act:{ count }|
).

ENDMETHOD.
METHOD error_input.

DATA: test_table TYPE STANDARD TABLE OF sflight.

DATA(count) = zcl_afl_utilities=>get_distinct_count( tab_data = test_table field_name = 'XCARRID' ).
cl_abap_unit_assert=>assert_equals(
act = count
exp = 0
msg = |exp: 0, act:{ count }|
).

ENDMETHOD.

ENDCLASS.
1 change: 1 addition & 0 deletions src/zcl_afl_utilities.clas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
</VSEOCLASS>
</asx:values>
</asx:abap>
Expand Down

0 comments on commit 1d281b8

Please sign in to comment.