Skip to Content
author's profile photo Former Member
Former Member

G_ACCOUNT_BALANCE_ACC_GET wrong balance

Hi,

i'm using G_ACCOUNT_BALANCE_ACC_GET to calculate account balances for a given period (day of the year) for a new ledger.

While checking the values with transaction FAGLB03 i noticed that for some accounts the value returned by the function module was equivalent to the one in FAGLB03 divided by 100.

I did a liitle debug and noticed that this was caused when FM G_GLU1_TO_AC_DOC_TRANSFORM (called inside G_ACCOUNT_BALANCE_ACC_GET) returns an exception.

Is this function module (G_ACCOUNT_BALANCE_ACC_GET) obsolete? is there any alternative?

Am I missing something? is anything else that should be done?

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 07:46 PM

    Rob:

    yes, I have 'Fixed point arithmetic' clicked.

    Clemens:

    Could you provide me the code for the forms you call within your code.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Nuno,

      yes I can, but it was very special purpose. Don't know if you can really use it.

      I just post it all.

      I remember we had to run this program to get correct assignment to CO objects in aggregates.

      TYPE-POOLS:

      slis, "Globale Typen für generische Listbausteine

      icon, "Icons

      col, "colors type CHAR(1)

      abap, "ABAP Language Type-Pool

      sydes, "Datenstruktur für die Typbeschreibung bei DESCRIBE TYPE ...

      gb002, "RuleMan: Type definitionen für Boolesche Klassen

      gusl. "Typen zur Selektion von FI-SL-Tabellen

      *&----


      *

      *& Tables

      *&----


      *

      DATA:

      ss_bseg TYPE bseg,

      ss_bkpf TYPE bkpf." used for select-options - all required fields

      *&----


      *

      *& Includes

      *&----


      *

      *&----


      *

      *& Types

      *& TY_

      *&----


      *

      TYPES:

      ty_t_docnr TYPE HASHED TABLE OF belnr_d

      WITH UNIQUE KEY table_line,

      BEGIN OF ty_saknr_txt,

      saknr TYPE skat-saknr,

      txt50 TYPE skat-txt50,

      END OF ty_saknr_txt,

      ty_t_saknr_txt TYPE HASHED TABLE OF ty_saknr_txt

      WITH UNIQUE KEY saknr,

      BEGIN OF ty_bukrs_hwaer,

      bukrs TYPE bukrs,

      hwaer TYPE hwaer,

      END OF ty_bukrs_hwaer,

      ty_t_bukrs_hwaer TYPE HASHED TABLE OF ty_bukrs_hwaer

      WITH UNIQUE KEY bukrs,

      • display table structure

      BEGIN OF ty_alv_display,

      sel TYPE psele,

      lights TYPE icon_d,

      color TYPE slis_t_specialcol_alv,

      rbukrs TYPE bukrs,

      ryear TYPE ryear,

      racct TYPE yaa00eccs-racct,

      cost_elem TYPE kstar, "Cost Element

      prctr TYPE prctr,

      rassc TYPE rassc, "Partner company

      rcntr TYPE kostl, "Cost Center

      rfarea TYPE fkber,"functional area

      rmvct TYPE rmvct,"BWA transaction type

      rtcur TYPE rtcur,

      zzbilkt TYPE zzbilkt,"ECCS item

      zzbilkt_new TYPE zzbilkt,"ECCS item changed by substitution

      zzmulti TYPE zzmulti, "any4multi

      txt50 TYPE txt50_skat,

      tslxx TYPE tslxx12,

      hslxx TYPE hslxx12,

      hwaer TYPE hwaer,

      tslxx_posted TYPE tslxx12,

      hslxx_posted TYPE hslxx12,

      tslxx_topost TYPE tslxx12,

      hslxx_topost TYPE hslxx12,

      t_redoc TYPE ty_t_docnr,"reposted documents

      protocol TYPE icon_d,

      • technical fields for storage of information

      t_prot TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY,

      docnum TYPE belnr_d,

      END OF ty_alv_display,

      ty_t_alv_display TYPE STANDARD TABLE OF ty_alv_display

      WITH DEFAULT KEY,

      • consolidated account values

      BEGIN OF ty_acc_balance,

      rbukrs TYPE bukrs,

      ryear TYPE ryear,

      racct TYPE racct,

      cost_elem TYPE kstar, "Cost Element

      perio TYPE rpmax,

      prctr TYPE prctr,"profit center

      rassc TYPE rassc, "Partner company

      rcntr TYPE kostl, "Cost Center

      rfarea TYPE fkber,"functional area

      rmvct TYPE rmvct,"BWA transaction type

      rtcur TYPE rtcur,"currency

      zzbilkt TYPE zzbilkt,"ECCS item

      zzbilkt_new TYPE zzbilkt,"ECCS item changed by substitution

      zzmulti TYPE zzmulti, "any4multi

      deb_t TYPE tslxx12,

      cre_t TYPE tslxx12,

      tslxx TYPE tslxx12,

      deb_h TYPE hslvt12,

      cre_h TYPE hslvt12,

      hslxx TYPE hslxx12,

      END OF ty_acc_balance,

      ty_t_acc_balance TYPE SORTED TABLE OF ty_acc_balance

      WITH UNIQUE DEFAULT KEY,

      • consolidated total balances per company account dimension

      • in company currency

      BEGIN OF ty_balance,

      rbukrs TYPE bukrs,

      ryear TYPE ryear,

      racct TYPE racct,

      cost_elem TYPE kstar, "Cost Element

      prctr TYPE prctr,

      rassc TYPE rassc, "Partner company

      rcntr TYPE kostl, "Cost Center

      rfarea TYPE fkber,"functional area

      rmvct TYPE rmvct,"BWA transaction type

      rtcur TYPE rtcur, "transaction currency

      zzbilkt TYPE zzbilkt,"ECCS item

      zzbilkt_new TYPE zzbilkt,"ECCS item

      zzmulti TYPE zzmulti, "any4multi

      tslxx TYPE tslxx12,

      hslxx TYPE hslxx12,

      END OF ty_balance,

      ty_t_balance TYPE SORTED TABLE OF ty_balance

      • everything in key except zzbilkt_new due to possible reassignment

      WITH UNIQUE KEY rbukrs ryear racct cost_elem prctr rassc rcntr rfarea rmvct rtcur zzbilkt zzmulti,

      ty_t_racct TYPE HASHED TABLE OF racct WITH UNIQUE KEY table_line,

      ty_t_zzbilkt TYPE HASHED TABLE OF zzbilkt WITH UNIQUE KEY table_line,

      ty_rt_zzbilkt TYPE RANGE OF zzbilkt,

      BEGIN OF ty_posting_detail,

      sel TYPE psele,

      bukrs TYPE bukrs,

      gjahr TYPE gjahr,

      belnr TYPE belnr_d,

      blart TYPE bkpf-blart,

      bldat TYPE bkpf-bldat,

      budat TYPE bkpf-budat,

      monat TYPE bkpf-monat,

      cpudt TYPE bkpf-cpudt,

      cputm TYPE bkpf-cputm,

      usnam TYPE bkpf-usnam,

      tcode TYPE bkpf-tcode,

      END OF ty_posting_detail,

      ty_t_posting_detail TYPE STANDARD TABLE OF ty_posting_detail.

      *&----


      *

      *& Global data

      *&----


      *

      DATA:

      gv_dynnr TYPE dynpronr,

      gv_repid TYPE syrepid,

      gv_relevant_ledger TYPE rldnr_flex,

      gs_variant_main TYPE disvariant,

      gr_tot_table TYPE REF TO data,

      • balances of accounts involved

      t_zzbilkt_aggregate TYPE ty_t_balance,

      t_alv_display TYPE ty_t_alv_display,

      t_posting_detail TYPE ty_t_posting_detail.

      .

      *&----


      *

      *& Field-Symbols

      *& FS_

      *&----


      *

      *&----


      *

      *& Variables

      *& lv_ for local variable

      *& RC = return code

      *&----


      *

      *&----


      *

      *& Constants

      *& C_

      *&----


      *

      CONSTANTS:

      c_true TYPE flag VALUE 'X'.

      *&----


      *

      *& Selection-screen

      *& P_ for Selection/Input parameter, Radio button, Check box

      *& S_ for Select options

      *& R_ for Ranges

      *&----


      *

      SELECTION-SCREEN BEGIN OF BLOCK imsel WITH FRAME TITLE text-igs.

      SELECT-OPTIONS:

      s_bukrs FOR ss_bseg-bukrs OBLIGATORY MEMORY ID buk,

      s_gjahr FOR ss_bseg-gjahr OBLIGATORY MEMORY ID gjr,

      s_racct FOR ss_bseg-saknr,

      s_monat FOR ss_bkpf-monat.

      SELECTION-SCREEN END OF BLOCK imsel.

      SELECTION-SCREEN BEGIN OF BLOCK post WITH FRAME TITLE text-pdt.

      PARAMETERS:

      p_ktopl TYPE ktopl,

      p_blart TYPE t003-blart,

      p_gjahr TYPE gjahr,

      p_bper TYPE monat,

      p_budat TYPE budat,

      p_bldat TYPE bldat,

      p_gkont TYPE gkont.

      SELECTION-SCREEN END OF BLOCK post.

      SELECTION-SCREEN BEGIN OF BLOCK opt WITH FRAME TITLE text-opt.

      PARAMETERS:

      p_eval TYPE rr_xausw RADIOBUTTON GROUP opt,

      p_both TYPE flag RADIOBUTTON GROUP opt,

      p_xselb TYPE xselb AS CHECKBOX,"show correct aggegates

      p_empty TYPE flag,

      p_layout TYPE disvariant-variant,

      p_commit TYPE edi_comcnt NO-DISPLAY."found nothing better

      SELECTION-SCREEN END OF BLOCK opt.

      ************************************************************************

      INITIALIZATION.

      PERFORM initialization.

      ************************************************************************

      AT SELECTION-SCREEN ON s_racct.

      IF s_racct IS NOT INITIAL.

      MESSAGE w000(0k)

      WITH 'Account selection must be initial'(ami)

      'for correct and complete reposting'(fcc) '' ''.

      • & & & &

      ENDIF." s_racct is not initial.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.

      PERFORM reuse_alv_variant_f4 CHANGING gs_variant_main p_layout.

      AT SELECTION-SCREEN OUTPUT.

      PERFORM screen.

      ************************************************************************

      START-OF-SELECTION.

      PERFORM get_eccs_aggregates

      CHANGING t_zzbilkt_aggregate.

      • check selection

      IF t_zzbilkt_aggregate IS INITIAL.

      MESSAGE e429(mo).

      • No table entries found for specified key

      EXIT.

      ENDIF." t_zzbilkt_aggregate is initial.

      PERFORM process_data

      USING t_zzbilkt_aggregate

      CHANGING t_alv_display.

      IF p_xselb IS INITIAL.

      DELETE t_alv_display WHERE zzbilkt_new IS INITIAL.

      IF t_alv_display IS INITIAL.

      MESSAGE e035(ni).

      • There are no incorrectly processed documents

      ENDIF." t_alv_display is initial.

      ENDIF." P_XSELB is initial.

      PERFORM alv_display

      USING t_alv_display.

      ************************************************************************

      *&----


      *

      *& Subroutines

      *&

      *& Initialize selection screen

      *&----


      *

      *&----


      *

      *& Form initialization

      *&----


      *

      *& Initialize selection screen

      *&----


      *

      FORM initialization .

      PERFORM insert_range USING:

      'IEQ' sy-datum(4) '' CHANGING s_gjahr[],

      'IBT' 1 sy-datum+4(2) CHANGING s_monat[].

      PERFORM find_relevant_ledger

      CHANGING gv_relevant_ledger.

      p_ktopl = '0CTA'.

      p_gjahr = sy-datum(4).

      p_gkont = '1994135000'.

      p_blart = 'SU'.

      p_budat =

      p_bldat = sy-datum.

      p_bper = sy-datum+4(2).

      p_commit = 1000.

      gv_repid = sy-repid.

      • initialize variant

      gs_variant_main-report = gv_repid.

      gs_variant_main-log_group = 'MAIN'.

      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

      EXPORTING

      i_save = 'A'

      CHANGING

      cs_variant = gs_variant_main

      EXCEPTIONS

      wrong_input = 1

      not_found = 2

      program_error = 3

      OTHERS = 4.

      IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ELSE.

      p_layout = gs_variant_main-variant.

      ENDIF.

      ENDFORM. " initialization

      *&----


      *

      *& Form insert_range

      *&----


      *

      • append selection range

      *----


      *

      FORM insert_range USING p_signopt TYPE c

      p_low TYPE any

      p_high TYPE any

      CHANGING pt_range TYPE table.

      FIELD-SYMBOLS:

      INTO pt_range INDEX sy-tabix.

      ENDFORM. " insert_range

      *&----


      *

      *& Form GET_ECCS_AGGREGATES

      *----


      *

      FORM get_eccs_aggregates

      CHANGING t_zzbilkt_aggregate TYPE ty_t_balance.

      PERFORM sapgui_progress_indicator

      USING 'Select ECCS aggregates'(sea) 0 0 .

      PERFORM get_zzbilkt_aggregates

      CHANGING t_zzbilkt_aggregate.

      ENDFORM. " GET_ECCS_AGGREGATES

      *&----


      *

      *& Form alV_display

      *&----


      *

      FORM alv_display

      USING pt_list TYPE table.

      DATA:

      ls_alv_layout TYPE slis_layout_alv,

      lv_title TYPE lvc_title,

      ls_exit_by_user TYPE slis_exit_by_user,

      ls_glay TYPE lvc_s_glay,

      ls_print TYPE slis_print_alv,

      lt_alv_fieldcat TYPE slis_t_fieldcat_alv,

      lt_events TYPE slis_t_event,

      lv_variant TYPE disvariant.

      PERFORM sapgui_progress_indicator USING 'Transfer to ALV...'(001) 0 0.

      gv_dynnr = sy-dynnr.

      lv_variant-report = gv_repid.

      lv_variant-username = sy-uname.

      PERFORM alv_layout CHANGING ls_alv_layout.

      PERFORM alv_events CHANGING lt_events.

      PERFORM alv_fieldcat_for_itab TABLES pt_list

      CHANGING lt_alv_fieldcat.

      PERFORM alv_fieldcat_enhance CHANGING lt_alv_fieldcat.

      PERFORM alv_print CHANGING ls_print.

      PERFORM alv_grid_settings CHANGING ls_glay.

      IF p_empty IS INITIAL.

      PERFORM alv_reduce_significant USING pt_list CHANGING lt_alv_fieldcat.

      ENDIF." p_empty is initial.

      lv_title = 'ECCS Delta'(edl).

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      • I_INTERFACE_CHECK = ' '

      • I_BYPASSING_BUFFER = ' '

      • I_BUFFER_ACTIVE = ' '

      i_callback_program = gv_repid

      • I_CALLBACK_PF_STATUS_SET = ' '

      • I_CALLBACK_USER_COMMAND = ' '

      • I_CALLBACK_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_END_OF_LIST = ' '

      • I_STRUCTURE_NAME =

      • I_BACKGROUND_ID = ' '

      i_grid_title = lv_title

      i_grid_settings = ls_glay

      is_layout = ls_alv_layout

      it_fieldcat = lt_alv_fieldcat

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      • IT_SORT =

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      i_save = 'A'

      is_variant = lv_variant

      it_events = lt_events

      • IT_EVENT_EXIT =

      is_print = ls_print

      • IS_REPREP_ID =

      • I_SCREEN_START_COLUMN = 0

      • I_SCREEN_START_LINE = 0

      • I_SCREEN_END_COLUMN = 0

      • I_SCREEN_END_LINE = 0

      • I_HTML_HEIGHT_TOP = 0

      • I_HTML_HEIGHT_END = 0

      • IT_ALV_GRAPHICS =

      • IT_HYPERLINK =

      • IT_ADD_FIELDCAT =

      • IT_EXCEPT_QINFO =

      • IR_SALV_FULLSCREEN_ADAPTER =

      IMPORTING

      • E_EXIT_CAUSED_BY_CALLER =

      es_exit_caused_by_user = ls_exit_by_user

      TABLES

      t_outtab = pt_list

      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.

      CHECK ls_exit_by_user-back IS INITIAL.

      • User used EXIT or CANCEL

      MESSAGE s415(0k).

      • Process cancelled by user

      ENDFORM. " alV_display

      *&----


      *

      *& Form statistics

      *&----


      *

      • Statistics Handler

      *----


      *

      FORM statistics USING p_func TYPE char01

      p_count TYPE sy-dbcnt

      p_text TYPE text80.

      DATA:

      • Fehlerstruktur

      BEGIN OF lv_gp_error,

      txt TYPE text80,

      count TYPE sydbcnt VALUE 1,

      END OF lv_gp_error,

      • Ausgabelänge

      lv_outlen TYPE sy-tleng.

      • Statische Tabelle

      STATICS:

      lt_gp_error LIKE TABLE OF lv_gp_error.

      CASE p_func.

      WHEN 'S'. "Store Message

      • Nachricht merken und zählen

      lv_gp_error-txt = p_text.

      lv_gp_error-count = p_count.

      COLLECT lv_gp_error INTO lt_gp_error.

      WHEN 'L'. "List Messages

      • Nachrichten ausgeben

      SORT lt_gp_error.

      LOOP AT lt_gp_error INTO lv_gp_error.

      AT FIRST.

      FORMAT COLOR COL_HEADING INTENSIFIED.

      DESCRIBE FIELD lv_gp_error-count OUTPUT-LENGTH lv_outlen.

      WRITE:

      sy-vline,

      p_text,

      sy-vline,

      AT (lv_outlen) text-025,"'Anzahl',

      sy-vline,

      AT sy-linsz sy-vline.

      FORMAT COLOR COL_NORMAL INTENSIFIED.

      ENDAT." first.

      WRITE:

      sy-vline,

      lv_gp_error-txt,

      sy-vline,

      lv_gp_error-count,

      sy-vline,

      AT sy-linsz sy-vline.

      ENDLOOP." at lt_gp_error into lv_gp_error.

      ENDCASE." p_func.

      ENDFORM. " statistics

      *&----


      *

      *& Form alv_events

      *&----


      *

      • ALV events

      *----


      *

      FORM alv_events CHANGING pt_events TYPE slis_t_event.

      FIELD-SYMBOLS:

      TYPE LINE OF slis_t_event.

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      • EXPORTING

      • I_LIST_TYPE = 0

      IMPORTING

      et_events = pt_events

      EXCEPTIONS

      list_type_wrong = 1

      OTHERS = 2

      .

      IF sy-subrc .

      ENDFORM. " alv_events

      *&----


      *

      *& Form alv_fieldcat_enhance

      *&----


      *

      • Individual Enrichment of field catalog

      *----


      *

      FORM alv_fieldcat_enhance

      CHANGING pt_alv_fieldcat TYPE slis_t_fieldcat_alv.

      FIELD-SYMBOLS:

      .

      ENDFORM. " alv_fieldcat_enhance

      *&----


      *

      *& Form SAPGUI_PROGRESS_INDICATOR

      *&----


      *

      FORM sapgui_progress_indicator

      USING

      p_text TYPE c

      p_share TYPE sytfill

      p_total TYPE sytfill.

      STATICS:

      lv_time LIKE sy-uzeit,

      lv_txt TYPE text80.

      DATA:

      lv_seconds_since_lastcall TYPE sytfill,

      lv_share TYPE p,

      lv_pct TYPE sytfill,

      lv_txt1 TYPE tline-tdline,

      lv_txt2 TYPE tline-tdline.

      GET TIME.

      lv_seconds_since_lastcall = sy-uzeit - lv_time.

      CHECK lv_seconds_since_lastcall >= 1 OR lv_txt <> p_text.

      lv_txt = p_text.

      lv_time = sy-uzeit.

      IF p_total > 0.

      lv_share = p_share.

      lv_share = p_share.

      lv_pct = lv_share * 100 / p_total.

      WRITE p_share TO lv_txt1 LEFT-JUSTIFIED.

      WRITE p_total TO lv_txt2 LEFT-JUSTIFIED.

      CONCATENATE

      p_text lv_txt1 '/' lv_txt2 INTO lv_txt1 SEPARATED BY space.

      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

      EXPORTING

      percentage = lv_pct

      text = lv_txt1.

      ELSE.

      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

      EXPORTING

      • percentage = lv_pct

      text = p_text.

      ENDIF. " p_total > 0.

      ENDFORM. " SAPGUI_PROGRESS_INDICATOR

      *&----


      *

      *& Form ALV_FIELDCAT_FOR_ITAB

      *&----


      *

      • Feldkatalog from (arbitrary) internal Table (c) Clemens Li

      • * build field catalog from type description

      *----


      *

      FORM alv_fieldcat_for_itab "#EC *

      TABLES pt_outtab TYPE table "#EC *

      CHANGING pt_alv_fieldcat TYPE slis_t_fieldcat_alv."#EC *

      DATA:

      lv_desc TYPE sydes_desc,

      ls_alv_fieldcat TYPE slis_fieldcat_alv,

      lv_longfield TYPE fname.

      FIELD-SYMBOLS:

      .

      IF sy-subrc = 0.

      • Caution: Help-ID may be Tablename-Fieldname and thus longer

      • than 30 Chars; ls_alv_fieldcat-rollname is 30 Chars only

      ls_alv_fieldcat-rollname = -name

      INTO lv_longfield.

      ENDWHILE." not lv_desc-continue is initial.

      • help id may be data element or <table>-<field>

      IF lv_longfield CA '-'.

      • get data type for table field

      PERFORM get_rollname_4_tabfield

      USING lv_longfield CHANGING ls_alv_fieldcat.

      ENDIF." lv_longfield ca '-'.

      ELSE.

      • No Help-ID: Use Fieldname as text

      ls_alv_fieldcat-seltext_s =

      ls_alv_fieldcat-seltext_m =

      ls_alv_fieldcat-seltext_l =

      ls_alv_fieldcat-reptext_ddic =

      -name.

      ENDIF." sy-subrc = 0.

      • Starting 4.7: get edit mask

      IF NOT -IDX_EDIT_MASK is initial.

      • assign length, output length and decimals

      ls_alv_fieldcat-intlen = -type.

      APPEND ls_alv_fieldcat TO pt_alv_fieldcat.

      CLEAR: "prevent anything 2 B taken for subsequent fields

      ls_alv_fieldcat.

      ENDLOOP." at lv_desc-types where not IDX_NAME is in initial.

      ENDFORM. " ALV_FIELDCAT_FOR_ITAB

      *&----

      -


      *& Form get_rollname_4_tabfield

      *&----

      -


      • Get Data type for Table field

      *----

      -


      FORM get_rollname_4_tabfield

      USING p_fname TYPE fname

      CHANGING p_alv_fieldcat TYPE slis_fieldcat_alv.

      FIELD-SYMBOLS:

      TYPE dfies.

      DATA:

      lv_tabname TYPE tabname,

      lt_dfies TYPE TABLE OF dfies,

      lv_fieldname TYPE fieldname.

      SPLIT p_fname AT '-'

      INTO lv_tabname lv_fieldname.

      CLEAR p_alv_fieldcat-rollname.

      CALL FUNCTION 'DDIF_FIELDINFO_GET'

      EXPORTING

      tabname = lv_tabname

      fieldname = lv_fieldname

      • LANGU = SY-LANGU

      • LFIELDNAME = ' '

      • ALL_TYPES = ' '

      • IMPORTING

      • X030L_WA =

      • DDOBJTYPE =

      • DFIES_WA =

      • LINES_DESCR =

      TABLES

      dfies_tab = lt_dfies

      • FIXED_VALUES =

      EXCEPTIONS

      not_found = 1

      internal_error = 2

      OTHERS = 3

      .

      IF sy-subrc -rollname.

      • Und wenn keinerlei Twexte gepflegt sind?

      IF -scrtext_l IS INITIAL.

      • No Text: Use Fieldname as text

      p_alv_fieldcat-seltext_s =

      p_alv_fieldcat-seltext_m =

      p_alv_fieldcat-seltext_l =

      p_alv_fieldcat-reptext_ddic =

      p_alv_fieldcat-fieldname.

      ENDIF." -reptext IS INITIAL AND

      ENDIF.

      ENDFORM. " get_rollname_4_tabfield

      *&----


      *

      *& Form ALV_END_OF_LIST

      *&----


      *

      • Something as you like

      *----


      *

      FORM alv_end_of_list . "#EC CALLED

      PERFORM statistics USING 'L' 0 text-003.

      PERFORM list_selectoptions.

      ENDFORM. " ALV_END_OF_LIST

      *&----


      *

      *& Form ALV_LAYOUT

      *&----


      *

      FORM alv_layout CHANGING p_alv_layout TYPE slis_layout_alv.

      p_alv_layout-colwidth_optimize = c_true.

      p_alv_layout-detail_initial_lines = c_true.

      p_alv_layout-zebra = c_true.

      p_alv_layout-min_linesize = 132.

      p_alv_layout-coltab_fieldname = 'COLOR'.

      p_alv_layout-box_fieldname = 'SEL'.

      ENDFORM. " ALV_LAYOUT

      *&----


      *

      *& Form list_selectoptions

      *&----


      *

      • List Selections

      *----


      *

      FORM list_selectoptions. "#EC CALLED

      FIELD-SYMBOLS:

      TYPE rsparams.

      DATA:

      lt_textpool TYPE TABLE OF textpool,

      lt_rsparams TYPE TABLE OF rsparams,

      lv_printline TYPE text1024,

      lv_repid TYPE syrepid.

      lv_repid = sy-repid.

      • Werte der Select-Options besorgen

      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

      EXPORTING

      curr_report = lv_repid

      • IMPORTING

      • SP =

      TABLES

      selection_table = lt_rsparams

      EXCEPTIONS

      not_found = 1

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

      • Texte aus Textpool besorgen

      READ TEXTPOOL lv_repid INTO lt_textpool LANGUAGE sy-langu.

      DELETE lt_textpool WHERE NOT id = 'S'. " Selection screen only

      • Anzeigen

      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

      ULINE.

      • Überschrift

      WRITE: / sy-vline,text-004, lv_repid,

      text-005,sy-datum, sy-uzeit,AT sy-linsz sy-vline.

      ULINE.

      • Parametertabelle sortieren nach Ordnung auf Screen

      • Nur das ausgeben, was auch ausgefüllt/angekreuzt ist

      DELETE lt_rsparams WHERE ( low IS INITIAL AND high IS INITIAL ).

      PERFORM sort_screen_params CHANGING lt_rsparams.

      LOOP AT lt_rsparams ASSIGNING .

      CHECK:

      sy-subrc = 0.

      lv_printline(1) = sy-vline.

      lv_printline2(40) = <textpool>-entry8(40).

      lv_printline+44(1) = sy-vline.

      lv_printline+46(1) = .

      ULINE.

      SKIP.

      ENDFORM. " list_selectoptions

      *&----


      *

      *& Form sort_screen_params

      *&----


      *

      • Sort Parameter table according to Screen position

      *----


      *

      FORM sort_screen_params

      CHANGING pt_rsparams TYPE rsparams_tt.

      DATA:

      lv_repid TYPE sy-repid,

      lt_dynp_fields TYPE TABLE OF rsdcf,

      lt_lines TYPE TABLE OF tline,

      lt_rsparams TYPE TABLE OF rsparams.

      FIELD-SYMBOLS:

      TYPE rsdcf.

      lv_repid = sy-repid.

      CALL FUNCTION 'DYNPRO_FIELD_GET'

      EXPORTING

      dynpro = gv_dynnr

      • FLG_CHECK = '1'

      • FLG_CONTROL = '0'

      • LANGU = SY-LANGU

      program = lv_repid

      TABLES

      dynp_fields = lt_dynp_fields

      lines = lt_lines

      • lines =

      EXCEPTIONS

      dynpro_not_found = 1

      OTHERS = 2.

      IF sy-subrc .

      pt_rsparams = lt_rsparams.

      ENDFORM. " sort_screen_params

      *&----


      *

      *& Form ALV_TOP_OF_PAGE

      *&----


      *

      • Out Standard page header

      • Process Statistics ahead

      • ALV herself writes column headers

      *----


      *

      FORM alv_top_of_page. "#EC CALLED

      DATA:

      lv_len TYPE syfdpos,

      lv_txt TYPE sylisel,

      lv_datxt TYPE sylisel,

      lv_uztxt TYPE sylisel,

      lv_pagno_pos TYPE syfdpos.

      lv_pagno_pos = sy-linsz - 6.

      WRITE: sy-datum TO lv_datxt, sy-uzeit TO lv_uztxt.

      FORMAT COLOR COL_HEADING.

      ULINE.

      CONCATENATE

      sy-sysid sy-mandt sy-repid sy-uname lv_datxt lv_uztxt

      INTO lv_txt SEPARATED BY space.

      lv_len = STRLEN( lv_txt ).

      WRITE: / sy-vline,

      'System-Client-Program-User-Date-Time:'(002),

      AT (lv_len) lv_txt,

      AT lv_pagno_pos(6) sy-pagno NO-SIGN,

      AT sy-linsz sy-vline,

      AT sy-linsz sy-vline.

      ULINE AT (sy-linsz).

      FORMAT COLOR COL_NORMAL.

      IF p_eval IS INITIAL.

      FORMAT COLOR COL_NEGATIVE.

      WRITE:

      / sy-vline,'Production run with database update'(006),

      AT sy-linsz sy-vline.

      ELSE.

      FORMAT COLOR COL_POSITIVE.

      WRITE:

      / sy-vline,

      'Test run without database update'(007),

      AT sy-linsz sy-vline.

      ENDIF." p_test is initial.

      FORMAT COLOR COL_HEADING INTENSIFIED OFF.

      WRITE: / sy-vline,

      'ECCS aggregation and reconciliation postings'(005),

      AT sy-linsz sy-vline.

      ULINE AT (sy-linsz).

      ENDFORM." alv_top_of_page

      *&----


      *

      *& Form ALV_PF_STATUS_SET

      *&----

      -


      • set ALV user status

      *----

      -


      *

      FORM alv_pf_status_set CHANGING pt_extab TYPE slis_t_extab."#EC CALLED

      APPEND '&NFO' TO pt_extab.

      SET PF-STATUS 'STANDARD_FULLSCREEN' EXCLUDING pt_extab.

      ENDFORM." ALV__PF_STATUS_SET

      *&----


      *

      *& Form alv_user_command

      *&----


      *

      • double-click functions

      *----


      *

      FORM alv_user_command

      USING pv_ucomm TYPE sy-ucomm

      ps_selfield TYPE slis_selfield."#EC CALLED

      CASE pv_ucomm.

      WHEN '&IC1'.

      PERFORM alv_double_click

      USING pv_ucomm

      ps_selfield.

      WHEN 'INFO'.

      PERFORM alv_info

      USING pv_ucomm

      ps_selfield.

      ENDCASE." pv_ucomm.

      ENDFORM. " alv_user_command

      *&----


      *

      *& Form alv_print

      *&----


      *

      • Print options

      *----


      *

      FORM alv_print CHANGING ps_print TYPE slis_print_alv.

      ps_print-no_print_selinfos = 'X'.

      ps_print-no_print_listinfos = c_true.

      ENDFORM. " alv_print

      *&----


      *

      *& Form alv_grid_settings

      *&----


      *

      FORM alv_grid_settings CHANGING ps_glay TYPE lvc_s_glay.

      ps_glay-coll_top_p = c_true.

      ps_glay-coll_end_l = c_true.

      ENDFORM. " alv_grid_settings

      *&----


      *

      *& Form alv_color

      *&----


      *

      • set field color

      *----


      *

      FORM alv_color USING pv_fieldname TYPE fieldname

      pv_color TYPE c

      pv_intensify TYPE i

      pv_inverse TYPE i

      CHANGING pt_colors TYPE slis_t_specialcol_alv.

      DATA:

      ls_colors TYPE LINE OF slis_t_specialcol_alv.

      READ TABLE pt_colors TRANSPORTING NO FIELDS WITH KEY

      fieldname = pv_fieldname

      color-col = pv_color

      color-int = pv_intensify

      color-inv = pv_inverse

      BINARY SEARCH.

      CHECK sy-subrc <> 0.

      ls_colors-fieldname = pv_fieldname.

      ls_colors-color-col = pv_color.

      ls_colors-color-int = pv_intensify.

      ls_colors-color-inv = pv_inverse.

      INSERT ls_colors INTO pt_colors INDEX sy-tabix.

      ENDFORM. "alv_color

      *&----


      *

      *& Form getfields

      *&----


      *

      • get fieldnames for table or structure

      *----


      *

      FORM getfields

      USING px_data TYPE any

      CHANGING pt_fields TYPE table.

      DATA:

      lt_comp TYPE abap_compdescr_tab,

      lr_dat TYPE REF TO data,

      lr_typedescr TYPE REF TO cl_abap_typedescr,

      lr_structdescr TYPE REF TO cl_abap_structdescr.

      FIELD-SYMBOLS:

      components.

      WHEN OTHERS.

      MESSAGE e241(00).

      • Function is invalid in this environment

      ENDCASE.

      CLEAR pt_fields.

      LOOP AT lt_comp ASSIGNING .

      ENDFORM. " getfields

      *&----


      *

      *& Form process_data

      *&----


      *

      • Evaluate, post if required, create ALV List

      *----


      *

      FORM process_data

      USING value(pt_balance) TYPE ty_t_balance

      CHANGING pt_alv_display TYPE ty_t_alv_display.

      DATA:

      ls_alv_display TYPE LINE OF ty_t_alv_display.

      FIELD-SYMBOLS:

      TO ls_alv_display.

      PERFORM get_bukrs_hwaer

      USING ls_alv_display-rbukrs

      CHANGING ls_alv_display-hwaer.

      IF ls_alv_display-zzbilkt_new IS NOT INITIAL.

      PERFORM alv_color USING:

      'ZZBILKT_NEW' col_group 0 0 CHANGING ls_alv_display-color,

      'ZZBILKT' col_group 0 0 CHANGING ls_alv_display-color.

      • calculate amount to be reposted

      ls_alv_display-hslxx_topost = ls_alv_display-hslxx

      - ls_alv_display-hslxx_posted.

      ls_alv_display-tslxx_topost = ls_alv_display-tslxx

      - ls_alv_display-tslxx_posted.

      ENDIF." ls_alv_display-zzbilkt_new is not initial.

      • turn on the lights (yellow for amounts to be posted)

      IF ls_alv_display-tslxx_topost IS INITIAL AND

      ls_alv_display-hslxx_topost IS INITIAL.

      ls_alv_display-lights = icon_green_light.

      ELSE.

      ls_alv_display-lights = icon_yellow_light.

      ENDIF." ls_alv_display-zzbilkt_new is initial.

      PERFORM collect_alv_display

      USING ls_alv_display CHANGING pt_alv_display.

      CLEAR:

      ls_alv_display.

      ENDLOOP." at pt_balance assigning assigning .

      • account short texts

      PERFORM merge_account_text

      CHANGING pt_alv_display.

      • already reposted

      • Note: LIGHTS may change!

      PERFORM merge_reposted CHANGING pt_alv_display.

      • Post and write posted to database

      PERFORM post_eccs_correction

      CHANGING pt_alv_display.

      ENDFORM. " process_data

      *&----


      *

      *& Form merge_account_text

      • - account descriptive texts

      *&----


      *

      FORM merge_account_text

      CHANGING pt_alv_display TYPE ty_t_alv_display.

      DATA:

      lt_fields TYPE TABLE OF fieldname,

      lt_saknr TYPE ty_t_racct,

      lt_saknr_txt TYPE ty_t_saknr_txt.

      FIELD-SYMBOLS:

      TYPE LINE OF ty_t_alv_display.

      • accounts involved

      LOOP AT pt_alv_display ASSIGNING .

      CHECK lt_saknr IS NOT INITIAL.

      • get texts

      PERFORM getfields USING lt_saknr_txt CHANGING lt_fields.

      SELECT (lt_fields)

      INTO CORRESPONDING FIELDS OF TABLE lt_saknr_txt

      FROM skat FOR ALL ENTRIES IN lt_saknr

      WHERE spras = sy-langu

      AND saknr = lt_saknr-table_line

      AND ktopl = p_ktopl.

      • fill text field in line item

      LOOP AT pt_alv_display ASSIGNING .

      ENDFORM. " merge_account_text

      *&----


      *

      *& Form get_bukrs_hwaer

      *&----


      *

      FORM get_bukrs_hwaer USING pv_bukrs TYPE bukrs

      CHANGING pv_hwaer TYPE waers.

      STATICS:

      lv_hwaer TYPE hwaer,

      lv_bukrs TYPE bukrs,

      lt_bukrs_hwaer TYPE ty_t_bukrs_hwaer.

      FIELD-SYMBOLS:

      lv_bukrs.

      pv_hwaer = lv_hwaer.

      ENDFORM. " get_bukrs_hwaer

      *&----


      *

      *& Form find_relevant_ledger

      *&----


      *

      FORM find_relevant_ledger CHANGING cc_relevant_ledger TYPE fagl_rldnr.

      • default ledger.

      CALL FUNCTION 'FAGL_GET_LEADING_LEDGER'

      IMPORTING

      e_rldnr = cc_relevant_ledger

      EXCEPTIONS

      not_found = 1.

      IF sy-subrc <> 0.

      MESSAGE

      ID sy-msgid

      TYPE sy-msgty

      NUMBER sy-msgno

      WITH sy-msgv1

      sy-msgv2

      sy-msgv3

      sy-msgv4.

      ENDIF." sy-subrc <> 0.

      ENDFORM. " find_relevant_ledger

      *&----


      *

      *& Form consolidate_totals

      • FAGLFLEXT fields TSL01 .. TSL16 and HSL01 .. HSL16

      • collected per account, currency abd period into debit and credit

      • transaction and local currency

      *&----


      *

      FORM consolidate_totals

      USING pt_tot TYPE table

      CHANGING pt_acc_balance TYPE ty_t_acc_balance.

      DATA:

      lv_fieldname TYPE fieldname,

      lv_num2 TYPE num2,

      ls_acc_balance TYPE LINE OF ty_t_acc_balance.

      FIELD-SYMBOLS:

      .

      • currency and account

      MOVE-CORRESPONDING:

      0 'S'.

      • Maximum of 16 periods

      DO 16 TIMES.

      • regarding periods here...

      CHECK sy-index IN s_monat.

      ls_acc_balance-perio = lv_num2 = sy-index.

      CONCATENATE 'TSL' lv_num2 INTO lv_fieldname.

      ASSIGN COMPONENT lv_fieldname OF STRUCTURE IS NOT INITIAL.

      ls_acc_balance-tslxx = ls_acc_balance-deb_t - ls_acc_balance-cre_t.

      ls_acc_balance-hslxx = ls_acc_balance-deb_h - ls_acc_balance-cre_h.

      • non-breakdown-criteria to be cleared here

      • breakdown partner is done anyway

      • PERFORM regard_eccs_breakdown CHANGING ls_acc_balance.

      COLLECT ls_acc_balance INTO pt_acc_balance.

      CLEAR:

      ls_acc_balance-deb_t,

      ls_acc_balance-cre_t,

      ls_acc_balance-tslxx,

      ls_acc_balance-deb_h,

      ls_acc_balance-cre_h,

      ls_acc_balance-hslxx.

      ENDDO.

      ENDLOOP." at pt_tot assigning .

      ENDFORM. " consolidate_totals

      *&----


      *

      *& Form fill_fieldlist

      *&----


      *

      ...fill t_fieldlist with fields, which have to be ignored by.........

      ...function modul G_TABLE_SELECT_WITH_CURSOR during aggregation.......

      *----


      *

      FORM fill_fieldlist

      USING pv_relevant_ledger TYPE rldnr_flex

      CHANGING ct_fieldlist TYPE gusl_t_fields.

      DATA:

      ls_fagl_ab_c TYPE fagl_ab_c.

      PERFORM append_table USING:

      'COST_ELEM' CHANGING ct_fieldlist,"CLI20060703

      'DRCRK' CHANGING ct_fieldlist,

      'HSL' CHANGING ct_fieldlist,

      'PRCTR' CHANGING ct_fieldlist,

      'RACCT' CHANGING ct_fieldlist,

      'RASSC' CHANGING ct_fieldlist,

      'RBUKRS' CHANGING ct_fieldlist,

      'RFAREA' CHANGING ct_fieldlist,"CLI20060703

      'RCNTR' CHANGING ct_fieldlist,

      'RLDNR' CHANGING ct_fieldlist,

      'RMVCT' CHANGING ct_fieldlist,"CLI20060427

      'RTCUR' CHANGING ct_fieldlist,

      'RYEAR' CHANGING ct_fieldlist,

      'TSL' CHANGING ct_fieldlist,

      'ZZBILKT' CHANGING ct_fieldlist,

      'ZZMULTI' CHANGING ct_fieldlist.

      ENDFORM. " get_fagl_fields

      *&----


      *

      *& Form fagl_fill_selections

      *&----


      *

      • fill t_selections

      *----


      *

      FORM fagl_fill_selections

      TABLES ut_rbukrs TYPE fagl_range_t_bukrs

      USING ut_rldnr TYPE rldnr

      CHANGING pt_t_selection TYPE gusl_t_selection.

      DATA:

      ls_selection TYPE gusl_s_selection,

      ls_range TYPE LINE OF gusl_s_selection-t_range,

      lt_rangetab TYPE gusl_t_range,

      ls_rangetab TYPE gusl_s_range.

      FIELD-SYMBOLS:

      TYPE LINE OF fagl_range_t_bukrs.

      • Transfer account selectioon if present

      ls_selection-fieldname = 'RACCT'.

      LOOP AT s_racct ASSIGNING TO ls_rangetab.

      APPEND ls_rangetab TO lt_rangetab.

      ENDLOOP.

      • Always exclude our technical account - re-postings merged later

      PERFORM insert_range USING 'EEQ' p_gkont '' CHANGING lt_rangetab.

      ls_selection-t_range = lt_rangetab.

      APPEND ls_selection TO pt_t_selection.

      CLEAR lt_rangetab.

      • fill s_bukrs into t_selection.

      CLEAR ls_selection.

      REFRESH lt_rangetab.

      ls_selection-fieldname = 'RBUKRS'.

      LOOP AT ut_rbukrs ASSIGNING TO ls_rangetab.

      APPEND ls_rangetab TO lt_rangetab.

      ENDLOOP.

      ls_selection-t_range = lt_rangetab.

      APPEND ls_selection TO pt_t_selection.

      • in transaction FAGLB03 only actual values are shown.

      CLEAR ls_selection.

      REFRESH lt_rangetab.

      ls_selection-fieldname = 'RRCTY'.

      PERFORM insert_range USING 'IEQ' '0' '0' CHANGING lt_rangetab.

      ls_selection-t_range = lt_rangetab.

      APPEND ls_selection TO pt_t_selection.

      • fill ryear into t_selection

      CLEAR ls_selection.

      ls_selection-fieldname = 'RYEAR'.

      LOOP AT s_gjahr ASSIGNING TO ls_range.

      APPEND ls_range TO ls_selection-t_range.

      ENDLOOP." at s_gjahr.

      APPEND ls_selection TO pt_t_selection.

      • fill rldnr into t_selection

      CLEAR ls_selection.

      REFRESH lt_rangetab.

      ls_selection-fieldname = 'RLDNR'.

      PERFORM insert_range USING 'IEQ' ut_rldnr '' CHANGING lt_rangetab.

      ls_selection-t_range = lt_rangetab.

      APPEND ls_selection TO pt_t_selection.

      ENDFORM. " fagl_fill_selections

      *&----


      *

      *& Form move_if_ok

      *&----


      *

      • Move if p_subrc is clear

      *----


      *

      FORM move_if_ok USING p_subrc TYPE sysubrc

      p_any_src TYPE any

      CHANGING p_any_tgt TYPE any.

      CHECK:

      p_subrc IS INITIAL.

      p_any_tgt = p_any_src.

      ENDFORM. " move_if_ok

      *&----


      *

      *& Form APPEND_TABLE

      *&----


      *

      • append line to table - empty lines not appended

      *----


      *

      FORM append_table USING p_line TYPE any

      CHANGING pt_table TYPE table.

      CHECK p_line IS NOT INITIAL.

      APPEND p_line TO pt_table.

      ENDFORM. " APPEND_TABLE

      *&----


      *

      *& Form alv_double_Click

      *&----


      *

      • double-click-functions

      *----


      *

      FORM alv_double_click

      USING pv_ucomm TYPE sy-ucomm

      ps_selfield TYPE slis_selfield.

      FIELD-SYMBOLS:

      TYPE ty_alv_display.

      IF ps_selfield-tabindex IS INITIAL.

      MESSAGE e004(0k).

      • Bitte positionieren Sie den Cursor auf eine Zeile des Listkörpers

      • Position the cursor on a line in the list

      ENDIF." ps_selfield-tabindex is initial.

      READ TABLE t_alv_display INDEX ps_selfield-tabindex

      ASSIGNING -ryear.

      ENDCASE." ps_selfield-fieldname.

      CLEAR: pv_ucomm.

      ENDFORM. " alv_double_Click

      *&----


      *

      *& Form alv_info

      *&----


      *

      • double-click-functions

      *----


      *

      FORM alv_info "EC *

      USING pv_ucomm TYPE sy-ucomm "EC *

      ps_selfield TYPE slis_selfield. "EC *

      • dont'know how to get rid of this nasty extended syntax check warning

      CHECK:

      pv_ucomm IS INITIAL OR

      pv_ucomm IS NOT INITIAL OR

      ps_selfield IS INITIAL OR

      ps_selfield IS NOT INITIAL.

      MESSAGE e143(ba).

      • No information available

      ENDFORM. " alv_info

      *&----


      *

      *& Form alv_protocol

      *&----


      *

      • Show the (BAPI) message protocol

      *----


      *

      FORM alv_protocol USING ps_alv TYPE ty_alv_display

      ps_selfield TYPE slis_selfield."#EC *

      DATA:

      lt_fieldcat TYPE slis_t_fieldcat_alv.

      PERFORM alv_fieldcat_for_itab

      TABLES ps_alv-t_prot CHANGING lt_fieldcat.

      PERFORM alv_popup USING 10 3 100 15 ps_alv-t_prot lt_fieldcat.

      ENDFORM. " alv_protocol

      *&----


      *

      *& Form alv_popup

      *&----


      *

      • ALV popup

      *----


      *

      FORM alv_popup

      USING p_scol TYPE sycucol

      p_srow TYPE sycurow

      p_ecol TYPE sycucol

      p_erow TYPE sycurow

      pt_table TYPE table

      pt_fieldcat TYPE slis_t_fieldcat_alv.

      DATA:

      ls_alv_layout TYPE slis_layout_alv.

      PERFORM alv_layout_popup CHANGING ls_alv_layout.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      • I_INTERFACE_CHECK = ' '

      • I_BYPASSING_BUFFER = ' '

      • I_BUFFER_ACTIVE = ' '

      • I_CALLBACK_PROGRAM = ' '

      • I_CALLBACK_PF_STATUS_SET = ' '

      • I_CALLBACK_USER_COMMAND = ' '

      • I_CALLBACK_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_END_OF_LIST = ' '

      • I_STRUCTURE_NAME =

      • I_BACKGROUND_ID = ' '

      • I_GRID_TITLE =

      • I_GRID_SETTINGS =

      is_layout = ls_alv_layout

      it_fieldcat = pt_fieldcat

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      • IT_SORT =

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      • I_SAVE = ' '

      • IS_VARIANT =

      • IT_EVENTS =

      • IT_EVENT_EXIT =

      • IS_PRINT =

      • IS_REPREP_ID =

      i_screen_start_column = p_scol

      i_screen_start_line = p_srow

      i_screen_end_column = p_ecol

      i_screen_end_line = p_erow

      • I_HTML_HEIGHT_TOP = 0

      • I_HTML_HEIGHT_END = 0

      • IT_ALV_GRAPHICS =

      • IT_HYPERLINK =

      • IT_ADD_FIELDCAT =

      • IT_EXCEPT_QINFO =

      • IR_SALV_FULLSCREEN_ADAPTER =

      • IMPORTING

      • E_EXIT_CAUSED_BY_CALLER =

      • ES_EXIT_CAUSED_BY_USER =

      TABLES

      t_outtab = pt_table

      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. " alv_popup

      *&----


      *

      *& Form ALV_LAYOUT_POPUP

      *&----


      *

      FORM alv_layout_popup CHANGING p_alv_layout_popup TYPE slis_layout_alv.

      p_alv_layout_popup-colwidth_optimize =

      p_alv_layout_popup-detail_initial_lines =

      p_alv_layout_popup-zebra = c_true.

      ENDFORM. " ALV_LAYOUT_POPUP

      *&----


      *

      *& Form FB03

      *&----


      *

      FORM fb03

      USING

      pv_docnum TYPE belnr_d

      pv_gjahr TYPE gjahr

      pv_bukrs TYPE bukrs.

      CHECK NOT pv_docnum IS INITIAL.

      SET PARAMETER ID:

      'BLN' FIELD pv_docnum,

      'BUK' FIELD pv_bukrs,

      'GJR' FIELD pv_gjahr.

      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.

      ENDFORM. "fb03

      *&----


      *

      *& Form fs10n

      *&----


      *

      • G/L Account Balance Display

      *----


      *

      FORM fs10n USING ps_alv TYPE ty_alv_display

      ps_selfield TYPE slis_selfield."#EC *

      SET PARAMETER ID:

      'SAK' FIELD ps_alv-racct,

      'BUK' FIELD ps_alv-rbukrs,

      'GJR' FIELD ps_alv-ryear.

      CALL TRANSACTION 'FS10N' AND SKIP FIRST SCREEN.

      ENDFORM. " fs10n

      *&----


      *

      *& Form post_ECCS_CORRECTION

      *&----


      *

      • Post sums with categories regarding change of ZZBILKT

      *----


      *

      FORM post_eccs_correction

      CHANGING pt_alv_display TYPE ty_t_alv_display.

      DATA:

      lv_commit TYPE sytabix.

      FIELD-SYMBOLS:

      0,

      p_eval IS INITIAL.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

      ENDFORM. " post_ECCS_CORRECTION

      *&----


      *

      *& Form post_diff

      *&----


      *

      • post difference to notes account against technical

      *----


      *

      FORM post_diff CHANGING ps_alv_display TYPE LINE OF ty_t_alv_display.

      STATICS:

      lv_logsys TYPE t000-logsys.

      DATA:

      lv_currency_iso TYPE isocd,

      ls_documentheader TYPE bapiache08,

      lv_obj_type TYPE bapiache02-obj_type,"#EC NEEDED

      lv_obj_key TYPE bapiache02-obj_key,"#EC NEEDED

      lv_obj_sys TYPE bapiache02-obj_sys,"#EC NEEDED

      lt_accountgl TYPE TABLE OF bapiacgl08,

      ls_accountgl TYPE bapiacgl08,

      ls_ygl00eccs_repost TYPE ygl00eccs_repost,

      lt_currencyamount TYPE TABLE OF bapiaccr08,

      ls_currencyamount TYPE bapiaccr08,

      lt_extension1 TYPE TABLE OF bapiextc,

      lt_return TYPE TABLE OF bapiret2.

      CHECK:

      p_eval IS INITIAL,

      ps_alv_display-tslxx_topost <> 0 OR

      ps_alv_display-hslxx_topost <> 0.

      IF lv_logsys IS INITIAL.

      SELECT SINGLE logsys INTO lv_logsys FROM t000 WHERE mandt = sy-mandt.

      ENDIF." lv_logsys is initial.

      PERFORM get_curr_4_ccode

      USING ps_alv_display-rbukrs CHANGING lv_currency_iso.

      • (technical) header data

      ls_documentheader-obj_type = 'BKPFF'.

      ls_documentheader-obj_sys = lv_logsys.

      ls_documentheader-obj_key = '$'.

      ls_documentheader-username = sy-uname.

      • (business) header data

      CONCATENATE

      ps_alv_display-racct

      'ECCS virtual reconciliation'(evr)

      INTO

      ls_documentheader-header_txt

      SEPARATED BY space.

      ls_documentheader-comp_code = ps_alv_display-rbukrs.

      ls_documentheader-doc_date = p_bldat.

      ls_documentheader-fisc_year = p_gjahr.

      ls_documentheader-pstng_date = p_budat.

      ls_documentheader-fis_period = p_bper .

      ls_documentheader-doc_type = p_blart.

      • item GL data - 2 items per posting

      • item GL data - item 1 data

      ls_accountgl-itemno_acc = 1.

      • Post to offset account

      ls_accountgl-gl_account = p_gkont.

      ls_accountgl-comp_code = ps_alv_display-rbukrs.

      • Put ECCS item into item text

      CONCATENATE ps_alv_display-zzbilkt text-evr

      INTO ls_accountgl-item_text

      SEPARATED BY space.

      ls_accountgl-profit_ctr = ps_alv_display-prctr.

      • Append item 1 to item GL table

      APPEND ls_accountgl TO lt_accountgl.

      • item GL data - item 2 data - differing fields only

      ls_accountgl-itemno_acc = 2.

      • Put new ECCS item into item text

      CONCATENATE ps_alv_display-zzbilkt_new text-evr

      INTO ls_accountgl-item_text

      SEPARATED BY space.

      • Append item 2 to item GL table

      APPEND ls_accountgl TO lt_accountgl.

      • item currency amount data accordingly

      • 1st item: origninal ECCS position to be inversed

      ls_currencyamount-itemno_acc = 1.

      • Company code currency

      • Only if not zero

      IF ps_alv_display-hslxx_topost IS NOT INITIAL.

      ls_currencyamount-curr_type = '10'. "Company code currency

      ls_currencyamount-currency_iso = lv_currency_iso.

      ls_currencyamount-amt_doccur = - ps_alv_display-hslxx_topost.

      • append reversal item 1 with company code currency

      APPEND ls_currencyamount TO lt_currencyamount.

      ENDIF." ps_alv_display-hslxx_topost is not initial.

      • Transaction currency

      IF ps_alv_display-tslxx_topost IS NOT INITIAL.

      ls_currencyamount-curr_type = '00'. "Transaction currency

      ls_currencyamount-currency_iso = ps_alv_display-rtcur.

      ls_currencyamount-amt_doccur = - ps_alv_display-tslxx_topost.

      • append reversal item 1 with Transaction currency

      APPEND ls_currencyamount TO lt_currencyamount.

      ENDIF." ps_alv_display-tslxx_topost is not initial.

      • 2nd item original value with new ECCS position

      IF ps_alv_display-hslxx_topost IS NOT INITIAL.

      ls_currencyamount-itemno_acc = 2.

      ls_currencyamount-currency_iso = lv_currency_iso.

      ls_currencyamount-curr_type = '10'. "Company code currency

      ls_currencyamount-amt_doccur = ps_alv_display-hslxx_topost.

      • append item 2 with company code currency

      APPEND ls_currencyamount TO lt_currencyamount.

      ENDIF." ps_alv_display-hslxx_topost is not initial.

      • Transaction currency

      IF ps_alv_display-tslxx_topost IS NOT INITIAL.

      ls_currencyamount-curr_type = '00'. "Transaction currency

      ls_currencyamount-currency_iso = ps_alv_display-rtcur.

      ls_currencyamount-amt_doccur = ps_alv_display-tslxx_topost.

      • append item 2 with Transaction currency

      APPEND ls_currencyamount TO lt_currencyamount.

      ENDIF." ps_alv_display-tslxx_topost is not initial.

      • Additional and category fields transfered via BAPI extension

      PERFORM bapi_extension_append USING:

      • ECCS item in field ZZBILKT: item 1 original,

      'ZZBILKT' '1' ps_alv_display-zzbilkt CHANGING lt_extension1,

      • ECCS item in field ZZBILKT: item '2' new assignment

      'ZZBILKT' '2' ps_alv_display-zzbilkt_new CHANGING lt_extension1,

      • RASSC trading partner

      'RASSC' '1' ps_alv_display-rassc CHANGING lt_extension1,

      'RASSC' '2' ps_alv_display-rassc CHANGING lt_extension1,

      • ZZMULTI multiple use

      'ZZMULTI' '1' ps_alv_display-zzmulti CHANGING lt_extension1,

      'ZZMULTI' '2' ps_alv_display-zzmulti CHANGING lt_extension1,

      • RFAREA functional area

      'RFAREA' '1' ps_alv_display-rfarea CHANGING lt_extension1,

      'RFAREA' '2' ps_alv_display-rfarea CHANGING lt_extension1,

      • PRCTR profit center

      'PRCTR' '1' ps_alv_display-prctr CHANGING lt_extension1,

      'PRCTR' '2' ps_alv_display-prctr CHANGING lt_extension1,

      • RMVCT transaction type

      'RMVCT' '1' ps_alv_display-rmvct CHANGING lt_extension1,

      'RMVCT' '2' ps_alv_display-rmvct CHANGING lt_extension1,

      • COST_ELEM Cost Element KSTAR

      'KSTAR' '1' ps_alv_display-cost_elem CHANGING lt_extension1,

      'KSTAR' '2' ps_alv_display-cost_elem CHANGING lt_extension1,

      • RCNTR Cost Center KOSTL

      'KOSTL' '1' ps_alv_display-rcntr CHANGING lt_extension1,

      'KOSTL' '2' ps_alv_display-rcntr CHANGING lt_extension1.

      CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

      EXPORTING

      documentheader = ls_documentheader

      IMPORTING

      obj_type = lv_obj_type

      obj_key = lv_obj_key

      obj_sys = lv_obj_sys

      TABLES

      accountgl = lt_accountgl

      currencyamount = lt_currencyamount

      return = lt_return

      extension1 = lt_extension1.

      • append the processing protocol to current display record

      APPEND LINES OF lt_return TO ps_alv_display-t_prot.

      ps_alv_display-protocol = icon_protocol.

      LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type CA 'EAX'.

      ENDLOOP." at lt_return where TYPE ca 'EAX'.

      IF sy-subrc = 0.

      • error encountered

      ps_alv_display-lights = icon_failure.

      ELSE.

      • posted - turn lights green

      ps_alv_display-lights = icon_green_light.

      • posted - get document number

      ps_alv_display-docnum = lv_obj_key(10).

      • correct postings to be stored in YGL00ECCS_REPOST

      MOVE-CORRESPONDING:

      ps_alv_display TO ls_ygl00eccs_repost.

      ls_ygl00eccs_repost-tslxx = ps_alv_display-tslxx_topost.

      ls_ygl00eccs_repost-hslxx = ps_alv_display-hslxx_topost.

      • Will be commited together with posting

      INSERT ygl00eccs_repost FROM ls_ygl00eccs_repost.

      ENDIF." sy-subrc = 0.

      ENDFORM. " post_diff

      *&----


      *

      *& Form get_curr_4_ccode

      *&----


      *

      • get iso currency code

      *----


      *

      FORM get_curr_4_ccode USING p_bukrs TYPE bukrs

      CHANGING p_isocd TYPE isocd.

      SELECT isocd INTO p_isocd UP TO 1 ROWS

      FROM t001

      JOIN tcurc ON tcurcwaers = t001waers

      WHERE bukrs = p_bukrs.

      ENDSELECT.

      CHECK sy-subrc <> 0.

      ENDFORM. " get_curr_4_ccode

      *&----


      *

      *& Form screen

      *&----


      *

      • selection screen modifictions, i.e. no mod of account/doctype

      *----


      *

      FORM screen .

      LOOP AT SCREEN.

      CASE screen-name.

      WHEN 'P_GKONT'

      OR 'P_KTOPL'

      OR 'P_COMMIT'

      OR 'P_BLART'.

      screen-input = 0.

      ENDCASE." screen-name.

      CASE screen-name.

      WHEN 'P_DETAIL'.

      screen-active = 0.

      ENDCASE." screen-name.

      MODIFY SCREEN.

      ENDLOOP." at screen.

      ENDFORM. " screen

      *&----


      *

      *& Form GET_ZZBILKT_AGGREGATES

      *&----


      *

      • accumulate balances

      *----


      *

      FORM get_zzbilkt_aggregates

      CHANGING pt_balance TYPE ty_t_balance.

      DATA:

      lt_acc_balance TYPE ty_t_acc_balance,

      ls_balance TYPE LINE OF ty_t_balance.

      FIELD-SYMBOLS:

      TO ls_balance.

      PERFORM collect_balance USING ls_balance CHANGING pt_balance.

      • COLLECT ls_balance INTO pt_balance.

      ENDLOOP." at pl_acc_balance assigning .

      ENDFORM. " GET_ZZBILKT_AGGREGATES

      *&----


      *

      *& Form faglb03

      *&----


      *

      FORM faglb03 USING pv_racct TYPE racct

      pv_rbukrs TYPE bukrs

      pv_ryear TYPE ryear.

      SET PARAMETER ID:

      'ACC' FIELD pv_racct,

      'BUK' FIELD pv_rbukrs,

      'GJR' FIELD pv_ryear.

      CALL TRANSACTION 'FAGLB03' AND SKIP FIRST SCREEN.

      ENDFORM. " faglb03

      *&----


      *

      *& Form collect_alv_display

      *&----


      *

      • No simple collect possible due to table sructure

      *----


      *

      FORM collect_alv_display

      USING ps_alv_display TYPE LINE OF ty_t_alv_display

      CHANGING pt_alv_display TYPE ty_t_alv_display.

      FIELD-SYMBOLS:

      WITH KEY table_line = ps_alv_display

      • rbukrs = ps_alv_display-rbukrs

      • ryear = ps_alv_display-ryear

      • racct = ps_alv_display-racct

      • cost_elem = ps_alv_display-cost_elem

      • rcntr = ps_alv_display-rcntr

      • rtcur = ps_alv_display-rtcur

      • zzbilkt = ps_alv_display-zzbilkt

      • rassc = ps_alv_display-rassc

      • prctr = ps_alv_display-prctr

      • rmvct = ps_alv_display-rmvct

      • zzmulti = ps_alv_display-zzmulti

      • zzbilkt_new = ps_alv_display-zzbilkt_new

      • rfarea = ps_alv_display-rfarea

      BINARY SEARCH.

      IF sy-subrc <> 0.

      INSERT ps_alv_display INTO pt_alv_display INDEX sy-tabix.

      ELSE.

      • This record must not yet exist in internal table

      MESSAGE w000(0k)

      WITH 'Internal error'(ier)

      'Form COLLECT_ALV_DISPLAY'(fca) sy-repid ''.

      • & & & &

      ENDIF." sy-subrc <> 0.

      ENDFORM. " collect_alv_display

      *&----


      *

      *& Form fagl_get_balance

      *&----


      *

      • determine balances for ZZBILKT ECCS items

      *----


      *

      FORM fagl_get_balance

      CHANGING pt_acc_balance TYPE ty_t_acc_balance.

      DATA:

      lrt_zzbilkt TYPE RANGE OF zzbilkt,

      lt_bukrs TYPE fagl_range_t_bukrs,

      lt_selection TYPE gusl_t_selection,

      lt_dfies TYPE TABLE OF dfies,

      ls_dfies TYPE dfies,

      ls_fagl_tabnames TYPE fagl_tabnames,

      lt_fieldlist TYPE gusl_t_fields.

      FIELD-SYMBOLS:

      0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.

      FREE lt_selection.

      • prepare selections to be passed to authority check and table select

      PERFORM fagl_fill_selections

      TABLES s_bukrs

      USING gv_relevant_ledger

      CHANGING lt_selection.

      lt_bukrs[] = s_bukrs[].

      ...authority check of the selection screen.....................

      DATA ld_label TYPE string.

      DATA ld_fieldvalue TYPE string.

      CALL FUNCTION 'FAGL_CHECK_AUTHORITY_SELECTION'

      EXPORTING

      it_selections = lt_selection

      id_table = ls_fagl_tabnames-tot_table

      it_bukrs = lt_bukrs

      id_actvt = '27' "sum data set

      IMPORTING

      ed_label = ld_label

      ed_field = ld_fieldvalue

      EXCEPTIONS

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

      DATA lt_fields TYPE fieldname_tab.

      DATA ld_field TYPE fieldname.

      lt_fields[] = lt_fieldlist[].

      LOOP AT lt_fields INTO ld_field.

      IF ld_field = 'RTCUR'

      OR ld_field = 'DRCRK'

      OR ld_field = 'RYEAR'

      OR ld_field = 'TSL'

      OR ld_field = 'HSL'

      OR ld_field = 'KSL'

      OR ld_field = 'OSL'.

      DELETE lt_fields.

      ENDIF.

      ENDLOOP.

      ...authority check of the selected data.............................

      CALL FUNCTION 'FAGL_CHECK_AUTHORITY_SUM_TABLE'

      EXPORTING

      it_fields = lt_fields

      id_actvt = '27' "sum data set

      CHANGING

      it_data =

      CHANGING pt_acc_balance.

      • should not exists but will be ignored: Documents without ECCS item

      DELETE pt_acc_balance WHERE zzbilkt is initial.

      ENDFORM. " fagl_get_balance

      *&----


      *

      *& Form run_zzbilkt_substitution

      *&----


      *

      FORM run_zzbilkt_substitution

      CHANGING pt_balance TYPE ty_t_balance.

      DATA:

      lv_tfill TYPE sytfill.

      FIELD-SYMBOLS:

      .

      • changed ECCS?

      IF .

      ENDFORM. " run_zzbilkt_substitution

      *&----


      *

      *& Form balance_2_bseg

      *&----


      *

      FORM balance_2_bseg

      USING ps_balance TYPE LINE OF ty_t_balance

      CHANGING ps_bseg TYPE bseg.

      ps_bseg-bukrs = ps_balance-rbukrs.

      ps_bseg-gjahr = ps_balance-ryear.

      ps_bseg-hkont = ps_balance-racct.

      ps_bseg-vbund = ps_balance-rassc.

      • ps_bseg-zzbilkt = ps_balance-zzbilkt. "2bsubstituted

      ps_bseg-zzmulti = ps_balance-zzmulti.

      ps_bseg-fkber = ps_bseg-fkber_long

      = ps_balance-rfarea.

      ps_bseg-prctr = ps_balance-prctr.

      ps_bseg-bewar = ps_balance-rmvct.

      ps_bseg-wrbtr = ps_balance-tslxx.

      ps_bseg-dmbtr = ps_balance-hslxx.

      ENDFORM. " balance_2_bseg

      *&----


      *

      *& Form COLLECT_balance

      *&----


      *

      • No direct collect possible due to non-key field ZZBILKT_NEW

      *----


      *

      FORM collect_balance

      USING ps_balance TYPE LINE OF ty_t_balance

      CHANGING pt_balance TYPE ty_t_balance.

      FIELD-SYMBOLS:

      -hslxx.

      ELSE.

      INSERT ps_balance INTO TABLE pt_balance.

      ENDIF." sy-subrc = 0.

      ENDFORM." collect_balance

      *&----


      *

      *& Form Bapi_extension_append

      *&----


      *

      • transfer values to bapi extension structure and append table

      *----


      *

      FORM bapi_extension_append

      USING pv_field1 TYPE c

      pv_field2 TYPE c

      pv_field3 TYPE c

      CHANGING pt_bapiextc TYPE tab_bapiextc.

      DATA:

      ls_bapiextc TYPE bapiextc.

      ls_bapiextc-field1 = pv_field1.

      ls_bapiextc-field2 = pv_field2.

      ls_bapiextc-field3 = pv_field3.

      APPEND ls_bapiextc TO pt_bapiextc.

      ENDFORM. " Bapi_extension_append

      *&----


      *

      *& Form substitute_new_bilkt

      *&----


      *

      • dynamic perform or function call - what is correct, Mr. C.?

      • coding looks comparable but not identical - danger!

      • the feature is used naccording to mouth propaganda

      • -> see document

      *J:MAG_Projekt_Common_TemplateMETRO AG Common Template04Team Customizing_Development4.23 EnhancementsProfitCenterBeschreibung Substitutionen und Validierung.doc

      *----


      *

      FORM substitute_new_bilkt

      CHANGING ps_balance TYPE LINE OF ty_t_balance.

      DATA:

      ls_bseg TYPE bseg,

      ls_gb002_015 TYPE gb002_015.

      FIELD-SYMBOLS:

      TYPE bseg.

      IF 1 = 1.

      • this is the actuakl substitution routine as provided by Kaczmarek Mariusz

      CALL FUNCTION 'Y_FI02_SUB3_ZZBILKT'

      EXPORTING

      im_bukrs = ps_balance-rbukrs

      im_hkont = ps_balance-racct

      im_fkber = ps_balance-rfarea

      IMPORTING

      ex_zzbilkt = ps_balance-zzbilkt_new.

      ELSE.

      • this is what looks as defined for substitution

      PERFORM balance_2_bseg USING ps_balance CHANGING ls_bseg.

      APPEND ls_bseg TO ls_gb002_015-bseg.

      PERFORM fi303 IN PROGRAM yrggbs100

      • the category USING of the called form routine is wrong and misleading

      CHANGING ls_gb002_015. "#EC *

      READ TABLE ls_gb002_015-bseg ASSIGNING -zzbilkt.

      ENDIF. " 1 = 1.

      ENDFORM. " substitute_new_bilkt

      *&----


      *

      *& Form merge_reposted

      *&----


      *

      • read already reposted data from database

      • and merge them into balance table

      *----


      *

      FORM merge_reposted

      CHANGING pt_alv_display TYPE ty_t_alv_display.

      DATA:

      lv_tabix TYPE sytabix,

      ls_alv_display TYPE LINE OF ty_t_alv_display,

      ls_bkpf TYPE bkpf,

      lv_stblg_initial TYPE stblg,

      lt_repost TYPE SORTED TABLE OF ygl00eccs_repost WITH UNIQUE DEFAULT KEY.

      FIELD-SYMBOLS:

      LIKE LINE OF lt_repost.

      • note: table must have source and target ECCS group account

      SELECT *

      INTO CORRESPONDING FIELDS OF TABLE lt_repost

      FROM ygl00eccs_repost

      WHERE racct IN s_racct.

      • Anything already reposted

      CHECK lt_repost IS NOT INITIAL.

      • Remove canceled documents

      SELECT bukrs belnr gjahr

      INTO CORRESPONDING FIELDS OF ls_bkpf

      FROM bkpf

      FOR ALL ENTRIES IN lt_repost

      WHERE bukrs = lt_repost-rbukrs

      AND belnr = lt_repost-docnum

      AND gjahr = lt_repost-ryear

      AND stblg <> lv_stblg_initial.

      DELETE lt_repost

      WHERE rbukrs = ls_bkpf-bukrs

      AND docnum = ls_bkpf-belnr

      AND ryear = ls_bkpf-gjahr.

      ENDSELECT." bukrs belnr gjahr

      • Anything already reposted and not cancelled?

      CHECK lt_repost IS NOT INITIAL.

      • have it sorted to ensure binary search access

      SORT pt_alv_display

      BY

      rbukrs

      ryear

      racct

      cost_elem

      prctr

      rassc

      rcntr

      rfarea

      rmvct

      rtcur

      zzbilkt

      zzbilkt_new

      zzmulti.

      LOOP AT lt_repost ASSIGNING -zzmulti

      BINARY SEARCH.

      lv_tabix = sy-tabix.

      IF sy-subrc = 0.

      • record found: add to reposted amount, reduce to-be-posted amount

      ADD:

      -tslxx_topost.

      • Have relation to document

      INSERT -t_redoc.

      • colorize reposted

      PERFORM alv_color USING:

      'TSLXX_POSTED' col_positive 0 0 CHANGING -color.

      ELSE.

      • repostal document found without corresponding reposting line

      • this might happen if i.e. cancelled after reposting

      MOVE-CORRESPONDING -tslxx TO ls_alv_display-tslxx_topost.

      CLEAR:

      ls_alv_display-hslxx,

      ls_alv_display-tslxx.

      INSERT ls_alv_display INTO pt_alv_display INDEX lv_tabix.

      ENDIF." sy-subrc = 0.

      • update lights status

      READ TABLE pt_alv_display ASSIGNING .

      ENDFORM. " merge_reposted

      *&----


      *

      *& Form alv_reduce_significant

      *&----


      *

      • Mark empty columns as 'TECH' in fieldcat - don't show them

      *----


      *

      FORM alv_reduce_significant

      USING pt_list TYPE table

      CHANGING pt_alv_fieldcat TYPE slis_t_fieldcat_alv.

      DATA:

      lt_fields TYPE TABLE OF fieldname.

      FIELD-SYMBOLS:

      TYPE fieldname.

      • what fields are present?

      PERFORM getfields USING pt_list CHANGING lt_fields.

      LOOP AT pt_list ASSIGNING IS NOT INITIAL.

      • field is assigned and not empty: No further checks, no remove

      DELETE lt_fields.

      ENDLOOP." at lt_fields assigning .

      • remaining fields are empty - don't need the column, mark as tech

      LOOP AT lt_fields ASSIGNING .

      ENDFORM. " alv_reduce_significant

      *&----


      *

      *& Form alv_popup_postings

      *&----


      *

      • Show postig details for investment sum

      *----


      *

      FORM alv_popup_postings USING ps_alv TYPE ty_alv_display.

      DATA:

      lt_fields TYPE TABLE OF fieldname,

      lrt_belnr TYPE RANGE OF belnr_d.

      FIELD-SYMBOLS:

      TYPE belnr_d.

      CHECK NOT ps_alv-t_redoc IS INITIAL.

      • build range

      LOOP AT ps_alv-t_redoc ASSIGNING .

      • fields of internal table

      PERFORM getfields USING t_posting_detail CHANGING lt_fields.

      • the ones in table for selection

      PERFORM adjust_sel_fields USING 'BKPF' CHANGING lt_fields.

      SELECT (lt_fields)

      INTO CORRESPONDING FIELDS OF TABLE t_posting_detail

      FROM bkpf

      WHERE belnr IN lrt_belnr

      AND gjahr = ps_alv-ryear

      AND bukrs = ps_alv-rbukrs.

      PERFORM alv_display_popup USING t_posting_detail.

      ENDFORM. " alv_popup_postings

      *&----


      *

      *& Form alV_display_popup

      *&----


      *

      FORM alv_display_popup

      USING pt_list TYPE table.

      DATA:

      lv_screen_start_column TYPE sycucol VALUE 5,

      lv_screen_start_line TYPE sycurow VALUE 5,

      lv_screen_end_column TYPE sycucol VALUE 140,

      lv_screen_end_line TYPE sycurow VALUE 20,

      l_alv_layout TYPE slis_layout_alv,

      l_repid TYPE sy-repid,

      lv_title TYPE lvc_title,

      ls_exit_by_user TYPE slis_exit_by_user,

      ls_glay TYPE lvc_s_glay,

      ls_print TYPE slis_print_alv,

      lt_alv_fieldcat TYPE slis_t_fieldcat_alv,

      lt_events TYPE slis_t_event,

      lv_variant TYPE disvariant.

      FIELD-SYMBOLS:

      INDEX 1.

      CHECK sy-subrc = 0.

      PERFORM popup_align

      USING pt_list

      CHANGING lv_screen_start_column

      lv_screen_start_line

      lv_screen_end_column

      lv_screen_end_line.

      PERFORM sapgui_progress_indicator USING 'Transfer to ALV...'(001) 0 0.

      lv_variant-report = l_repid.

      lv_variant-username = sy-uname.

      lv_variant-log_group = 'DETA'.

      PERFORM alv_layout CHANGING l_alv_layout.

      PERFORM alv_events CHANGING lt_events.

      PERFORM alv_fieldcat_for_itab TABLES pt_list CHANGING lt_alv_fieldcat.

      PERFORM alv_print CHANGING ls_print.

      PERFORM alv_grid_settings CHANGING ls_glay.

      lv_title = 'ECCS Reposting Documents'(erd).

      PERFORM alv_reduce_significant USING pt_list CHANGING lt_alv_fieldcat.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      • I_INTERFACE_CHECK = ' '

      • I_BYPASSING_BUFFER = ' '

      • I_BUFFER_ACTIVE = ' '

      i_callback_program = gv_repid

      • I_CALLBACK_PF_STATUS_SET = ' '

      i_callback_user_command = 'ALV_DOUBLE_CLICK_POPUP '

      • I_CALLBACK_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_END_OF_LIST = ' '

      • I_STRUCTURE_NAME =

      • I_BACKGROUND_ID = ' '

      i_grid_title = lv_title

      i_grid_settings = ls_glay

      is_layout = l_alv_layout

      it_fieldcat = lt_alv_fieldcat

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      • IT_SORT =

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      i_save = 'A'

      is_variant = lv_variant

      • it_events = lt_events

      • IT_EVENT_EXIT =

      is_print = ls_print

      • IS_REPREP_ID =

      i_screen_start_column = lv_screen_start_column

      i_screen_start_line = lv_screen_start_line

      i_screen_end_column = lv_screen_end_column

      i_screen_end_line = lv_screen_end_line

      • I_HTML_HEIGHT_TOP = 0

      • I_HTML_HEIGHT_END = 0

      • IT_ALV_GRAPHICS =

      • IT_HYPERLINK =

      • IT_ADD_FIELDCAT =

      • IT_EXCEPT_QINFO =

      • IR_SALV_FULLSCREEN_ADAPTER =

      IMPORTING

      • E_EXIT_CAUSED_BY_CALLER =

      es_exit_caused_by_user = ls_exit_by_user

      TABLES

      t_outtab = pt_list

      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.

      CHECK ls_exit_by_user-back IS INITIAL.

      • User used EXIT or CANCEL

      MESSAGE s415(0k).

      • Process cancelled by user

      ENDFORM. " alV_display_popup

      *&----


      *

      *& Form popup_align

      *&----


      *

      • align popup position according to contents

      *----


      *

      FORM popup_align

      USING pt_any TYPE STANDARD TABLE

      CHANGING pv_screen_start_column TYPE sycucol

      pv_screen_start_line TYPE sycurow

      pv_screen_end_column TYPE sycucol

      pv_screen_end_line TYPE sycurow.

      FIELD-SYMBOLS:

      sy-srows.

      ENDFORM. " popup_align

      *&----


      *

      *& Form adjust_sel_fields

      *&----


      *

      • merge the missing key fields into the field table

      • delete non-existing fields fo selection

      *----


      *

      FORM adjust_sel_fields

      USING pv_tabname TYPE tabname

      CHANGING pt_fields TYPE fieldname_tab.

      FIELD-SYMBOLS:

      TYPE LINE OF fieldname_tab.

      DATA:

      lt_field TYPE fieldname_tab,

      lv_field TYPE fieldname.

      CHECK pt_fields IS NOT INITIAL.

      SORT pt_fields.

      • delete nonexisting fields

      SELECT fieldname

      INTO TABLE lt_field

      FROM dd03l FOR ALL ENTRIES IN pt_fields

      WHERE tabname = pv_tabname

      AND fieldname = pt_fields-table_line

      AND as4local = 'A'

      AND as4vers = space.

      SORT lt_field.

      LOOP AT pt_fields ASSIGNING .

      • insert missing keyfields

      SELECT fieldname

      INTO lv_field

      FROM dd03l

      WHERE tabname = pv_tabname

      AND as4local = 'A'

      AND as4vers = space

      AND keyflag <> space.

      READ TABLE pt_fields TRANSPORTING NO FIELDS

      WITH KEY table_line = lv_field

      BINARY SEARCH.

      CHECK sy-subrc <> 0.

      INSERT lv_field INTO pt_fields INDEX sy-tabix.

      ENDSELECT." fieldname

      ENDFORM. "adjust_sel_fields

      *&----


      *

      *& Form ALV_DOUBLE_CLICK_POPUP

      *&----


      *

      • double-click-functions

      *----


      *

      FORM alv_double_click_popup

      USING pv_ucomm TYPE sy-ucomm

      ps_selfield TYPE slis_selfield.

      FIELD-SYMBOLS:

      TYPE LINE OF ty_t_posting_detail.

      IF ps_selfield-tabindex IS INITIAL.

      MESSAGE e004(0k).

      • Bitte positionieren Sie den Cursor auf eine Zeile des Listkörpers

      • Position the cursor on a line in the list

      ENDIF." ps_selfield-tabindex is initial.

      READ TABLE t_posting_detail INDEX ps_selfield-tabindex

      ASSIGNING -bukrs.

      ENDCASE." ps_selfield-fieldname.

      CLEAR: pv_ucomm.

      ENDFORM. " ALV_DOUBLE_CLICK_POPUP

      *&----


      *

      *& Form REUSE_ALV_VARIANT_F4

      *&----


      *

      FORM reuse_alv_variant_f4

      CHANGING ps_variant TYPE disvariant

      pv_layout TYPE disvariant-variant.

      DATA:

      ls_variant TYPE disvariant,

      lv_exit TYPE flag.

      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

      EXPORTING

      is_variant = ps_variant

      • I_TABNAME_HEADER =

      • I_TABNAME_ITEM =

      • IT_DEFAULT_FIELDCAT =

      i_save = 'A'

      • I_DISPLAY_VIA_GRID = ' '

      IMPORTING

      e_exit = lv_exit

      es_variant = ls_variant

      EXCEPTIONS

      not_found = 1

      program_error = 2

      OTHERS = 3

      .

      IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ELSEIF lv_exit IS INITIAL.

      ps_variant = ls_variant.

      pv_layout = ls_variant-variant.

      ENDIF.

      ENDFORM. " REUSE_ALV_VARIANT_F4

      Hope it helps.

      Regards,

      Clemens

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 04:15 PM

    Well the FM is not obsolete (in 4.7); on the other hand, it is neither released nor documented, so you use it at your own peril.

    Having said that, do you have 'Fixed point arithmetic' clicked in the attributes of your program?

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 04:39 PM

    Hi Nuno,

    possibly you are better off just re-creating the code given in FAGL_ACCOUNT_BALANCE (FAGLB03).

    It is very efficient and fast.

    Check the attached code of mine I created for a similar purpose. Possibly you can adapt it to your needs.

    Regards,

    Clemens

    *&---------------------------------------------------------------------*
    *&      Form  fagl_get_balance
    *&---------------------------------------------------------------------*
    *       determine balances for ZZBILKT ECCS items
    *----------------------------------------------------------------------*
    FORM fagl_get_balance
      CHANGING     pt_acc_balance             TYPE ty_t_acc_balance.
      DATA:
        lrt_zzbilkt                           TYPE RANGE OF zzbilkt,
        lt_bukrs                              TYPE fagl_range_t_bukrs,
        lt_selection                          TYPE gusl_t_selection,
        lt_dfies                              TYPE TABLE OF dfies,
        ls_dfies                              TYPE dfies,
        ls_fagl_tabnames                      TYPE fagl_tabnames,
        lt_fieldlist                          TYPE gusl_t_fields.
      FIELD-SYMBOLS:
        <zzbilkt>                             TYPE racct,
        <tot_table>                           TYPE STANDARD TABLE,
        <tot_table_structure>                 TYPE ANY,
        <target_field_value>                  TYPE ANY.
    
    
      CALL FUNCTION 'FAGL_GET_TABLENAMES'
        EXPORTING
          i_ledger            = gv_relevant_ledger
        IMPORTING
          es_tabnames         = ls_fagl_tabnames
        EXCEPTIONS
          not_found           = 1
          configuration_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.
    
      FREE lt_selection.
    
    * prepare selections to be passed to authority check and table select
      PERFORM fagl_fill_selections
        TABLES   s_bukrs
        USING    gv_relevant_ledger
        CHANGING lt_selection.
    
      lt_bukrs[]                              = s_bukrs[].
    
    *...authority check of the selection screen.....................*
      DATA ld_label                           TYPE string.
      DATA ld_fieldvalue                      TYPE string.
    
      CALL FUNCTION 'FAGL_CHECK_AUTHORITY_SELECTION'
        EXPORTING
          it_selections = lt_selection
          id_table      = ls_fagl_tabnames-tot_table
          it_bukrs      = lt_bukrs
          id_actvt      = '27'           "sum data set
        IMPORTING
          ed_label      = ld_label
          ed_field      = ld_fieldvalue
        EXCEPTIONS
          no_authority  = 1
          OTHERS        = 2.
    
      IF sy-subrc                             <> 0.
        MESSAGE e030(fagl_post_service) WITH ld_label ld_fieldvalue.
      ENDIF.
    
    *...fill lt_fieldlist with fields, which have to be ignored by
    *...function modul G_TABLE_SELECT_WITH_CURSOR during aggregation.
      PERFORM fill_fieldlist
        USING    gv_relevant_ledger
        CHANGING lt_fieldlist.
    
      CREATE DATA gr_tot_table                TYPE TABLE OF (ls_fagl_tabnames-tot_table).
      ASSIGN gr_tot_table->* TO <tot_table>.
    
      CALL FUNCTION 'G_TABLE_SELECT_WITH_CURSOR'
        EXPORTING
          i_tabname         = ls_fagl_tabnames-tot_table
          i_selection       = lt_selection
          i_fieldlist       = lt_fieldlist
          i_aggregation     = 'X'
          i_zero_records    = 'X'                               "865353
        CHANGING
          c_t_data          = <tot_table>
        EXCEPTIONS
          invalid_selection = 1
          invalid_table     = 2
          internal_error    = 3
          foreign_lock      = 4
          OTHERS            = 5.
    
      IF sy-subrc                             <> 0.
        MESSAGE ID sy-msgid                   TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    
      DATA lt_fields                          TYPE fieldname_tab.
      DATA ld_field                           TYPE fieldname.
      lt_fields[]                             = lt_fieldlist[].
    
      LOOP AT lt_fields INTO ld_field.
        IF ld_field                           = 'RTCUR'
        OR ld_field                           = 'DRCRK'
        OR ld_field                           = 'RYEAR'
        OR ld_field                           = 'TSL'
        OR ld_field                           = 'HSL'
        OR ld_field                           = 'KSL'
        OR ld_field                           = 'OSL'.
          DELETE lt_fields.
        ENDIF.
      ENDLOOP.
    
    *...authority check of the selected data.............................*
      CALL FUNCTION 'FAGL_CHECK_AUTHORITY_SUM_TABLE'
        EXPORTING
          it_fields    = lt_fields
          id_actvt     = '27'           "sum data set
        CHANGING
          it_data      = <tot_table>
        EXCEPTIONS
          no_authority = 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.
    
    *...change sign for all <tot_table> entries, if debit credit indicator
    *...has value credit.
    
      LOOP AT <tot_table> ASSIGNING <tot_table_structure>.
    
        ASSIGN COMPONENT 'DRCRK'
        OF STRUCTURE <tot_table_structure> TO <target_field_value>.
        IF <target_field_value> EQ 'H'.
    
          CALL FUNCTION 'DDIF_NAMETAB_GET'
            EXPORTING
              tabname   = 'FAGL_S_PERIOD_BLOCK'
            TABLES
              dfies_tab = lt_dfies
            EXCEPTIONS
              OTHERS    = 0.
    
          LOOP AT lt_dfies INTO ls_dfies.
            CHECK ls_dfies-fieldname NE 'DRCRK'
            AND ls_dfies-fieldname NE 'HSLVT'
            AND ls_dfies-fieldname NE 'TSLVT'
            AND ls_dfies-fieldname NE 'KSLVT'
            AND ls_dfies-fieldname NE 'OSLVT'
            AND ls_dfies-fieldname NE 'MSLVT'.
            ASSIGN
              COMPONENT ls_dfies-fieldname
              OF STRUCTURE <tot_table_structure>
              TO <target_field_value>.
            <target_field_value>              = 0 - <target_field_value>.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
      PERFORM consolidate_totals
        USING
        <tot_table>
        CHANGING pt_acc_balance.
    * should not exists but will be ignored: Documents without ECCS item
      DELETE pt_acc_balance WHERE zzbilkt is initial.
    ENDFORM.                    " fagl_get_balance
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.