Multiple tables in ALV / Normal report

Hi,
I have an internal table ,INT with 4 fields a,b,c and d.
i want to group the table by field A and display report. I want to display report in groups ..
for ex:
PERSAREA         NAME         AGE
0001                    sfsdf              45
0001                    ffffffffff             54
0001                    ggggg            67
PERSAREA         NAME         AGE
0004                    sfsdf              45
0004                    ffffffffff             54
PERSAREA         NAME         AGE
0009                    rrrrrrrrr            45
0009                    jjjjjjjjjjjjj           54
I need to display table header for each group. The groups should be separated by lines.
Whts the best way to do? ALV/Normal ?
<<removed by moderator>>
Regards,
JV.

Hi,
    Do with Normal report with Control break statements( AT and ENDAT events in LOOP and ENDLOOP.
Regards
Bala Krishna

Similar Messages

  • How to use one query against multiple table and recieve one report?

    I have duplicate tables, (except for their names of course) with commodities prices. They have the same column headings, but the data is different of course. I have a query that gives me a certain piece of information I am looking for but now I need to run this query against every table. I will do this every day as well, to see if the buying criteria is met. There are alot of tables though (256). Is there a way to say run query in all tables and return the results in one place? Thanks for your help.

    hey
    a. the all 256 tables whuld be one big partitoned table
    b. you can use all_tables in order to write a select that will write the report for you:
    SQL> set head off
    SQL> select 'select * from (' from dual
      2  union all
      3  select 'select count(*) from ' || table_name || ' union all ' from a
      4  where table_name like 'DB%' AND ROWNUM <= 3
      5  union all
      6  select ')' from dual;
    select * from (
    select count(*) from DBMS_LOCK_ALLOCATED union all
    select count(*) from DBMS_ALERT_INFO union all
    select count(*) from DBMS_UPG_LOG$ union all
    remove the last 'union all', and tun the generated quary -
    SQL> set head on
    SQL> select * from (
      2  select count(*) from DBMS_LOCK_ALLOCATED union all
      3  select count(*) from DBMS_ALERT_INFO union all
      4  select count(*) from DBMS_UPG_LOG$
      5  );
      COUNT(*)
             0
             0
             0
    Amiel

  • Fatch data in ALV Reports from multiple Tables

    Respected Sir,
    How to fatch data in ALV Grid report from selected Field and selected Table.
    Please Help and My require Field and Table is :
    sono LIKE vbak-vbeln,
           sodat LIKE vbak-erdat,
           cust LIKE kna1-name1,
           pono LIKE vbkd-bstkd,
           podat LIKE vbkd-bstdk,
           item_no LIKE vbap-posnr,
           item_des LIKE vbap-arktx,
           name LIKE vbak-kunnr,
           pdate LIKE vbak-bstdk,
           acdel LIKE lips-lgmng,
           netweight LIKE likp-ntgew,
           ordval LIKE VBRP-netwr,
       CUST_MAT_NO LIKE VBAP-KDMAT,
           order_qty LIKE vbap-kwmeng,
           desp_qty(5) TYPE p DECIMALS 2, "LIKE lips-lfimg,
           balance(5) TYPE p DECIMALS 2,
           delv_no LIKE likp-vbeln,
           delv_dat LIKE likp-bldat,
           invoice LIKE vbrk-vbeln,
           exnum like J_1IEXCHDR-exnum,
           invoice_dat LIKE vbrk-fkdat,
           invoice_val LIKE konv-kwert,
           END OF it_out.
    *Please Refere the following code and if u wnt to change at ur own ieda u can change and reply me back.*
    *Thnaks In ADVANCE.*
    *Please Do  need full it.*
    *Bhavesh Panchal*
    *Baroda*
    Also I Make Reports For SO : full coding is.
    *& Report  Z_NEW1
    REPORT  Z_NEW1.
    TABLES : vbak,    "Sales Document: Header Data
             vbkd,    "Sales Document: Business Data
             likp,    "SD Document: Delivery Header Data
             vbrk,    "Billing Document: Header Data
             konv,    "Conditions (Transaction Data)
             lips,    "SD document: Delivery: Item data
             vbap,    "Sales Document: Item Data
             vbrp,    "Billing Document: Item Data
             kna1,    "General Data in Customer Master
             J_1IEXCHDR.
    DATA : i_vbak LIKE vbak OCCURS 10 WITH HEADER LINE.
    DATA : it_vbkd LIKE vbkd OCCURS 10 WITH HEADER LINE.
    DATA : it_likp LIKE likp OCCURS 10 WITH HEADER LINE.
    DATA : it_vbrk LIKE vbrk OCCURS 10 WITH HEADER LINE.
    DATA : it_konv LIKE konv OCCURS 10 WITH HEADER LINE.
    DATA : it_lips LIKE lips OCCURS 10 WITH HEADER LINE.
    DATA : it_vbap LIKE vbap OCCURS 10 WITH HEADER LINE.
    DATA : it_vbrp LIKE vbrp OCCURS 10 WITH HEADER LINE.
    DATA : it_kna1 LIKE kna1 OCCURS 10 WITH HEADER LINE.
    DATA : it_vbrp1 LIKE vbrp OCCURS 10 WITH HEADER LINE.
    DATA : it_temp LIKE lips OCCURS 10 WITH HEADER LINE.
    DATA : it_lips1 LIKE lips OCCURS 10 WITH HEADER LINE.
    DATA : it_lips2 LIKE lips OCCURS 10 WITH HEADER LINE.
    DATA : it_lips3 LIKE lips OCCURS 10 WITH HEADER LINE.
    DATA : it_vbak1 LIKE vbak OCCURS 10 WITH HEADER LINE.
    DATA : it_vbak2 LIKE vbak OCCURS 10 WITH HEADER LINE.
    DATA : it_vbap1 LIKE vbap OCCURS 10 WITH HEADER LINE.
    DATA : it_posnv LIKE zdelprt OCCURS 10 WITH HEADER LINE.
    DATA : BEGIN OF it_out OCCURS 10,
           sono LIKE vbak-vbeln,
           sodat LIKE vbak-erdat,
           cust LIKE kna1-name1,
           pono LIKE vbkd-bstkd,
           podat LIKE vbkd-bstdk,
           item_no LIKE vbap-posnr,
           item_des LIKE vbap-arktx,
           name LIKE vbak-kunnr,
           pdate LIKE vbak-bstdk,
           acdel LIKE lips-lgmng,
           netweight LIKE likp-ntgew,
           ordval LIKE VBRP-netwr,
       CUST_MAT_NO LIKE VBAP-KDMAT,
           order_qty LIKE vbap-kwmeng,
           desp_qty(5) TYPE p DECIMALS 2, "LIKE lips-lfimg,
           balance(5) TYPE p DECIMALS 2,
           delv_no LIKE likp-vbeln,
           delv_dat LIKE likp-bldat,
           invoice LIKE vbrk-vbeln,
           exnum like J_1IEXCHDR-exnum,
           invoice_dat LIKE vbrk-fkdat,
           invoice_val LIKE konv-kwert,
           END OF it_out.
    SELECT-OPTIONS: sono FOR vbak-vbeln.
    SELECT-OPTIONS: customer FOR vbak-kunnr.
    SELECT-OPTIONS: d_date FOR likp-bldat.
       LOOP AT it_OUT.
       select * into table i_vbak from vbak
       where vbeln IN sono.
       sono = vbak-vbeln.
       append it_out.
       modify it_out.
       endloop.
    LOOP AT it_out.
          SELECT single vbeln netwr FROM vbak
              INTO (it_out-pono,it_out-podat)
              WHERE vbeln = it_out-sono.
              "it_out-item_no.
         append it_out.
       ENDLOOP.
        select * into table i_vbak from vbak
        where vbeln IN sono.
        call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
        i_structure_name = 'VBAK'
        I_grid_title     = 'Bhavesh Panchal'
        tables
        t_outtab = i_vbak
        t_outtab = it_out
         exceptions
         others = 1.

    Hi Bhavesh Panchal  ,
    You have to create another internal table with fields which you would like to display in the ALV output.
    once you fetch the data from different tables into respective internal tables.  loop those internal tables and insert the field values to internal table which you want to display in ALV output.
    Create  field catalog for the internal table created for  ALV  output.
    Hope it shall be useful.
    Regards
    Santosh Kumaar.M

  • Can i use classes or grid control (alv) in normal report

    Hai,
    Can i use Grid control or classes in normal report.If yes what are the steps that i have to go for.
    thanks
    kiran

    Sure... here is a sample of an ALV in a report.  All you need to do is call a screen.  I believe that there is also a way to do it without having to create a screen.
    REPORT ZRICH_0001.
    DATA: BEGIN OF I_ALV OCCURS 0,
          MATNR TYPE MARA-MATNR,
          MAKTX TYPE MAKT-MAKTX,
          END OF I_ALV.
    DATA: ALV_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: ALV_GRID       TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LAYOUT    TYPE LVC_S_LAYO.
    DATA: FIELDCAT  TYPE LVC_T_FCAT.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS: S_MATNR FOR i_ALV-MATNR.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      CALL SCREEN 100.
    *      Module  status_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
      SET TITLEBAR '0100'.
      DATA: VARIANT TYPE  DISVARIANT.
      VARIANT-REPORT = SY-REPID.
      VARIANT-USERNAME = SY-UNAME.
    * Create Controls
      CREATE OBJECT ALV_CONTAINER
             EXPORTING
                   CONTAINER_NAME    = 'ALV_CONTAINER'.
      CREATE OBJECT ALV_GRID
             EXPORTING
                   I_PARENT          =  ALV_CONTAINER.
    *  ALV Specific. Data selection.
    *  Populate Field Catalog
      PERFORM GET_FIELDCATALOG.
      CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
               IS_LAYOUT              = LAYOUT
               IS_VARIANT             = VARIANT
               I_SAVE                 = 'U'
               I_STRUCTURE_NAME       = 'I_ALV'
          CHANGING
               IT_OUTTAB       = I_ALV[]
               IT_FIELDCATALOG = FIELDCAT[].
    ENDMODULE.
    *      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK' OR 'CANC'.
          IF NOT ALV_CONTAINER IS INITIAL.
            CALL METHOD ALV_CONTAINER->FREE.
            CLEAR: ALV_CONTAINER.
            FREE : ALV_CONTAINER.
          ENDIF.
          IF SY-SUBRC = 0.
            SET SCREEN 0.
            LEAVE SCREEN.
          ELSE.
            LEAVE PROGRAM.
          ENDIF.
        WHEN 'EXIT'.
          IF NOT ALV_CONTAINER IS INITIAL.
            CALL METHOD ALV_CONTAINER->FREE.
            CLEAR: ALV_CONTAINER.
            FREE : ALV_CONTAINER.
          ENDIF.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.
    * FORM GET_DATA
    FORM GET_DATA.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
            FROM MARA
              INNER JOIN MAKT
                ON MARA~MATNR = MAKT~MATNR
                   WHERE MARA~MATNR IN S_MATNR
                     AND MAKT~SPRAS = SY-LANGU.
      SORT I_ALV ASCENDING BY MATNR.
    ENDFORM.
    *      Form  Get_Fieldcatalog - Set Up Columns/Headers
    FORM GET_FIELDCATALOG.
      DATA: LS_FCAT TYPE LVC_S_FCAT.
      REFRESH: FIELDCAT.
      CLEAR: LS_FCAT.
      LS_FCAT-REPTEXT    = 'Material Number'.
      LS_FCAT-COLTEXT    = 'Material Number'.
      LS_FCAT-FIELDNAME  = 'MATNR'.
      LS_FCAT-REF_TABLE  = 'I_ALV'.
      LS_FCAT-OUTPUTLEN  = '18'.
      LS_FCAT-COL_POS    = 1.
      APPEND LS_FCAT TO FIELDCAT.
      CLEAR: LS_FCAT.
      LS_FCAT-REPTEXT    = 'Material Description'.
      LS_FCAT-COLTEXT    = 'Material Description'.
      LS_FCAT-FIELDNAME  = 'MAKTX'.
      LS_FCAT-REF_TABLE  = 'I_ALV'.
      LS_FCAT-OUTPUTLEN  = '40'.
      LS_FCAT-COL_POS    = 2.
      APPEND LS_FCAT TO FIELDCAT.
    ENDFORM.
    Regards,
    Rich Heilman

  • How to select multiple lines in ALV report

    hi gurus,
    I am working on an interactive ALV report where i have to select multiple lines from the basic list into an internal table, based on check box clicks. Using RS_SELFIELD i can select only 1 row. The coding has been done based on Call Function. Can u please suggest some way.
    Regards,
    Satyajit

    hi,
    try like this
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    TYPES: BEGIN OF t_ekko,
      sel,                         "stores which row user has selected
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          fieldcatalog1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid.
    DATA : BEGIN OF det_tab OCCURS 0,
            ebeln LIKE ekpo-ebeln,
           END OF det_tab.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM build_layout.
      gd_layout-box_fieldname     = 'SEL'.
      "set field name to store row selection
      gd_layout-edit              = 'X'. "makes whole ALV table editable
      gd_layout-zebra             = 'X'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = gd_repid
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_STAT'
          is_layout                = gd_layout
          it_fieldcat              = fieldcatalog[]
          i_save                   = 'X'
        TABLES
          t_outtab                 = it_ekko
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
          IF rs_selfield-fieldname = 'EBELN'.
            READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
            SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
            CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
          ENDIF.
        WHEN 'DET'.  "button add by me
          CLEAR det_tab.
          REFRESH det_tab.
          LOOP AT it_ekko INTO wa_ekko WHERE sel = 'X'.
            MOVE-CORRESPONDING wa_ekko TO det_tab.
            APPEND det_tab.
          ENDLOOP.
          PERFORM build_cat.
          PERFORM dis_data.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  set_stat
    *       text
    *      -->RT_EXTAB   text
    FORM set_stat USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTAT' EXCLUDING rt_extab.
    ENDFORM.                    "set_stat
    *&      Form  build_cat
    *       text
    FORM build_cat.
      CLEAR fieldcatalog1.
      REFRESH fieldcatalog1.
      fieldcatalog1-fieldname = 'EBELN'.
      fieldcatalog1-tabname = 'DET_TAB'.
      fieldcatalog1-seltext_m = 'Order No.'.
      fieldcatalog1-outputlen = 10.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR fieldcatalog1.
    ENDFORM.                    "build_cat
    *&      Form  dis_data
    *       text
    FORM dis_data.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_DS'
          it_fieldcat        = fieldcatalog1[]
          i_save             = 'X'
        TABLES
          t_outtab           = det_tab.
    ENDFORM.                    "dis_data
    here i have copied standard gui status of ALV into my z status ZSTAT and add one button DET......
    here u can select morethan one line using control(ctrl)
    reward if usefull...

  • I have a normal report , i need to make it into ALV,

    Hi,
    i have a normal report and i need to make it into ALV Report in ECC5.0version. when i making it into ALV its giving blank.
    can any one help me out to make below code in to ALV report.
    REPORT ZSAMPLE line-size 260
                      line-count 65
                      no standard page heading.
    ====================================================================
    TABLES *********************************
    ====================================================================
    tables : bseg,
             bkpf,
             kna1,
             bsid,
             bsad,
             knb1.
    data : begin of customer_tab occurs 0,
              kunnr         like kna1-kunnr,
              name1         like kna1-name1,
              flag(1)       type c,
           end of customer_tab.
    data : begin of customerdoc_tab occurs 0,
              kunnr         like kna1-kunnr,
              belnr         like bkpf-belnr,
              gjahr         like bkpf-gjahr,
              monat         like bkpf-monat,
           end of customerdoc_tab.
    data : begin of doc_tab occurs 0,
              belnr         like bkpf-belnr,
              gjahr         like bkpf-gjahr,
              monat         like bkpf-monat,
           end of doc_tab.
    DATA: BEGIN OF BSID_TAB OCCURS 0,
             BUKRS LIKE BSID-BUKRS,
             PRCTR LIKE BSID-PRCTR,
             KUNNR LIKE BSID-KUNNR,
             FLAG(1),
             UMSKZ LIKE BSID-UMSKZ,
             BLART LIKE BSID-BLART,
             BELNR LIKE BSID-BELNR,
             BUZEI LIKE BSID-BUZEI,
             NETDT LIKE BSID-ZFBDT,
             ZFBDT LIKE BSID-ZFBDT,
             BUDAT LIKE BSID-BUDAT,
             BLDAT LIKE BSID-BLDAT,
             BSCHL LIKE BSID-BSCHL,
             DMBTR LIKE BSID-DMBTR,
             SHKZG LIKE BSID-SHKZG,
             ZBD1T LIKE BSID-ZBD1T,
             ZBD2T LIKE BSID-ZBD2T,
             ZBD3T LIKE BSID-ZBD3T,
             REBZG LIKE BSID-REBZG,
             REBZT LIKE BSID-REBZT,
             KOART LIKE BSEG-KOART,
             SK1DT LIKE FAEDE-SK1DT,
             SK2DT LIKE FAEDE-SK2DT,
             DAYSD LIKE SY-TABIX,
          END OF BSID_TAB.
    ranges : r_bukrs for bsid-bukrs,
             r_kunnr for kna1-kunnr.
    ===================================================================
    VARIABLES *******************************
    ===================================================================
    data : v_belnr     like  bseg-belnr,
           v_gjahr     like  bkpf-gjahr,
           v_monat     like  bkpf-monat,
           v_ttlc      type  p,
           v_flag(1)   type  c,
           V_COUNT1(4) TYPE  N,
           V_COUNT2(4) TYPE  N,
           V_COUNT3(4) TYPE  N,
           V_COUNT4(4) TYPE  N,
           V_COUNT5(4) TYPE  N,
           V_COUNT6(4) TYPE  N,
           V_COUNT7(4) TYPE  N,
           V_COUNT8(4) TYPE  N,
           V_COUNT9(4) TYPE  N,
           V_COUNT10(4) TYPE  N,
           V_NET1      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 1
           V_NET2      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 2
           V_NET3      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 3
           V_NET4      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 4
           V_NET5      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 5
           V_NET6      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 6
           V_NET7      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 7
           V_NET8      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 8
           V_NET9      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 9
           V_NET10      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 10
           V_NET11      LIKE  BSID-DMBTR, "CALCULATE CUSTOMER AGE 11
           V_NET       LIKE  BSID-DMBTR, "Total Balance of Customer
           V_ttlNET1   LIKE  BSID-DMBTR,
           V_ttlNET2   LIKE  BSID-DMBTR,
           V_ttlNET3   LIKE  BSID-DMBTR,
           V_ttlNET4   LIKE  BSID-DMBTR,
           V_ttlNET5   LIKE  BSID-DMBTR,
           V_ttlNET6   LIKE  BSID-DMBTR,
           V_ttlNET7   LIKE  BSID-DMBTR,
           V_ttlNET8   LIKE  BSID-DMBTR,
           V_ttlNET9   LIKE  BSID-DMBTR,
           V_ttlNET10   LIKE  BSID-DMBTR,
           V_ttlNET11   LIKE  BSID-DMBTR,
           V_ttlNET    LIKE  BSID-DMBTR,
           v_kunnr     like  bseg-kunnr,
           V_BUTXT     like t001-butxt.
    ===================================================================
    SELECTION SCREEN ****************************
    ===================================================================
    selection-screen begin of block b1 with frame title text-001.
    parameters :     p_bukrs    like bseg-bukrs obligatory.
    select-options : s_kunnr    for  kna1-kunnr,
                     s_BRSCH    for  kna1-BRSCH,
                     s_REGIO    for  kna1-REGIO,
                     s_KTOKD    for  kna1-KTOKD,
                     s_BUSAB    for  knb1-BUSAB.
    selection-screen: end of block b1.
    selection-screen begin of block b2 with frame title text-003.
    PARAMETERS: DAT LIKE SY-DATUM DEFAULT SY-DATUM.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) TEXT-002.
    SELECTION-SCREEN POSITION POS_LOW.
    *PARAMETERS: RASTBIS1 LIKE RFPDO1-ALLGROGR DEFAULT '000'.
    *PARAMETERS: RASTBIS2 LIKE RFPDO1-ALLGROGR DEFAULT '030'.
    *PARAMETERS: RASTBIS3 LIKE RFPDO1-ALLGROGR DEFAULT '060'.
    *PARAMETERS: RASTBIS4 LIKE RFPDO1-ALLGROGR DEFAULT '090'.
    *PARAMETERS: RASTBIS5 LIKE RFPDO1-ALLGROGR DEFAULT '120'.
    PARAMETERS: RASTBIS1(4) type n DEFAULT '0000'.
    PARAMETERS: RASTBIS2(4) type n DEFAULT '0030'.
    PARAMETERS: RASTBIS3(4) type n DEFAULT '0060'.
    PARAMETERS: RASTBIS4(4) type n DEFAULT '0090'.
    PARAMETERS: RASTBIS5(4) type n DEFAULT '0120'.
    PARAMETERS: RASTBIS6(4) type n DEFAULT '0150'.
    PARAMETERS: RASTBIS7(4) type n DEFAULT '0180'.
    PARAMETERS: RASTBIS8(4) type n DEFAULT '0210'.
    PARAMETERS: RASTBIS9(4) type n DEFAULT '0240'.
    PARAMETERS: RASTBIS0(4) type n DEFAULT '0270'.
    SELECTION-SCREEN END OF LINE.
    Noted item removed as per FI instruction
    PARAMETERS: P_STAND AS CHECKBOX default 'X',
               P_NOTED AS CHECKBOX ,
                P_SPCAL AS CHECKBOX .
    selection-screen: end of block b2.
    selection-screen begin of block b3 with frame.
    PARAMETERS: allgline like RFPDO1-allgline .
    Parameters : p_balyes type c radiobutton group grp9 default 'X',
                 p_balno  type c radiobutton group grp9.
    selection-screen: end of block b3.
    Check for the Select option
    AT SELECTION-SCREEN.
    IF P_STAND = '' AND P_SPCAL = '' .
      MESSAGE E398(00) WITH 'PLEASE CHOOSE AT LEAST ONE G/L INDICATOR!'.
    ENDIF.
    Check for Company code Authorization
      authority-check object 'F_BKPF_BUK'
         ID 'BUKRS' FIELD p_bukrs
         ID 'ACTVT' FIELD '03'.
      if sy-subrc ne 0.
       message e398(00) with 'You are not Authorized for CC ' p_bukrs.
      Endif.
    ===================================================================
    START-OF-SELECTION ****************************
    ===================================================================
    START-OF-SELECTION.
    V_COUNT1 = RASTBIS1 + 1.
    V_COUNT2 = RASTBIS2 + 1.
    V_COUNT3 = RASTBIS3 + 1.
    V_COUNT4 = RASTBIS4 + 1.
    V_COUNT5 = RASTBIS5 + 1.
    V_COUNT6 = RASTBIS6 + 1.
    V_COUNT7 = RASTBIS7 + 1.
    V_COUNT8 = RASTBIS8 + 1.
    V_COUNT9 = RASTBIS9 + 1.
    V_COUNT10 = RASTBIS0 + 1.
    perform extract_data.
    ===================================================================
    At line Selection *****************************
    ===================================================================
    at line-selection.
    if sy-lilli >= 9 .
       refresh r_bukrs.
       move p_bukrs to r_bukrs-low.
       move 'I' to r_bukrs-sign.
       move 'EQ' to r_bukrs-option.
       append r_bukrs.
       refresh r_kunnr.
       move customer_tab-kunnr to r_kunnr-low.
       move 'I' to r_kunnr-sign.
       move 'EQ' to r_kunnr-option.
       append r_kunnr.
       submit ZFARVR0040  and return
        with p_bukrs = p_bukrs
        with dat     = dat
        with p_stand = p_stand
        with p_spcal = P_SPCAL
        with s_kunnr in r_kunnr.
    endif.
    ===================================================================
    Top of Page *******************************
    ===================================================================
    TOP-OF-PAGE.
      SELECT SINGLE BUTXT FROM T001 INTO V_BUTXT
                          WHERE BUKRS = p_BUKRS .
      WRITE:/73'Customers Aging Analysis',140'PAGE NO.',
      SY-PAGNO.
      WRITE:/002 'COMPANY',
             011 P_BUKRS,
             017 V_BUTXT,
             055 allgline centered,
             140 'DATE :',
             150 sy-datum .
      write:/002 'User',
             011 sy-UNAME,
             140 'Time :',
             150 sy-UZEIT.
      SKIP.
      format color col_heading intensified off.
      WRITE:/  SY-ULINE,
                  SY-VLINE,002 'Customer',
              012 SY-VLINE,013 'Name',
              043 SY-VLINE,048 'CURRENT',
              061 SY-VLINE,065 'FROM  ',V_COUNT1,
              079 SY-VLINE,083 'FROM  ',V_COUNT2,
              097 SY-VLINE,101 'FROM  ',V_COUNT3,
              115 SY-VLINE,119 'FROM  ',V_COUNT4,
              133 SY-VLINE,137 'FROM  ',V_COUNT5,
              151 SY-VLINE,155 'FROM  ',V_COUNT6,
              169 SY-VLINE,173 'FROM  ',V_COUNT7,
              187 SY-VLINE,191 'FROM  ',V_COUNT8,
              205 SY-VLINE,209 'FROM  ',V_COUNT9,
              223 SY-VLINE,228 'FROM  ',V_COUNT10,
              243 SY-VLINE,248 'TOTAL',
              268 SY-VLINE.
      WRITE:/      SY-VLINE,002 'Number',
               12  SY-VLINE,
               43  SY-VLINE,
               061 SY-VLINE,065 'TO    ',RASTBIS2,
               079 SY-VLINE,083 'TO    ',RASTBIS3,
               097 SY-VLINE,101 'TO    ',RASTBIS4,
               115 SY-VLINE,119 'TO    ',RASTBIS5,
               133 SY-VLINE,137 'FROM  ',RASTBIS6,
               151 SY-VLINE,155 'FROM  ',RASTBIS7,
               169 SY-VLINE,173 'FROM  ',RASTBIS8,
               187 SY-VLINE,191 'FROM  ',RASTBIS9,
               205 SY-VLINE,209 'FROM  ',RASTBIS0,
               223 SY-VLINE,
               243 SY-VLINE,
               268 SY-VLINE,
               SY-ULINE.
      format color off.
    ===================================================================
    END-OF-SELECTION ***************************
    ===================================================================
    end-of-selection.
    ===================================================================
    Form : Extract_Data *
    ===================================================================
    form extract_data.
    Select the Customers
       Select t1~kunnr t2~name1
         into corresponding fields of table  customer_tab
         from knb1 as t1 inner join kna1 as t2
              on t2~kunnr = t1~kunnr
                   where t1~bukrs = p_bukrs
                     and t1~kunnr in s_kunnr
                     and t1~BUSAB in s_busab
                     and t2~regio in s_regio
                     and t2~BRSCH in s_BRSCH
                     and t2~KTOKD in s_KTOKD.
       if sy-subrc <> 0.
          message e398(00) with 'No Customers Selected'.
       endif.
       sort customer_tab.
       describe table customer_tab lines v_ttlc.
       v_ttlc = v_ttlc + 10.
       loop at customer_tab.
          v_net1 = 0.
          v_net2 = 0.
          v_net3 = 0.
          v_net4 = 0.
          v_net5 = 0.
          v_net6 = 0.
          v_net7 = 0.
          v_net8 = 0.
          v_net9 = 0.
          v_net10 = 0.
          v_net11 = 0.
          v_net  = 0.
          perform calculate_ageing
                    using
                      p_bukrs
                      customer_tab-kunnr
                      dat
                      RASTBIS1
                      RASTBIS2
                      RASTBIS3
                      RASTBIS4
                      RASTBIS5
                      RASTBIS6
                      RASTBIS7
                      RASTBIS8
                      RASTBIS9
                      RASTBIS0
                      P_STAND
                      ' ' "noted item
                      P_SPCAL
                   changing
                      v_net1
                      v_net2
                      v_net3
                      v_net4
                      v_net5
                      v_net6
                      v_net7
                      v_net8
                      v_net9
                      v_net10
                      v_net11
                      v_net.
          if p_balyes = 'X' or v_net > 0.
            format color col_total.
            write:/  sy-vline,
                    002 customer_tab-kunnr,
                    012 SY-VLINE,013(30) customer_tab-name1,
                    043 SY-VLINE,044(16)  v_net1,
                    061 SY-VLINE,062(16)  v_net2,
                    079 SY-VLINE,080(16)  v_net3,
                    097 SY-VLINE,098(16)  v_net4,
                    115 SY-VLINE,116(16)  v_net5,
                    133 SY-VLINE,134(16)  v_net6,
                    151 SY-VLINE,152(16)  v_net7,
                    169 SY-VLINE,170(16)  v_net8,
                    187 SY-VLINE,188(16)  v_net9,
                    205 SY-VLINE,206(16)  v_net10,
                    223 SY-VLINE,224(16)  v_net11,
                    239 SY-VLINE,240(16)  v_net,
                    258 SY-VLINE.
             format color off.
             hide : customer_tab-kunnr.
             v_ttlnet1 = v_ttlnet1 + v_net1.
             v_ttlnet2 = v_ttlnet2 + v_net2.
             v_ttlnet3 = v_ttlnet3 + v_net3.
             v_ttlnet4 = v_ttlnet4 + v_net4.
             v_ttlnet5 = v_ttlnet5 + v_net5.
             v_ttlnet6 = v_ttlnet6 + v_net6.
             v_ttlnet7 = v_ttlnet7 + v_net7.
             v_ttlnet8 = v_ttlnet8 + v_net8.
             v_ttlnet9 = v_ttlnet9 + v_net9.
             v_ttlnet10 = v_ttlnet10 + v_net10.
             v_ttlnet11 = v_ttlnet11 + v_net11.
             v_ttlnet  = v_ttlnet  + v_net.
          endif.
       endloop.
       ULINE.
           format color col_total.
           write:/  sy-vline,
                    012 SY-VLINE,012(30) ' T O T A L',
                    043 SY-VLINE,044(16)  v_ttlnet1,
                    061 SY-VLINE,062(16)  v_ttlnet2,
                    079 SY-VLINE,080(16)  v_ttlnet3,
                    097 SY-VLINE,098(16)  v_ttlnet4,
                    115 SY-VLINE,116(16)  v_ttlnet5,
                    133 SY-VLINE,134(16)  v_ttlnet6,
                    151 SY-VLINE,152(16)  v_ttlnet7,
                    169 SY-VLINE,170(16)  v_ttlnet8,
                    187 SY-VLINE,188(16)  v_ttlnet9,
                    205 SY-VLINE,206(16)  v_ttlnet10,
                    223 SY-VLINE,224(16)  v_ttlnet11,
                    239 SY-VLINE,240(16)  v_ttlnet,
                    258 SY-VLINE.
          format color off.
       ULINE.
    endform.
    Function to Calculate Aging.
    Form calculate_ageing using
                            bukrs
                            kunnr
                            dat
                            RASTBIS1
                            RASTBIS2
                            RASTBIS3
                            RASTBIS4
                            RASTBIS5
                            RASTBIS6
                            RASTBIS7
                            RASTBIS8
                            RASTBIS9
                            RASTBIS0
                            P_STAND
                            P_NOTED
                            P_SPCAL
                          changing
                            v_net1
                            v_net2
                            v_net3
                            v_net4
                            v_net5
                            v_net6
                            v_net7
                            v_net8
                            v_net9
                            v_net10
                            v_net11
                            v_net.
    DATA: BEGIN OF BSID_TAB1 OCCURS 0,
             BUKRS LIKE BSID-BUKRS,
             PRCTR LIKE BSID-PRCTR,
             KUNNR LIKE BSID-KUNNR,
             FLAG(1),
             UMSKZ LIKE BSID-UMSKZ,
             BLART LIKE BSID-BLART,
             BELNR LIKE BSID-BELNR,
             BUZEI LIKE BSID-BUZEI,
             NETDT LIKE BSID-ZFBDT,
             ZFBDT LIKE BSID-ZFBDT,
             BUDAT LIKE BSID-BUDAT,
             BLDAT LIKE BSID-BLDAT,
             BSCHL LIKE BSID-BSCHL,
             DMBTR LIKE BSID-DMBTR,
             SHKZG LIKE BSID-SHKZG,
             ZBD1T LIKE BSID-ZBD1T,
             ZBD2T LIKE BSID-ZBD2T,
             ZBD3T LIKE BSID-ZBD3T,
             REBZG LIKE BSID-REBZG,
             REBZT LIKE BSID-REBZT,
             KOART LIKE BSEG-KOART,
             SK1DT LIKE FAEDE-SK1DT,
             SK2DT LIKE FAEDE-SK2DT,
             DAYSD LIKE SY-TABIX,
          END OF BSID_TAB1.
    RANGES: R_UMSKZ FOR BSID-UMSKZ.
    Data : V_ZFBDT     Like  bsid-ZFBDT,
           V_ZBD1T     Like  bsid-ZBD1T,
           V_ZBD2T     Like  bsid-ZBD2T,
           V_ZBD3T     Like  bsid-ZBD3T,
           V_LINES(8)  TYPE n.
    IF P_NOTED = 'X'.     "CHECK NOTED ITEMS
      R_UMSKZ-SIGN = 'I'.
      R_UMSKZ-OPTION = 'EQ'.
      R_UMSKZ-LOW = 'D'.
      APPEND R_UMSKZ.
      R_UMSKZ-SIGN = 'I'.
      R_UMSKZ-OPTION = 'EQ'.
      R_UMSKZ-LOW = 'L'.
      APPEND R_UMSKZ.
    ENDIF.
    IF P_STAND = 'X'.    "CHECK STANDARD ITEMS
      R_UMSKZ-SIGN = 'I'.
      R_UMSKZ-OPTION = 'EQ'.
      R_UMSKZ-LOW = ' '.
      APPEND R_UMSKZ.
    ENDIF.
    IF P_SPCAL = 'X'.    "CHECK SPECIAL G/L TRANSACTION
      R_UMSKZ-SIGN = 'I'.
      R_UMSKZ-OPTION = 'EQ'.
      R_UMSKZ-LOW = 'A'.
      APPEND R_UMSKZ.
      R_UMSKZ-SIGN = 'I'.
      R_UMSKZ-OPTION = 'EQ'.
      R_UMSKZ-LOW = 'B'.
      APPEND R_UMSKZ.
    ENDIF.
    SELECT * FROM BSID INTO CORRESPONDING FIELDS OF TABLE BSID_TAB
               WHERE BUKRS = BUKRS AND
                     budat <= dat  AND
                     KUNNR = KUNNR AND
                     UMSKZ in R_UMSKZ.
    SELECT * FROM BSAD appending CORRESPONDING FIELDS OF TABLE BSID_TAB
               WHERE BUKRS = BUKRS AND
                     budat <= dat  AND
                     augdt >= dat  AND
                     KUNNR = KUNNR AND
                     UMSKZ in R_UMSKZ.
    DESCRIBE TABLE BSID_TAB LINES V_LINES.
    LOOP AT BSID_TAB.
        if bsid_tab-BLART = 'DZ'.
          Select single ZFBDT ZBD1T ZBD2T ZBD3T
            into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
            from bsid where BUKRS = BUKRS
                        and kunnr = bsid_tab-kunnr
                        and BELNR = bsid_tab-REBZG.
          if sy-subrc = 0.
             bsid_tab-ZFBDT = V_ZFBDT.
             bsid_tab-ZBD1T = V_ZBD1T.
             bsid_tab-ZBD2T = V_ZBD2T.
             bsid_tab-ZBD3T = V_ZBD3T.
          else.
             Select single ZFBDT ZBD1T ZBD2T ZBD3T
               into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
               from bsad where BUKRS = BUKRS
                           and kunnr = bsid_tab-kunnr
                           and BELNR = bsid_tab-REBZG.
             if sy-subrc <> 0.
               bsid_tab-ZFBDT = V_ZFBDT.
               bsid_tab-ZBD1T = V_ZBD1T.
               bsid_tab-ZBD2T = V_ZBD2T.
               bsid_tab-ZBD3T = V_ZBD3T.
             endif.
          endif.
        endif.
        IF BSID_TAB-SHKZG = 'H'.
          BSID_TAB-DMBTR = BSID_TAB-DMBTR * ( - 1 ).
        ENDIF.
        bsid_tab-netdt = bsid_tab-ZFBDT.
      bsid_tab-netdt = bsid_tab-budat.
        bsid_tab-koart = 'D'.
        MODIFY BSID_TAB.
       PERFORM CALC_DUE_DATE USING BSID_TAB.
        BSID_TAB-DAYSD = DAT - BSID_TAB-NETDT.
        IF BSID_TAB-DAYSD <= RASTBIS1.
          V_NET1 = V_NET1 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS2.
          V_NET2 = V_NET2 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS3.
          V_NET3 = V_NET3 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS4.
          V_NET4 = V_NET4 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
          V_NET5 = V_NET5 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS6.
          V_NET6 = V_NET6 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS7.
          V_NET7 = V_NET7 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
          V_NET8 = V_NET8 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <= RASTBIS9.
          V_NET9 = V_NET9 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD <=  RASTBIS0.
          V_NET10 = V_NET10 + BSID_TAB-DMBTR.
        ELSEIF BSID_TAB-DAYSD >  RASTBIS0.
          V_NET11 = V_NET11 + BSID_TAB-DMBTR.
        ENDIF.
        V_NET = V_NET + BSID_TAB-DMBTR.
        MODIFY BSID_TAB.
    ENDLOOP.
    endform.
    Calculate Due Date
    FORM CALC_DUE_DATE USING P_BSID_TAB STRUCTURE BSID_TAB.
      DATA : REFE TYPE P.
    IF P_BSID_TAB-KOART = 'K' OR P_BSID_TAB-KOART = 'D'.
      IF P_BSID_TAB-ZFBDT IS INITIAL.
        P_BSID_TAB-ZFBDT = P_BSID_TAB-BLDAT.
      ENDIF.
    *Nettofälligkeit bestimmen--
      IF NOT P_BSID_TAB-ZBD3T IS INITIAL.
        REFE = P_BSID_TAB-ZBD3T.
      ELSE.
        IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
          REFE = P_BSID_TAB-ZBD2T.
        ELSE.
          REFE = P_BSID_TAB-ZBD1T.
        ENDIF.
      ENDIF.
    *Nichtrechnungsbezogene Gutschriften sind sofort fällig--
      IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
      OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
        IF P_BSID_TAB-REBZG IS INITIAL.
          REFE = 0.
        ENDIF.
      ENDIF.
      P_BSID_TAB-NETDT = P_BSID_TAB-ZFBDT + REFE.
    *Skontofälligkeiten bestimmen--
      IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
        P_BSID_TAB-SK2DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD2T.
      ELSE.
        P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
      ENDIF.
      IF NOT P_BSID_TAB-ZBD1T IS INITIAL
      OR NOT P_BSID_TAB-ZBD2T IS INITIAL.
        P_BSID_TAB-SK1DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD1T.
      ELSE.
        P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
      ENDIF.
    *Nichtrechnungsbezogene Gutschriften sind sofort fällig--
      IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
      OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
        IF P_BSID_TAB-REBZG IS INITIAL.
          P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
          P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
        ENDIF.
      ENDIF.
    ELSE.
       MESSAGE E122 RAISING ACCOUNT_TYPE_NOT_SUPPORTED.
    ENDIF.
    E_FAEDE = FAEDE.
    ENDFORM.

    Hi,
    As vijay said...
    1.Declare One final Internal table which you want to show the data
    2 . populate the fieldcatalog using the FM or Manually using the itab in step1
    3. Collect the Data into final internal table which you created in Step 1.
    4. pass the fieldcat and Internal table to ALV FM.
    chk out the prg below i have created your program but i donn knw wht are the output fields... chk your prg
    *REPORT ZALVTEST .
    REPORT ZSAMPLE line-size 260
    line-count 65
    no standard page heading.
    TYPE-POOLS: SLIS.
    ====================================================================
    TABLES *********************************
    ====================================================================
    tables : bseg,
    bkpf,
    kna1,
    bsid,
    bsad,
    knb1.
    data : begin of customer_tab occurs 0,
    kunnr like kna1-kunnr,
    name1 like kna1-name1,
    flag(1) type c,
    end of customer_tab.
    data : begin of customerdoc_tab occurs 0,
    kunnr like kna1-kunnr,
    belnr like bkpf-belnr,
    gjahr like bkpf-gjahr,
    monat like bkpf-monat,
    end of customerdoc_tab.
    data : begin of doc_tab occurs 0,
    belnr like bkpf-belnr,
    gjahr like bkpf-gjahr,
    monat like bkpf-monat,
    end of doc_tab.
    DATA: BEGIN OF BSID_TAB OCCURS 0,
    BUKRS LIKE BSID-BUKRS,
    PRCTR LIKE BSID-PRCTR,
    KUNNR LIKE BSID-KUNNR,
    FLAG(1),
    UMSKZ LIKE BSID-UMSKZ,
    BLART LIKE BSID-BLART,
    BELNR LIKE BSID-BELNR,
    BUZEI LIKE BSID-BUZEI,
    NETDT LIKE BSID-ZFBDT,
    ZFBDT LIKE BSID-ZFBDT,
    BUDAT LIKE BSID-BUDAT,
    BLDAT LIKE BSID-BLDAT,
    BSCHL LIKE BSID-BSCHL,
    DMBTR LIKE BSID-DMBTR,
    SHKZG LIKE BSID-SHKZG,
    ZBD1T LIKE BSID-ZBD1T,
    ZBD2T LIKE BSID-ZBD2T,
    ZBD3T LIKE BSID-ZBD3T,
    REBZG LIKE BSID-REBZG,
    REBZT LIKE BSID-REBZT,
    KOART LIKE BSEG-KOART,
    SK1DT LIKE FAEDE-SK1DT,
    SK2DT LIKE FAEDE-SK2DT,
    DAYSD LIKE SY-TABIX,
    END OF BSID_TAB.
    ranges : r_bukrs for bsid-bukrs,
    r_kunnr for kna1-kunnr.
    ===================================================================
    VARIABLES *******************************
    ===================================================================
    data : v_belnr like bseg-belnr,
    v_gjahr like bkpf-gjahr,
    v_monat like bkpf-monat,
    v_ttlc type p,
    v_flag(1) type c,
    V_COUNT1(4) TYPE N,
    V_COUNT2(4) TYPE N,
    V_COUNT3(4) TYPE N,
    V_COUNT4(4) TYPE N,
    V_COUNT5(4) TYPE N,
    V_COUNT6(4) TYPE N,
    V_COUNT7(4) TYPE N,
    V_COUNT8(4) TYPE N,
    V_COUNT9(4) TYPE N,
    V_COUNT10(4) TYPE N,
    V_NET1 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 1
    V_NET2 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 2
    V_NET3 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 3
    V_NET4 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 4
    V_NET5 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 5
    V_NET6 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 6
    V_NET7 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 7
    V_NET8 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 8
    V_NET9 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 9
    V_NET10 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 10
    V_NET11 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 11
    V_NET LIKE BSID-DMBTR, "Total Balance of Customer
    V_ttlNET1 LIKE BSID-DMBTR,
    V_ttlNET2 LIKE BSID-DMBTR,
    V_ttlNET3 LIKE BSID-DMBTR,
    V_ttlNET4 LIKE BSID-DMBTR,
    V_ttlNET5 LIKE BSID-DMBTR,
    V_ttlNET6 LIKE BSID-DMBTR,
    V_ttlNET7 LIKE BSID-DMBTR,
    V_ttlNET8 LIKE BSID-DMBTR,
    V_ttlNET9 LIKE BSID-DMBTR,
    V_ttlNET10 LIKE BSID-DMBTR,
    V_ttlNET11 LIKE BSID-DMBTR,
    V_ttlNET LIKE BSID-DMBTR,
    v_kunnr like bseg-kunnr,
    V_BUTXT like t001-butxt.
    ********Declare Data Areas for List Viewer ***********
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          FIELDCAT_LN LIKE LINE OF FIELDCAT,
          FIELD TYPE SLIS_FIELDNAME,
          COL_POS TYPE I ,
          PGM LIKE SY-REPID,
          FIELD_VALUE(20),
          TABLE_NAME(10).
    ===================================================================
    SELECTION SCREEN ****************************
    ===================================================================
    selection-screen begin of block b1 with frame title text-001.
    parameters : p_bukrs like bseg-bukrs obligatory.
    select-options : s_kunnr for kna1-kunnr,
    s_BRSCH for kna1-BRSCH,
    s_REGIO for kna1-REGIO,
    s_KTOKD for kna1-KTOKD,
    s_BUSAB for knb1-BUSAB.
    selection-screen: end of block b1.
    selection-screen begin of block b2 with frame title text-003.
    PARAMETERS: DAT LIKE SY-DATUM DEFAULT SY-DATUM.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) TEXT-002.
    SELECTION-SCREEN POSITION POS_LOW.
    *PARAMETERS: RASTBIS1 LIKE RFPDO1-ALLGROGR DEFAULT '000'.
    *PARAMETERS: RASTBIS2 LIKE RFPDO1-ALLGROGR DEFAULT '030'.
    *PARAMETERS: RASTBIS3 LIKE RFPDO1-ALLGROGR DEFAULT '060'.
    *PARAMETERS: RASTBIS4 LIKE RFPDO1-ALLGROGR DEFAULT '090'.
    *PARAMETERS: RASTBIS5 LIKE RFPDO1-ALLGROGR DEFAULT '120'.
    PARAMETERS: RASTBIS1(4) type n DEFAULT '0000'.
    PARAMETERS: RASTBIS2(4) type n DEFAULT '0030'.
    PARAMETERS: RASTBIS3(4) type n DEFAULT '0060'.
    PARAMETERS: RASTBIS4(4) type n DEFAULT '0090'.
    PARAMETERS: RASTBIS5(4) type n DEFAULT '0120'.
    PARAMETERS: RASTBIS6(4) type n DEFAULT '0150'.
    PARAMETERS: RASTBIS7(4) type n DEFAULT '0180'.
    PARAMETERS: RASTBIS8(4) type n DEFAULT '0210'.
    PARAMETERS: RASTBIS9(4) type n DEFAULT '0240'.
    PARAMETERS: RASTBIS0(4) type n DEFAULT '0270'.
    SELECTION-SCREEN END OF LINE.
    Noted item removed as per FI instruction
    PARAMETERS: P_STAND AS CHECKBOX default 'X',
    P_NOTED AS CHECKBOX ,
    P_SPCAL AS CHECKBOX .
    selection-screen: end of block b2.
    selection-screen begin of block b3 with frame.
    PARAMETERS: allgline like RFPDO1-allgline .
    Parameters : p_balyes type c radiobutton group grp9 default 'X',
    p_balno type c radiobutton group grp9.
    selection-screen: end of block b3.
    Check for the Select option
    AT SELECTION-SCREEN.
    IF P_STAND = '' AND P_SPCAL = '' .
    MESSAGE E398(00) WITH 'PLEASE CHOOSE AT LEAST ONE G/L INDICATOR!'.
    ENDIF.
    Check for Company code Authorization
    authority-check object 'F_BKPF_BUK'
    ID 'BUKRS' FIELD p_bukrs
    ID 'ACTVT' FIELD '03'.
    if sy-subrc ne 0.
    message e398(00) with 'You are not Authorized for CC ' p_bukrs.
    Endif.
    ===================================================================
    START-OF-SELECTION ****************************
    ===================================================================
    START-OF-SELECTION.
    V_COUNT1 = RASTBIS1 + 1.
    V_COUNT2 = RASTBIS2 + 1.
    V_COUNT3 = RASTBIS3 + 1.
    V_COUNT4 = RASTBIS4 + 1.
    V_COUNT5 = RASTBIS5 + 1.
    V_COUNT6 = RASTBIS6 + 1.
    V_COUNT7 = RASTBIS7 + 1.
    V_COUNT8 = RASTBIS8 + 1.
    V_COUNT9 = RASTBIS9 + 1.
    V_COUNT10 = RASTBIS0 + 1.
    perform extract_data.
    Build Field Catalogs **************************
      PERFORM BUILD_FIELDCAT.
    *******Start List Viewer *******************************
      PERFORM START_LIST_VIEWER.
    ===================================================================
    At line Selection *****************************
    ===================================================================
    at line-selection.
    if sy-lilli >= 9 .
    refresh r_bukrs.
    move p_bukrs to r_bukrs-low.
    move 'I' to r_bukrs-sign.
    move 'EQ' to r_bukrs-option.
    append r_bukrs.
    refresh r_kunnr.
    move customer_tab-kunnr to r_kunnr-low.
    move 'I' to r_kunnr-sign.
    move 'EQ' to r_kunnr-option.
    append r_kunnr.
    submit ZFARVR0040 and return
    with p_bukrs = p_bukrs
    with dat = dat
    with p_stand = p_stand
    with p_spcal = P_SPCAL
    with s_kunnr in r_kunnr.
    endif.
    ===================================================================
    Top of Page *******************************
    ===================================================================
    TOP-OF-PAGE.
    SELECT SINGLE BUTXT FROM T001 INTO V_BUTXT
    WHERE BUKRS = p_BUKRS .
    WRITE:/73'Customers Aging Analysis',140'PAGE NO.',
    SY-PAGNO.
    WRITE:/002 'COMPANY',
    011 P_BUKRS,
    017 V_BUTXT,
    055 allgline centered,
    140 'DATE :',
    150 sy-datum .
    write:/002 'User',
    011 sy-UNAME,
    140 'Time :',
    150 sy-UZEIT.
    SKIP.
    format color col_heading intensified off.
    WRITE:/ SY-ULINE,
    SY-VLINE,002 'Customer',
    012 SY-VLINE,013 'Name',
    043 SY-VLINE,048 'CURRENT',
    061 SY-VLINE,065 'FROM ',V_COUNT1,
    079 SY-VLINE,083 'FROM ',V_COUNT2,
    097 SY-VLINE,101 'FROM ',V_COUNT3,
    115 SY-VLINE,119 'FROM ',V_COUNT4,
    133 SY-VLINE,137 'FROM ',V_COUNT5,
    151 SY-VLINE,155 'FROM ',V_COUNT6,
    169 SY-VLINE,173 'FROM ',V_COUNT7,
    187 SY-VLINE,191 'FROM ',V_COUNT8,
    205 SY-VLINE,209 'FROM ',V_COUNT9,
    223 SY-VLINE,228 'FROM ',V_COUNT10,
    243 SY-VLINE,248 'TOTAL',
    268 SY-VLINE.
    WRITE:/ SY-VLINE,002 'Number',
    12 SY-VLINE,
    43 SY-VLINE,
    061 SY-VLINE,065 'TO ',RASTBIS2,
    079 SY-VLINE,083 'TO ',RASTBIS3,
    097 SY-VLINE,101 'TO ',RASTBIS4,
    115 SY-VLINE,119 'TO ',RASTBIS5,
    133 SY-VLINE,137 'FROM ',RASTBIS6,
    151 SY-VLINE,155 'FROM ',RASTBIS7,
    169 SY-VLINE,173 'FROM ',RASTBIS8,
    187 SY-VLINE,191 'FROM ',RASTBIS9,
    205 SY-VLINE,209 'FROM ',RASTBIS0,
    223 SY-VLINE,
    243 SY-VLINE,
    268 SY-VLINE,
    SY-ULINE.
    format color off.
    ===================================================================
    END-OF-SELECTION ***************************
    ===================================================================
    end-of-selection.
    ===================================================================
    Form : Extract_Data *
    ===================================================================
    form extract_data.
    Select the Customers
    Select t1~kunnr t2~name1
    into corresponding fields of table customer_tab
    from knb1 as t1 inner join kna1 as t2
    on t2~kunnr = t1~kunnr
    where t1~bukrs = p_bukrs
    and t1~kunnr in s_kunnr
    and t1~BUSAB in s_busab
    and t2~regio in s_regio
    and t2~BRSCH in s_BRSCH
    and t2~KTOKD in s_KTOKD.
    if sy-subrc <> 0.
    message e398(00) with 'No Customers Selected'.
    endif.
    sort customer_tab.
    describe table customer_tab lines v_ttlc.
    v_ttlc = v_ttlc + 10.
    loop at customer_tab.
    v_net1 = 0.
    v_net2 = 0.
    v_net3 = 0.
    v_net4 = 0.
    v_net5 = 0.
    v_net6 = 0.
    v_net7 = 0.
    v_net8 = 0.
    v_net9 = 0.
    v_net10 = 0.
    v_net11 = 0.
    v_net = 0.
    perform calculate_ageing
    using
    p_bukrs
    customer_tab-kunnr
    dat
    RASTBIS1
    RASTBIS2
    RASTBIS3
    RASTBIS4
    RASTBIS5
    RASTBIS6
    RASTBIS7
    RASTBIS8
    RASTBIS9
    RASTBIS0
    P_STAND
    ' ' "noted item
    P_SPCAL
    changing
    v_net1
    v_net2
    v_net3
    v_net4
    v_net5
    v_net6
    v_net7
    v_net8
    v_net9
    v_net10
    v_net11
    v_net.
    if p_balyes = 'X' or v_net > 0.
    format color col_total.
    write:/ sy-vline,
    002 customer_tab-kunnr,
    012 SY-VLINE,013(30) customer_tab-name1,
    043 SY-VLINE,044(16) v_net1,
    061 SY-VLINE,062(16) v_net2,
    079 SY-VLINE,080(16) v_net3,
    097 SY-VLINE,098(16) v_net4,
    115 SY-VLINE,116(16) v_net5,
    133 SY-VLINE,134(16) v_net6,
    151 SY-VLINE,152(16) v_net7,
    169 SY-VLINE,170(16) v_net8,
    187 SY-VLINE,188(16) v_net9,
    205 SY-VLINE,206(16) v_net10,
    223 SY-VLINE,224(16) v_net11,
    239 SY-VLINE,240(16) v_net,
    258 SY-VLINE.
    format color off.
    hide : customer_tab-kunnr.
    v_ttlnet1 = v_ttlnet1 + v_net1.
    v_ttlnet2 = v_ttlnet2 + v_net2.
    v_ttlnet3 = v_ttlnet3 + v_net3.
    v_ttlnet4 = v_ttlnet4 + v_net4.
    v_ttlnet5 = v_ttlnet5 + v_net5.
    v_ttlnet6 = v_ttlnet6 + v_net6.
    v_ttlnet7 = v_ttlnet7 + v_net7.
    v_ttlnet8 = v_ttlnet8 + v_net8.
    v_ttlnet9 = v_ttlnet9 + v_net9.
    v_ttlnet10 = v_ttlnet10 + v_net10.
    v_ttlnet11 = v_ttlnet11 + v_net11.
    v_ttlnet = v_ttlnet + v_net.
    endif.
    endloop.
    ULINE.
    format color col_total.
    write:/ sy-vline,
    012 SY-VLINE,012(30) ' T O T A L',
    043 SY-VLINE,044(16) v_ttlnet1,
    061 SY-VLINE,062(16) v_ttlnet2,
    079 SY-VLINE,080(16) v_ttlnet3,
    097 SY-VLINE,098(16) v_ttlnet4,
    115 SY-VLINE,116(16) v_ttlnet5,
    133 SY-VLINE,134(16) v_ttlnet6,
    151 SY-VLINE,152(16) v_ttlnet7,
    169 SY-VLINE,170(16) v_ttlnet8,
    187 SY-VLINE,188(16) v_ttlnet9,
    205 SY-VLINE,206(16) v_ttlnet10,
    223 SY-VLINE,224(16) v_ttlnet11,
    239 SY-VLINE,240(16) v_ttlnet,
    258 SY-VLINE.
    format color off.
    ULINE.
    endform.
    Function to Calculate Aging.
    Form calculate_ageing using
    bukrs
    kunnr
    dat
    RASTBIS1
    RASTBIS2
    RASTBIS3
    RASTBIS4
    RASTBIS5
    RASTBIS6
    RASTBIS7
    RASTBIS8
    RASTBIS9
    RASTBIS0
    P_STAND
    P_NOTED
    P_SPCAL
    changing
    v_net1
    v_net2
    v_net3
    v_net4
    v_net5
    v_net6
    v_net7
    v_net8
    v_net9
    v_net10
    v_net11
    v_net.
    DATA: BEGIN OF BSID_TAB1 OCCURS 0,
    BUKRS LIKE BSID-BUKRS,
    PRCTR LIKE BSID-PRCTR,
    KUNNR LIKE BSID-KUNNR,
    FLAG(1),
    UMSKZ LIKE BSID-UMSKZ,
    BLART LIKE BSID-BLART,
    BELNR LIKE BSID-BELNR,
    BUZEI LIKE BSID-BUZEI,
    NETDT LIKE BSID-ZFBDT,
    ZFBDT LIKE BSID-ZFBDT,
    BUDAT LIKE BSID-BUDAT,
    BLDAT LIKE BSID-BLDAT,
    BSCHL LIKE BSID-BSCHL,
    DMBTR LIKE BSID-DMBTR,
    SHKZG LIKE BSID-SHKZG,
    ZBD1T LIKE BSID-ZBD1T,
    ZBD2T LIKE BSID-ZBD2T,
    ZBD3T LIKE BSID-ZBD3T,
    REBZG LIKE BSID-REBZG,
    REBZT LIKE BSID-REBZT,
    KOART LIKE BSEG-KOART,
    SK1DT LIKE FAEDE-SK1DT,
    SK2DT LIKE FAEDE-SK2DT,
    DAYSD LIKE SY-TABIX,
    END OF BSID_TAB1.
    RANGES: R_UMSKZ FOR BSID-UMSKZ.
    Data : V_ZFBDT Like bsid-ZFBDT,
    V_ZBD1T Like bsid-ZBD1T,
    V_ZBD2T Like bsid-ZBD2T,
    V_ZBD3T Like bsid-ZBD3T,
    V_LINES(8) TYPE n.
    IF P_NOTED = 'X'. "CHECK NOTED ITEMS
    R_UMSKZ-SIGN = 'I'.
    R_UMSKZ-OPTION = 'EQ'.
    R_UMSKZ-LOW = 'D'.
    APPEND R_UMSKZ.
    R_UMSKZ-SIGN = 'I'.
    R_UMSKZ-OPTION = 'EQ'.
    R_UMSKZ-LOW = 'L'.
    APPEND R_UMSKZ.
    ENDIF.
    IF P_STAND = 'X'. "CHECK STANDARD ITEMS
    R_UMSKZ-SIGN = 'I'.
    R_UMSKZ-OPTION = 'EQ'.
    R_UMSKZ-LOW = ' '.
    APPEND R_UMSKZ.
    ENDIF.
    IF P_SPCAL = 'X'. "CHECK SPECIAL G/L TRANSACTION
    R_UMSKZ-SIGN = 'I'.
    R_UMSKZ-OPTION = 'EQ'.
    R_UMSKZ-LOW = 'A'.
    APPEND R_UMSKZ.
    R_UMSKZ-SIGN = 'I'.
    R_UMSKZ-OPTION = 'EQ'.
    R_UMSKZ-LOW = 'B'.
    APPEND R_UMSKZ.
    ENDIF.
    SELECT * FROM BSID INTO CORRESPONDING FIELDS OF TABLE BSID_TAB
    WHERE BUKRS = BUKRS AND
    budat <= dat AND
    KUNNR = KUNNR AND
    UMSKZ in R_UMSKZ.
    SELECT * FROM BSAD appending CORRESPONDING FIELDS OF TABLE BSID_TAB
    WHERE BUKRS = BUKRS AND
    budat <= dat AND
    augdt >= dat AND
    KUNNR = KUNNR AND
    UMSKZ in R_UMSKZ.
    DESCRIBE TABLE BSID_TAB LINES V_LINES.
    LOOP AT BSID_TAB.
    if bsid_tab-BLART = 'DZ'.
    Select single ZFBDT ZBD1T ZBD2T ZBD3T
    into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
    from bsid where BUKRS = BUKRS
    and kunnr = bsid_tab-kunnr
    and BELNR = bsid_tab-REBZG.
    if sy-subrc = 0.
    bsid_tab-ZFBDT = V_ZFBDT.
    bsid_tab-ZBD1T = V_ZBD1T.
    bsid_tab-ZBD2T = V_ZBD2T.
    bsid_tab-ZBD3T = V_ZBD3T.
    else.
    Select single ZFBDT ZBD1T ZBD2T ZBD3T
    into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
    from bsad where BUKRS = BUKRS
    and kunnr = bsid_tab-kunnr
    and BELNR = bsid_tab-REBZG.
    if sy-subrc <> 0.
    bsid_tab-ZFBDT = V_ZFBDT.
    bsid_tab-ZBD1T = V_ZBD1T.
    bsid_tab-ZBD2T = V_ZBD2T.
    bsid_tab-ZBD3T = V_ZBD3T.
    endif.
    endif.
    endif.
    IF BSID_TAB-SHKZG = 'H'.
    BSID_TAB-DMBTR = BSID_TAB-DMBTR * ( - 1 ).
    ENDIF.
    bsid_tab-netdt = bsid_tab-ZFBDT.
    bsid_tab-netdt = bsid_tab-budat.
    bsid_tab-koart = 'D'.
    MODIFY BSID_TAB.
    PERFORM CALC_DUE_DATE USING BSID_TAB.
    BSID_TAB-DAYSD = DAT - BSID_TAB-NETDT.
    IF BSID_TAB-DAYSD <= RASTBIS1.
    V_NET1 = V_NET1 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS2.
    V_NET2 = V_NET2 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS3.
    V_NET3 = V_NET3 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS4.
    V_NET4 = V_NET4 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
    V_NET5 = V_NET5 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS6.
    V_NET6 = V_NET6 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS7.
    V_NET7 = V_NET7 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
    V_NET8 = V_NET8 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS9.
    V_NET9 = V_NET9 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD <= RASTBIS0.
    V_NET10 = V_NET10 + BSID_TAB-DMBTR.
    ELSEIF BSID_TAB-DAYSD > RASTBIS0.
    V_NET11 = V_NET11 + BSID_TAB-DMBTR.
    ENDIF.
    V_NET = V_NET + BSID_TAB-DMBTR.
    MODIFY BSID_TAB.
    ENDLOOP.
    endform.
    Calculate Due Date
    FORM CALC_DUE_DATE USING P_BSID_TAB STRUCTURE BSID_TAB.
    DATA : REFE TYPE P.
    IF P_BSID_TAB-KOART = 'K' OR P_BSID_TAB-KOART = 'D'.
    IF P_BSID_TAB-ZFBDT IS INITIAL.
    P_BSID_TAB-ZFBDT = P_BSID_TAB-BLDAT.
    ENDIF.
    *Nettofälligkeit bestimmen--
    IF NOT P_BSID_TAB-ZBD3T IS INITIAL.
    REFE = P_BSID_TAB-ZBD3T.
    ELSE.
    IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
    REFE = P_BSID_TAB-ZBD2T.
    ELSE.
    REFE = P_BSID_TAB-ZBD1T.
    ENDIF.
    ENDIF.
    *Nichtrechnungsbezogene Gutschriften sind sofort fällig--
    IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
    OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
    IF P_BSID_TAB-REBZG IS INITIAL.
    REFE = 0.
    ENDIF.
    ENDIF.
    P_BSID_TAB-NETDT = P_BSID_TAB-ZFBDT + REFE.
    *Skontofälligkeiten bestimmen--
    IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
    P_BSID_TAB-SK2DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD2T.
    ELSE.
    P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
    ENDIF.
    IF NOT P_BSID_TAB-ZBD1T IS INITIAL
    OR NOT P_BSID_TAB-ZBD2T IS INITIAL.
    P_BSID_TAB-SK1DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD1T.
    ELSE.
    P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
    ENDIF.
    *Nichtrechnungsbezogene Gutschriften sind sofort fällig--
    IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
    OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
    IF P_BSID_TAB-REBZG IS INITIAL.
    P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
    P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
    ENDIF.
    ENDIF.
    ELSE.
    MESSAGE E122 RAISING ACCOUNT_TYPE_NOT_SUPPORTED.
    ENDIF.
    E_FAEDE = FAEDE.
    ENDFORM.
    *&      Form  BUILD_FIELDCAT
    FORM BUILD_FIELDCAT .
      PGM = SY-REPID.
      FIELD      = 'give field name'.
      TABLE_NAME = 'give table name'.
      PERFORM FIELDCAT_FILL USING FIELD.
    and so on for the no. of fields you want to display
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  START_LIST_VIEWER
    FORM START_LIST_VIEWER.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
       I_INTERFACE_CHECK              = ' '
         I_CALLBACK_PROGRAM             = PGM
       I_CALLBACK_PF_STATUS_SET       = ' '
         I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
       I_STRUCTURE_NAME               =
       IS_LAYOUT                      =
         IT_FIELDCAT                    = FIELDCAT
       IT_EXCLUDING                   =
       IT_SPECIAL_GROUPS              =
       IT_SORT                        =
       IT_FILTER                      =
       IS_SEL_HIDE                    =
         I_DEFAULT                      = 'X'
         I_SAVE                         = 'A'
       IS_VARIANT                     =
       IT_EVENTS                      =
       IT_EVENT_EXIT                  =
       IS_PRINT                       =
       IS_REPREP_ID                   =
       I_SCREEN_START_COLUMN          = 0
       I_SCREEN_START_LINE            = 0
       I_SCREEN_END_COLUMN            = 0
       I_SCREEN_END_LINE              = 0
       IR_SALV_LIST_ADAPTER           =
       IT_EXCEPT_QINFO                =
       I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER        =
       ES_EXIT_CAUSED_BY_USER         =
       TABLES
         T_OUTTAB                       = FINAL TAB(OUTPUT STATEMENTS TABLE)
      EXCEPTIONS
        PROGRAM_ERROR                   = 1
        OTHERS                          = 2.
    ENDFORM.                    " START_LIST_VIEWER
    *&      Form  FIELDCAT_FILL
          text
    FORM FIELDCAT_FILL USING FIELD_VALUE.
      ADD 1 TO COL_POS.
      FIELDCAT_LN-REF_TABNAME = TABLE_NAME.
      FIELDCAT_LN-FIELDNAME = FIELD_VALUE.
      FIELDCAT_LN-KEY = SPACE.
      FIELDCAT_LN-DO_SUM = SPACE.
      FIELDCAT_LN-COL_POS = COL_POS.
      FIELDCAT_LN-NO_OUT = SPACE.
      FIELDCAT_LN-QFIELDNAME = SPACE.
      FIELDCAT_LN-HOTSPOT = SPACE.
      APPEND FIELDCAT_LN TO FIELDCAT.
    ENDFORM.                    " FIELDCAT_FILL
    Reward points if you find this helpful
    Regards,
    Harini

  • Move data from multiple Tables to a Single Table & Convert the list to ALV.

    Hi,
    My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
    Also tell me how to convert this list into ALV.
    Below is the program code.
    *& Report  Y_REORDER_REPORT
    REPORT  Y_REORDER_REPORT.
    tables : marc,makt, mard.
    DATA: Begin of i_final occurs 0,
            matnr type marc-matnr,
            maktx type makt-maktx,
            DISPO type marc-DISPO,
            MINBE type marc-MINBE,
            LABST type mard-LABST,
          end of i_final.
    DATA: Begin of i_marc occurs 0,
           matnr type marc-matnr,
           DISPO type marc-DISPO,
           MINBE type marc-MINBE,
          end of i_marc.
    DATA: Begin of i_makt occurs 0,
           matnr type makt-matnr,
           maktx type makt-maktx,
          end of i_makt.
    DATA: Begin of i_mard occurs 0,
           matnr type mard-matnr,
           LABST type mard-LABST,
           LGORT TYPE MARD-LGORT,
          end of i_mard.
    SELECT  matnr
            dispo
            minbe from marc
            into corresponding fields of table i_marc
            where dispo EQ 'STR'.
    SORT I_MARC by MATNR.
    WRITE: /10  'Material',
            75  'MRP',
            80  'Reorder Qty.'.
    LOOP at i_marc.
    Write: /10  i_marc-matnr,
            75  i_marc-dispo,
            80  i_marc-minbe.
    ENDLOOP.
    write: /.
    SELECT  matnr
            MAKTX from makt
            into corresponding fields of table i_makt
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_makt.
    Write: /10 i_makt-matnr,
            30 i_makt-maktx.
    ENDLOOP.
    SELECT  matnr
            LGORT
            LABST from mard
            into corresponding fields of table i_mard
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_mard.
    Write: /10 i_mard-matnr,
            30 I_MARD-LGORT,
            40 i_mard-labst.
    ENDLOOP.
    move  i_mard-matnr to i_final-matnr.
    move  i_marc-dispo to i_final-dispo.
    move  i_marc-minbe to i_final-minbe.
    move  i_makt-maktx to i_final-maktx.
    move  i_mard-labst to i_final-labst.
    WRITE: /10  'Material',
            30  'Material Desc.',
            75  'MRP',
            80  'Reorder Qty.',
            105 'Current Stock'.
    LOOP at i_final.
    Write: /10  i_final-matnr,
            30  i_final-maktx,
            75  i_final-dispo,
            80  i_final-minbe,
            105 i_final-labst.
    ENDLOOP.
    *LOOP at i_mard.
    *Write: /10  i_mard-matnr,
           30  i_makt-maktx,
           75  i_marc-dispo,
           80  i_marc-minbe,
           105 i_mard-labst.
    *ENDLOOP.
    Regards,
    Vishal

    Change like this,
    SELECT matnr
    lgort
    labst FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_mard
    FOR ALL ENTRIES IN i_marc
    WHERE matnr = i_marc-matnr.
    LOOP AT i_mard.
       WRITE: /10 i_mard-matnr,
       30 i_mard-lgort,
       40 i_mard-labst.
    ENDLOOP.
    LOOP AT i_marc.
       READ TABLE i_mard WITH KEY matnr =  i_marc-matnr.
       READ TABLE i_makt WITH KEY matnr =  i_marc-matnr.
       MOVE i_mard-matnr TO i_final-matnr.
       MOVE i_marc-dispo TO i_final-dispo.
       MOVE i_marc-minbe TO i_final-minbe.
       MOVE i_makt-maktx TO i_final-maktx.
       MOVE i_mard-labst TO i_final-labst.
       APPEND i_final.
    ENDLOOP.
    WRITE: /10 'Material',
    30 'Material Desc.',
    75 'MRP',
    80 'Reorder Qty.',
    105 'Current Stock'.

  • ALV for fields from multiple tables and make them editable

    Hi,
    I am working on a forecasting report. We have created few custom table e.g. store forcaset detail for whole year month wise. tables are say sales data, budget data, forcast data etc.
    Now i need to make a report based on monthwise based on above mention table.
    eg.o/p looks like:
    column name                     type desc monthapr monthmay .......
    table forcast                      Qty  sales    100          150
    table budget/sales             amt   amou    20.50    130.50
    table sales vs forcast       amt   amount  3000     50000
    -Now i don't know how to display data from multiple table in single ALV list that to with different field type.
    -2nd issue is i need to make only perticuler row editable so that user can chage data.
    -3rd when user change data and press calulate button - it should calculate data for future month - i got formula for that and disply the calulated data.
    - 4th if user like the forcast data then when press save - change data should update dbtable.
    Is this all possible with simple abap FM Or need to use ABAPOO.
    I will appericiate all expert help.
    Many thanks in advance.
    KDE.
    Edited by: kde_test on Jun 4, 2010 5:44 PM

    Hi,
    Solutions :
    1. You can use  FM REUSE_ALV_HIERSEQ_LIST_DISPLAY as guided by Ashutosh.
    You can also check out this
    [http://www.sap technical.com/Tutorials/ABAP/3DGraph/demo.htm]  change link to saptechnical without space
    2. [How to make certain rows in ALV grid editable...;
    3 & 4. Use two importing paramaters 'PF_STATUS_SET' 'USER_COMMAND' of  REUSE_ALV_GRID_DISPLAY.
    create two function codes 'CALC and 'SAVE' in pf-status and provide your required functionality to these function codes using User-Command.
    Sorry am unable to provide you with supporting code, but you can search for it and It can solve your problem
    Regards,
    Rohit

  • How to design Customized ALV report like normal report !

    Hello Friends,
                  I like to design a ALV report, with sub headers, sub totals, summary total and other summary details like percentage sale, which is not relavent to the fields displayed in the ALV.
    I know it is possible to get total of the displayed field, but is it possible to design flexible ALV report like normal report.
    Could U please provide example code, if available.
    Thank you,
    Senthil

    HI,
    Just check this example.
    REPORT  ZLAXMI_ALVEXER2  MESSAGE-ID ZZ                       .
    *& TABLES DECLARATION                                                  *
    TABLES: VBAK.
    *& TYPE POOLS DECLARATION                                              *
    TYPE-POOLS: SLIS.
    *& INTERNAL TABLE DECLARATION                                          *
    DATA: BEGIN OF ITAB OCCURS 0,
           ICON TYPE ICON-ID,
           VBELN LIKE VBAK-VBELN,
           AUDAT LIKE VBAK-AUDAT,
           VBTYP LIKE VBAK-VBTYP,
           AUART LIKE VBAK-AUART,
           AUGRU LIKE VBAK-AUGRU,
           NETWR LIKE VBAK-NETWR,
           WAERK LIKE VBAK-WAERK,
        END OF ITAB.
    *INTERNAL TABLE FOR FIELD CATALOG
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
               WITH HEADER LINE,
    *INTERNAL TABLE FOR EVENTS
    DATA:    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_VBELN FOR VBAK-VBELN,
                    S_VBTYP FOR VBAK-VBTYP DEFAULT 'C'.
    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.
      PERFORM VALIDATE_SCREEN.
    *& START OF SELECTION                                               *
    START-OF-SELECTION.
      CLEAR: ITAB, ITAB[].
    V_REPID = SY-REPID.
      PERFORM GET_DATA.
      PERFORM DISPLAY_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 VBELN
             AUDAT
             VBTYP
             AUART
             AUGRU
             NETWR
             WAERK
             INTO CORRESPONDING FIELDS OF TABLE ITAB
             FROM VBAK
             WHERE VBELN IN S_VBELN AND
             AUDAT > '04.04.2005'
             AND NETWR > 0.
      LOOP AT ITAB.
        IF ITAB-NETWR < 10000.
          ITAB-ICON = '@08@'.
        ELSEIF ITAB-NETWR > 10000 AND ITAB-NETWR < 100000.
          ITAB-ICON = '@09@'.
        ELSEIF ITAB-NETWR > 100000.
          ITAB-ICON = '@0A@'.
        ENDIF.
        MODIFY ITAB INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  sort_fields
    FORM SORT_FIELDS .
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'VBTYP'.
      WA_SORT-SPOS = '1'.
      WA_SORT-UP = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'NETWR'.
      WA_SORT-SPOS = '2'.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
    ENDFORM.                    " sort_fields
    *&      Form  build_fieldcat
    *FORM BUILD_FIELDCAT .
    IT_FIELDCAT-COL_POS    = '1'.
    IT_FIELDCAT-FIELDNAME  = 'ICON'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '10'.
    IT_FIELDCAT-SELTEXT_L  = 'LIGHT'.
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '2'.
    IT_FIELDCAT-FIELDNAME  = 'VBELN'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '10'.
    IT_FIELDCAT-SELTEXT_L  = 'SALES DOC NUMBER'(009).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '3'.
    IT_FIELDCAT-FIELDNAME  = 'AUDAT'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'DOCUMENT DATE'(010).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '4'.
    IT_FIELDCAT-FIELDNAME  = 'VBTYP'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'CATEGORY'(011).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '5'.
    IT_FIELDCAT-FIELDNAME  = 'AUART'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'DOCUMENT TYPE'(012).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '6'.
    IT_FIELDCAT-FIELDNAME  = 'AUGRU'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'Order reason'(013).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '7'.
    IT_FIELDCAT-FIELDNAME  = 'NETWR'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'NET VALUE'(014).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '8'.
    IT_FIELDCAT-FIELDNAME  = 'WAERK'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'SD DOC CURR'(015).
    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'(016).
        WA_LAYOUT-ZEBRA = 'X'.
    *-- ALV LIST DISPLAY
        PERFORM LIST_DISPLAY TABLES ITAB.
    *-- ALV GRID DISPLAY
      ELSEIF P_GRID = C_X.
        WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'(017).
        WA_LAYOUT-ZEBRA = 'X'.
        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[]
          I_SAVE             = 'U'
        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
    *&      Form  VALIDATE_SCREEN
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_SCREEN .
      DATA: LV_VBELN LIKE VBAK-VBELN.
      IF NOT S_VBELN IS INITIAL.
        SELECT VBELN
        INTO LV_VBELN
        UP TO 1 ROWS
        FROM VBAK
        WHERE VBELN IN S_VBELN.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID SALES DOC'.
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_SCREEN
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_DATA .
      DEFINE M_FIELDCAT.
        ADD 1 TO WA_FIELDCAT-COL_POS.
        WA_FIELDCAT-FIELDNAME   = &1.
        WA_FIELDCAT-REF_TABNAME = 'VBAK'.
        WA_FIELDCAT-DO_SUM      = &2.
        WA_FIELDCAT-CFIELDNAME  = &3.
        APPEND WA_FIELDCAT TO IT_FIELDCAT.
      END-OF-DEFINITION.
    DATA:
        LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
      M_FIELDCAT 'ICON' ''  ''.
      M_FIELDCAT 'VBELN' ''  ''.
      M_FIELDCAT 'AUDAT' ''  ''.
      M_FIELDCAT 'VBTYP' ''  ''.
      M_FIELDCAT 'AUART' ''  ''.
      M_FIELDCAT 'AUGRU' ''  ''.
      M_FIELDCAT 'NETWR' 'C' 'WAERK'.
      M_FIELDCAT 'WAERK' ''  ''.
    ENDFORM.                    " display_data
    Regards
    Laxmi

  • "Failed to open the connection" problem related to multiple tables in the report?

    Post Author: Gadow
    CA Forum: Data Connectivity and SQL
    System specifics:
    Web environment using ASP.Net 2.0 (from Visual Studio 2005 Professional)
    Crystal Reports 2008, v. 12.0.0.549, Full
    We have set up the following method for displaying reports via our website:
    User is sent to a report-specific page. The user is given some filtering options specific to the report that will be viewed. When the user has specified the data filters, the user clicks a button.
    The page wraps up the report parameters -- selection query, formula values, report location, the name to be displayed, etc. -- into a class which gets put into the Session object.
    The page redirects to DisplayReport.aspx. ALL reports redirect to this page.
    DisplayReport.aspx retrieves the report parameters from Session. A ReportDocument object is created and loaded, then set with the data from the parameters class.
    A ConnectionInfo object is created and set with the relevant log on credentials. All of the reports draw from the same database, so the connection information is hard-coded as the same for all reports. The page then iterates through all of the tables in the Database.Tables collection of the ReportDocument and calls ApplyLogOnInfo to each table using the ConnectionInfo object.
    The page is rendered and the user gets the filtered report.
    We currently have seven reports. Five reports work fine and display the correctly filtered data with no error messages. Two reports generate a Failed to open the connection error and do not display. I have verified that the queries being sent to DisplayReport.aspx are valid, and as I said the connection information itself is hard-coded in the one page that displays the reports and this is identical to all reports.
    The five reports that do work all have a single data table, either an actual database table or a single view. The two reports that do not work all have multiple tables. As far as I can tell, this is the only difference between the sets; all seven reports are based on the same DSN and I have verified the database on all of the reports. All of the reports were written using Crystal Reports 8, and all of the reports display fine in a Windows app I wrote some years ago using Crystal Reports 8. Again, the only difference between those reports that do work and those that do not is the number of tables used in the report: one table or view in the reports that display, more than one table (tables only, none use views) in the reports that do not display.
    As for the code I am using, below are the relevant methods. The function MakeConnectionInfo simply parses out the components of a standard SQL connection string into a ConnectionInfo object. DisplayedReport is the ID of the CrystalReportViewer on the page.Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim o As Object = Session("ReportParams")
            Dim ReportURL As String = ""
            'Verify that there is a ReportParameters object
            If o Is Nothing OrElse o.GetType IsNot GetType(ReportParameters) Then 'Redirect to the error page
                Response.Redirect("/errors/MissingReport.aspx")
            End If
            ReportParams = CType(o, ReportParameters)
            'Verify that the report exists
            ReportURL = "/Reports/ReportFiles/" + ReportParams.ReportName
            ReportPath = Server.MapPath(ReportURL)
            If Not File.Exists(ReportPath) Then
                Response.Redirect("/errors/MissingReport.aspx?Report=" + ReportParams.ReportTitle)
            End If
            InitializeReport()       
        End Sub
        Protected Sub InitializeReport()
            Dim RD As New ReportDocument
            Dim CI As ConnectionInfo = MakeConnectionInfo(DB_Bonus)
            Dim RPF As CrystalDecisions.Shared.ParameterField = Nothing
            RD.Load(ReportPath)
            If ReportParams.SelectString <> "" Then
                Dim Adapt As New SqlDataAdapter(ReportParams.SelectString, DB_Bonus)
                Dim DS As New Data.DataSet
                Adapt.Fill(DS)
                RD.SetDataSource(DS.Tables(0))
            End If
            For Each kvp As KeyValuePair(Of String, String) In ReportParams.Formulas
                Dim FFD As FormulaFieldDefinition = Nothing
                Try
                    FFD = RD.DataDefinition.FormulaFields(kvp.Key)
                Catch ex As Exception
                    'Do nothing
                End Try
                If FFD IsNot Nothing Then
                    Select Case FFD.ValueType
                        Case FieldValueType.DateField, FieldValueType.DateTimeField
                            If IsDate(kvp.Value) Then
                                FFD.Text = String.Format("Date()", Convert.ToDateTime(kvp.Value).ToString("yyyy, MM, dd"))
                            Else
                                FFD.Text = "Date(1960, 01, 01)"
                            End If
                        Case FieldValueType.StringField
                            FFD.Text = String.Format("""""", kvp.Value)
                        Case Else
                            'For now, treat these as if they were strings. If things blow up here,
                            'we will need to add the appropriate formatting for the field type.
                            FFD.Text = String.Format("""""", kvp.Value)
                    End Select
                End If
            Next
            For Each T As CrystalDecisions.CrystalReports.Engine.Table In RD.Database.Tables
                Dim TLI As TableLogOnInfo = T.LogOnInfo
                TLI.ConnectionInfo = CI
                T.ApplyLogOnInfo(TLI)
            Next
            DisplayedReport.ReportSource = RD
        End Sub
    Does this approach not work with reports containing multiple tables, or is there something I'm missing? Any meaningful suggestions would be much appreciated.

    Dear Dixit,
    Please refer to the Crystal report landing page to get the details
    information about the support for crystal report issues.
    Please use the following thread to post your questions related to
    crystal report.
    SAP Business One and Crystal Reports
    Regards,
    Rakesh Pati
    SAP Business One Forum Team.

  • Navigate from ALV list to normal Report

    Hi ,
    I am working on a ALV report where it will display the list of materials and by selecting these materials from the list and process them using a custom button , it should take me to the normal report which give the log from that material processing.
    Any ideas navigating from AVL to normal report in the same program would be appriciated.
    Thank you.

    Hi,
    if you use drill down you have to define header print twice:
    TOP-OF-PAGE.
      perform 050print_header .
    END-OF-PAGE.
    TOP-OF-PAGE DURING LINE-SELECTION.
      perform 050print_header .
    END-OF-PAGE.

  • Dynamic display of fields of table in ALV report.

    To display the records of a table in ALV report dynamically such that first 10 fields of the table should only be displayed excluding 'mandt' field .
    That is field no 2nd to 11th should be displayed.

    parameters: p_vari type slis_vari.
    at selection-screen on value-request for p_vari.
      perform alv_variant_f4 changing p_vari.
    form alv_variant_f4 changing l_vari type slis_vari.
    On F4 for layout selection - Get laouts created to this report.
      data: l_variant type disvariant.
      l_variant-report   = sy-repid.
      l_variant-username = sy-uname.
      call function 'REUSE_ALV_VARIANT_F4'
        exporting
          is_variant = l_variant
          i_save     = 'A'
        importing
          es_variant = l_variant
        exceptions
          others     = 1.
      if sy-subrc = 0.
        l_vari = l_variant-variant.
      endif.
    Create a structure
    data: wa_layout type disvariant.
    fill up the layout with selected fields.
    wa_layout-report = sy-repid.
    wa_layout-username = sy-uname " Choose this if you want user specific
    wa_layout-variant = p_vari.
    Assign the same to the REUSE_ALV_GRID_DISPLAY
    it is a import paramter  IS_VARIANT = wa_layout.
    All you have to do is first execute the report and save layouts what exactly you want
    and then next time you run the report you will get a chance to select the layout of your own.
    or
    You can get rid of MANDT field from fieldcatalog and internal table by creating a new
    structure. I mean, if you know you always want to display the field from 2 to 11 then simply
    delete the field from fieldcatalog.
    You can assign to different field catalog using Field symbols and change your internal
    table as well since you have created a dynamic internal table.
    Let me know if you need more.

  • How to display ICONS in normal report without using icons table

    Hi Friends,
    I have to display icons(traffic lights) in a normal report.
    Can we do that without using icons table?
    If yes, please let me know how?
    Thanks,

    Hi Pagidala,
    Go to txcode - ABAPDOCU and in that expand BC-ABAP Programming->ABAP User Dialog->Screens->complex screen elements->status icons on Screens.
    In this you can see sample code which may help you.
    Cheers!!

  • How to select multiple row in ALV report

    Hi friends,
    1. How to select multiple row in ALV report
                   ( How to set tab in ALV report and want to select multiple line.)
    Thanking you.
    Subash

    Hi Sahoo,
    If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
    in layout structure you will find field SEL_MODE
    pass :
    LS_LAYOUT-SEL_MODE = 'A'.
    In PAI.
      CALL METHOD GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = T_ROWS
          ET_ROW_NO     = T_ROWID.
    Hope these will solve your problem.
    Regards,
    Kumar M.

  • Crystal Reports and connecting to multiple tables in a dataset - I'm Going Crazy!!

    This is my first application, first report and first everything.  Wouldn't you know the report I am trying to produce is probably more difficult!!  What is happening is that I have a form(screen) up in my application with the information displayed on it from a recrod in a table that I want to put on a report to be view and/or printed and eventually down the road I want to incorporate a signature.  One step at a time though, here is what I have accomplished.  I have created the report, I have gotten it to display in the viewer but it will not push the data from the table that I want displayed.  It only displays the text that I have typed on the form.  This is a Visual Basic application created in Visual Studio 2005 using a SQL database.  If you need more information then just ask and I will try to fumble through and tell you what I know.  (Oh and to top it off............I am also trying to get information to display from other tables also (codes connected to descriptions etc.))
    Any help would be really appreciated as I have went through tutorials, read white papers, tech notes and anything else I can find but I just can't get it to work!!
    Thanks!

    You do need to give more information. To better help, we would need to know the database, when you say SQL do you mean SQL Server, how you created the dataset, whether there are multiple tables in a single dataset or multiple datasets, etc.
    The report appears to be running so the underlying issue as you know will likely be the dataset. You may want to confirm the dataset does in fact have data in it.  Returning a simple count will let you know there are rows. If you used the components rather than code to create the objects you can also see the data returned in the fill process.
    Once you know you have data in the dataset, you can check your reports connection to the dataset.
    Just hang in there... the problem is probably a simple fix. I am sure others will follow on with more suggestions.
    Regards,
    John W.

Maybe you are looking for