fidley / falv

FALV - Fast ALV Grid
https://abapblog.com
GNU General Public License v3.0
141 stars 52 forks source link

Cfieldname fieldcat not working [Question] #56

Closed hervianzhou closed 4 years ago

hervianzhou commented 4 years ago

Hi @fidley ,

currently i'm using falv for creating some report image

i'm using IDR currency... but the amount still not reflected like using currency already referenced.. it should be times by 100 like JPY

image

please kindly assist.. is there something i missed? it's also not working for quantity field

hervianzhou commented 4 years ago

i'm expecting result like this..

code using salv image

image

fidley commented 4 years ago

Hi @hervianzhou ,

I'll check it on my installation and I'll come back to you.

fidley commented 4 years ago

I have just quickly checked and seems this setting is applied. Just wondering if you have REF_TABLE and REF_FIELD fields in your field-catalog. Sometimes they mess up things

hervianzhou commented 4 years ago

Hi @fidley ..

i just check the fieldcat before using falv->display.. REF_TABLE and REF_FIELD is blank... both quantity and currency field... image

this is all the type i'm declared

      kostl  TYPE coep-kostl,
      lstar  TYPE coep-lstar,
      wtgbtr TYPE coep-wtgbtr,
      twaer  TYPE coep-twaer,
      mbgbtr TYPE coep-mbgbtr,
      meinb  TYPE coep-meinb.
fidley commented 4 years ago

I've played a little bit and I know how to make it work, but I don't know why it doesn't work from scratch....

image

I've compared the fieldcat of the demo program (which was giving me exactly the same results)


REPORT zdemo_falv24.

TYPES: BEGIN OF t_output,
         price    TYPE sflight-price,
         currency TYPE sflight-currency,
       END OF t_output.

DATA: output TYPE STANDARD TABLE OF t_output.

SELECT price, currency UP TO 10000 ROWS
      INTO CORRESPONDING FIELDS OF TABLE @output
      FROM sflight.

data(falv) = zcl_falv=>create(
               CHANGING
                 ct_table          = output
             ).

falv->column( 'PRICE'  )->set_cfieldname( 'CURRENCY' ).

falv->display( ).

With demo fcat of program from ALV grid in nutshell, where it is working correctly


report zdemo_ain_cl09.
include zdemo_ain_include_screen.

initialization.

select * up to 10000 rows from sflight into table @data(flights).

data(grid) = new cl_gui_alv_grid(
                  i_parent = new cl_gui_custom_container( container_name = 'CC' )
                                 ).
data(fcat) = value lvc_t_fcat(
                               ( fieldname = 'CARRID'  )
                               ( fieldname = 'CONNID' )
                               ( fieldname = 'PRICE' cfieldname = 'CURRENCY' )
                               ( fieldname = 'CURRENCY' )
                             ).

grid->set_table_for_first_display(
  changing
    it_fieldcatalog               = fcat
    it_outtab                     = flights
  exceptions
    invalid_parameter_combination = 1
    program_error                 = 2
    too_many_lines                = 3
    others                        = 4
).
if sy-subrc eq 0.
  call screen 0100.
endif.

And the difference was field TECH_FORM.... in case of correct program it was set to 2, in FALV it was 1. I have no idea where this field is set, as where used list is not working for it, but using method SET_TECH_FORM on that column with value 2, helps. Quite strange.

hervianzhou commented 4 years ago

Hi @fidley.. thanks for your time and solution...

fidley commented 4 years ago

I will also add this in the next commit as automatic switch from 1 to 2 ;)