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: 

ABC Analysis Error

spartans007
Participant
0 Kudos
1,609

Hello,

I am facing this issue while trying to use ABC Analysis. Unable to figure out the issue.

Can anyone help me out?

Thanks.

1 ACCEPTED SOLUTION

xiaosanyu
Participant
1,515

Can you provide your code?

14 REPLIES 14

Sandra_Rossi
Active Contributor
0 Kudos
1,515

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).

xiaosanyu
Participant
1,516

Can you provide your code?

0 Kudos
1,515

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.

0 Kudos
1,515

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.

0 Kudos
1,515

OK i will. Thank you

spartans007
Participant
0 Kudos
1,515

Yes Sandra, But for my piece of code it is throwing me an error.

xiaosanyu
Participant
1,515

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.












0 Kudos
1,515

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.

1,515

You're welcome. 🙂

1,515

spartans007 Please mark this answer as correct, rather than the other one which is just a question ("Can you provide your code?")

0 Kudos
1,515

Yes i have done it.

0 Kudos
1,515

spartans007 No you didn't, but of course it's just a recommendation, do as you wish.

Sandra_Rossi
Active Contributor
1,515

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( ).

spartans007
Participant
0 Kudos
1,515

Thank you. My issue is fixed. Thanks for all