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

ALV display

Former Member
0 Likes
754

HI,

I need get the details as follow :

If Document currency of GBP and its amount is 1000, 3000

and for USD it has 3000, 4000.

In alv display in bottom it has to display as :

GBP 4000

USD 7000.

Please let me know how to do this.

Thanks,

Pavan.

HI,

I need get the details as follow :

If Document currency of GBP and its amount is 1000, 3000

and for USD it has 3000, 4000.

In alv display in bottom it has to display as :

GBP 4000

USD 7000.

Please let me know how to do this.

Thanks,

Pavan.

6 REPLIES 6
Read only

Former Member
0 Likes
714

Hi,

You could SUM / Collect based on the currency key and then display the results passing currency key to one field and amount to another field of an internal table and then call the standard ALV grid display function module for the display.

Rgds,

HR

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
714

Please post the code that you have so far. The functionality that you require happens when you tied the currency to the field being subtotaled.

Regards,

Rich Heilman

Read only

0 Likes
714

If you are using the REUSE function module and building your fieldcat, please see the example below. You must tied the UOM field to the actually field being subtotaled. See here we are tieing DISTID to the DISTANCE field in the field catalog.



report zrich_0004
       no standard page heading.

type-pools slis.

data: fieldcat type slis_t_fieldcat_alv.

data: begin of ispfli occurs 0,
      carrid type spfli-carrid,
      connid type spfli-connid,
      distance type spfli-distance,
      distid type spfli-distid,
      end of ispfli.

start-of-selection.

  select * into corresponding fields of table ispfli from spfli.

  perform build_field_catalog.

* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat = fieldcat
       tables
            t_outtab    = ispfli.


************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.

  data: fc_tmp type slis_fieldcat_alv.
  clear fieldcat. refresh fieldcat.

  clear fc_tmp.
  fc_tmp-reptext_ddic    = 'Airline carrier ID'.
  fc_tmp-fieldname  = 'CARRID'.
  fc_tmp-tabname   = 'ISPFLI'.
  fc_tmp-outputlen  = '3'.
  append fc_tmp to fieldcat.

  clear fc_tmp.
  fc_tmp-reptext_ddic    = 'Flight connection Id'.
  fc_tmp-fieldname  = 'CONNID'.
  fc_tmp-tabname   = 'ISPFLI'.
  fc_tmp-outputlen  = '4'.
  append fc_tmp to fieldcat.

  clear fc_tmp.
  fc_tmp-reptext_ddic    = 'Distance'.
  fc_tmp-fieldname  = 'DISTANCE'.
  fc_tmp-tabname   = 'ISPFLI'.
  fc_tmp-outputlen  = '15'.
<b>  fc_tmp-cfieldname = 'DISTID'.</b>
  fc_tmp-do_sum     = 'X'.
  append fc_tmp to fieldcat.

  clear fc_tmp.
  fc_tmp-reptext_ddic    = 'UOM'.
  fc_tmp-fieldname  = 'DISTID'.
  fc_tmp-tabname   = 'ISPFLI'.
  fc_tmp-outputlen  = '3'.
  append fc_tmp to fieldcat.

endform.


This is working good in my system.

Regards,

Rich Heilman

Read only

0 Likes
714

Hi Rich,

Below is my code using for ALV display

FORM f_alv_sort_subtot_info.

DATA: wa_sort TYPE slis_sortinfo_alv.

SORT gt_finalfx BY hkont.

CLEAR wa_sort.

wa_sort-fieldname = 'ZZ_BUKRS'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO gt_sort.

CLEAR wa_sort.

wa_sort-fieldname = 'HKONT'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO gt_sort.

CLEAR wa_sort.

wa_sort-fieldname = 'ZZDOC_CURR'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO gt_sort.

CLEAR wa_sort.

wa_sort-fieldname = 'ZZLCL_CURR'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO gt_sort.

ENDFORM. "f_alv_sort_subtot_info

FORM f_build_fieldcatalog_fx.

DATA: lv_tmp_tabix LIKE sy-tfill.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'ZGLS_FX_ENTRIES'

CHANGING

ct_fieldcat = gt_fieldcat

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.

LOOP AT gt_fieldcat INTO gs_fieldcat.

IF gs_fieldcat-fieldname = 'ZZ_BELNR' OR

gs_fieldcat-fieldname = 'GJAHR' OR

gs_fieldcat-fieldname = 'ZZ_USNAM' OR

gs_fieldcat-fieldname = 'BUDAT' OR

gs_fieldcat-fieldname = 'VBUND' OR

gs_fieldcat-fieldname = 'ZZBS_ACCT' OR

gs_fieldcat-fieldname = 'ZZ_PPRCT' OR

gs_fieldcat-fieldname = 'PROJK' OR

gs_fieldcat-fieldname = 'KOSTL'.

gs_fieldcat-no_out = 'X'.

MODIFY gt_fieldcat FROM gs_fieldcat.

ENDIF.

IF gs_fieldcat-fieldname = 'ZZAMT_DC' OR

gs_fieldcat-fieldname = 'ZZ_DMBTR' OR

gs_fieldcat-fieldname = 'ZZAMT_GCC'.

gs_fieldcat-do_sum = 'X'.

MODIFY gt_fieldcat FROM gs_fieldcat.

ENDIF.

IF gs_fieldcat-fieldname = 'ZZ_TXT50'.

gs_fieldcat-outputlen = '20'.

gs_fieldcat-intlen = '20'.

gs_fieldcat-ddic_outputlen = '20'.

MODIFY gt_fieldcat FROM gs_fieldcat.

ENDIF.

IF gs_fieldcat-fieldname = 'ZZ_SGTXT'.

gs_fieldcat-outputlen = '20'.

gs_fieldcat-intlen = '20'.

gs_fieldcat-ddic_outputlen = '20'.

MODIFY gt_fieldcat FROM gs_fieldcat.

ENDIF.

ENDLOOP.

DESCRIBE TABLE gt_fieldcat LINES sy-tfill.

lv_tmp_tabix = sy-tfill + 1.

MOVE lv_tmp_tabix TO gv_col_pos.

FORM f_build_events_fx.

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = gt_events[].

READ TABLE gt_events WITH KEY name = slis_ev_end_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE 'END_OF_PAGE' TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

READ TABLE gt_events WITH KEY name = slis_ev_end_of_list

INTO ls_event.

IF sy-subrc = 0.

MOVE 'END_OF_LIST' TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

ENDFORM. "f_build_events_fx

*&----


**& Form BUILD_PRINT_PARAMS

*&----


    • text : Build Print Params

*----


FORM f_build_print_params_fx.

gd_prntparams-reserve_lines = '0'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

ENDFORM. "f_build_print_params_fx

Read only

0 Likes
714

Ok, so, somewhere in here, you need to set the cfieldname as the Currency UNIT in your internal table.

IF gs_fieldcat-fieldname = 'ZZAMT_DC' OR
gs_fieldcat-fieldname = 'ZZ_DMBTR' OR
gs_fieldcat-fieldname = 'ZZAMT_GCC'.
gs_fieldcat-do_sum = 'X'.
<b>gs_fieldcat-cfieldname = <the currency unit field>.</b>
MODIFY gt_fieldcat FROM gs_fieldcat.
ENDIF.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
714

hi Pavan,

do this way ..

FORM event_list.
  t_event-name = slis_ev_end_of_list.
  t_event-form = 'END_OF_LIST'.
  APPEND t_event TO it_event.

ENDFORM.                    " EVENT_LIST

FORM end_of_list.

 < Write your Logic here>

ENDFORM.

Regards,

Santosh