2023 Jul 13 7:24 PM
Hello,
I am facing this issue while trying to use ABC Analysis. Unable to figure out the issue.
Can anyone help me out?
Thanks.
2023 Jul 14 6:55 AM
2023 Jul 14 6:30 AM
ABC analysis seems to have the ALV table refer to a DDIC structure. If you try with the demo programs, which use SFLIGHT, SBOOK or whatever, you'll see that it works fine (by running &ABC).
2023 Jul 14 6:55 AM
2023 Jul 14 7:11 AM
This is the error i get whenever i try to use ABC Analysis.
Also attached the code below. Thank You.
TYPE-POOLS : slis.
"Declared Table Type
TYPES: BEGIN OF ty_sel,
lifnr TYPE ekko-lifnr,
bedat TYPE ekko-bedat,
ebeln TYPE ekko-ebeln,
afnam TYPE ekpo-afnam,
netwr TYPE ekpo-netwr,
name1 TYPE lfa1-name1,
zhldt TYPE fmioi-zhldt,
END OF ty_sel.
"For ALV
DATA: gt_sel TYPE TABLE OF ty_sel,
gs_sel TYPE ty_sel.
*Local Class to process data
CLASS lcl_data DEFINITION CREATE PUBLIC FINAL.
PUBLIC SECTION.
CLASS-METHODS:
get_data RETURNING VALUE(rt_data) TYPE tt_outtb,
process_data IMPORTING it_data TYPE tt_outtb.
ENDCLASS.
CLASS lcl_data IMPLEMENTATION.
METHOD get_data.
"Selecting data based on filter (radiobutton)
IF p_const = abap_true.
SELECT a~lifnr,
a~bedat,
a~ebeln,
b~afnam,
b~netwr,
c~name1,
d~zhldt
FROM ekpo AS b
INNER JOIN ekko AS a
ON a~ebeln = b~ebeln
LEFT OUTER JOIN lfa1 AS c
ON a~lifnr = c~lifnr
LEFT OUTER JOIN fmioi AS d
ON d~refbn = a~ebeln
INTO TABLE @rt_data
WHERE b~loekz NE @abap_true
"WHERE netwr IN @so_amt
AND a~lifnr IN @so_vndr
AND a~bedat BETWEEN @so_date-low AND @so_date-high
ENDIF.
IF sy-subrc = 0.
SORT rt_data BY lifnr ebeln bedat.
ENDIF.
"Collecting and summing up the values of netwr
LOOP AT rt_data INTO gs_tmp.
gs_tmp-netwr = gs_tmp-netwr.
COLLECT gs_tmp INTO gt_tmp.
ENDLOOP.
"DELETE The Data Where Amount Not in Range.
DELETE gt_tmp WHERE netwr NOT IN so_amt.
"Moving temp data to final internal table to display
CLEAR: rt_data.
MOVE-CORRESPONDING gt_tmp TO rt_data.
ENDMETHOD.
METHOD process_data.
gt_sel = it_data.
ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM display .
DATA: lo_gr_alv TYPE REF TO cl_salv_table,
lo_gr_functions TYPE REF TO cl_salv_functions_list.
DATA: "lo_selections type ref to cl_salv_selections,
lo_columns TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_table.
DATA: lo_header TYPE REF TO cl_salv_form_layout_grid,
lo_h_label TYPE REF TO cl_salv_form_label,
lv_text TYPE char100.
*Create alv object.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_gr_alv
CHANGING
t_table = gt_sel.
CATCH cx_salv_msg.
ENDTRY.
* Enabling the ABC Analysis
lo_gr_alv->set_screen_status( pfstatus = 'STANDARD_FULLSCREEN'
report = 'SAPLSLVC_FULLSCREEN'
set_functions = lo_gr_alv->c_functions_all
).
* Show all alv functions.
lo_gr_functions = lo_gr_alv->get_functions( ).
lo_gr_functions->set_all( abap_true ).
* Fit the columns
lo_columns = lo_gr_alv->get_columns( ).
lo_columns->set_optimize( abap_true ).
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
lr_layout = lo_gr_alv->get_layout( ).
ls_key-report = sy-repid.
* If uv_change_mode = abap_true.
ls_key-handle = 'h0ch'.
lr_layout->set_key( ls_key ).
lr_layout->set_default( abap_true ).
lr_layout->set_save_restriction( '3' ).
* Display alv
lo_gr_alv->display( ).
ENDFORM.
2023 Jul 14 12:31 PM
Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
2023 Jul 14 2:17 PM
2023 Jul 14 7:12 AM
Yes Sandra, But for my piece of code it is throwing me an error.
2023 Jul 14 8:03 AM
The error reason is alv's fieldcatlog no reftable
* Fit the columns
lo_columns = lo_gr_alv->get_columns( ).
lo_columns->set_optimize( abap_true ).
DATA: lo_column_list TYPE REF TO cl_salv_column_list.
TRY.
lo_column_list ?= lo_columns->get_column( 'LIFNR' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'EKKO' field = 'LIFNR' ) ).
lo_column_list ?= lo_columns->get_column( 'EBELN' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'EKKO' field = 'EBELN' ) ).
lo_column_list ?= lo_columns->get_column( 'BEDAT' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'EKKO' field = 'BEDAT' ) ).
lo_column_list ?= lo_columns->get_column( 'AFNAM' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'EKPO' field = 'AFNAM' ) ).
lo_column_list ?= lo_columns->get_column( 'NETWR' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'EKPO' field = 'NETWR' ) ).
lo_column_list ?= lo_columns->get_column( 'NAME1' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'LFA1' field = 'NAME1' ) ).
lo_column_list ?= lo_columns->get_column( 'ZHLDT' ).
lo_column_list->set_ddic_reference( value = VALUE #( table = 'FMIOI' field = 'ZHLDT' ) ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
2023 Jul 14 8:17 AM
Thanks a lot for your help. It helped me resolve my issue.
My issue has been fixed. Thank you so much once again for your support.
2023 Jul 14 8:46 AM
2023 Jul 14 12:31 PM
spartans007 Please mark this answer as correct, rather than the other one which is just a question ("Can you provide your code?")
2023 Jul 14 2:18 PM
2023 Jul 14 3:21 PM
spartans007 No you didn't, but of course it's just a recommendation, do as you wish.
2023 Jul 14 2:02 PM
In fact 99% of SALV demo programs define internally the internal tables, so they have the same issue as yours.
BUT this simple demo works because it's based directly on DDIC structure (flights based on SFLIGHT table):
REPORT.
SELECT * FROM sflight INTO TABLE @DATA(flights).
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(alv)
CHANGING t_table = flights ).
alv->set_screen_status( pfstatus = 'STANDARD_FULLSCREEN'
report = 'SAPLSLVC_FULLSCREEN'
set_functions = alv->c_functions_all ).
alv->display( ).
2023 Jul 14 2:11 PM