Skip to Content
-1
Former Member
Jun 20, 2022 at 12:34 PM

CONVERT_AMOUNT_TO_CURRENCY in table SFLIGHT

53 Views Last edit Jun 20, 2022 at 12:55 PM 3 rev

Hello,

I have a Z program which uses 2 tables SFLIGHT and SPFLI which contains 2 ALV DISPLAY

i have to add 2 currencies to the selection screen and apply the currency to the ALV that uses it.

I have to use de function module " CONVERT_AMOUNT_TO_CURRENCY "

how can i use this Funtion Modal in each of ALV .

thanks

*&---------------------------------------------------------------------*<br>*& Include          Z_AAA_ALV_FOR<br>*&---------------------------------------------------------------------*<br>*&---------------------------------------------------------------------*<br>*& Form search_data<br>*&---------------------------------------------------------------------*<br>*& text<br>*&---------------------------------------------------------------------*<br>*& -->  p1        text<br>*& <--  p2        text<br>*&---------------------------------------------------------------------*<br>FORM search_data .<br><br>  IF p_sfl = 'X'.<br><br>    SELECT carrid connid fldate price currency<br>      FROM sflight<br><br>      INTO TABLE gt_flight<br>       WHERE carrid IN comp<br>      AND connid IN num_vol<br>      AND fldate IN date_vol<br>      AND price IN prix_vol<br>      AND currency IN devise.<br>      <br>    t_header-header = 'Carrid'.<br>    APPEND t_header.<br>    t_header-header = 'Connid'.<br>    APPEND t_header.<br>    t_header-header = 'Fldate'.<br>    APPEND t_header.<br>    t_header-header = 'Price'.<br>    APPEND t_header.<br>    t_header-header = 'Currency'.<br>    APPEND t_header.<br><br>  ELSEIF p_spfli = 'X'.<br><br>      SELECT *<br>        FROM spfli<br>        INTO TABLE it_spfli<br>        WHERE carrid    IN comp_ae<br>        AND   connid    IN n_vol<br>        AND   countryfr IN pays_dep<br>        AND   cityfrom  IN ville_D<br>        AND   airpfrom  IN aerop_D<br>        AND   countryto IN pays_arr<br>        AND   cityto    IN ville_A<br>        AND   airpto    IN aerop_A<br>        AND   distance  IN distance<br>        .<br>endif.<br><br><br>  IF p_sfl = 'X'.<br><br>    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'<br>      EXPORTING<br>        i_callback_program       = sy-repid<br>        it_fieldcat              = lt_fieldcat[]<br>        i_callback_pf_status_set = 'SET_PF_STATUS'<br>        i_callback_user_command  = 'AAA_REPORT'<br>        i_save                   = 'A'<br>        i_default                = 'X'<br>      TABLES<br>        t_outtab                 = gt_flight.<br><br>  ELSEIF<br>     p_spfli              = 'X'.<br><br>    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'<br>      EXPORTING<br>        i_callback_program       = sy-repid<br>        it_fieldcat              = lt_fieldcatt[]<br>        i_callback_pf_status_set = 'SET_PF_STATUS'<br>        i_callback_user_command  = 'AAA_REPORT_SPLFI'<br>      TABLES<br>        t_outtab                 = it_spfli.<br>  ENDIF.<br><br>ENDFORM.<br><br><br><br>FORM set_pf_status USING rt_extab TYPE slis_t_extab.<br><br>****************** btn alv01 ***************<br>  IF p_sfl = 'X'.<br>    SET PF-STATUS 'ZAAA_ALV' EXCLUDING rt_extab.<br><br><br>****************** BTN ALV02 ***************<br>  ELSEIF p_spfli = 'X'.<br>    SET PF-STATUS 'ZAAA_ALV_SPFLI' EXCLUDING rt_extab.<br><br>  ENDIF.<br><br>ENDFORM.<br><br>FORM aaa_report USING r_ucomm LIKE sy-ucomm<br>  rs_selfield TYPE slis_selfield.<br>  DATA : lt_data TYPE TABLE OF string,<br>         ls_data TYPE string,<br>         lv_p(10)    TYPE c.<br><br>  CASE sy-ucomm.<br>    WHEN 'EXIT'.<br>      LEAVE PROGRAM.<br>    WHEN 'ENREG'.<br><br><br>      CALL METHOD cl_gui_frontend_services=>file_save_dialog<br>        EXPORTING<br>          initial_directory = 'C:\'<br>          file_filter       = '*.csv'<br>          default_extension = 'csv'<br>        CHANGING<br>          filename          = v_filename<br>          path              = v_path<br>          fullpath          = v_fullpath.<br><br>      ls_data = 'Désignation de la compagnie aérienne;Code liaison aérienne individuelle;Date du vol;Prix du vol;Devise'.<br>      APPEND ls_data TO lt_data.<br><br>      LOOP AT gt_flight INTO DATA(ls_sflight).<br>        CLEAR : ls_data,<br>                lv_p.<br><br>        MOVE ls_sflight-price TO lv_p.<br><br>        CONCATENATE ls_sflight-carrid<br>                    ls_sflight-connid<br>                    ls_sflight-fldate<br>                    lv_p<br>                    ls_sflight-currency<br>               INTO ls_data<br>       SEPARATED BY ';'.<br><br>        APPEND ls_data TO lt_data.<br>      ENDLOOP.<br><br><br>      CALL METHOD cl_gui_frontend_services=>gui_download<br>        EXPORTING<br>          filename = v_filename<br>        CHANGING<br>          data_tab = lt_data<br>        .<br><br><br>    WHEN 'ENREG'.<br><br>      CALL METHOD cl_gui_frontend_services=>gui_download<br>        EXPORTING<br>          filename = v_filename<br>        CHANGING<br>          data_tab = gt_flight[].<br><br>      IF sy-subrc <> 0.<br>        EXIT.<br>      ENDIF.<br>  ENDCASE.<br>ENDFORM.<br><br><br>FORM user_command USING r_ucomm LIKE sy-ucomm<br>      rs_selfield TYPE slis_selfield.<br>  CASE sy-ucomm.<br>    WHEN 'SE11'.<br>      CALL TRANSACTION 'SE11'.<br>  ENDCASE.<br>ENDFORM.<br><br><br>*&---------------------------------------------------------------------*<br>*& Form fill_fieldcat<br>*&---------------------------------------------------------------------*<br>*& text<br>*&---------------------------------------------------------------------*<br>*& -->  p1        text<br>*& <--  p2        text<br>*&---------------------------------------------------------------------*<br>FORM fill_fieldcat .<br>  CLEAR ls_fieldcat.<br>  ls_fieldcat-col_pos   = 1.<br>  ls_fieldcat-fieldname = 'CARRID'.<br>  ls_fieldcat-tabname   = 'lt_sflight'.<br>  ls_fieldcat-seltext_m  = 'Carrid'.<br>  APPEND ls_fieldcat TO lt_fieldcat.<br>  CLEAR ls_fieldcat.<br>  ls_fieldcat-col_pos   = 2.<br>  ls_fieldcat-fieldname = 'CONNID'.<br>  ls_fieldcat-tabname   = 'lt_sflight'.<br>  ls_fieldcat-seltext_m  = 'connid'.<br>  APPEND ls_fieldcat TO lt_fieldcat.<br><br>  CLEAR ls_fieldcat.<br>  ls_fieldcat-col_pos   = 3.<br>  ls_fieldcat-fieldname = 'FLDATE'.<br>  ls_fieldcat-tabname   = 'lt_sflight'.<br>  ls_fieldcat-seltext_m  = 'Date'.<br>  APPEND ls_fieldcat TO lt_fieldcat.<br><br>  CLEAR ls_fieldcat.<br>  ls_fieldcat-col_pos   = 4.<br>  ls_fieldcat-fieldname = 'PRICE'.<br>  ls_fieldcat-tabname   = 'lt_sflight'.<br>  ls_fieldcat-seltext_m  = 'Prix'.<br>  APPEND ls_fieldcat TO lt_fieldcat.<br><br>  CLEAR ls_fieldcat.<br>  ls_fieldcat-col_pos   = 5.<br>  ls_fieldcat-fieldname = 'CURRENCY'.<br>  ls_fieldcat-tabname   = 'lt_sflight'.<br>  ls_fieldcat-seltext_m  = 'Devise'.<br>  APPEND ls_fieldcat TO lt_fieldcat.<br>ENDFORM.<br><br><br>*&---------------------------------------------------------------------*<br>*& Form fill_fieldcatt<br>*&---------------------------------------------------------------------*<br>*& text<br>*&---------------------------------------------------------------------*<br>*& -->  p1        text<br>*& <--  p2        text<br>*&---------------------------------------------------------------------*<br><br>FORM fill_fieldcatt .<br>  CLEAR ls_fieldcatt.<br>  ls_fieldcatt-col_pos   = 1.<br>  ls_fieldcatt-fieldname = 'CARRID'.<br>  ls_fieldcatt-tabname   = 'lt_sflight'.<br>  ls_fieldcatt-seltext_m  = 'C_ie'.<br>  APPEND ls_fieldcatt TO lt_fieldcatt.<br>  CLEAR ls_fieldcatt.<br>  ls_fieldcatt-col_pos   = 2.<br>  ls_fieldcatt-fieldname = 'CONNID'.<br>  ls_fieldcatt-tabname   = 'lt_sflight'.<br>  ls_fieldcatt-seltext_m  = 'Code_Liaison'.<br>  APPEND ls_fieldcatt TO lt_fieldcatt.<br><br>  CLEAR ls_fieldcatt.<br>  ls_fieldcatt-col_pos   = 3.<br>  ls_fieldcatt-fieldname = 'CITYFROM'.<br>  ls_fieldcatt-tabname   = 'lt_sflight'.<br>  ls_fieldcatt-seltext_m  = 'Ville dep'.<br>  APPEND ls_fieldcatt TO lt_fieldcatt.<br><br>  CLEAR ls_fieldcatt.<br>  ls_fieldcatt-col_pos   = 4.<br>  ls_fieldcatt-fieldname = 'CITYTO'.<br>  ls_fieldcatt-tabname   = 'lt_sflight'.<br>  ls_fieldcatt-seltext_m  = 'Ville Arr'.<br>  APPEND ls_fieldcatt TO lt_fieldcatt.<br><br>ENDFORM.<br>