Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HI , OOPS GUI STATUS

Former Member
0 Likes
1,056

hi

in the below example i need to have gui status, how to create gui status for the following program.

below program is running but there is no gui status.

how to create gui status for the below program.

data : ispfli type table of spfli.

data : xspfli type spfli.

data : gr_table type ref to cl_salv_table.

data : gr_functions type ref to cl_salv_functions_list.

data : gr_events type ref to cl_salv_events_table.

data : gr_selections type ref to cl_salv_selections.

class lcl_handle_events definition.

public section.

methods: on_user_command for event added_function of cl_salv_events

importing e_salv_function,

on_double_click for event double_click of cl_salv_events_table

importing row column.

endclass.

data : event_handler type ref to lcl_handle_events.

start-of-selection.

select * into corresponding fields of table ispfli from spfli up to 100 rows .

call method cl_salv_table=>factory

importing

r_salv_table = gr_table

changing

t_table = ispfli.

gr_table->set_screen_status(

pfstatus = 'SALV_TABLE_STANDARD

report = sy-repid

set_functions = gr_table->c_functions_all ).

gr_events = gr_table->get_event( ).

create object event_handler.

set handler event_handler->on_user_command for gr_events.

set handler event_handler->on_double_click for gr_events.

gr_selections = gr_table->get_selections( ).

gr_selections->set_selection_mode( 1 ).

gr_table->display( ).

class lcl_handle_events implementation.

method on_user_command.

Get the selection rows

data: lr_selections type ref to cl_salv_selections.

data: lt_rows type salv_t_row.

data: ls_rows type i.

data: message type string.

case e_salv_function.

when 'MYFUNCTION' .

lr_selections = gr_table->get_selections( ).

lt_rows = lr_selections->get_selected_rows( ).

read table lt_rows into ls_rows index 1.

read table ispfli into xspfli index ls_rows.

concatenate xspfli-carrid xspfli-connid xspfli-cityfrom xspfli-cityto into message separated by space.

message i001(00) with 'You pushed the button!' message .

endcase.

Endmethod.

method on_double_click.

data: message type string.

data: row_c(4) type c.

row_c = row.

concatenate 'Row' row_c 'Column' column into message separated by space.

message i001(00) with 'You double-clicked on ' message.

endmethod.

endclass.

thanx

rocky

hi

in the below example i need to have gui status, how to create gui status for the following program.

below program is running but there is no gui status.

how to create gui status for the below program.

data : ispfli type table of spfli.

data : xspfli type spfli.

data : gr_table type ref to cl_salv_table.

data : gr_functions type ref to cl_salv_functions_list.

data : gr_events type ref to cl_salv_events_table.

data : gr_selections type ref to cl_salv_selections.

class lcl_handle_events definition.

public section.

methods: on_user_command for event added_function of cl_salv_events

importing e_salv_function,

on_double_click for event double_click of cl_salv_events_table

importing row column.

endclass.

data : event_handler type ref to lcl_handle_events.

start-of-selection.

select * into corresponding fields of table ispfli from spfli up to 100 rows .

call method cl_salv_table=>factory

importing

r_salv_table = gr_table

changing

t_table = ispfli.

gr_table->set_screen_status(

pfstatus = 'SALV_TABLE_STANDARD

report = sy-repid

set_functions = gr_table->c_functions_all ).

gr_events = gr_table->get_event( ).

create object event_handler.

set handler event_handler->on_user_command for gr_events.

set handler event_handler->on_double_click for gr_events.

gr_selections = gr_table->get_selections( ).

gr_selections->set_selection_mode( 1 ).

gr_table->display( ).

class lcl_handle_events implementation.

method on_user_command.

Get the selection rows

data: lr_selections type ref to cl_salv_selections.

data: lt_rows type salv_t_row.

data: ls_rows type i.

data: message type string.

case e_salv_function.

when 'MYFUNCTION' .

lr_selections = gr_table->get_selections( ).

lt_rows = lr_selections->get_selected_rows( ).

read table lt_rows into ls_rows index 1.

read table ispfli into xspfli index ls_rows.

concatenate xspfli-carrid xspfli-connid xspfli-cityfrom xspfli-cityto into message separated by space.

message i001(00) with 'You pushed the button!' message .

endcase.

Endmethod.

method on_double_click.

data: message type string.

data: row_c(4) type c.

row_c = row.

concatenate 'Row' row_c 'Column' column into message separated by space.

message i001(00) with 'You double-clicked on ' message.

endmethod.

endclass.

thanx

rocky

3 REPLIES 3
Read only

Former Member
0 Likes
942

Go to se80, type in your program name ( make sure the pull down says program). then in the left navigation panel, RIGHT click on the top node, program name. go thru Created menu and select GUI status.

Read only

Former Member
0 Likes
942

Hi,

If you are using OOPs,

The valid GUI status must be set at the PBO event in the flow logic of the ALV subscreen container.

The OK_CODE processing for the cancel functions must be programmed at the PAI event.

or;-

go to function group SALV_METADATA_STATUS and copy the gui status SALV_TABLE_STANDARD into your program. This is the standard gui status for the ALV grid. Once you have copied the status, set the screen status using the appropriate method of the object GR_TABLE. Go to the gui status and add a new button on the application toolbar and name it as “MYFUNCTION”.

report zalvom_demo3. data: ispfli type table of spfli. data: xspfli type spfli. data: gr_table type ref to cl_salv_table. data: gr_selections type ref to cl_salv_selections.

start-of-selection. select * into corresponding fields of table ispfli from spfli up to 100 rows. call method cl_salv_table=>factory importing r_salv_table = gr_table changing t_table = ispfli. gr_table->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD' report = sy-repid set_functions = gr_table->c_functions_all ). * Set up selections. gr_selections = gr_table->get_selections( ). gr_selections->set_selection_mode( 1 ). "Single

  • Display gr_table->display( ).

Regards,

Renjith Michael.

Edited by: Renjith Michael on Jan 18, 2008 8:18 AM

Edited by: Renjith Michael on Jan 18, 2008 8:20 AM

Read only

aris_hidalgo
Contributor
0 Likes
942

Hi Rocky,

Please check the code below for your reference. Hope it helps...

P.S. Please award points if it helps...

&----


*& Report ZFR_ASSET_LAPSE_SCHED

*&

*& PROGRAM TYPE : Report

*& RICEF ID : R-570

*& TITLE : ZFR_ASSET_LAPSE_SCHED

*& SAP Module : FI

*& CREATION DATE : 01/03/2008

*& AUTHOR : Aris Hidalgo

*& DESIGNER : Aris Hidalgo

&----


*& DESCRIPTION :

&----


$*********************************************************************

*$ CHANGE HISTORY

*$----


*$ DATE | T-Num | Description | Reference

    • | | |

$*********************************************************************

REPORT zfr_asset_lapse_sched

NO STANDARD PAGE HEADING

MESSAGE-ID zfi.

----


  • Data Dictionary Table/s *

----


TABLES: anla,

anlz,

anlp.

----


  • SELECTION-SCREEN *

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_bukrs TYPE t001-bukrs OBLIGATORY.

SELECT-OPTIONS: s_anlkl FOR anla-anlkl,

s_kostl FOR anlz-kostl.

SELECTION-SCREEN SKIP 1.

SELECT-OPTIONS: s_peraf FOR anlp-peraf OBLIGATORY.

PARAMETERS: p_gjahr TYPE anlp-gjahr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

----


  • SELECTION-SCREEN *

----


AT SELECTION-SCREEN.

IF s_peraf-low < '1' OR

s_peraf-low > '12'.

MESSAGE e000 WITH text-e01.

ELSEIF s_peraf-high > '12'.

MESSAGE e000 WITH text-e02.

ENDIF.

/ CLASS DEFINITION/S /

----


  • CLASS lcl_data_def DEFINITION

----


*

----


CLASS lcl_data_def DEFINITION ABSTRACT.

PUBLIC SECTION.

TYPES: BEGIN OF t_anla,

bukrs TYPE anla-bukrs,

anln1 TYPE anla-anln1,

anln2 TYPE anla-anln2,

anlkl TYPE anla-anlkl,

zugdt TYPE anla-zugdt,

deakt TYPE anla-deakt,

txt50 TYPE anla-txt50,

bstdt TYPE anla-bstdt,

END OF t_anla.

TYPES: BEGIN OF t_anlc,

bukrs TYPE anlc-bukrs,

anln1 TYPE anlc-anln1,

anln2 TYPE anlc-anln2,

gjahr TYPE anlc-gjahr,

afabe TYPE anlc-afabe,

kansw TYPE anlc-kansw,

knafa TYPE anlc-knafa,

answl TYPE anlc-answl,

END OF t_anlc.

TYPES: BEGIN OF t_anlp,

bukrs TYPE anlp-bukrs,

anln1 TYPE anlp-anln1,

anln2 TYPE anlp-anln2,

gjahr TYPE anlp-gjahr,

peraf TYPE anlp-peraf,

nafaz TYPE anlp-nafaz,

END OF t_anlp.

TYPES: BEGIN OF t_anlz,

bukrs TYPE anlz-bukrs,

anln1 TYPE anlz-anln1,

anln2 TYPE anlz-anln2,

bdatu TYPE anlz-bdatu,

kostl TYPE anlz-kostl,

END OF t_anlz.

TYPES: BEGIN OF t_anlb,

bukrs TYPE anlb-bukrs,

anln1 TYPE anlb-anln1,

anln2 TYPE anlb-anln2,

afabe TYPE anlb-afabe,

bdatu TYPE anlb-bdatu,

ndjar TYPE anlb-ndjar,

END OF t_anlb.

TYPES: BEGIN OF t_output,

bukrs TYPE anla-bukrs,

anlkl TYPE anla-anlkl,

kostl TYPE anlz-kostl,

anln1 TYPE anla-anln1,

anln2 TYPE anla-anln2,

txt50 TYPE anla-txt50,

ndjar TYPE anlb-ndjar,

zugdt TYPE anla-zugdt,

bstdt TYPE anla-bstdt,

waers TYPE t005-waers,

kansw TYPE anlc-kansw,

accum_dep TYPE anlc-kansw,

gjahr TYPE anlc-gjahr,

jan TYPE anlc-kansw,

feb TYPE anlc-kansw,

mar TYPE anlc-kansw,

apr TYPE anlc-kansw,

may TYPE anlc-kansw,

jun TYPE anlc-kansw,

jul TYPE anlc-kansw,

aug TYPE anlc-kansw,

sep TYPE anlc-kansw,

oct TYPE anlc-kansw,

nov TYPE anlc-kansw,

dec TYPE anlc-kansw,

subtotal TYPE anlc-kansw,

total TYPE anlc-kansw,

net_book TYPE anlc-kansw,

END OF t_output.

TYPES: BEGIN OF t_accum_dep,

bukrs TYPE anla-bukrs,

anln1 TYPE anla-anln1,

anln2 TYPE anla-anln2,

accum_dep TYPE anlp-nafaz,

END OF t_accum_dep.

DATA: gt_anla TYPE STANDARD TABLE OF t_anla,

gt_anlc TYPE SORTED TABLE OF t_anlc

WITH NON-UNIQUE KEY bukrs anln1 anln2 gjahr,

gt_anlp TYPE SORTED TABLE OF t_anlp

WITH NON-UNIQUE KEY bukrs anln1 anln2 gjahr,

gt_anlz TYPE HASHED TABLE OF t_anlz

WITH UNIQUE KEY bukrs anln1 anln2 bdatu,

gt_anlb TYPE SORTED TABLE OF t_anlb

WITH NON-UNIQUE KEY bukrs anln1 anln2,

gt_output TYPE STANDARD TABLE OF t_output,

gt_accum_dep TYPE STANDARD TABLE OF t_accum_dep.

DATA: wa_output LIKE LINE OF gt_output,

wa_accum_dep LIKE LINE OF gt_accum_dep.

ENDCLASS. "lcl_data_def DEFINITION

CLASS lcl_alv_routines DEFINITION DEFERRED.

CLASS lcl_handle_events DEFINITION DEFERRED.

----


  • CLASS lcl_get_data DEFINITION

----


*

----


CLASS lcl_get_data DEFINITION INHERITING FROM lcl_data_def.

PUBLIC SECTION.

METHODS: get_asset_details,

get_asset_life,

get_orig_asset_values,

get_monthly_depreciation,

get_cost_center,

determine_month_from_number

IMPORTING

im_peraf TYPE anlp-peraf

im_nafaz TYPE anlp-nafaz

EXPORTING

ex_subtotal TYPE anlp-nafaz,

process_data.

DATA: o_lcl_alv_routines TYPE REF TO lcl_alv_routines.

CONSTANTS: lc_deakt TYPE anla-deakt VALUE '00000000',

lc_afabe_start TYPE anlc-afabe VALUE '01',

lc_afabe_end TYPE anlc-afabe VALUE '99',

lc_bdatu TYPE anlz-bdatu VALUE '99991231',

lc_waers TYPE t005-waers VALUE 'PHP'.

CONSTANTS: lc_001 TYPE anlp-peraf VALUE '001',

lc_002 TYPE anlp-peraf VALUE '002',

lc_003 TYPE anlp-peraf VALUE '003',

lc_004 TYPE anlp-peraf VALUE '004',

lc_005 TYPE anlp-peraf VALUE '005',

lc_006 TYPE anlp-peraf VALUE '006',

lc_007 TYPE anlp-peraf VALUE '007',

lc_008 TYPE anlp-peraf VALUE '008',

lc_009 TYPE anlp-peraf VALUE '009',

lc_010 TYPE anlp-peraf VALUE '010',

lc_011 TYPE anlp-peraf VALUE '011',

lc_012 TYPE anlp-peraf VALUE '012'.

ENDCLASS. "lcl_get_data DEFINITION

----


  • CLASS lcl_alv_routines DEFINITION

----


*

----


CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_get_data.

PUBLIC SECTION.

DATA: lcl_table TYPE REF TO cl_salv_table,

lcl_container TYPE REF TO cl_gui_custom_container,

  • lcl_handle_events TYPE REF TO lcl_handle_events,

lcl_columns TYPE REF TO cl_salv_columns,

lcl_column TYPE REF TO cl_salv_column_table,

lcl_events2 TYPE REF TO cl_salv_events_table,

lcl_display_settings TYPE REF TO cl_salv_display_settings,

lcl_functions TYPE REF TO cl_salv_functions_list,

lcl_display TYPE REF TO cl_salv_display_settings,

lcl_aggregations TYPE REF TO cl_salv_aggregations,

lcl_sorts TYPE REF TO cl_salv_sorts,

lcl_content TYPE REF TO cl_salv_form_element,

lcl_header TYPE REF TO cl_salv_form_header_info,

ls_color TYPE lvc_s_colo.

DATA: lcl_grid TYPE REF TO cl_salv_form_layout_grid,

lcl_grid_1 TYPE REF TO cl_salv_form_layout_grid,

lcl_grid_2 TYPE REF TO cl_salv_form_layout_grid,

lcl_label TYPE REF TO cl_salv_form_label,"#EC NEEDED

lcl_text TYPE REF TO cl_salv_form_text,

o_lcl_handle_events TYPE REF TO lcl_handle_events,

gt_t247 TYPE STANDARD TABLE OF t247,

wa_t247 LIKE LINE OF gt_t247,

lv_text TYPE string.

METHODS: display_data

IMPORTING

im_output LIKE gt_output,

display_top_of_page.

ENDCLASS. "alv_routines DEFINITION

----


  • CLASS lcl_handle_events DEFINITION

----


*

----


CLASS lcl_handle_events DEFINITION INHERITING FROM lcl_alv_routines.

PUBLIC SECTION.

METHODS: on_single_click FOR EVENT link_click OF cl_salv_events_table

IMPORTING row column.

ENDCLASS. "lcl_handle_events DEFINITION

/ CLASS IMPLEMENTATION/S /

----


  • CLASS lcl_get_data IMPLEMENTATION

----


*

----


CLASS lcl_get_data IMPLEMENTATION.

  • METHOD get_asset_details

METHOD get_asset_details.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

  • PERCENTAGE = 0

text = text-p01.

  • Get asset details

SELECT bukrs anln1 anln2

anlkl aktiv deakt

txt50 bstdt

FROM anla

INTO TABLE gt_anla

WHERE anlkl IN s_anlkl

AND bukrs = p_bukrs.

IF NOT gt_anla[] IS INITIAL.

DELETE gt_anla WHERE deakt <> lc_deakt.

IF NOT gt_anla[] IS INITIAL.

CALL METHOD me->get_asset_life.

CALL METHOD me->get_orig_asset_values.

CALL METHOD me->get_cost_center.

CALL METHOD me->process_data.

ENDIF.

ELSE.

MESSAGE i000 WITH text-i01.

ENDIF.

ENDMETHOD. "get_asset_details

  • METHOD get_asset_life

METHOD get_asset_life.

SELECT bukrs anln1 anln2

afabe bdatu ndjar

FROM anlb

INTO TABLE gt_anlb

FOR ALL ENTRIES IN gt_anla

WHERE bukrs = gt_anla-bukrs

AND anln1 = gt_anla-anln1

AND anln2 = gt_anla-anln2

AND afabe BETWEEN lc_afabe_start AND lc_afabe_end

AND bdatu = lc_bdatu.

ENDMETHOD. "get_asset_life

  • METHOD get_orig_asset_values

METHOD get_orig_asset_values.

SELECT bukrs anln1 anln2

gjahr afabe kansw

knafa answl

FROM anlc

INTO TABLE gt_anlc

FOR ALL ENTRIES IN gt_anla

WHERE bukrs = gt_anla-bukrs

AND anln1 = gt_anla-anln1

AND anln2 = gt_anla-anln2

AND gjahr BETWEEN '1000' AND '9999'

AND afabe BETWEEN lc_afabe_start AND lc_afabe_end.

IF NOT gt_anlc[] IS INITIAL.

CALL METHOD me->get_monthly_depreciation.

ENDIF.

ENDMETHOD. "get_orig_asset_values

  • METHOD get_monthly_depreciation

METHOD get_monthly_depreciation.

SELECT bukrs anln1 anln2

gjahr peraf nafaz

FROM anlp

INTO TABLE gt_anlp

FOR ALL ENTRIES IN gt_anlc

WHERE bukrs = gt_anlc-bukrs

AND anln1 = gt_anlc-anln1

AND anln2 = gt_anlc-anln2

AND gjahr = gt_anlc-gjahr.

ENDMETHOD. "get_monthly_depreciation

  • METHOD get_cost_center

METHOD get_cost_center.

SELECT bukrs anln1 anln2

bdatu kostl

FROM anlz

INTO TABLE gt_anlz

FOR ALL ENTRIES IN gt_anla

WHERE bukrs = gt_anla-bukrs

AND anln1 = gt_anla-anln1

AND anln2 = gt_anla-anln2

AND bdatu = lc_bdatu.

IF NOT gt_anlz[] IS INITIAL.

IF NOT s_kostl[] IS INITIAL.

DELETE gt_anlz WHERE kostl NOT IN s_kostl[].

ENDIF.

ENDIF.

ENDMETHOD. "get_cost_center

  • METHOD determine_month_from_number

METHOD determine_month_from_number.

CASE im_peraf.

WHEN lc_001.

wa_output-jan = im_nafaz.

ADD wa_output-jan TO ex_subtotal.

WHEN lc_002.

wa_output-feb = im_nafaz.

ADD wa_output-feb TO ex_subtotal.

WHEN lc_003.

wa_output-mar = im_nafaz.

ADD wa_output-mar TO ex_subtotal.

WHEN lc_004.

wa_output-apr = im_nafaz.

ADD wa_output-apr TO ex_subtotal.

WHEN lc_005.

wa_output-may = im_nafaz.

ADD wa_output-may TO ex_subtotal.

WHEN lc_006.

wa_output-jun = im_nafaz.

ADD wa_output-jun TO ex_subtotal.

WHEN lc_007.

wa_output-jul = im_nafaz.

ADD wa_output-jul TO ex_subtotal.

WHEN lc_008.

wa_output-aug = im_nafaz.

ADD wa_output-aug TO ex_subtotal.

WHEN lc_009.

wa_output-sep = im_nafaz.

ADD wa_output-sep TO ex_subtotal.

WHEN lc_010.

wa_output-oct = im_nafaz.

ADD wa_output-oct TO ex_subtotal.

WHEN lc_011.

wa_output-nov = im_nafaz.

ADD wa_output-nov TO ex_subtotal.

WHEN lc_012.

wa_output-dec = im_nafaz.

ADD wa_output-dec TO ex_subtotal.

ENDCASE.

ENDMETHOD. "determine_month_from_number

  • METHOD process_data

METHOD process_data.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

  • PERCENTAGE = 0

text = text-p02.

DATA: gt_anlp_dum LIKE gt_anlp,

lv_subtotal TYPE anlp-nafaz.

FIELD-SYMBOLS: <fs_anla> LIKE LINE OF gt_anla,

<fs_anlz> LIKE LINE OF gt_anlz,

<fs_anlc> LIKE LINE OF gt_anlc,

<fs_anlp> LIKE LINE OF gt_anlp,

<fs_anlp_dum> LIKE LINE OF gt_anlp_dum,

<fs_anlb> LIKE LINE OF gt_anlb.

gt_anlp_dum[] = gt_anlp[].

DELETE gt_anlp_dum WHERE gjahr <> p_gjahr.

DELETE gt_anlp_dum WHERE peraf >= s_peraf-low.

LOOP AT gt_anlp_dum ASSIGNING <fs_anlp_dum>.

MOVE-CORRESPONDING <fs_anlp_dum> TO wa_accum_dep.

wa_accum_dep-accum_dep = <fs_anlp_dum>-nafaz.

COLLECT wa_accum_dep INTO gt_accum_dep.

CLEAR wa_accum_dep.

ENDLOOP.

DELETE gt_anlp WHERE gjahr <> p_gjahr.

DELETE gt_anlp WHERE peraf NOT IN s_peraf[].

DELETE gt_anlc WHERE gjahr <> p_gjahr.

SORT gt_accum_dep BY bukrs anln1 anln2.

LOOP AT gt_anla ASSIGNING <fs_anla>.

wa_output-bukrs = <fs_anla>-bukrs.

wa_output-anlkl = <fs_anla>-anlkl.

READ TABLE gt_anlz ASSIGNING <fs_anlz>

WITH TABLE KEY bukrs = <fs_anla>-bukrs

anln1 = <fs_anla>-anln1

anln2 = <fs_anla>-anln2

bdatu = lc_bdatu.

IF sy-subrc = 0.

wa_output-kostl = <fs_anlz>-kostl.

ELSE.

CLEAR wa_output.

CONTINUE.

ENDIF.

wa_output-anln1 = <fs_anla>-anln1.

wa_output-anln2 = <fs_anla>-anln2.

wa_output-txt50 = <fs_anla>-txt50.

READ TABLE gt_anlb ASSIGNING <fs_anlb>

WITH TABLE KEY bukrs = <fs_anla>-bukrs

anln1 = <fs_anla>-anln1

anln2 = <fs_anla>-anln2.

IF sy-subrc = 0.

wa_output-ndjar = <fs_anlb>-ndjar.

ENDIF.

wa_output-zugdt = <fs_anla>-zugdt.

wa_output-bstdt = <fs_anla>-bstdt.

wa_output-waers = lc_waers.

READ TABLE gt_anlc ASSIGNING <fs_anlc>

WITH TABLE KEY bukrs = <fs_anla>-bukrs

anln1 = <fs_anla>-anln1

anln2 = <fs_anla>-anln2

gjahr = p_gjahr.

IF sy-subrc = 0.

wa_output-kansw = <fs_anlc>-kansw.

IF wa_output-kansw IS INITIAL.

wa_output-kansw = <fs_anlc>-answl.

ENDIF.

wa_output-gjahr = <fs_anlc>-gjahr.

CLEAR wa_accum_dep.

READ TABLE gt_accum_dep INTO wa_accum_dep

WITH KEY bukrs = <fs_anlc>-bukrs

anln1 = <fs_anlc>-anln1

anln2 = <fs_anlc>-anln2

BINARY SEARCH.

IF sy-subrc = 0.

wa_output-accum_dep = <fs_anlc>-knafa + wa_accum_dep-accum_dep.

ELSE.

wa_output-accum_dep = <fs_anlc>-knafa.

ENDIF.

LOOP AT gt_anlp ASSIGNING <fs_anlp>

WHERE bukrs = <fs_anlc>-bukrs

AND anln1 = <fs_anlc>-anln1

AND anln2 = <fs_anlc>-anln2

AND gjahr = <fs_anlc>-gjahr.

CALL METHOD me->determine_month_from_number

EXPORTING

im_peraf = <fs_anlp>-peraf

im_nafaz = <fs_anlp>-nafaz

IMPORTING

ex_subtotal = lv_subtotal.

ENDLOOP.

wa_output-subtotal = lv_subtotal.

wa_output-total = wa_output-accum_dep +

wa_output-subtotal.

wa_output-net_book = wa_output-kansw - ABS( wa_output-total ).

ENDIF.

APPEND wa_output TO gt_output.

CLEAR: wa_output, lv_subtotal.

ENDLOOP.

  • Display data

IF NOT gt_output[] IS INITIAL.

CREATE OBJECT o_lcl_alv_routines.

CALL METHOD o_lcl_alv_routines->display_data

EXPORTING

im_output = gt_output[].

ENDIF.

ENDMETHOD. "process_data

ENDCLASS. "lcl_get_data IMPLEMENTATION

----


  • CLASS lcl_alv_routines IMPLEMENTATION

----


*

----


CLASS lcl_alv_routines IMPLEMENTATION.

  • METHOD display_data

METHOD display_data.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

  • PERCENTAGE = 0

text = text-p03.

DATA: lv_header1 TYPE scrtext_l,

lv_header2 TYPE scrtext_m,

lv_peraf TYPE anlp-peraf,

lv_from TYPE t247-ktx,

lv_to TYPE t247-ktx.

gt_output[] = im_output[].

TRY.

cl_salv_table=>factory(

EXPORTING

list_display = ''

IMPORTING

r_salv_table = lcl_table

CHANGING

t_table = gt_output ).

CATCH cx_salv_msg. "#EC NO_HANDLER

ENDTRY.

  • Set all standard ALV functions

lcl_functions = lcl_table->get_functions( ).

lcl_functions->set_all( abap_true ).

  • Optimize width of columns

lcl_columns = lcl_table->get_columns( ).

lcl_columns->set_optimize( '' ).

  • Set display to striped pattern

lcl_display = lcl_table->get_display_settings( ).

lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).

*/Sort columns

TRY.

lcl_sorts = lcl_table->get_sorts( ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

lcl_sorts->set_group_active( ).

TRY.

lcl_sorts->add_sort(

columnname = 'BUKRS'

subtotal = '' ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_sorts->add_sort(

columnname = 'ANLKL'

subtotal = abap_true ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_sorts->add_sort(

columnname = 'KOSTL'

subtotal = abap_true ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_sorts->add_sort(

columnname = 'ANLN1'

subtotal = '' ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_sorts->add_sort(

columnname = 'ANLN2'

subtotal = '' ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_sorts->add_sort(

columnname = 'ZUGDT'

subtotal = '' ).

CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

ENDTRY.

*/Set column names

TRY.

lcl_column ?= lcl_columns->get_column( 'BUKRS' ).

  • lcl_column->set_short_text( text-h01 ).

lcl_column->set_medium_text( text-h01 ).

lcl_column->set_long_text( text-h01 ).

lcl_column->set_output_length( '13' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'ANLKL' ).

  • lcl_column->set_short_text( text-h02 ).

lcl_column->set_medium_text( text-h02 ).

lcl_column->set_long_text( text-h02 ).

lcl_column->set_output_length( '11' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'KOSTL' ).

  • lcl_column->set_short_text( text-h03 ).

lcl_column->set_medium_text( text-h03 ).

lcl_column->set_long_text( text-h03 ).

lcl_column->set_output_length( '11' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'ANLN1' ).

  • lcl_column->set_short_text( text-h04 ).

lcl_column->set_medium_text( text-h04 ).

lcl_column->set_long_text( text-h04 ).

lcl_column->set_output_length( '17' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'ANLN2' ).

  • lcl_column->set_short_text( text-h05 ).

lcl_column->set_medium_text( text-h05 ).

lcl_column->set_long_text( text-h05 ).

lcl_column->set_output_length( '15' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'TXT50' ).

  • lcl_column->set_short_text( text-h06 ).

lcl_column->set_medium_text( text-h06 ).

lcl_column->set_long_text( text-h06 ).

lcl_column->set_output_length( '17' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'NDJAR' ).

  • lcl_column->set_short_text( text-h28 ).

lcl_column->set_medium_text( text-h28 ).

lcl_column->set_long_text( text-h28 ).

lcl_column->set_output_length( '11' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'ZUGDT' ).

  • lcl_column->set_short_text( text-h07 ).

  • lcl_column->set_medium_text( text-h07 ).

lcl_column->set_long_text( text-h07 ).

lcl_column->set_output_length( '22' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'BSTDT' ).

  • lcl_column->set_short_text( text-h29 ).

lcl_column->set_medium_text( text-h29 ).

lcl_column->set_long_text( text-h29 ).

lcl_column->set_output_length( '13' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'WAERS' ).

lcl_column->set_short_text( text-h08 ).

lcl_column->set_medium_text( text-h08 ).

lcl_column->set_long_text( text-h08 ).

lcl_column->set_output_length( '08' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'KANSW' ).

  • lcl_column->set_short_text( text-h09 ).

  • lcl_column->set_medium_text( text-h09 ).

lcl_column->set_long_text( text-h09 ).

lcl_column->set_output_length( '25' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Routine to get month name

*/for accumulated depreciation column

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

language = sy-langu

  • IMPORTING

  • RETURN_CODE =

TABLES

month_names = gt_t247

EXCEPTIONS

month_names_not_found = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF NOT s_peraf-low = lc_001.

lv_peraf = s_peraf-low - 1.

ELSE.

lv_peraf = lc_012.

ENDIF.

IF NOT gt_t247[] IS INITIAL.

SORT gt_t247 BY spras mnr.

READ TABLE gt_t247 INTO wa_t247

WITH KEY spras = sy-langu

mnr = lv_peraf+1(2)

BINARY SEARCH

TRANSPORTING ktx.

IF sy-subrc = 0.

CONCATENATE text-h10 wa_t247-ktx

INTO lv_header1

SEPARATED BY space.

ENDIF.

ENDIF.

TRY.

lcl_column ?= lcl_columns->get_column( 'ACCUM_DEP' ).

  • lcl_column->set_short_text( lv_header1 ).

  • lcl_column->set_medium_text( lv_header1 ).

lcl_column->set_long_text( lv_header1 ).

lcl_column->set_output_length( '40' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'GJAHR' ).

  • lcl_column->set_short_text( text-h11 ).

lcl_column->set_medium_text( text-h11 ).

lcl_column->set_long_text( text-h11 ).

lcl_column->set_output_length( '11' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'JAN' ).

lcl_column->set_short_text( text-h12 ).

lcl_column->set_medium_text( text-h12 ).

lcl_column->set_long_text( text-h12 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'FEB' ).

lcl_column->set_short_text( text-h13 ).

lcl_column->set_medium_text( text-h13 ).

lcl_column->set_long_text( text-h13 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'MAR' ).

lcl_column->set_short_text( text-h14 ).

lcl_column->set_medium_text( text-h14 ).

lcl_column->set_long_text( text-h14 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'APR' ).

lcl_column->set_short_text( text-h15 ).

lcl_column->set_medium_text( text-h15 ).

lcl_column->set_long_text( text-h15 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'MAY' ).

lcl_column->set_short_text( text-h16 ).

lcl_column->set_medium_text( text-h16 ).

lcl_column->set_long_text( text-h16 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'JUN' ).

lcl_column->set_short_text( text-h17 ).

lcl_column->set_medium_text( text-h17 ).

lcl_column->set_long_text( text-h17 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'JUL' ).

lcl_column->set_short_text( text-h18 ).

lcl_column->set_medium_text( text-h18 ).

lcl_column->set_long_text( text-h18 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'AUG' ).

lcl_column->set_short_text( text-h19 ).

lcl_column->set_medium_text( text-h19 ).

lcl_column->set_long_text( text-h19 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'SEP' ).

lcl_column->set_short_text( text-h20 ).

lcl_column->set_medium_text( text-h20 ).

lcl_column->set_long_text( text-h20 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'OCT' ).

lcl_column->set_short_text( text-h21 ).

lcl_column->set_medium_text( text-h21 ).

lcl_column->set_long_text( text-h21 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'NOV' ).

lcl_column->set_short_text( text-h22 ).

lcl_column->set_medium_text( text-h22 ).

lcl_column->set_long_text( text-h22 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_column ?= lcl_columns->get_column( 'DEC' ).

lcl_column->set_short_text( text-h23 ).

lcl_column->set_medium_text( text-h23 ).

lcl_column->set_long_text( text-h23 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Routine to get month name(from - to) for

*/subtotal column

CLEAR lv_header1.

IF NOT gt_t247[] IS INITIAL.

CLEAR wa_t247.

READ TABLE gt_t247 INTO wa_t247

WITH KEY spras = sy-langu

mnr = s_peraf-low+1(2)

BINARY SEARCH

TRANSPORTING ktx.

IF sy-subrc = 0.

lv_from = wa_t247-ktx.

ENDIF.

IF NOT s_peraf-high IS INITIAL.

CLEAR wa_t247.

READ TABLE gt_t247 INTO wa_t247

WITH KEY spras = sy-langu

mnr = s_peraf-high+1(2)

BINARY SEARCH

TRANSPORTING ktx.

IF sy-subrc = 0.

lv_to = wa_t247-ktx.

CONCATENATE lv_from 'to' lv_to

INTO lv_header1

SEPARATED BY space.

ENDIF.

ELSE.

CONCATENATE lv_from 'to' lv_from

INTO lv_header1

SEPARATED BY space.

ENDIF.

ENDIF.

lv_header2 = lv_header1.

TRY.

lcl_column ?= lcl_columns->get_column( 'SUBTOTAL' ).

  • lcl_column->set_short_text( lv_header1 ).

lcl_column->set_medium_text( lv_header2 ).

lcl_column->set_long_text( lv_header1 ).

lcl_column->set_output_length( '16' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Routine to get month name for

*/total column

CLEAR lv_header1.

IF NOT lv_to IS INITIAL.

CONCATENATE text-h24 lv_to

INTO lv_header1

SEPARATED BY space.

ELSE.

CONCATENATE text-h24 lv_from

INTO lv_header1

SEPARATED BY space.

ENDIF.

TRY.

lcl_column ?= lcl_columns->get_column( 'TOTAL' ).

  • lcl_column->set_short_text( lv_header1 ).

  • lcl_column->set_medium_text( lv_header1 ).

lcl_column->set_long_text( lv_header1 ).

lcl_column->set_output_length( '40' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Routine to get month name for

*/netbook value column

CLEAR lv_header1.

IF NOT lv_to IS INITIAL.

CONCATENATE text-h25 lv_to

INTO lv_header1

SEPARATED BY space.

ELSE.

CONCATENATE text-h25 lv_from

INTO lv_header1

SEPARATED BY space.

ENDIF.

TRY.

lcl_column ?= lcl_columns->get_column( 'NET_BOOK' ).

  • lcl_column->set_short_text( lv_header1 ).

  • lcl_column->set_medium_text( lv_header1 ).

lcl_column->set_long_text( lv_header1 ).

lcl_column->set_output_length( '40' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Set aggregations

TRY.

lcl_aggregations = lcl_table->get_aggregations( ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'KANSW' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'ACCUM_DEP' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'JAN' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'FEB' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'MAR' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'APR' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'MAY' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'JUN' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'JUL' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'AUG' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'SEP' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'OCT' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'NOV' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'DEC' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'SUBTOTAL' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'TOTAL' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

TRY.

lcl_aggregations->add_aggregation( 'NET_BOOK' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

ENDTRY.

*/Hide columns

*/Routine to hide months that are not included

*/for the user defined month range in the selection screen

CLEAR lv_peraf.

DO 12 TIMES.

ADD 1 TO lv_peraf.

IF lv_peraf = lc_001 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'JAN' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_002 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'FEB' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_003 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'MAR' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_004 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'APR' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_005 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'MAY' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_006 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'JUN' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_007 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'JUL' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_008 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'AUG' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_009 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'SEP' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_010 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'OCT' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_011 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'NOV' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ELSEIF lv_peraf = lc_012 AND lv_peraf NOT IN s_peraf[].

TRY.

lcl_column ?= lcl_columns->get_column( 'DEC' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

ENDIF.

ENDDO.

TRY.

lcl_column ?= lcl_columns->get_column( 'GJAHR' ).

lcl_column->set_visible( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*/Display top of page

CALL METHOD me->display_top_of_page.

lcl_table->set_top_of_list( lcl_content ).

*/Set ALV events

lcl_events2 = lcl_table->get_event( ).

CREATE OBJECT o_lcl_handle_events.

SET HANDLER o_lcl_handle_events->on_single_click FOR lcl_events2.

*/Display data

lcl_display_settings = lcl_table->get_display_settings( ).

lcl_table->display( ).

ENDMETHOD. "display_data

  • METHOD display_top_of_page

METHOD display_top_of_page.

TYPES: BEGIN OF t_t001,

bukrs TYPE t001-bukrs,

butxt TYPE t001-butxt,

END OF t_t001.

DATA: lt_t001 TYPE HASHED TABLE OF t_t001

WITH UNIQUE KEY bukrs,

wa_t001 LIKE LINE OF lt_t001,

lv_from TYPE t247-ltx,

lv_to TYPE t247-ltx,

lv_day_in TYPE sy-datum,

lv_last_day TYPE sy-datum.

SELECT bukrs butxt

FROM t001

INTO TABLE lt_t001

WHERE bukrs = p_bukrs.

IF NOT lt_t001[] IS INITIAL.

READ TABLE lt_t001 INTO wa_t001

WITH TABLE KEY bukrs = p_bukrs

TRANSPORTING butxt.

IF sy-subrc = 0.

lv_text = wa_t001-butxt.

ENDIF.

ENDIF.

CREATE OBJECT lcl_grid.

lcl_grid->create_header_information(

row = 1

column = 1

text = lv_text

tooltip = lv_text ).

lcl_grid->add_row( ).

lcl_grid_1 = lcl_grid->create_grid(

row = 3

column = 1 ).

lcl_label = lcl_grid_1->create_label(

row = 1

column = 1

text = text-h26

tooltip = text-h26 ).

  • lcl_text = lcl_grid_1->create_text(

  • row = 1

  • column = 2

  • text = lv_text

  • tooltip = lv_text ).

lcl_label->set_label_for( lcl_text ).

CLEAR wa_t247.

READ TABLE gt_t247 INTO wa_t247

WITH KEY spras = sy-langu

mnr = s_peraf-low+1(2)

BINARY SEARCH

TRANSPORTING ltx.

IF sy-subrc = 0.

lv_from = wa_t247-ltx.

ENDIF.

IF s_peraf-high IS INITIAL.

lv_to = lv_from.

ELSE.

CLEAR wa_t247.

READ TABLE gt_t247 INTO wa_t247

WITH KEY spras = sy-langu

mnr = s_peraf-high+1(2)

BINARY SEARCH

TRANSPORTING ltx.

IF sy-subrc = 0.

lv_to = wa_t247-ltx.

ENDIF.

ENDIF.

IF s_peraf-high IS INITIAL.

CONCATENATE p_gjahr s_peraf-low+1(2) '01'

INTO lv_day_in.

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

day_in = lv_day_in

IMPORTING

last_day_of_month = lv_last_day

EXCEPTIONS

day_in_no_date = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR lv_text.

CONCATENATE text-h27 lv_from '01' 'to'

lv_to lv_last_day+6(2) p_gjahr

INTO lv_text

SEPARATED BY space.

ELSE.

CONCATENATE p_gjahr s_peraf-high+1(2) '01'

INTO lv_day_in.

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

day_in = lv_day_in

IMPORTING

last_day_of_month = lv_last_day

EXCEPTIONS

day_in_no_date = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR lv_text.

CONCATENATE text-h27 lv_from '01' 'to'

lv_to lv_last_day+6(2) p_gjahr

INTO lv_text

SEPARATED BY space.

ENDIF.

lcl_label = lcl_grid_1->create_label(

row = 2

column = 1

text = lv_text

tooltip = lv_text ).

  • lcl_text = lcl_grid_1->create_text(

  • row = 2

  • column = 2

  • text = lv_text

  • tooltip = lv_text ).

lcl_label->set_label_for( lcl_text ).

lcl_content = lcl_grid.

ENDMETHOD. "display_top_of_page

ENDCLASS. "lcl_alv_routines IMPLEMENTATION

----


  • CLASS lcl_handle_events IMPLEMENTATION

----


*

----


CLASS lcl_handle_events IMPLEMENTATION.

METHOD on_single_click.

ENDMETHOD. "on_single_click

ENDCLASS. "lcl_handle_events IMPLEMENTATION

----


  • START-OF-SELECTION *

----


START-OF-SELECTION.

DATA: o_lcl_get_data TYPE REF TO lcl_get_data.

CREATE OBJECT o_lcl_get_data.

CALL METHOD o_lcl_get_data->get_asset_details.