Application Development 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: 

ALV Report doubt

Former Member
0 Kudos

Hi All

I am creating a ALV report and had realized that we can use REUSE_ALV_FIELDCATALOG_MERGE to create a fieldcatalog.

However in I_STRUCTURE_NAME parameters I have to pass only structure that are defined in DDIC. I can"t pass my internal table defined for output.

So this option maynot be much useful. instead I can build fieldcatalog manually.

Am I right ? also at this time I am only concentrating on ALV using Functional Modules. Please let me know.

Regards

Madhu.

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi Madhu,

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = 'the_name_of_your_program'

i_internal_tabname = 'the_name_of_the_internal_table_in_your_program'

...

hope this helps

pls. note that the fields in your internal table have to be declared with LIKE, otherwise the standard FM won't be able to build the fieldcatalouge.

ec

8 REPLIES 8

naimesh_patel
Active Contributor
0 Kudos

Yes you right. If you don't have the structure in the DDIC, fill the field catalog manually.

Regards,

Naimesh Patel

Former Member
0 Kudos

Yup you are right!

But if you want to test out the FM REUSE_ALV_FIELDCATALOG_MERGE then create a custom structure in DDIC and it will work!

JozsefSzikszai
Active Contributor
0 Kudos

hi Madhu,

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = 'the_name_of_your_program'

i_internal_tabname = 'the_name_of_the_internal_table_in_your_program'

...

hope this helps

pls. note that the fields in your internal table have to be declared with LIKE, otherwise the standard FM won't be able to build the fieldcatalouge.

ec

0 Kudos

Hi Eric and others,

Thank you very much for your replies.

Actually Eric answer is right to my question. maybe I did not asked the question rightly.

I was in impression that we can"t build fieldcatlog automatically for user build internal table using 'REUSE_ALV_FIELDCATALOG_MERGE' .

now I have understund that, I have one more question.

in my internal table, I have a amount field, I want to create totals for that, how can I do that. I am using 'REUSE_ALV_FIELDCATALOG_MERGE' for build field catalog automatically.

Thank you

madhu

0 Kudos

Ok.. After building the fieldcatalog just loop on the that FCAT table and set DO_SUM for the amount field.

LIKE:


DATA:  l_fcat   TYPE slis_fieldcat_alv.


LOOP AT FCAT INTO L_FCAT WHERE FIELDNAME = 'AMOUNT'.
  L_FCAT-DO_SUM = 'X'.
  MODIFY FCAT FROM L_FCAT.
ENDLOOP.

Regards,

Naimesh Patel

0 Kudos

1. you have to change the fieldcatalog for the field you want to make sum (there is a field do_sum, change it to X for the fields you want to make sum (if it is not done automatically)

2. you have to build a sort table for that and pass that table to the REUSE_ALV_LIST_DISPLAY FM (or GRID_DISPLAY). in the sort table you can also tell to the system if you want make subtotal acc. to the sorted field. pls. check the type slis_sortinfo_alv in type group slis

0 Kudos

Hi ERIC and others,

Thanks you once again.

Can you please let me know where I am doing mistake, i am not getting totals on price but I getting sort on carrid and they are grouping.

Please help me.

REPORT ZALV_REPORT_SFLIGHT.

TABLES : SFLIGHT.

TYPE-POOLS : SLIS.

DATA : IT_SFLIGHT TYPE TABLE OF SFLIGHT.

**DATA DECLARTION

DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

GD_sort type STANDARD TABLE OF slis_sortinfo_alv WITH HEADER LINE,

I_REPID LIKE SY-REPID.

i_repid = sy-repid.

perform get_data.

perform build_fieldcat.

perform display.

&----


*& Form get_data

&----


form get_data .

select * from sflight into table it_sflight.

endform. " get_data

&----


*& Form build_fieldcat

&----


form build_fieldcat .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = i_repid

I_INTERNAL_TABNAME = 'IT_SFLIGHT'

I_STRUCTURE_NAME = 'SFLIGHT'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = FIELDCATALOG[]

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

GD_sort-fieldname = 'CARRID'.

GD_sort-tabname = 'SFLIGHT'.

*GD_sort-up =

*GD_sort-down =

*GD_sort-group = 'X'.

GD_sort-subtot = 'X'.

append gd_sort TO GD_SORT.

endform. " build_fieldcat

&----


*& Form display

&----


form display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = I_REPID

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = FIELDCATALOG[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = GD_sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_SFLIGHT

EXCEPTIONS

PROGRAM_ERROR = 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.

endform. " display

Thank you

0 Kudos

GD_sort-fieldname = '<b>CARRID</b>'. <i>Put ur price's fieldname instead of CARRID</i>

GD_sort-tabname = 'SFLIGHT'.

*GD_sort-up =

*GD_sort-down =

*GD_sort-group = 'X'.

GD_sort-subtot = 'X'.

append gd_sort TO GD_SORT.

Cheers

~Arun