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

how to maintain the column heading in two lines

for example i have field ACCOUNTING CLEARK

i want to display this description in alv list

like ACC

clk

Please send the solution for this.

very urgent

thanks in advance

regards

venu

 

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 01:56 PM

    Hi,

    <b>I guess that is not possible .</b>

    For this you need to modify the field catalog .

    Look the sample code here :

    LOOP AT f_fieldcat INTO wa_fieldcat .

    IF wa_fieldcat-fieldname = 'ACCOUNTING CLERK'.

    wa_fieldcat-seltext_m = 'ACC CLK'.

    MODIFY f_fieldcat FROM wa_fieldcat.

    ENDIF.

    ENDLOOP.

    Regards,

    Varun.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 02:00 PM

    Hi,

    Plz check this code once.

    &----


    *& Report PROGRAM TO PRINT THE REPORT IN ALV LIST FORMAT AND GRID FORMAT *

    &----


    report zxx_alvexer1 message-id zz .

    &----


    *& TABLES DECLARATION *

    &----


    tables:lfa1, lfb1, lfm1.

    &----


    *& TYPE POOLS DECLARATION *

    &----


    type-pools: slis.

    &----


    *& INTERNAL TABLE DECLARATION *

    &----


    data: begin of itab occurs 0,

    lifnr like lfa1-lifnr, " VENDOR

    bukrs like lfb1-bukrs, " COMPANY CODE

    ekorg like lfm1-ekorg, " PURCHASING ORG

    ktokk like lfa1-ktokk, " ACCOUNT GROUP

    name1 like lfa1-name1, " VENDOR NAME

    stras like lfa1-stras, " STREET

    ort01 like lfa1-ort01, " CITY

    regio like lfa1-regio, " REGION

    pfort like lfa1-pfort, " PO BOX

    pstlz like lfa1-pstlz, " PO CODE

    pstl2 like lfa1-pstl2, " PO ZIP

    telf1 like lfa1-telf1, " TELEPHONE

    end of itab.

    *INTERNAL TABLE FOR FIELD CATALOG

    data: it_fieldcat type standard table of slis_fieldcat_alv

    with header line,

    *INTERNAL TABLE FOR EVENTS

    it_event type slis_t_event,

    wa_event type slis_alv_event,

    *INTERNAL TABLE FOR SORTING

    it_sort type slis_t_sortinfo_alv,

    wa_sort type slis_sortinfo_alv,

    *INTERNAL TABLE FOR LAYOUT

    wa_layout type slis_layout_alv.

    &----


    *& VARIABLE DECLARATION *

    &----


    data : v_repid type sy-repid,

    v_pagno(4) type n,

    v_date(8) type c.

    &----


    *& CONSTANTS *

    &----


    constants: c_x type c value 'X'.

    &----


    *& SELECTION SCREEN *

    &----


    selection-screen: begin of block b1 with frame title text-001.

    select-options: s_lifnr for lfa1-lifnr,

    s_bukrs for lfb1-bukrs,

    s_ekorg for lfm1-ekorg,

    s_ktokk for lfa1-ktokk.

    selection-screen: end of block b1.

    selection-screen: begin of block b2 with frame title text-002.

    selection-screen : begin of line.

    selection-screen comment 1(20) text-003.

    parameters: p_list radiobutton group rad1 default 'X'.

    selection-screen : end of line.

    selection-screen : begin of line.

    selection-screen comment 1(20) text-004.

    parameters: p_grid radiobutton group rad1.

    selection-screen : end of line.

    selection-screen: end of block b2.

    &----


    *& AT SELECTION SCREEN *

    &----


    at selection-screen.

    perform validate_screen.

    &----


    *& START OF SELECTION *

    &----


    start-of-selection.

    clear: itab, itab[].

    v_repid = sy-repid.

    perform get_data.

    &----


    *& END OF SELECTION *

    &----


    end-of-selection.

    *--DO ALV Process

    v_repid = sy-repid.

    *--Sort the Output Fields

    perform sort_fields.

    *--Build Field catalog for the Output fields

    perform build_fieldcat.

    *--Set the Layout for ALV

    perform set_layout.

    &----


    *& Form GET_DATA

    &----


    • text

    ----


    • TO GET THE DATA FROM TABLES INTO ITAB

    ----


    form get_data .

    select

    a~lifnr

    b~bukrs

    c~ekorg

    a~ktokk

    a~name1

    a~stras

    a~ort01

    a~regio

    a~pfort

    a~pstlz

    a~pstl2

    a~telf1

    into table itab

    from lfa1 as a join lfb1 as b

    on alifnr = blifnr

    join lfm1 as c

    on alifnr = clifnr

    where a~lifnr in s_lifnr and

    b~bukrs in s_bukrs and

    c~ekorg in s_ekorg and

    a~ktokk in s_ktokk.

    endform. " GET_DATA

    &----


    *& Form validate_screen

    &----


    form validate_screen .

    data: lv_lifnr like lfa1-lifnr,

    lv_bukrs like lfb1-bukrs,

    lv_ekorg like lfm1-ekorg,

    lv_ktokk like lfa1-ktokk.

    if not s_lifnr[] is initial.

    select lifnr

    up to 1 rows

    into lv_lifnr

    from lfa1

    where lifnr in s_lifnr.

    endselect.

    if sy-subrc <> 0.

    message e000 with 'Invalid vendor'(005).

    endif.

    endif.

    if not s_bukrs is initial.

    select bukrs

    up to 1 rows

    into lv_bukrs

    from t001

    where bukrs in s_bukrs.

    endselect.

    if sy-subrc <> 0.

    message e000 with 'Invalid company code'(006).

    endif.

    endif.

    if not s_ekorg is initial.

    select ekorg

    up to 1 rows

    into lv_ekorg

    from t024e

    where ekorg in s_ekorg.

    endselect.

    if sy-subrc <> 0.

    message e000 with 'Invalid purchasing org'(007).

    endif.

    endif.

    if not s_ktokk is initial.

    select ktokk

    up to 1 rows

    into lv_ktokk

    from t077k

    where ktokk in s_ktokk.

    endselect.

    if sy-subrc <> 0.

    message e000 with 'Invalid acct group'(008).

    endif.

    endif.

    endform. " validate_screen

    &----


    *& Form sort_fields

    &----


    form sort_fields .

    clear wa_sort.

    wa_sort-fieldname = 'LIFNR'.

    wa_sort-spos = '1'.

    wa_sort-up = 'X'.

    append wa_sort to it_sort.

    clear wa_sort.

    wa_sort-fieldname = 'BUKRS'.

    wa_sort-spos = '2'.

    wa_sort-up = 'X'.

    append wa_sort to it_sort.

    clear wa_sort.

    wa_sort-fieldname = 'EKORG'.

    wa_sort-spos = '3'.

    wa_sort-up = 'X'.

    append wa_sort to it_sort.

    endform. " sort_fields

    &----


    *& Form build_fieldcat

    &----


    form build_fieldcat .

    it_fieldcat-col_pos = '1'.

    it_fieldcat-fieldname = 'LIFNR'.

    it_fieldcat-key = 'X'.

    it_fieldcat-outputlen = '10'.

    it_fieldcat-seltext_l = 'VENDOR'(009).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '2'.

    it_fieldcat-fieldname = 'BUKRS'.

    it_fieldcat-key = 'X'.

    it_fieldcat-outputlen = '4'.

    it_fieldcat-seltext_l = 'COMPANY CODE'(010).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '3'.

    it_fieldcat-fieldname = 'EKORG'.

    it_fieldcat-key = 'X'.

    it_fieldcat-outputlen = '4'.

    it_fieldcat-seltext_l = 'PURCHASING ORG'(011).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '4'.

    it_fieldcat-fieldname = 'KTOKK'.

    it_fieldcat-outputlen = '4'.

    it_fieldcat-seltext_l = 'ACCOUNT GRP'(012).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '5'.

    it_fieldcat-fieldname = 'NAME1'.

    it_fieldcat-outputlen = '12'.

    it_fieldcat-seltext_l = 'VENDOR NAME'(013).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '6'.

    it_fieldcat-fieldname = 'STRAS'.

    it_fieldcat-outputlen = '12'.

    it_fieldcat-seltext_l = 'STREET'(014).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '7'.

    it_fieldcat-fieldname = 'ORT01'.

    it_fieldcat-outputlen = '12'.

    it_fieldcat-seltext_l = 'CITY'(015).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '8'.

    it_fieldcat-fieldname = 'REGIO'.

    it_fieldcat-outputlen = '2'.

    it_fieldcat-seltext_l = 'REGION'(016).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '9'.

    it_fieldcat-fieldname = 'PFORT'.

    it_fieldcat-outputlen = '10'.

    it_fieldcat-seltext_l = 'PO BOX'(017).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '10'.

    it_fieldcat-fieldname = 'PFTLZ'.

    it_fieldcat-outputlen = '10'.

    it_fieldcat-seltext_l = 'POST CODE'(018).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '11'.

    it_fieldcat-fieldname = 'PSTL2'.

    it_fieldcat-outputlen = '10'.

    it_fieldcat-seltext_l = 'PO ZIP'(019).

    append it_fieldcat.

    clear it_fieldcat.

    it_fieldcat-col_pos = '12'.

    it_fieldcat-fieldname = 'TELF1'.

    it_fieldcat-outputlen = '16'.

    it_fieldcat-seltext_l = 'TELEPHONE'(020).

    append it_fieldcat.

    clear it_fieldcat.

    endform. " build_fieldcat

    &----


    *& Form set_layout

    &----


    form set_layout .

    if p_list = c_x .

    wa_layout-window_titlebar = 'LIST DISPLAY'(021).

    *-- ALV LIST DISPLAY

    perform list_display tables itab.

    *-- ALV GRID DISPLAY

    elseif p_grid = c_x.

    wa_layout-window_titlebar = 'GRID DISPLAY'(022).

    perform grid_display tables itab.

    endif.

    endform. " set_layout

    &----


    *& Form list_display

    &----


    form list_display tables p_itab .

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = v_repid

    is_layout = wa_layout

    it_fieldcat = it_fieldcat[]

    it_sort = it_sort[]

    tables

    t_outtab = itab

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

    &----


    *& Form GRID_DISPLAY

    &----


    form grid_display tables p_itab .

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = v_repid

    is_layout = wa_layout

    it_fieldcat = it_fieldcat[]

    it_sort = it_sort[]

    it_events = it_event

    tables

    t_outtab = itab

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

    Regards,

    Laxmi.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi

      please check my code

      for field KNB1-BUSAB

      i want the description ACC in place of ACC CLK

      CLK

      means in two lines

      report zfir0098 message-id zz

      line-size 255

      line-count 65

      no standard page heading.

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

      • (C) Copyright <2006> by Eastman Kodak Company - All Rights Reserved.

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

      • Report Name : ZFIR0098

      • Author : Venugopalreddy.K

      • Created on : 12-MAY-2006

      • SIR# : 086279

      • Interface ID# : RO-01509 - Open AR Aging by Due Date

      • Correction# : D11K947333

      • Transaction code: Z_ZFIR0098

      • Logical Database: N/A

      • SAPScript name : N/A

      • Application Area: FI

      • Programs Called : N/A

      • Function Modules: REUSE_ALV_VARIANT_F4

      • REUSE_ALV_VARIANT_DEFAULT_GET

      • REUSE_ALV_EVENTS_GET

      • REUSE_ALV_LIST_DISPLAY

      • REUSE_ALV_EVENTS_GET

      • REUSE_ALV_COMMENTARY_WRITE

      • Description : Report to display Open AR with Aging by due

      • date. The open items are displayed by Linked

      • Accounts, Customer Account, Business unit and

      • Posting Date.

      **----


      *

      • Correction# SIR# Modified By Date

      • D11Kxxxxxx xxxxxx xxxx MM/DD/YYYY

      *

      • Description of change (copy from SIR):

      • (text)................................................................

      ----


      ----


      • TABLE DEFINITION *

      ----


      tables : t001, "Company Codes

      knvv, "Customer Master Sales Data

      bsid, "Accounting: Secondary Index for Customers

      knkk, "Customer master credit management: Control area data

      kna1, "General Data in Customer Master

      knb1, "Customer Master (Company Code)

      t052, "Terms of Payment

      tvv1. "Customer Group 1

      ----


      • TYPE POOLS *

      ----


      type-pools: slis.

      ----


      • INTERNAL TABLE DECLARATION

      ----


      • Internal table for Customer Master (Company Code)

      data : begin of i_knb1 occurs 0,

      kunnr type knb1-kunnr,

      bukrs type knb1-bukrs,

      busab type knb1-busab,

      end of i_knb1.

      • Internal table for Customer Master Sales Data

      data : begin of i_knvv occurs 0,

      kunnr type knvv-kunnr,

      vkorg type knvv-vkorg,

      kvgr1 type knvv-kvgr1,

      zterm type knvv-zterm,

      end of i_knvv.

      • Internal table for linked account nos.

      data : begin of i_knkk occurs 0,

      kunnr type knkk-kunnr,

      kkber type knkk-kkber,

      klimk type knkk-klimk,

      knkli type knkk-knkli,

      sbgrp type knkk-sbgrp,

      grupp type knkk-grupp,

      kdgrp type knkk-kdgrp,

      end of i_knkk.

      • Internal table for Customer's credit limit

      data : begin of i_knkk_knkli occurs 0,

      kunnr type knkk-kunnr,

      klimk type knkk-klimk,

      knkli type knkk-knkli,

      end of i_knkk_knkli.

      • Internal table for T001 records

      data: begin of i_t001 occurs 0,

      bukrs type t001-bukrs,

      waers type t001-waers,

      end of i_t001.

      • Internal table for BSID records

      data : begin of i_bsid occurs 0,

      bukrs type bsid-bukrs,

      kunnr type bsid-kunnr,

      zuonr type bsid-zuonr,

      belnr type bsid-belnr,

      budat type bsid-budat,

      bldat type bsid-bldat,

      waers type bsid-waers,

      shkzg type bsid-shkzg,

      dmbtr type bsid-dmbtr,

      wrbtr type bsid-wrbtr,

      zfbdt type bsid-zfbdt,

      zterm type bsid-zterm,

      zbd1t type bsid-zbd1t,

      zbd2t type bsid-zbd2t,

      zbd3t type bsid-zbd3t,

      kkber type bsid-kkber,

      end of i_bsid.

      • Internal table for Customer Master

      data : begin of i_kna1 occurs 0,

      kunnr type kna1-kunnr,

      name1 type kna1-name1,

      end of i_kna1.

      • Internal table for Terms of Payment

      data : begin of i_t052 occurs 0,

      zterm type t052-zterm,

      ztagg type t052-ztagg,

      ztag1 type t052-ztag1,

      ztag2 type t052-ztag2,

      ztag3 type t052-ztag3,

      end of i_t052.

      • Internal table for final output

      data : begin of i_output occurs 0,

      kunnr1 type bsid-kunnr,

      kunnr type bsid-kunnr,

      bukrs type t001-bukrs,

      kdgrp type knkk-kdgrp,

      name1 type kna1-name1,

      kvgr1 type knvv-kvgr1,

      knkli type knkk-knkli,

      klimk type knkk-klimk,

      sbgrp type knkk-sbgrp,

      zuonr type bsid-zuonr,

      bldat type bsid-bldat,

      due_date type bsid-zfbdt,

      not_due type bsid-dmbtr,

      curr_due type bsid-dmbtr,

      due_01_30 type bsid-dmbtr,

      due_31_60 type bsid-dmbtr,

      due_61_90 type bsid-dmbtr,

      due_91_180 type bsid-dmbtr,

      due_181_365 type bsid-dmbtr,

      due_gt_365 type bsid-dmbtr,

      spcol type bsid-dmbtr,

      tot_due type bsid-dmbtr,

      tot_ar type bsid-dmbtr,

      waers type t001-waers,

      zterm type bsid-zterm,

      zterm1 type knvv-zterm,

      v_no_days type i,

      busab type knb1-busab,

      end of i_output.

      • Internal table for summary data

      data : begin of i_output_summary occurs 0,

      bukrs type t001-bukrs,

      kunnr type bsid-kunnr,

      name1 type kna1-name1,

      kvgr1 type knvv-kvgr1,

      klimk type knkk-klimk,

      zterm type knvv-zterm,

      kdgrp type knkk-kdgrp,

      sbgrp type knkk-sbgrp,

      busab type knb1-busab,

      not_due type bsid-dmbtr,

      curr_due type bsid-dmbtr,

      due_01_30 type bsid-dmbtr,

      due_31_60 type bsid-dmbtr,

      due_61_90 type bsid-dmbtr,

      due_91_180 type bsid-dmbtr,

      due_181_365 type bsid-dmbtr,

      due_gt_365 type bsid-dmbtr,

      spcol type bsid-dmbtr,

      tot_due type bsid-dmbtr,

      tot_ar type bsid-dmbtr,

      waers type t001-waers,

      end of i_output_summary.

      • Temporary internal table for KNVV records.

      data : i_knvv_tmp like i_knvv occurs 0 with header line.

      • Temporary internal table for KNKK records.

      data : i_knkk_tmp like i_knkk occurs 0 with header line.

      • Temporary internal table for BSID records.

      data : i_bsid_tmp like i_bsid occurs 0 with header line.

      ----


      • FIELD STRING DECLARATION

      ----


      • Structure to validate selection screen

      data : begin of v_radio,

      rd1 type c,

      rd2 type c,

      rd3 type c,

      end of v_radio.

      • Structure to validate selection screen

      data : begin of v_radio1,

      rd1 type c,

      rd2 type c,

      rd3 type c,

      end of v_radio1.

      *----


      • Internal Tables for ALV Report

      *----


      data: i_fieldcat_alv type slis_t_fieldcat_alv,

      i_sort type slis_t_sortinfo_alv,

      i_sort1 type slis_t_sortinfo_alv,

      i_events type slis_t_event,

      v_events type slis_alv_event,

      v_fieldcat_alv type slis_fieldcat_alv,

      v_sort like line of i_sort,

      v_sort1 like line of i_sort1,

      v_layout type slis_layout_alv,

      v_print type slis_print_alv,

      i_list_comments type slis_t_listheader,

      v_list_comments like line of i_list_comments,

      v_variant like disvariant, "Layout-External Use

      v_variant_save type c, "To Store the Varient

      v_variant1 like disvariant,

      v_exit type c. "Event exit

      *----


      • Data declaration

      *----


      data: v_paym_days type i,

      v_date_diff type i,

      v_zterm type t052-zterm,

      v_bukrs1 like bsid-bukrs,

      v_kunnr like bsid-kunnr,

      v_kdgrp like knkk-kdgrp,

      v_bukrs like bsid-bukrs,

      v_name1 like kna1-name1,

      v_knkli like knkk-knkli,

      v_klimk(20) type c,

      v_kvgr1 like knvv-kvgr1,

      v_kkber like knkk-kkber,

      v_sbgrp like knkk-sbgrp,

      v_busab like knb1-busab.

      data: v_cust_not_due type bsid-dmbtr,

      v_cust_curr_due type bsid-dmbtr,

      v_cust_due_01_30 type bsid-dmbtr,

      v_cust_due_31_60 type bsid-dmbtr,

      v_cust_due_61_90 type bsid-dmbtr,

      v_cust_due_91_180 type bsid-dmbtr,

      v_cust_due_181_365 type bsid-dmbtr,

      v_cust_due_gt_365 type bsid-dmbtr,

      v_cust_spcol type bsid-dmbtr,

      v_cust_tot_due type bsid-dmbtr,

      v_cust_tot_ar type bsid-dmbtr,

      v_curr type t001-waers,

      v_name type kna1-name1,

      v_kvgr type knvv-kvgr1,

      v_kdgrp1 type knkk-kdgrp,

      v_klimk1 type knkk-klimk,

      v_zterm1 type knvv-zterm,

      v_sbgrp1 type knkk-sbgrp,

      v_busab1 type knb1-busab.

      data: v_repid like sy-repid,

      v_flag type c.

      ----


      • CONSTANT DEFINITION

      ----


      constants:

      c_sel_x(1) type c value 'X',

      c_0(1) type c value '0',

      c_1(1) type c value '1',

      c_knkli(7) type c value 'S_KNKLI',

      c_kdgrp(7) type c value 'S_KDGRP',

      c_debit_s(1) type c value 'S',

      c_credit_h(1) type c value 'H',

      c_deflt_zterm_y000(4) type c value 'Y000',

      c_sc01(4) type c value 'SC01',

      c_subtotal_text type slis_formname value

      'ALV_SUBTOTALS',

      c_formname_top_of_page type slis_formname value

      'F_TOP_OF_PAGE',

      c_formname_top_of_page_summ type slis_formname value

      'F_TOP_OF_PAGE_SUMM'.

      *----


      • Selection-screen

      *----


      selection-screen begin of block b1 with frame title text-s01.

      parameters : p_bukrs type t001-bukrs obligatory.

      select-options : s_kvgr1 for knvv-kvgr1,

      s_sbgrp for knkk-sbgrp,

      s_busab for knb1-busab,

      s_budat for bsid-budat,

      s_kunnr for knvv-kunnr.

      selection-screen end of block b1.

      selection-screen begin of block b2 with frame title text-s02.

      selection-screen begin of line.

      parameters : p_lk_on as checkbox.

      selection-screen comment 5(24) text-s10 for field p_lk_on.

      selection-screen end of line.

      selection-screen comment 02(67) text-s12.

      selection-screen skip 1.

      selection-screen begin of line.

      parameters :p_knkli radiobutton group g1 user-command radi

      default 'X'.

      selection-screen comment 5(24) text-s05 for field p_knkli.

      select-options :s_knkli for knkk-knkli.

      selection-screen end of line.

      selection-screen begin of line.

      parameters :p_kdgrp radiobutton group g1.

      selection-screen comment 5(24) text-s06 for field p_kdgrp.

      select-options :s_kdgrp for knkk-kdgrp.

      selection-screen end of line.

      selection-screen begin of line.

      parameters :p_all_lk radiobutton group g1.

      selection-screen comment 5(24) text-s07 for field p_all_lk.

      selection-screen end of line.

      selection-screen end of block b2.

      selection-screen begin of block b3 with frame title text-s03.

      selection-screen begin of line.

      parameters :p_op_ab radiobutton group g2.

      selection-screen comment 5(32) text-s08 for field p_op_ab.

      selection-screen end of line.

      selection-screen begin of line.

      parameters :p_ab radiobutton group g2.

      selection-screen comment 5(16) text-s09 for field p_ab.

      selection-screen end of line.

      selection-screen end of block b3.

      selection-screen begin of block b4 with frame title text-s11.

      parameters :p_vari like disvariant-variant.

      selection-screen end of block b4.

      ----


      • INITIALIZATION

      ----


      initialization.

      • To initialize the variant

      perform initialize_variant.

      • To fetch the default variant for the ALV report

      perform display_default_variant.

      *----


      • At selection-screen

      *----


      at selection-screen.

      • To validate company code

      perform check_company_code.

      • To validate business unit

      perform check_business_unit.

      move: p_knkli to v_radio1-rd1,

      p_kdgrp to v_radio1-rd2,

      p_all_lk to v_radio1-rd3.

      if not s_kvgr1[] is initial and

      not s_sbgrp[] is initial.

      message e045 with text-073.

      endif.

      at selection-screen output.

      move: p_knkli to v_radio-rd1,

      p_kdgrp to v_radio-rd2,

      p_all_lk to v_radio-rd3.

      • To maintain the select options visiable and invisible

      perform selection_screen_output.

      • Check the radio buttons selected in selection screen

      if v_radio1 eq v_radio.

      • To maintain the default settings

      perform selection_screen_check.

      endif.

      ----


      • AT SELECTION-SCREEN ON VALUE-REQUEST

      ----


      • At Selection Screen Value Request.

      at selection-screen on value-request for p_vari.

      • To Display the Existing Variants(Layout).

      perform variant_help_f4 using p_vari.

      *----


      • Event start-of-selection

      *----


      start-of-selection.

      • Get the cusomer number

      perform get_knb1_details.

      • Get the customer group details

      perform get_knvv_details.

      • Get all linked account and credit account details from KNKK

      perform get_linked_accounts_details.

      • Get open AR documents from BSID

      perform get_open_ar_details.

      • Get the company code and curreny.

      perform get_com_code_curr.

      • Get the customer name

      perform get_customer_name.

      • Get the payment term days

      perform get_payment_term_days.

      • Populate the final table having all the field details

      perform populate_final_table.

      • To display the output in alv list.

      perform alv_list_dispaly.

      ----


      • Form initialize_variant

      ----


      • To initialize the ALV Variant

      ----


      form initialize_variant.

      clear: v_variant.

      v_repid = sy-repid.

      v_variant-report = v_repid.

      v_variant-username = sy-uname.

      v_variant_save = 'A'.

      endform. " initialize_variant

      ----


      • Form display_default_variant

      ----


      • To fetch the Default ALV variant

      ----


      form display_default_variant.

      if not p_vari is initial.

      v_variant-variant = p_vari.

      endif.

      clear v_variant1.

      v_variant1 = v_variant.

      • The function module is used to fetch the default variant

      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'

      exporting

      i_save = v_variant_save

      changing

      cs_variant = v_variant1

      exceptions

      wrong_input = 1

      not_found = 2

      program_error = 3

      others = 4.

      • Based on the SUBRC value the variant is assigned

      case sy-subrc.

      when 0.

      p_vari = v_variant1-variant.

      when 2.

      clear p_vari.

      endcase.

      endform. " display_default_variant

      ----


      • Form check_company_code

      ----


      • Validate Company Code

      ----


      form check_company_code.

      select single *

      from t001

      where bukrs eq p_bukrs.

      if sy-subrc ne 0.

      message e339.

      endif.

      endform. " check_company_code

      ----


      • Form check_business_unit

      ----


      • Validate Business Unit

      ----


      form check_business_unit.

      select single *

      from tvv1

      where kvgr1 in s_kvgr1.

      if sy-subrc ne 0.

      message e045 with text-e01.

      endif.

      endform. " check_business_unit

      ----


      • Form selection-screen-output

      ----


      • On selection of corresponding radio button the respective

      • Select-option will be high lighted

      ----


      form selection_screen_output.

      loop at screen.

      if p_knkli = c_sel_x.

      • Credit Account invisible

      if screen-name cs c_knkli.

      screen-invisible = c_0.

      screen-active = c_1.

      modify screen.

      endif .

      • Customer Group visible

      if screen-name cs c_kdgrp.

      screen-invisible = c_1.

      screen-active = c_0.

      modify screen.

      endif.

      elseif p_kdgrp = c_sel_x.

      • Credit Account invisible

      if screen-name cs c_knkli.

      screen-invisible = c_1.

      screen-active = c_0.

      modify screen.

      endif .

      • Customer Group visible

      if screen-name cs c_kdgrp.

      screen-invisible = c_0.

      screen-active = c_1.

      modify screen.

      endif.

      elseif p_all_lk = c_sel_x.

      • Credit Account invisible

      if screen-name cs c_knkli.

      screen-invisible = c_1.

      screen-active = c_0.

      modify screen.

      endif .

      • Customer Group invisible

      if screen-name cs c_kdgrp.

      screen-invisible = c_1.

      screen-active = c_0.

      modify screen.

      endif.

      endif.

      endloop.

      endform. " selection_screen_output

      ----


      • Form selection_screen_check

      ----


      • To check the selection screen radio buttons

      ----


      form selection_screen_check.

      if p_knkli = c_sel_x.

      if p_op_ab is initial.

      p_op_ab = c_sel_x.

      p_ab = ''.

      endif.

      elseif p_kdgrp = c_sel_x.

      if p_op_ab is initial.

      p_op_ab = c_sel_x.

      p_ab = ''.

      endif.

      elseif p_all_lk = c_sel_x.

      if p_op_ab is initial.

      p_op_ab = c_sel_x.

      p_ab = ''.

      endif.

      endif.

      endform. " selection_screen_check

      ----


      • Form variant_help_f4

      ----


      • To get the list of ALV help variants

      ----


      form variant_help_f4 using p_variant.

      call function 'REUSE_ALV_VARIANT_F4'

      exporting

      is_variant = v_variant

      i_save = v_variant_save

      importing

      e_exit = v_exit

      es_variant = v_variant

      exceptions

      not_found = 1

      program_error = 2

      others = 3.

      if sy-subrc <> 0.

      • If no variants exist

      message s045 with text-e02.

      endif.

      if v_exit is initial.

      p_variant = v_variant-variant.

      endif.

      endform. " variant_help_f4

      ----


      • Form get_knb1_details

      ----


      • To get the Customer number

      ----


      form get_knb1_details.

      • Fetch data from Customer Master (Company Code)

      • based on selection criteria(company code)

      select kunnr bukrs busab

      from knb1

      into table i_knb1

      where bukrs eq p_bukrs.

      if sy-subrc ne 0.

      message i561.

      leave list-processing.

      endif.

      endform. " get_knb1_details

      ----


      • Form get_knvv_details

      ----


      • To get the Customer group details

      ----


      form get_knvv_details.

      if not i_knb1[] is initial.

      sort i_knb1 by kunnr bukrs.

      delete adjacent duplicates from i_knb1 comparing kunnr bukrs.

      • Fecth data from Customer Master Sales Data

      • based on internal table I_KNB1 and selection criteria

      • (customer group)

      select kunnr vkorg kvgr1 zterm

      from knvv

      into table i_knvv

      for all entries in i_knb1

      where kunnr eq i_knb1-kunnr

      and kunnr in s_kunnr

      and vkorg eq i_knb1-bukrs.

      if sy-subrc ne 0.

      message i561.

      leave list-processing.

      endif.

      endif.

      endform. " get_knvv_details

      ----


      • Form get_linked_accounts_details

      ----


      • To get the linked account details

      ----


      form get_linked_accounts_details.

      if not i_knvv[] is initial.

      • get unique customer account KUNNR from i_bsid.

      i_knvv_tmp[] = i_knvv[].

      sort i_knvv_tmp by kunnr.

      delete adjacent duplicates from i_knvv_tmp comparing kunnr.

      clear v_kkber.

      concatenate 'C' p_bukrs+1(3) into v_kkber.

      sort i_knvv_tmp by kunnr.

      • Fetch the Customer's account number and Customer Group

      • details form Customer master credit management based on

      • internal table i_bsid_tmp and Credit control area

      select kunnr kkber klimk knkli sbgrp grupp kdgrp

      from knkk

      into table i_knkk

      for all entries in i_knvv_tmp

      where kunnr eq i_knvv_tmp-kunnr

      and kkber eq v_kkber.

      if not i_knkk[] is initial.

      i_knkk_tmp[] = i_knkk[].

      if p_lk_on = 'X' or not s_knkli[] is initial

      or not s_kdgrp[] is initial.

      loop at i_knkk_tmp.

      loop at i_knkk where knkli eq i_knkk_tmp-knkli

      and kunnr ne i_knkk_tmp-knkli.

      exit.

      endloop.

      if sy-subrc ne 0.

      delete i_knkk where knkli eq i_knkk_tmp-knkli.

      endif.

      endloop.

      endif.

      if not s_knkli[] is initial.

      delete i_knkk where not knkli in s_knkli.

      endif.

      if not s_kdgrp[] is initial.

      delete i_knkk where not kdgrp in s_kdgrp.

      endif.

      if not s_sbgrp[] is initial.

      delete i_knkk where not sbgrp in s_sbgrp.

      endif.

      else.

      message i561.

      leave list-processing.

      endif.

      else.

      message i561.

      leave list-processing.

      endif.

      endform. " get_linked_accounts_details

      ----


      • Form get_com_code_curr

      ----


      • Get the company code and currency

      ----


      form get_com_code_curr .

      select bukrs waers

      from t001

      into table i_t001

      where bukrs eq p_bukrs.

      endform. " get_com_code_curr

      ----


      • Form get_open_ar_details

      ----


      • Read BSID for all open AR

      ----


      form get_open_ar_details.

      if not i_knkk[] is initial.

      refresh i_knkk_tmp.

      i_knkk_tmp[] = i_knkk[].

      sort i_knkk_tmp by knkli.

      delete adjacent duplicates from i_knkk_tmp comparing kunnr.

      • Fetch the from Accounting: Secondary Index for Customers

      • based on internal table i_knvv and selection criteria(Posting Date

      • -in the Document)

      select bukrs kunnr zuonr belnr budat bldat waers shkzg

      dmbtr wrbtr zfbdt zterm zbd1t zbd2t zbd3t kkber

      from bsid

      into table i_bsid

      for all entries in i_knkk_tmp

      where bukrs eq p_bukrs

      and kunnr eq i_knkk_tmp-kunnr

      and umskz eq space

      and bstat eq space

      and budat in s_budat.

      if i_bsid[] is initial.

      message i561.

      leave list-processing.

      endif.

      else.

      message i561.

      leave list-processing.

      endif.

      endform. " get_open_ar_details

      ----


      • Form get_customer_name

      ----


      • To get the customer name

      ----


      form get_customer_name.

      if not i_knvv_tmp[] is initial.

      • Get the customer name from KNA1 for all customer

      select kunnr name1

      from kna1

      into table i_kna1

      for all entries in i_knvv_tmp

      where kunnr = i_knvv_tmp-kunnr.

      endif.

      endform. " get_customer_name

      ----


      • Form get_payment_term_days

      ----


      • To get the payment days

      ----


      form get_payment_term_days.

      if not i_bsid[] is initial.

      clear i_bsid_tmp.

      refresh i_bsid_tmp.

      i_bsid_tmp[] = i_bsid[].

      sort i_bsid_tmp by zterm.

      delete i_bsid_tmp where shkzg ne c_debit_s.

      if not i_bsid_tmp[] is initial.

      • Get the Payment days from T052

      select zterm ztagg ztag1 ztag2 ztag3

      from t052

      into table i_t052

      for all entries in i_bsid

      where zterm = i_bsid-zterm.

      endif.

      endif.

      endform. " get_payment_term_days

      ----


      • Form populate_final_table

      ----


      • To polupate final internal table

      ----


      form populate_final_table.

      sort i_bsid.

      sort i_kna1 by kunnr.

      sort i_knkk by kunnr.

      sort i_knkk_knkli by kunnr.

      sort i_knvv by vkorg kunnr.

      sort i_t052 by zterm ztag1 ztag2 ztag3.

      sort i_t001 by bukrs.

      loop at i_bsid.

      clear i_knb1.

      read table i_knb1 with key kunnr = i_bsid-kunnr

      binary search.

      if not i_knb1-busab in s_busab.

      continue.

      else.

      i_output-busab = i_knb1-busab.

      endif.

      clear i_knvv.

      read table i_knvv with key kunnr = i_bsid-kunnr

      vkorg = i_bsid-bukrs

      binary search.

      if not i_knvv-kvgr1 in s_kvgr1.

      continue.

      else.

      i_output-kvgr1 = i_knvv-kvgr1.

      i_output-zterm1 = i_knvv-zterm.

      endif.

      • To read the data from kna1,knkk and knvv and moving data to final

      • internal table i_output.

      perform move_kna1_knkk_knvv.

      • To read the data from bsid and t052 and moving data to final

      • internal table i_output.

      perform move_bsid_t052.

      • To calculate the number of days.

      perform move_no_of_days.

      endloop.

      endform. " populate_final_table

      ----


      • Form move_kna1_knkk_knvv

      ----


      • To read the data fron kna1,knkk and knvv

      ----


      form move_kna1_knkk_knvv.

      clear i_kna1.

      read table i_kna1 with key kunnr = i_bsid-kunnr

      binary search.

      if sy-subrc eq 0.

      i_output-name1 = i_kna1-name1.

      endif.

      clear i_knkk.

      read table i_knkk with key kunnr = i_bsid-kunnr

      binary search.

      if sy-subrc eq 0.

      i_output-knkli = i_knkk-knkli.

      i_output-kdgrp = i_knkk-kdgrp.

      i_output-klimk = i_knkk-klimk.

      i_output-sbgrp = i_knkk-sbgrp.

      endif.

      endform. " move_kna1_knkk_knvv

      ----


      • Form move_bsid_t052

      ----


      • To read the data from BSID and T052

      ----


      form move_bsid_t052.

      move: i_bsid-kunnr to i_output-kunnr,

      i_bsid-zuonr to i_output-zuonr ,

      i_bsid-zterm to i_output-zterm,

      i_bsid-bldat to i_output-bldat,

      i_bsid-kunnr to i_output-kunnr1.

      read table i_t001 with key bukrs = i_bsid-bukrs

      binary search.

      if sy-subrc eq 0.

      move: i_t001-bukrs to i_output-bukrs,

      i_t001-waers to i_output-waers.

      endif.

      if i_bsid-shkzg eq c_credit_h.

      i_bsid-dmbtr = - i_bsid-dmbtr.

      endif.

      move i_bsid-dmbtr to i_output-tot_ar.

      • If base line date is initial, then use Document date.

      if i_bsid-zfbdt is initial.

      i_bsid-zfbdt = i_bsid-bldat.

      endif.

      if i_bsid-shkzg eq c_debit_s.

      clear v_paym_days.

      if not i_bsid-zbd3t is initial.

      v_paym_days = i_bsid-zbd3t.

      elseif not i_bsid-zbd2t is initial.

      v_paym_days = i_bsid-zbd2t.

      elseif not i_bsid-zbd1t is initial.

      v_paym_days = i_bsid-zbd1t.

      • if no discount days is existing in BSID the

      • take discount days from table T052

      else.

      clear : i_t052,

      v_zterm.

      if i_bsid-zterm is initial.

      v_zterm = c_deflt_zterm_y000.

      else.

      v_zterm = i_bsid-zterm.

      endif.

      read table i_t052 with key zterm = v_zterm

      binary search.

      if sy-subrc eq 0.

      if not i_t052-ztag3 is initial.

      v_paym_days = i_t052-ztag3.

      elseif not i_t052-ztag2 is initial.

      v_paym_days = i_t052-ztag2.

      elseif not i_t052-ztag1 is initial.

      v_paym_days = i_t052-ztag1.

      endif.

      endif.

      endif.

      i_output-due_date = i_bsid-zfbdt + v_paym_days.

      else.

      i_output-due_date = i_bsid-zfbdt.

      endif.

      clear v_date_diff.

      v_date_diff = sy-datum - i_output-due_date.

      i_output-v_no_days = v_date_diff.

      endform. " move_bsid_t052

      ----


      • Form move_no_of_days

      ----


      • To read the no of days

      ----


      form move_no_of_days.

      if i_knkk-grupp = c_sc01.

      i_output-spcol = i_bsid-dmbtr.

      else.

      if v_date_diff < 0.

      i_output-not_due = i_bsid-dmbtr.

      elseif v_date_diff = 0.

      i_output-curr_due = i_bsid-dmbtr.

      elseif v_date_diff <= 30.

      i_output-due_01_30 = i_bsid-dmbtr.

      elseif v_date_diff <= 60.

      i_output-due_31_60 = i_bsid-dmbtr.

      elseif v_date_diff <= 90.

      i_output-due_61_90 = i_bsid-dmbtr.

      elseif v_date_diff <= 180.

      i_output-due_91_180 = i_bsid-dmbtr.

      elseif v_date_diff <= 365.

      i_output-due_181_365 = i_bsid-dmbtr.

      elseif v_date_diff > 365.

      i_output-due_gt_365 = i_bsid-dmbtr.

      endif.

      endif.

      i_output-tot_due = i_output-tot_ar - i_output-not_due.

      append i_output.

      clear i_output.

      endform. "move_no_of_days

      ----


      • Form alv_list_dispaly

      ----


      • To display the list i alv

      ----


      form alv_list_dispaly.

      if p_op_ab = 'X'.

      • For detailed report

      perform detail_report_alv.

      endif.

      if p_ab = 'X'.

      • For summary report

      perform summary_report_alv.

      endif.

      endform. " alv_list_dispaly

      ----


      • Form detail_report_alv

      ----


      • To display the detailed report

      ----


      form detail_report_alv.

      • To maintain column headings.

      perform f_fieldcat_build.

      • To sort the field Billing Document No.

      perform f_sortinfo_build.

      • To print selection screen information

      perform f_print_build.

      • To trigger the events

      perform f_event_build.

      • To Maintain Layout settings.

      perform f_layout_build.

      • To display the output

      perform f_display_data_detail.

      endform. " detail_report_alv

      ----


      • Form f_fieldcat_build

      ----


      • To maintain the fieldcatalogs for detailed report

      ----


      form f_fieldcat_build.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KUNNR'.

      v_fieldcat_alv-reptext_ddic = text-007.

      v_fieldcat_alv-col_pos = 1.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KUNNR1'.

      v_fieldcat_alv-reptext_ddic = text-007.

      v_fieldcat_alv-no_out = 'X'.

      v_fieldcat_alv-tech = 'X'.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'NOT_DUE'.

      v_fieldcat_alv-reptext_ddic = text-013.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 7.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'CURR_DUE'.

      v_fieldcat_alv-reptext_ddic = text-014.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 8.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_01_30'.

      v_fieldcat_alv-reptext_ddic = text-015.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 9.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_31_60'.

      v_fieldcat_alv-reptext_ddic = text-016.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 10.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_61_90'.

      v_fieldcat_alv-reptext_ddic = text-017.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 11.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_91_180'.

      v_fieldcat_alv-reptext_ddic = text-018.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 12.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_181_365'.

      v_fieldcat_alv-reptext_ddic = text-019.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 13.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_GT_365'.

      v_fieldcat_alv-reptext_ddic = text-020.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 14.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'SPCOL'.

      v_fieldcat_alv-reptext_ddic = text-024.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 15.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'TOT_DUE'.

      v_fieldcat_alv-reptext_ddic = text-021.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 16.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'TOT_AR'.

      v_fieldcat_alv-reptext_ddic = text-022.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 17.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'WAERS'.

      v_fieldcat_alv-reptext_ddic = text-023.

      v_fieldcat_alv-outputlen = 4.

      v_fieldcat_alv-col_pos = 18.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'ZUONR'.

      v_fieldcat_alv-reptext_ddic = text-010.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 2.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'BLDAT'.

      v_fieldcat_alv-reptext_ddic = text-011.

      v_fieldcat_alv-outputlen = 10.

      v_fieldcat_alv-col_pos = 3.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_DATE'.

      v_fieldcat_alv-reptext_ddic = text-012.

      v_fieldcat_alv-outputlen = 10.

      v_fieldcat_alv-col_pos = 4.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'V_NO_DAYS'.

      v_fieldcat_alv-reptext_ddic = text-072.

      v_fieldcat_alv-outputlen = 10.

      v_fieldcat_alv-col_pos = 5.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'ZTERM'.

      v_fieldcat_alv-reptext_ddic = text-060.

      v_fieldcat_alv-outputlen = 8.

      v_fieldcat_alv-col_pos = 6.

      append v_fieldcat_alv to i_fieldcat_alv.

      endform. " f_fieldcat_build

      ----


      • Form f_sortinfo_build

      ----


      • To sort the fields

      ----


      form f_sortinfo_build.

      refresh: i_sort.

      v_sort-fieldname = 'KNKLI'.

      v_sort-spos = 1.

      v_sort-up = 'X'.

      append v_sort to i_sort.

      clear v_sort.

      v_sort-fieldname = 'KUNNR1'.

      v_sort-spos = 2.

      v_sort-up = 'X'.

      v_sort-subtot = 'X'.

      v_sort-group = '*'.

      append v_sort to i_sort.

      clear v_sort.

      endform. " f_sortinfo_build

      ----


      • Form F_print_build

      ----


      • To print selection screen information

      ----


      form f_print_build.

      v_print-no_print_selinfos = ' '.

      endform. "F_print_build

      ----


      • Form f_event_build

      ----


      • To trigger the events

      ----


      form f_event_build.

      refresh i_events.

      call function 'REUSE_ALV_EVENTS_GET'

      exporting

      i_list_type = 0

      importing

      et_events = i_events.

      read table i_events with key name = slis_ev_subtotal_text

      into v_events.

      if sy-subrc = 0.

      move c_subtotal_text to v_events-form.

      modify i_events from v_events index sy-tabix.

      endif.

      read table i_events with key name = slis_ev_top_of_page

      into v_events.

      if sy-subrc = 0.

      move c_formname_top_of_page to v_events-form.

      modify i_events from v_events index sy-tabix.

      endif.

      endform. " f_event_build

      ----


      • Form F_layout_build

      ----


      • To Maintain Layout settings.

      ----


      form f_layout_build.

      v_layout-get_selinfos = 'X'.

      v_layout-colwidth_optimize = 'X'.

      endform. "F_layout_build

      ----


      • Form f_display_data_detail

      ----


      • To display the detailed report in list format

      ----


      form f_display_data_detail.

      if not p_vari is initial.

      v_variant-variant = p_vari.

      endif.

      call function 'SAPGUI_PROGRESS_INDICATOR'

      exporting

      text = text-070.

      v_repid = sy-repid.

      call function 'REUSE_ALV_LIST_DISPLAY'

      exporting

      i_callback_program = v_repid

      it_fieldcat = i_fieldcat_alv

      it_events = i_events

      it_sort = i_sort

      is_layout = v_layout

      i_save = 'A'

      is_variant = v_variant

      is_print = v_print

      tables

      t_outtab = i_output.

      if sy-subrc <> 0. "#EC *

      message id sy-msgid type sy-msgty number sy-msgno

      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      endif.

      endform. " f_display_data_detail

      ----


      • Form summary_report_alv

      ----


      • Summary report details

      ----


      form summary_report_alv.

      • To fill the summary internal table

      perform get_data_summary.

      • To maintain column headings.

      perform f_fieldcat_build_summ.

      • To print selection screen information

      perform f_print_build.

      • To trigger the events

      perform f_event_build_summ.

      • To Maintain Layout settings.

      perform f_layout_build_sum.

      • To display the output

      perform f_display_data_summ.

      endform. " summary_report_alv

      ----


      • Form get_data_summary

      ----


      • To fill the summary report

      ----


      form get_data_summary.

      sort i_output by kunnr.

      loop at i_output.

      • To get the total.

      perform sum_cust.

      at end of kunnr.

      move: i_output-bukrs to i_output_summary-bukrs,

      i_output-kunnr to i_output_summary-kunnr,

      v_sbgrp1 to i_output_summary-sbgrp,

      v_busab1 to i_output_summary-busab,

      v_zterm1 to i_output_summary-zterm,

      v_name to i_output_summary-name1,

      v_kvgr to i_output_summary-kvgr1,

      v_klimk1 to i_output_summary-klimk,

      v_kdgrp1 to i_output_summary-kdgrp,

      v_cust_not_due to i_output_summary-not_due,

      v_cust_curr_due to i_output_summary-curr_due,

      v_cust_due_01_30 to i_output_summary-due_01_30,

      v_cust_due_31_60 to i_output_summary-due_31_60,

      v_cust_due_61_90 to i_output_summary-due_61_90,

      v_cust_due_91_180 to i_output_summary-due_91_180,

      v_cust_due_181_365 to i_output_summary-due_181_365,

      v_cust_due_gt_365 to i_output_summary-due_gt_365,

      v_cust_spcol to i_output_summary-spcol,

      v_cust_tot_due to i_output_summary-tot_due,

      v_cust_tot_ar to i_output_summary-tot_ar,

      v_curr to i_output_summary-waers.

      append i_output_summary.

      clear i_output_summary.

      clear: v_cust_not_due, v_cust_curr_due,v_cust_due_01_30,

      v_cust_due_31_60, v_cust_due_61_90, v_cust_due_91_180,

      v_cust_due_181_365,v_cust_due_gt_365,v_cust_spcol,

      v_cust_tot_due,v_cust_tot_ar,v_curr,v_name,v_kvgr,v_kdgrp1.

      endat.

      endloop.

      endform. " get_data_summary

      ----


      • Form f_fieldcat_build_summ

      ----


      • To maintain the fieldcatalog for summary report

      ----


      form f_fieldcat_build_summ.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KUNNR'.

      v_fieldcat_alv-reptext_ddic = text-007.

      v_fieldcat_alv-col_pos = 1.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'NAME1'.

      v_fieldcat_alv-reptext_ddic = text-003.

      v_fieldcat_alv-outputlen = 35.

      v_fieldcat_alv-col_pos = 2.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KVGR1'.

      v_fieldcat_alv-reptext_ddic = text-009.

      v_fieldcat_alv-col_pos = 3.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'SBGRP'.

      v_fieldcat_alv-reptext_ddic = text-078.

      v_fieldcat_alv-col_pos = 4.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'BUSAB'.

      v_fieldcat_alv-reptext_ddic = text-077.

      v_fieldcat_alv-col_pos = 5.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KLIMK'.

      v_fieldcat_alv-reptext_ddic = text-006.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 6.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'KDGRP'.

      v_fieldcat_alv-reptext_ddic = text-002.

      v_fieldcat_alv-col_pos = 7.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'ZTERM'.

      v_fieldcat_alv-reptext_ddic = text-081.

      v_fieldcat_alv-outputlen = 9.

      v_fieldcat_alv-col_pos = 8.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'NOT_DUE'.

      v_fieldcat_alv-reptext_ddic = text-013.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 9.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'CURR_DUE'.

      v_fieldcat_alv-reptext_ddic = text-014.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 10.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_01_30'.

      v_fieldcat_alv-reptext_ddic = text-015.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 11.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_31_60'.

      v_fieldcat_alv-reptext_ddic = text-016.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 12.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_61_90'.

      v_fieldcat_alv-reptext_ddic = text-017.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 13.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_91_180'.

      v_fieldcat_alv-reptext_ddic = text-018.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 14.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_181_365'.

      v_fieldcat_alv-reptext_ddic = text-019.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 15.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'DUE_GT_365'.

      v_fieldcat_alv-reptext_ddic = text-020.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 16.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'SPCOL'.

      v_fieldcat_alv-reptext_ddic = text-024.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 19.

      v_fieldcat_alv-col_pos = 17.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'TOT_DUE'.

      v_fieldcat_alv-reptext_ddic = text-021.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 18.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'TOT_AR'.

      v_fieldcat_alv-reptext_ddic = text-022.

      v_fieldcat_alv-do_sum = 'X'.

      v_fieldcat_alv-outputlen = 18.

      v_fieldcat_alv-col_pos = 19.

      append v_fieldcat_alv to i_fieldcat_alv.

      clear v_fieldcat_alv.

      v_fieldcat_alv-fieldname = 'WAERS'.

      v_fieldcat_alv-reptext_ddic = text-023.

      v_fieldcat_alv-outputlen = 4.

      v_fieldcat_alv-col_pos = 20.

      append v_fieldcat_alv to i_fieldcat_alv.

      endform. " f_fieldcat_build_summ

      ----


      • Form f_event_build_summ

      ----


      • To trigger the events

      ----


      form f_event_build_summ.

      refresh i_events.

      call function 'REUSE_ALV_EVENTS_GET'

      exporting

      i_list_type = 0

      importing

      et_events = i_events.

      read table i_events with key name = slis_ev_top_of_page

      into v_events.

      if sy-subrc = 0.

      move c_formname_top_of_page_summ to v_events-form.

      modify i_events from v_events index sy-tabix.

      endif.

      endform. "f_display_data_summ

      ----


      • Form F_layout_build

      ----


      • To Maintain Layout settings.

      ----


      form f_layout_build_sum.

      v_layout-totals_only = 'X'.

      v_layout-totals_text = 'Grand Total'.

      v_layout-get_selinfos = 'X'.

      v_layout-colwidth_optimize = 'X'.

      endform. "F_layout_build

      ----


      • Form f_display_data_summ

      ----


      • To display the summary report in AlV list format

      ----


      form f_display_data_summ.

      if not p_vari is initial.

      v_variant-variant = p_vari.

      endif.

      call function 'SAPGUI_PROGRESS_INDICATOR'

      exporting

      text = text-070.

      v_repid = sy-repid.

      call function 'REUSE_ALV_LIST_DISPLAY'

      exporting

      i_callback_program = v_repid

      it_fieldcat = i_fieldcat_alv

      it_events = i_events

      it_sort = i_sort1

      is_layout = v_layout

      i_save = 'A'

      is_variant = v_variant

      is_print = v_print

      tables

      t_outtab = i_output_summary.

      if sy-subrc <> 0. "#EC *

      message id sy-msgid type sy-msgty number sy-msgno

      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      endif.

      endform. " f_display_data_summ

      ----


      • Form f_top_of_page

      ----


      • To trigger the top-of-page event

      ----


      form f_top_of_page.

      if v_flag ne 'Y'.

      set blank lines on.

      • To maintain the selection screen data on top-of-page

      perform top_of_page.

      endif.

      move: i_output-bukrs to v_bukrs,

      i_output-kdgrp to v_kdgrp,

      i_output-name1 to v_name1,

      i_output-knkli to v_knkli,

      i_output-zterm1 to v_zterm,

      i_output-klimk to v_klimk,

      i_output-kvgr1 to v_kvgr1,

      i_output-sbgrp to v_sbgrp,

      i_output-busab to v_busab.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-057 to v_list_comments-info+0(15),

      v_knkli to v_list_comments-info+15(12),

      text-058 to v_list_comments-info+27(13),

      v_klimk to v_list_comments-info+40(20).

      append v_list_comments to i_list_comments .

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-068 to v_list_comments-info+0(15),

      v_kdgrp to v_list_comments-info+15(12),

      text-071 to v_list_comments-info+27(22),

      v_zterm to v_list_comments-info+49(11).

      append v_list_comments to i_list_comments .

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-061 to v_list_comments-info+0(13),

      v_bukrs to v_list_comments-info+13(14),

      text-062 to v_list_comments-info+27(14),

      v_kvgr1 to v_list_comments-info+41(19).

      append v_list_comments to i_list_comments .

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-079 to v_list_comments-info+0(17),

      v_busab to v_list_comments-info+17(10),

      text-080 to v_list_comments-info+27(17),

      v_sbgrp to v_list_comments-info+44(16).

      append v_list_comments to i_list_comments .

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-063 to v_list_comments-info+0(14),

      v_name1 to v_list_comments-info+14(35).

      append v_list_comments to i_list_comments .

      clear v_list_comments.

      v_flag = 'Y'.

      call function 'REUSE_ALV_COMMENTARY_WRITE'

      exporting

      it_list_commentary = i_list_comments.

      set blank lines off.

      refresh i_list_comments.

      endform. "f_top_of_page

      ----


      • Form f_top_of_page_summ

      ----


      • To trigger the top-of-page event

      ----


      form f_top_of_page_summ.

      refresh i_list_comments.

      • To maintain the selection screen data on top-of-page

      perform top_of_page.

      • List body comment block output

      call function 'REUSE_ALV_COMMENTARY_WRITE'

      exporting

      i_logo = 'ENJOYSAP_LOGO'

      it_list_commentary = i_list_comments.

      endform. "F_TOP_OF_PAGE_SUMM

      ----


      • Form top_of_page

      ----


      • To maintain the headings in top_of_page

      ----


      form top_of_page.

      data: v_bukrslow(20) type c,

      v_kvgr1low type knvv-kvgr1,

      v_kvgr1high type knvv-kvgr1,

      v_datelow(10) type c,

      v_datehigh(10) type c,

      v_kunnrlow type bsid-kunnr,

      v_kunnrhigh type bsid-kunnr,

      v_knklilow type knkk-knkli,

      v_knklihigh type knkk-knkli,

      v_kdgrplow type knkk-kdgrp,

      v_kdgrphigh type knkk-kdgrp,

      v_str_len type i,

      v_sbgrplow type knkk-sbgrp,

      v_sbgrphigh type knkk-sbgrp,

      v_busablow type knb1-busab,

      v_busabhigh type knb1-busab.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-061 to v_list_comments-info+0(13),

      p_bukrs to v_list_comments-info+13(20).

      append v_list_comments to i_list_comments .

      clear v_list_comments .

      if not s_kvgr1[] is initial.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: s_kvgr1-low to v_kvgr1low.

      if s_kvgr1-high is initial.

      move: s_kvgr1-low to v_kvgr1high.

      else.

      move: s_kvgr1-high to v_kvgr1high.

      endif.

      concatenate text-059 v_kvgr1low 'TO' v_kvgr1high

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if not s_sbgrp[] is initial.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: s_sbgrp-low to v_sbgrplow.

      if s_sbgrp-high is initial.

      move: s_sbgrp-low to v_sbgrphigh.

      else.

      move: s_sbgrp-high to v_sbgrphigh.

      endif.

      concatenate text-074 v_sbgrplow 'TO' v_sbgrphigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if not s_busab[] is initial.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: s_busab-low to v_busablow.

      if s_sbgrp-high is initial.

      move: s_busab-low to v_busabhigh.

      else.

      move: s_busab-high to v_busabhigh.

      endif.

      concatenate text-075 v_busablow 'TO' v_busabhigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if not s_budat[] is initial.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      write s_budat-low to v_datelow using edit mask '__/__/____'.

      if s_budat-high is initial.

      write s_budat-low to v_datehigh using edit mask '__/__/____'.

      else.

      write s_budat-high to v_datehigh using edit mask '__/__/____'.

      endif.

      concatenate text-h01 v_datelow 'TO' v_datehigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if not s_kunnr[] is initial.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: s_kunnr-low to v_kunnrlow.

      if s_kunnr-high is initial.

      move: s_kunnr-low to v_kunnrhigh.

      else.

      move: s_kunnr-high to v_kunnrhigh.

      endif.

      concatenate text-076 v_kunnrlow 'TO' v_kunnrhigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      clear v_list_comments.

      endif.

      if p_lk_on = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      v_list_comments-info = text-h08.

      append v_list_comments to i_list_comments.

      endif.

      if p_knkli = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: s_knkli-low to v_knklilow.

      if s_knkli-high is initial.

      move: s_knkli-low to v_knklihigh.

      else.

      move: s_knkli-high to v_knklihigh.

      endif.

      concatenate text-h03 v_knklilow 'TO' v_knklihigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if p_kdgrp = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      write s_kdgrp-low to v_kdgrplow.

      if s_kdgrp-high is initial.

      move: s_kdgrp-low to v_kdgrphigh.

      else.

      move: s_kdgrp-high to v_kdgrphigh.

      endif.

      concatenate text-h04 v_kdgrplow 'TO' v_kdgrphigh

      into v_list_comments-info separated by space.

      append v_list_comments to i_list_comments.

      endif.

      if p_all_lk = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-h05 to v_list_comments-info.

      append v_list_comments to i_list_comments.

      endif.

      if p_ab = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-h06 to v_list_comments-info.

      append v_list_comments to i_list_comments.

      endif.

      if p_op_ab = 'X'.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: text-h07 to v_list_comments-info.

      append v_list_comments to i_list_comments.

      endif.

      clear v_list_comments.

      v_list_comments-typ = 'H'.

      move: space to v_list_comments-info.

      append v_list_comments to i_list_comments.

      endform. "top_of_page

      ----


      • Form subtotal_text

      ----


      • To maintain the sub-total text

      ----


      form alv_subtotals using t_output

      my_subtotal type slis_subtot_text.

      clear: v_kunnr.

      if p_op_ab = 'X'.

      v_kunnr = i_output-kunnr1.

      endif.

      clear my_subtotal-display_text_for_subtotal.

      case my_subtotal-criteria.

      when 'KUNNR1'.

      concatenate text-064 v_kunnr into

      my_subtotal-display_text_for_subtotal separated by space.

      when space.

      concatenate text-066 space into

      my_subtotal-display_text_for_subtotal separated by space.

      endcase.

      endform. "ALV_SUBTOTALS

      ----


      • Form sum_cust

      ----


      • To calculate the sum based on customer

      ----


      form sum_cust .

      v_cust_not_due = v_cust_not_due + i_output-not_due.

      v_cust_curr_due = v_cust_curr_due + i_output-curr_due.

      v_cust_due_01_30 = v_cust_due_01_30 + i_output-due_01_30.

      v_cust_due_31_60 = v_cust_due_31_60 + i_output-due_31_60.

      v_cust_due_61_90 = v_cust_due_61_90 + i_output-due_61_90.

      v_cust_due_91_180 = v_cust_due_91_180 + i_output-due_91_180.

      v_cust_due_181_365 = v_cust_due_181_365 + i_output-due_181_365.

      v_cust_due_gt_365 = v_cust_due_gt_365 + i_output-due_gt_365.

      v_cust_spcol = v_cust_spcol + i_output-spcol.

      v_cust_tot_due = v_cust_tot_due + i_output-tot_due.

      v_cust_tot_ar = v_cust_tot_ar + i_output-tot_ar.

      v_curr = i_output-waers.

      v_name = i_output-name1.

      v_kvgr = i_output-kvgr1.

      v_kdgrp1 = i_output-kdgrp.

      v_klimk1 = i_output-klimk.

      v_zterm1 = i_output-zterm1.

      v_sbgrp1 = i_output-sbgrp.

      v_busab1 = i_output-busab.

      endform. " sum_cust

      ----


      • END-OF-PROGRAM

      ----


  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 02:10 PM

    Hi venu,

    check this link:

    http://www.abap4.it/download/ALV.pdf

    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid

    reward if helpful.

    regards,

    keerthi.

    Add comment
    10|10000 characters needed characters exceeded