Report on ALV fieldcatalog

Hi all,
Is it possible to display mulitple rows from the same table using the ALV field catalog?
Senerio:
if there are 10 columns in the table , first  5 are new values and another 5 are old values. all are in the same table. i would like to display first 5 columns in the first row of the report and then another 5 columns in the second row below that.
please help me if any body having sample senerio for the above or suggest me how can i  gain this.....
thanks in advance.
kP

hi,
iwith classical alv you can separate your 10 fields into 3 rows (with change layout)
A.

Similar Messages

  • Modification in report into ALV Format

    Hi Experts
    How can I modify this report in ALV Format with Top of page and Parameters should be display on runtime.
    Can anyone modify my program please
    Thanks in advanced.
    REPORT FZEL LINE-SIZE  220 LINE-COUNT 75
             NO STANDARD PAGE HEADING.
    TABLES : equi,
             equz,
             imptt,
             imrg,
             eqkt,
             iloa.
    TYPES:  BEGIN OF ty_data  ,
             equnr      type equnr,         " Euipment no
             eqktx      type eqkt-eqktx,    " Equipment Text
             eqfnr       type iloa-eqfnr,     " Equipment Sort field
             idate      type imrg-idate,    " Measuring Date
             recdu      type imrg-recdu,    " Unit of measuring ='KM','L','H'
             recdv      type imrg-recdv,    " Counter reading data
             cancl       type imrg-cancl,
           END OF ty_data.
    TYPES: BEGIN OF ty_final,
             equnr           type equnr,            "  Equipment no
             eqktx           type eqkt-eqktx,       "  Equipment Text
             eqfnr           type iloa-eqfnr,       "  Equipment Sort field
             idate               type imrg-idate,       "  Measuring Date
             min_date_km     type imrg-idate,       "  Min Date
             min_km          type imrg-recdv,       "  Max Km
             max_date_km     type imrg-idate,
             max_km          type imrg-recdv,       "  Min km
             t_max_min_km    type imrg-recdv,       "  Total min_km-max_km
             min_date_hr     type imrg-idate,       "  Max Date
             min_hr          type imrg-recdv,       "  Max hr
             max_date_hr     type imrg-idate,
             max_hr          type imrg-recdv,       "  Min hr
             t_max_min_hr    type imrg-recdv,                "  Total min_hr-max_hr
             min_date_lit    type imrg-idate,
             min_lit         type imrg-recdv,       "  Min lit
             max_date_lit    type imrg-idate,
             max_lit         type imrg-recdv,       "  Max lit
             fuel_con        type imrg-recdv,       "  Total_hrs / t_max_min_hr
             fuel_con2       type imrg-recdv,       "  Total_hrs / t_max_min_hr
             km_l            type imrg-recdv,       "  t max_min_km / t_max_min_lit
             l_p             type imrg-recdv ,          "  t_max_min_lit / t_max_min_hr
             l_p2            type imrg-recdv ,
           END OF ty_final.
    DATA: i_data TYPE TABLE OF ty_data, " internal table
    wa_data TYPE ty_data, " work area
    i_final TYPE TABLE OF ty_final, " internal table
    wa_final TYPE ty_final. " work area
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_equnr FOR equi-equnr OBLIGATORY, "no-extension no intervals,
                    p_idate FOR imrg-idate.  "NO-EXTENSION NO INTERVALS OBLIGATORY,
                   "p_recdu FOR imrg-recdu." NO-EXTENSION NO INTERVALS ."default 'M3'" OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    TOP-OF-PAGE.
      FORMAT INTENSIFIED ON.
      WRITE:/55(40) ' WAGNERS INVESTMENT LIMITED  '.
      WRITE:/50(40) ' VEHICLE FUEL CONSUMPTION REPORT ' CENTERED   ,
              2 'Page', sy-pagno.
      FORMAT INTENSIFIED OFF.
      WRITE:/50(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED ON.
      WRITE:/2 sy-datum COLOR 3, sy-uzeit .
      "WRITE:/1 S903-SPMON ."p_yearf.
      ULINE.
      "CENTERED.
    write: /2 'Equipment No :'left-justified,p_equnr-low  color 2 , '  to   '  , p_equnr-high color 2.
    write: /2 'Date From    :', p_idate-low color 2 ,  ' to  '  , p_idate-high color 2.
    "write: /2 'Sort Field:'left-justified,p_eqfnr-low  color 2 , '  to   '  , p_eqfnr-high color 2.
    SKIP.
      ULINE.
    WRITE:/1 sy-vline,
        2   ' EQUIP#',                10 sy-vline ,
        11  ' NAME',                  40 sy-vline,
        41  ' SORT',                  60 sy-vline,
        61  ' START DATE',            74 sy-vline,
        75  ' END DATE',               87 sy-vline,
        88  ' START KM',              100 sy-vline,
        101 ' END KM' ,               113 sy-vline,
        114 ' TOTAL KM',              126 sy-vline,
        127 ' START HR',              139 sy-vline,
        140 ' END HR',                152 sy-vline,
        153 ' TOTAL HR',              167 sy-vline,
        168 ' FUEL CON ',             180 sy-vline,
        181 ' KM L',                  193 sy-vline,
        194 ' LIT PER HR ',           206 sy-vline,
        207 ' EQUIP NO',              220 sy-vline,
        223 'KM L',                  232 sy-vline,
        233 'LIT PER KM',            245 sy-vline,
        246 'TOTAL L/HR',            258 sy-vline.
      FORMAT COLOR 3 ON.
      ULINE.
    END-OF-PAGE.
    START-OF-SELECTION.
    select aequnr deqktx feqfnr eidate erecdu erecdv
    into table i_data
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate and
    e~cancl ne 'X'.
    loop  at i_data into wa_data.
    CLEAR: wa_final.
      READ TABLE i_final into wa_final
               with key equnr = wa_data-equnr." BINARY SEARCH.
        if sy-subrc EQ 0.
          PERFORM F_GET_MAX_DATA.
          PERFORM F_GET_MAX_HOURS.
          PERFORM F_GET_MAX_LIT.
          PERFORM prepare_final_rec USING'M'. " Modify Existing Record
         ElSE.
          PERFORM prepare_final_rec USING'A'. " Append New Record.
        ENDIF.
        ENDLOOP.
        LOOP AT i_final into wa_final.
    on change of wa_final-equnr.
    WRITE:/1 sy-vline,
    2  wa_final-equnr                                                       , 10 sy-vline,
    11 wa_final-eqktx                                                       , 40 sy-vline,
    41 wa_final-eqfnr                                                       , 60 sy-vline,
    61 wa_final-min_date_km  color 2                                        , 74 sy-vline,
    75 wa_final-max_date_km  color 2 LEFT-JUSTIFIED                         , 87 sy-vline,
    88 wa_final-min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED   color 3       , 100 sy-vline,
    101 wa_final-max_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED   color 3      , 113 sy-vline,
    114 wa_final-t_max_min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED          , 126 sy-vline,
    127 wa_final-min_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED color 4        , 139 sy-vline,
    140 wa_final-max_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED color 4        , 152 sy-vline,
    153 wa_final-t_max_min_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED          , 167 sy-vline,
    168 wa_final-fuel_con2 EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED             , 180 sy-vline,
    181 wa_final-km_l EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED            ,193 sy-vline,
    194 wa_final-l_p2 EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED  color  2        , 206 sy-vline,
    207 wa_final-equnr                                                      ,220 sy-vline.
    endon.
    endloop.
    refresh i_final.
    clear i_final.
    FORM F_GET_MAX_DATA.
    select single MAX( eidate ) Min( eidate ) MAX( erecdv ) MIN( erecdv )
    into  corresponding fields of (wa_final-max_date_km,wa_final-min_date_km,wa_final-max_km ,wa_final-min_km)
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne 'X' and
    e~recdu =  'KM'
    AND a~equnr = wa_data-equnr.
    ENDFORM.
    FORM F_GET_MAX_HOURS.
    select single MAX( erecdv ) MIN( erecdv )
    into corresponding fields of (wa_final-max_hr, wa_final-min_hr)
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne  'X' and
    e~recdu =  'H'
    AND a~equnr = wa_data-equnr  .
    ENDFORM.
    FORM F_GET_MAX_LIT.
    select SUM( e~recdv )
    into corresponding fields of (wa_final-fuel_con2)
    from equi AS a
    inner join eqkt as b
    on bequnr = aequnr
    inner join imptt as c
    on cmpobj = aobjnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne  'X' and
    e~recdu =  'L'
    AND a~equnr = wa_data-equnr.
    ENDFORM.
    FORM prepare_final_rec  USING    p_mode TYPE char1.
    wa_final-t_max_min_km = wa_final-max_km - wa_final-min_km .
    wa_final-t_max_min_hr = wa_final-max_hr - wa_final-min_hr.
    if  wa_final-t_max_min_km <> 0 .
    wa_final-km_l =  ( wa_final-max_km - wa_final-min_km )  /  ( wa_final-fuel_con2 ) .
    ELSE.
    wa_final-km_l = 0.
    endif.
    if  wa_final-t_max_min_hr <> 0  .
    wa_final-l_p2 = ( wa_final-fuel_con2 ) / (  wa_final-t_max_min_hr ) .
    ELSE.
    wa_final-l_p2 = 0.
    endif.
      IF p_mode = 'A'.
        wa_final-equnr = wa_data-equnr.
        wa_final-eqktx = wa_data-eqktx.
        wa_final-eqfnr = wa_data-eqfnr.
        wa_final-t_max_min_km = wa_final-min_km - wa_final-max_km .
        wa_final-t_max_min_hr = wa_final-max_hr - wa_final-min_hr.
        wa_final-km_l =  ( wa_final-max_km - wa_final-min_km ) /  ( wa_final-fuel_con2 ).
        wa_final-l_p2 = ( wa_final-fuel_con2 ) / (  wa_final-t_max_min_hr ) .
        APPEND wa_final TO i_final  .
      ELSE.
        MODIFY i_final FROM wa_final
          TRANSPORTING
              eqfnr
              max_date_km
              min_date_km
              max_date_lit
              min_date_lit
              max_date_hr
              min_date_hr
              max_km
              min_km
              max_hr
              min_hr
              t_max_min_km
              t_max_min_hr
              fuel_con2
              km_l
              l_p2
              where equnr = wa_data-equnr.
      ENDIF.
    ENDFORM.                    " PREPARE_FINAL_REC

    Hi Guys
    Thanks for your reply, I know how to implement the FM for ALV but little confused where to call , See my correction below it is displaying the result in different way that ie...first displaying Equipment no, name,.correctly but the other values such as km,L,HR all are displaying zero first, when I press back then it is displying the value twice thrise........keep on displaying duplicate records continuesly when back back is press can anyone correct this please
    REPORT  XYZ LINE-SIZE  220 LINE-COUNT 75
             NO STANDARD PAGE HEADING.
    TABLES : equi,
             equz,
             imptt,
             imrg,
             eqkt,
             iloa.
    type-pools: slis.                                 "ALV Declarations
    TYPES:  BEGIN OF ty_data  ,
             equnr      type equnr,         " Euipment no
             eqktx      type eqkt-eqktx,    " Equipment Text
             eqfnr       type iloa-eqfnr,     " Equipment Sort field
             idate      type imrg-idate,    " Measuring Date
             recdu      type imrg-recdu,    " Unit of measuring ='KM','L','H'
             recdv      type imrg-recdv,    " Counter reading data
             cancl       type imrg-cancl,
           END OF ty_data.
    TYPES: BEGIN OF ty_final,
             equnr           type equnr,            "  Equipment no
             eqktx           type eqkt-eqktx,       "  Equipment Text
             eqfnr           type iloa-eqfnr,       "  Equipment Sort field
             idate               type imrg-idate,       "  Measuring Date
             min_date_km     type imrg-idate,       "  Min Date
             min_km          type P DECIMALS 2,       "  Max Km
             max_date_km     type imrg-idate,
             max_km          type P DECIMALS 2,       "  Min km
             t_max_min_km    type P DECIMALS 2,       "  Total min_km-max_km
             min_date_hr     type imrg-idate,       "  Max Date
             min_hr          type P DECIMALS 2,       "  Max hr
             max_date_hr     type imrg-idate,
             max_hr          type P DECIMALS 2,       "  Min hr
             t_max_min_hr    type P DECIMALS 2,                "  Total min_hr-max_hr
             min_date_lit    type imrg-idate,
             min_lit         type P DECIMALS 2,       "  Min lit
             max_date_lit    type imrg-idate,
             max_lit         type P DECIMALS 2,       "  Max lit
             fuel_con        type P DECIMALS 2,       "  Total_hrs / t_max_min_hr
             fuel_con2       type P DECIMALS 2,       "  Total_hrs / t_max_min_hr
             km_l            type P DECIMALS 2,       "  t max_min_km / t_max_min_lit
             l_p             type P DECIMALS 2 ,      "  t_max_min_lit / t_max_min_hr
             l_p2            type P DECIMALS 2 ,
           END OF ty_final.
    *ALV data declarations
    data: fieldcatalog 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: i_data TYPE TABLE OF ty_data, " internal table
    wa_data TYPE ty_data, " work area
    i_final TYPE TABLE OF ty_final, " internal table
    wa_final TYPE ty_final. " work area
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_equnr FOR equi-equnr OBLIGATORY, "no-extension no intervals,
                    p_idate FOR imrg-idate.  "NO-EXTENSION NO INTERVALS OBLIGATORY,
                   "p_recdu FOR imrg-recdu." NO-EXTENSION NO INTERVALS ."default 'M3'" OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    TOP-OF-PAGE.
      FORMAT INTENSIFIED ON.
      WRITE:/55(40) ' WAGNERS INVESTMENT LIMITED  '.
      WRITE:/50(40) ' VEHICLE FUEL CONSUMPTION REPORT ' CENTERED   ,
              2 'Page', sy-pagno.
      FORMAT INTENSIFIED OFF.
      WRITE:/50(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED ON.
      WRITE:/2 sy-datum COLOR 3, sy-uzeit .
      "WRITE:/1 S903-SPMON ."p_yearf.
      ULINE.
      "CENTERED.
    write: /2 'Equipment No :'left-justified,p_equnr-low  color 2 , '  to   '  , p_equnr-high color 2.
    write: /2 'Date From    :', p_idate-low color 2 ,  ' to  '  , p_idate-high color 2.
    END-OF-PAGE.
    START-OF-SELECTION.
    select aequnr deqktx feqfnr eidate erecdu erecdv
    into table i_data
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate and
    e~cancl ne 'X'.
    loop  at i_data into wa_data.
    CLEAR: wa_final.
      READ TABLE i_final into wa_final
               with key equnr = wa_data-equnr." BINARY SEARCH.
        if sy-subrc EQ 0.
          PERFORM F_GET_MAX_DATA.
          PERFORM F_GET_MAX_HOURS.
          PERFORM F_GET_MAX_LIT.
          PERFORM prepare_final_rec USING'M'. " Modify Existing Record
         ElSE.
          PERFORM prepare_final_rec USING'A'. " Append New Record.
          perform build_fieldcatalog.
          perform build_layout.
          perform display_alv_report.
        ENDIF.
       ENDLOOP.
    refresh i_final.
    clear i_final.
    FORM F_GET_MAX_DATA.
    select single MAX( eidate ) Min( eidate ) MAX( erecdv ) MIN( erecdv )
    into   corresponding fields of (wa_final-max_date_km,wa_final-min_date_km,wa_final-max_km ,wa_final-min_km)
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne 'X' and
    e~recdu =  'KM'
    AND a~equnr = wa_data-equnr.
    ENDFORM.
    FORM F_GET_MAX_HOURS.
    select single MAX( erecdv ) MIN( erecdv )
    into corresponding fields of (wa_final-max_hr, wa_final-min_hr)
    from equi AS a
    inner join equz as b
    on aequnr = bequnr
    inner join iloa as f
    on biloan = filoan
    inner join imptt as c
    on aobjnr = cmpobj
    inner join eqkt as d
    on aequnr = dequnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne  'X' and
    e~recdu =  'H'
    AND a~equnr = wa_data-equnr  .
    ENDFORM.
    FORM F_GET_MAX_LIT.
    select SUM( e~recdv )
    into corresponding fields of (wa_final-fuel_con2)
    from equi AS a
    inner join eqkt as b
    on bequnr = aequnr
    inner join imptt as c
    on cmpobj = aobjnr
    inner join imrg as e
    on epoint = cpoint
    where a~equnr in p_equnr
    and
    e~idate in p_idate
    and
    e~cancl ne  'X' and
    e~recdu =  'L'
    AND a~equnr = wa_data-equnr.
    ENDFORM.
    FORM prepare_final_rec  USING    p_mode TYPE char1.
    wa_final-t_max_min_km = wa_final-max_km - wa_final-min_km .
    wa_final-t_max_min_hr = wa_final-max_hr - wa_final-min_hr.
    if  wa_final-t_max_min_km <> 0 .
    wa_final-km_l =  ( wa_final-max_km - wa_final-min_km )  /  ( wa_final-fuel_con2 ) .
    ELSE.
    wa_final-km_l = 0.
    endif.
    if  wa_final-t_max_min_hr <> 0  .
    wa_final-l_p2 = ( wa_final-fuel_con2 ) / (  wa_final-t_max_min_hr ) .
    ELSE.
    wa_final-l_p2 = 0.
    endif.
      IF p_mode = 'A'.
        wa_final-equnr = wa_data-equnr.
        wa_final-eqktx = wa_data-eqktx.
        wa_final-eqfnr = wa_data-eqfnr.
        wa_final-t_max_min_km = wa_final-min_km - wa_final-max_km .
        wa_final-t_max_min_hr = wa_final-max_hr - wa_final-min_hr.
        wa_final-km_l =  ( wa_final-max_km - wa_final-min_km ) /  ( wa_final-fuel_con2 ).
      gd_repid = sy-repid.
        wa_final-l_p2 = ( wa_final-fuel_con2 ) / (  wa_final-t_max_min_hr ) .
        APPEND wa_final TO i_final  .
      ELSE.
        MODIFY i_final FROM wa_final
          TRANSPORTING
              eqfnr
              max_date_km
              min_date_km
              max_date_lit
              min_date_lit
              max_date_hr
              min_date_hr
              max_km
              min_km
              max_hr
              min_hr
              t_max_min_km
              t_max_min_hr
              fuel_con2
              km_l
              l_p2
              where equnr = wa_data-equnr.
      ENDIF.
    ENDFORM.                    " PREPARE_FINAL_REC
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EQUNR'.
      fieldcatalog-seltext_m   = 'Equip no'.
      fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EQKTX'.
      fieldcatalog-seltext_m   = 'Description'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 1.
    append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EQFNR'.
      fieldcatalog-seltext_m   = 'Sortfield'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MIN_DATE_KM'.
      fieldcatalog-seltext_m   = 'Min Date'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MAX_DATE_KM'.
      fieldcatalog-seltext_m   = 'Max Date'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MIN_KM' .
      fieldcatalog-seltext_m   = 'Min KM'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MAX_KM' .
      fieldcatalog-seltext_m   = 'Max KM'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'T_MAX_MIN_KM' .
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-seltext_m   = 'Total KM'.
      fieldcatalog-col_pos     = 7.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    fieldcatalog-fieldname   = 'MIN_HR' .
      fieldcatalog-seltext_m   = 'Min Hr'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MAX_HR' .
      fieldcatalog-seltext_m   = 'Max Hr'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 9.
    append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'T_MAX_MIN_HR' .
      fieldcatalog-seltext_m   = 'Total HR'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 10.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FUEL_CON2' .
      fieldcatalog-seltext_m   = 'Km/L'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 11.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'L_P2' .
      fieldcatalog-seltext_m   = 'Lit/HR'.
        fieldcatalog-tabname     =  'i_final'.
      fieldcatalog-col_pos     = 12.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    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_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = i_final
                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

  • Hi gurur's how we  do the interactive report in ALV

    hi gurur's how we  do the interactive report in ALV.
    PLZ HELP ME

    Hi Srivasu,
                    I will send a sample code along with Comments check it once ok.copy the below code and execute it and debug it ok..
    *& Report  YPURCHASEORDER_ALV_LISTDISP                                 *
    *&  DEVELOPER  : KIRAN KUMAR.G                                         *
    &  PURPOSE    : CREATING A PURCHASE ORDER BASED ON PURCHASE DOC NUMBER
    *&  CREATION DT: 22/11/2007                                            *
    *&  REQUEST   : ERPK900035                                             *
    REPORT  YPURCHASEORDER_ALV_LISTDISP.
    Tables
    TABLES : ekko, "Purchasing Document Header
             ekpo. "Purchasing Document Item
    Type pools
    TYPE-POOLS: slis.
    Internal Tables
    DATA: BEGIN OF gt_headerdat OCCURS 0,
           ebeln LIKE ekko-ebeln,        " Purchasing Document Number
           bukrs LIKE ekko-bukrs,        " Company Code
           bstyp LIKE ekko-bstyp,        " Purchasing Document Category
           bsart LIKE ekko-bsart,        " Purchasing Document LIKE
           aedat LIKE ekko-aedat,        " Date on which the recordwascreate
           ernam LIKE ekko-ernam,        " Name of Person who Created Object
           lifnr LIKE ekko-lifnr,        " Vendor's account number
           spras LIKE ekko-spras,        " Language Key
           ekorg LIKE ekko-ekorg,        " Purchasing Organization
           ekgrp LIKE ekko-ekgrp,        " Purchasing group
          END OF gt_headerdat.
    DATA: BEGIN OF gt_item OCCURS 0,
           matnr LIKE ekpo-matnr,        "Material Number
           werks LIKE ekpo-werks,        "Plant
           lgort LIKE ekpo-lgort,        "Storage location
           matkl LIKE ekpo-matkl,        "Material group
           menge LIKE ekpo-menge,        "Purchase order quantity
           meins LIKE ekpo-meins,        "Order unit
           netpr LIKE ekpo-netpr,        "Net price in purchasing document
           kunnr LIKE ekpo-kunnr,        "Customer Number 1
          END OF gt_item.
    Global Structures
    DATA: gt_header    TYPE slis_t_listheader, "For Headings
          wa_header    TYPE slis_listheader,
          gt_fieldcat  TYPE slis_t_fieldcat_alv, "Structure Defintion
          wa_fieldcat  TYPE slis_fieldcat_alv,
          gt_fieldcat1 TYPE slis_t_fieldcat_alv,
          wa_fieldcat1 TYPE slis_fieldcat_alv,
          wa_layout    TYPE slis_layout_alv,     "Layout
          gt_events    TYPE slis_t_event,        "For Events
          wa_events    TYPE slis_alv_event.
    Selection Screen
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS  : s_ebeln FOR ekko-ebeln.
    SELECTION-SCREEN: END OF BLOCK b1.
    Initialization
    INITIALIZATION.
      PERFORM initial.
    Fetch Data
    START-OF-SELECTION.
      PERFORM fetch_data.
    END-OF-SELECTION.
    Bulid fieldcatalog
      PERFORM fieldcat.
    Change fieldcatalog
      PERFORM fieldcat_change.
    Events Triggering
      PERFORM place_events.
    Layout.
      PERFORM layout.
    Display Data
      SORT gt_headerdat BY ebeln.
      PERFORM display_list.
    *&      Form  initial
          text
    -->  p1        text
    <--  p2        text
    FORM initial .
      s_ebeln-sign    = 'I'.
      s_ebeln-option  = 'BT'.
      s_ebeln-low     = '3000000090'.
      s_ebeln-high    = '3000000166'.
      APPEND s_ebeln.
    ENDFORM.                    " initial
    *&      Form  fetch_data
          text
    -->  p1        text
    <--  p2        text
    FORM fetch_data .
      REFRESH gt_headerdat.  "Clear the Body of Internal Table
      CLEAR   gt_headerdat.  "Clear Header Line
      SELECT ebeln
             bukrs
             bstyp
             bsart
             aedat
             ernam
             lifnr
             spras
             ekorg
             ekgrp
        FROM ekko
        INTO TABLE gt_headerdat
       WHERE ebeln IN s_ebeln.
    ENDFORM.                    " fetch_data
    *&      Form  display_list
          text
    -->  p1        text
    <--  p2        text
    FORM display_list .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
        i_callback_program             = sy-cprog
      I_CALLBACK_PF_STATUS_SET       = ' '
        i_callback_user_command        = 'USERCOMMAND'
      I_STRUCTURE_NAME               =
        is_layout                      = wa_layout
        it_fieldcat                    = gt_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
        it_events                      = gt_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
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
        t_outtab                       = gt_headerdat
       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_list
    *&      Form  place_events
          text
    -->  p1        text
    <--  p2        text
    FORM place_events .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = gt_events
        EXCEPTIONS
          list_type_wrong = 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.
      CLEAR wa_events.   "Clear Header Line
      READ TABLE gt_events INTO wa_events WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc = 0.
        wa_events-form = 'HEADING'.
        MODIFY gt_events FROM wa_events INDEX sy-tabix.
      ENDIF.
      CLEAR wa_events.   "Clear Header Line
      READ TABLE gt_events INTO wa_events WITH KEY name = 'END_OF_LIST'.
      IF sy-subrc = 0.
        wa_events-form = 'PAGEDOWN'.
        MODIFY gt_events FROM wa_events INDEX sy-tabix.
      ENDIF.
      CLEAR wa_events.    "Clear Header Line
      READ TABLE gt_events INTO wa_events WITH KEY name = 'USER_COMMAND'.
      IF sy-subrc = 0.
        wa_events-form = 'USERCOMMAND'.
        MODIFY gt_events FROM wa_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " place_events
    *&      Form  layout
          text
    -->  p1        text
    <--  p2        text
    FORM layout .
      CLEAR wa_layout.                   "Clear Header Line
      wa_layout-zebra = 'X'.             "Zebra Lines in the Output
      wa_layout-colwidth_optimize = 'X'. "Optimize the Column Width
    ENDFORM.                    " layout
    *&      Form  heading
          text
    FORM heading.
      WRITE:/6 'THIS REPORT DISPLAYS THE PURCHASE ORDER DETAILS'.
      WRITE:/6 'CLICK ON PURCHASE DOC NO FIELD(INTERACTIVE LIST)'.
    ENDFORM.                    "heading
    *&      Form  fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM fieldcat .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
        i_program_name               = SY-CPROG
        i_internal_tabname           = 'GT_HEADERDAT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
        i_inclname                   = SY-CPROG
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
        ct_fieldcat                  = gt_fieldcat
       EXCEPTIONS
        inconsistent_interface       = 1
        program_error                = 2
        OTHERS                       = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " fieldcat
    *&      Form  fieldcat_change
          text
    -->  p1        text
    <--  p2        text
    FORM fieldcat_change .
      LOOP AT gt_fieldcat INTO wa_fieldcat.
        CASE wa_fieldcat-fieldname.
          WHEN 'EBELN'.
            wa_fieldcat-hotspot  = 'X'.
        ENDCASE.
        MODIFY gt_fieldcat FROM wa_fieldcat INDEX sy-tabix.
      ENDLOOP.
    ENDFORM.                    " fieldcat_change
    *&      Form  pagedown
          text
    FORM pagedown.
      WRITE:/35 'HAVE A NICE DAY...' COLOR 4.
    ENDFORM.                    "pagedown
    *&      Form  usercommand
          text
         -->UCOMM      text
         -->SELFIELD   text
    FORM usercommand USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      READ TABLE gt_headerdat INDEX selfield-tabindex.
      CASE selfield-sel_tab_field.
        WHEN 'GT_HEADERDAT-EBELN'.
          REFRESH : gt_item.
          CLEAR   : gt_item.
          SELECT matnr
                 werks
                 lgort
                 matkl
                 menge
                 meins
                 netpr
                 kunnr
            FROM ekpo
            INTO TABLE gt_item
           WHERE ekpo~ebeln EQ gt_headerdat-ebeln.
    *Build a Field Catalog
          PERFORM fieldcat1.
    *For Heading in the Interactive List
          PERFORM heading1.
    *Display Interactive Data
          PERFORM display_data1.
      ENDCASE.
    ENDFORM.                    "usercommand
    *&      Form  fieldcat1
          text
    -->  p1        text
    <--  p2        text
    FORM fieldcat1 .
      REFRESH : gt_fieldcat1.
      CLEAR   : wa_fieldcat1.
      wa_fieldcat1-col_pos    = '1'.           "Column Postion
      wa_fieldcat1-fieldname  = 'MATNR'.       "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.   "Internal Table
      wa_fieldcat1-key        = 'X'.           "Blue Color
      wa_fieldcat1-seltext_l  = 'MATERIAL NO'. "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '2'.           "Column Postion
      wa_fieldcat1-fieldname  = 'WERKS'.       "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.   "Internal Table
      wa_fieldcat1-seltext_l  = 'PLANT'.       "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '3'.           "Column Postion
      wa_fieldcat1-fieldname  = 'LGORT'.       "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.   "Internal Table
      wa_fieldcat1-seltext_l  = 'STORAGE LOCATION'."Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '4'.            "Column Postion
      wa_fieldcat1-fieldname  = 'MATKL'.        "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.    "Internal Table
      wa_fieldcat1-seltext_l  = 'MATERIAL GRP'. "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '5'.            "Column Postion
      wa_fieldcat1-fieldname  = 'MENGE'.        "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.    "Internal TAble
      wa_fieldcat1-seltext_l  = 'PO QUANTITY'.  "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '6'.            "Column Pos tion
      wa_fieldcat1-fieldname  = 'MEINS'.        "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.    "Internal TAble
      wa_fieldcat1-seltext_l  = 'BASE UNIT MEASURE'."Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '7'.            "Column Postion
      wa_fieldcat1-fieldname  = 'NETPR'.        "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.    "Internal Table
      wa_fieldcat1-seltext_l  = 'NET PRICE'.    "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
      wa_fieldcat1-col_pos    = '8'.            "Column Postion
      wa_fieldcat1-fieldname  = 'KUNNR'.        "Field Name
      wa_fieldcat1-tabname    = 'GT_ITEM'.    "Internal Table
      wa_fieldcat1-seltext_l  = 'CUSTOMER NO'.  "Display Text Screen
      APPEND wa_fieldcat1 TO gt_fieldcat1.
      CLEAR wa_fieldcat1.
    ENDFORM.                                                    " fieldcat1
    *&      Form  heading1
          text
    -->  p1        text
    <--  p2        text
    FORM heading1 .
      REFRESH : gt_header.
      CLEAR   : wa_header.
      wa_header-typ  = 'H'.
      wa_header-info = 'THIS IS AN INTERACTIVE LIST'.
      APPEND wa_header TO gt_header.
    ENDFORM.                                                    " heading1
    *&      Form  top
          text
    FORM top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
        it_list_commentary       = gt_header
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    "top
    *&      Form  display_data1
          text
    -->  p1        text
    <--  p2        text
    FORM display_data1 .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
        i_callback_program                = SY-CPROG
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
        i_callback_top_of_page            = 'TOP'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
        it_fieldcat                       = gt_fieldcat1
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
        t_outtab                          = gt_item
       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_data1
    Reward points if helpful.
    Kiran Kumar.G.A
            Have a Nice Day..

  • How to convert an Interactive report to ALV report..please give a example..

    Hi experts,
    How to convert an interactive report to ALV report..plz suggest me an example...
    thanks in advance,
    Varsha.

    hi varsha,
    chk this link.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm
    you will get good idea.
    use this FM.
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE' 
                I_callback_user_command = 'USER_COMMAND' 
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]      "create a field catlog.
                i_save                  = 'X'
           tables
                t_outtab                = it_tab        "pass the final internal table.
           exceptions
                program_error           = 1
                others                  = 2.
    Regards
    Anver

  • Change report into ALV format

    Hi Experts
    I am new in ALV ......
    How can I make this report in ALV Grid Format, please help to change it and revert me back if possible
    I need the top of page which should shows parameters also
    regards
    Piroz
    REPORT Z_ESLP_ZROLE LINE-SIZE  90 LINE-COUNT 300
             NO STANDARD PAGE HEADING.
    TABLES : agr_tcodes,agr_users,tstct.
    TYPES:  BEGIN OF ty_data  ,
             agr_tcodes type agr_tcodes-tcode ,        " Transaction code     A
             agr_name   type agr_tcodes-agr_name,      " Role Name            B
             agr_uname  type agr_users-uname,          "  Short User Name     B
             ttext      type tstct-ttext,              "  Description Name    C
             sprsl      type tstct-sprsl ,             "  Language            c
           END OF ty_data.
    DATA: i_data TYPE TABLE OF ty_data, " internal table
    wa_data TYPE ty_data. " work area
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: p_tcode FOR agr_tcodes-tcode , "OBLIGATORY, "no-extension no intervals,
                    u_name  for agr_users-uname,
                    r_name for agr_users-uname .
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    TOP-OF-PAGE.
      FORMAT INTENSIFIED ON.
      WRITE:/25(40) ' GNG INVESTMENT LIMITED  '.
      WRITE:/20(40) ' USER TRANSACTION CODE REPORT ' CENTERED   ,
              2 'Page', sy-pagno.
      FORMAT INTENSIFIED OFF.
      WRITE:/20(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED ON.
      WRITE:/2 sy-datum COLOR 3, sy-uzeit .
      ULINE.
    write: /2 'Transaction Code  :'left-justified,p_tcode-low  color 2 , '  to   '  , p_tcode-high color 2.
    write: /2 'User Name         :'left-justified,u_name-low   color 2 , '  to   '  , u_name-high Color 2.
    write: /2 'Role Name         :'left-justified,r_name-low   color 2 , '  to   '  , r_name-high Color 2.
    ULINE.
      ULINE.
    WRITE:/1 sy-vline,
        2   'USER',                       15 sy-vline ,
        16  'ROLE NAME',                  30 sy-vline,
        31  'TRANS CODE',                 50 sy-vline,
        51  'DESCRIPTION',                90 sy-vline.
    FORMAT COLOR 3 ON.
      ULINE.
    END-OF-PAGE.
    START-OF-SELECTION.
    select agr_tcodestcode agr_tcodesagr_name agr_usersuname  tstctttext tstct~sprsl
    into table i_data
    from agr_tcodes
    inner join agr_users
    on agr_tcodesagr_name = agr_usersagr_name
    inner join tstct
    on agr_tcodestcode = tstcttcode
    where
    agr_tcodes~tcode in p_tcode
    and
    agr_users~uname in u_name
    and
    agr_tcodes~agr_name in r_name
    and
    tstct~sprsl eq 'E'.
    loop  at i_data into wa_data.
    format color off.
    WRITE:/1 sy-vline,
        2   wa_data-agr_uname   ,                       15 sy-vline ,
        16  wa_data-agr_name   ,                      30 sy-vline,
        31  wa_data-agr_tcodes ,                      50 sy-vline,
        51  wa_data-ttext,                            90 sy-vline.
    ULINE.
    endloop.

    Hi Piroz,
    Check this sample program to create ALV program. Steps are provided every step in the program.
    report  zvenkat_alv_2_grid_description.
    types:
          begin of t_mard,
           werks type mard-werks,
           lgort type mard-lgort,
           matnr type mard-matnr,
           insme type mard-insme,
           einme type mard-einme,
           speme type mard-speme,
          end of t_mard.
    data:
          w_mard type t_mard.
    data:
          i_mard type standard table of t_mard.
    " ALV Declarations
    "     ALV internal tables and Structures
    "     To refer ALV tables(slis tables) and structures.SLIS must be
    "     declared under TYPE-POOLS(see below).SLIS is a Type group which is
    "     defined in Dictionary.Internal tables and structures and constants
    "     are defined under type group.(Double click on SLIS).
    * Types Pools
    type-pools:
       slis.
    * Types
    types:
       t_fieldcat         type slis_fieldcat_alv,
       t_events           type slis_alv_event,
       t_layout           type slis_layout_alv.
    * Workareas
    data:
       w_fieldcat         type t_fieldcat,
       w_events           type t_events,
       w_layout           type t_layout.
    * Internal Tables
    data:
       i_fieldcat         type standard table of t_fieldcat,
       i_fieldcat1        type standard table of t_fieldcat,
       i_events           type standard table of t_events.
    *&      START-OF-SELECTION
    start-of-selection.
      perform get_data_from_database .
      "      END-OF-SELECTION
      "     Steps to create simple ALV program
      "      1. Pass an internal table with the set of output information
      "      2. Pass a field catalog as an internal table
      "      3. Pass a structure with general list layout details
    end-of-selection.
      perform build_fieldcatalog.
      perform build_events.
      perform build_layout.
      perform display_data.
      "      Form  build_fieldcatalog
      "     Fieldcatalog Internal table
      "    1. It contains descriptions of the list output fields
      "       (usually a subset of the internal output table fields).
      "    2. A field catalog is required for every ALV list output.
    form build_fieldcatalog .
      clear :
        w_fieldcat,
       i_fieldcat[].
      perform build_fcat using:
            "Field   Int.Table Column headings
            'WERKS' 'I_MARD' 'WERKS',
            'LGORT' 'I_MARD' 'LGORT',
            'MATNR' 'I_MARD' 'MATNR',
            'INSME' 'I_MARD' 'INSME',
            'EINME' 'I_MARD' 'EINME',
            'SPEME' 'I_MARD' 'SPEME'.
    endform.                    " build_fieldcatalog
    *&      Form  display_data
    form display_data .
      data :program like sy-repid value sy-repid.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
          i_callback_program = program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
          it_events          = i_events
        tables
          t_outtab           = i_mard.
      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_data
    *&      Form  get_data_from_database
    *       text
    form get_data_from_database .
      clear :i_mard,
             i_mard[].
      select werks lgort matnr insme einme speme
      from mard
      into corresponding fields of table i_mard
        up to 100 rows.
    endform.                    " get_data_from_database
    *&      Form  top_of_page
    *       text
    form top_of_page.
      data :
      i_header type slis_t_listheader,
      w_header like line of i_header.
      data:l_date1 type datum,
           l_date2 type datum.
      w_header-typ = 'S'.
      w_header-info = sy-title.
      append w_header to i_header.
      clear w_header.
      w_header-typ = 'H'.
      w_header-info = sy-repid.
      append w_header to i_header.
      clear w_header.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = i_header
          i_logo             = 'ENJOYSAP_LOGO'.
    endform.                    "top_of_page
    *&      Form  BUILD_FCAT
    form build_fcat  using  l_field l_tab l_text.
      w_fieldcat-fieldname = l_field.
      w_fieldcat-tabname   = l_tab.
      w_fieldcat-seltext_m = l_text.
      append w_fieldcat to i_fieldcat.
      clear w_fieldcat.
    endform.                    " BUILD_FCAT
    "      Form  build_events
    "     Events
    "    1. When we use ALV,certain events TOP-OF-PAGE ,END-OF-PAGE,
    "       AT LINE-SELECTION,AT USER-COMMANDs are not triggered.
    "    2. To perform those Functions ,we have to build Events table and
    "       pass this table through REUSE_ALV_LIST_DISPALY Function.
    form build_events .
      clear :
             w_events,i_events[].
      w_events-name = 'TOP_OF_PAGE'.
      w_events-form = 'TOP_OF_PAGE'.
      append w_events to i_events.
      clear w_events.
    endform.                    " build_events
    "&      Form  build_layout
    "     Layouts
    "  Use :We change the display of our list using layouts.
    "  ===
    "  Features
    "  ========
    "    The layouts that you can use vary according to the type of list:
    "   1-->In all lists, you can do the following:
    "       (a).Choose one of the std layouts supplied with the std system.
    "       (b).Change the current layout of the list .
    "   2-->In lists that use only the standard layouts in the std system
    "       you cannot save your changes to the current layout.When you
    "       choose the layouts, only the standard layouts will be proposed.
    "   3-->In some lists, you can also save the layouts that you have
    "       defined as our own layouts.
    "      User-defined layouts are generally saved for all users. They can
    "       then be used by all users. All users will be able to choose from
    "       the user-defined layouts as well as the standard layouts.
    "   4-->In some lists, you can also save user-specific layouts that you
    "       have defined . When you choose the current layout,only these
    "       layouts are available to you.
    "   5-->You can delete or transport layouts, or define them as initial
    "       layouts
    "   6-->STRUCTURE :SLIS_LAYOUT_ALV.
    form build_layout .
      clear:
            w_layout.
      w_layout-colwidth_optimize = 'X'.
    endform.                    " build_layout
    Regards,
    Venkat.O

  • Interactive reporting in alv

    hi experts ..
    i has a query of how to do interactive reporting in alv,s what are the function modules i can use to attain interactiveness. .?
    Regards,
    sujatha

    Hi,
    Check the below code... u will get some idea...
    REPORT  zmms_alv_1 NO STANDARD PAGE HEADING
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      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.
    *ALV data declarations
    DATA: fieldcatalog 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,
          gt_events     TYPE slis_t_event,
          gd_prntparams TYPE slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM build_events.
      PERFORM build_print_params.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
      fieldcatalog-hotspot     = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    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_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_pf_status_set = 'PF_STATUS_SET'
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           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 TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    * Form  TOP-OF-PAGE                                                 *
    * ALV Report Header                                                 *
    FORM top-of-page.
    *ALV Header declarations
      DATA: t_header TYPE slis_t_listheader,
            wa_header TYPE slis_listheader,
            t_line LIKE wa_header-info,
            ld_lines TYPE i,
            ld_linesc(10) TYPE c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      APPEND wa_header TO t_header.
      CLEAR wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      APPEND wa_header TO t_header.
      CLEAR: wa_header.
    * Total No. of Records Selected
      DESCRIBE TABLE it_ekko LINES ld_lines.
      ld_linesc = ld_lines.
      CONCATENATE 'Total No. of Records Selected: ' ld_linesc
                        INTO t_line SEPARATED BY space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      APPEND wa_header TO t_header.
      CLEAR: wa_header, t_line.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header
          i_logo             = 'HCL'.
    ENDFORM.                    "top-of-page
    *       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' or '&NFO'.
    *   Check field clicked on within ALVgrid report
          IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
            READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
            SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
            CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  BUILD_EVENTS
    *       Build events table
    FORM build_events.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gt_events[].
      READ TABLE gt_events WITH KEY name =  slis_ev_end_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE 'END_OF_PAGE' TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
      READ TABLE gt_events WITH KEY name =  slis_ev_end_of_list
                             INTO ls_event.
      IF sy-subrc = 0.
        MOVE 'END_OF_LIST' TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
    ENDFORM.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    FORM build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    ENDFORM.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    FORM end_of_page.
      DATA: listwidth TYPE i,
            ld_pagepos(10) TYPE c,
            ld_page(10)    TYPE c.
      WRITE: sy-uline(50).
      SKIP.
      WRITE:/40 'Page:', sy-pagno .
    ENDFORM.                    "END_OF_PAGE
    *&      Form  END_OF_LIST
    FORM end_of_list.
      DATA: listwidth TYPE i,
            ld_pagepos(10) TYPE c,
            ld_page(10)    TYPE c.
      SKIP.
      WRITE:/40 'Page:', sy-pagno .
    ENDFORM.                    "END_OF_LIST
    *&      Form  PF_STATUS_SET
    *       text
    *      -->RT_EXTAB   text
    FORM pf_status_set USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'STANDARD'.
    ENDFORM.                    "PF_STATUS_SET
    Reward Points if it is Useful.
    Thanks,
    Manjunath MS

  • Normal report to alv

    Hi Friends..
    I have create report using some table.
    Finally i have stored the result in one itab,from that itab only i have displayed results.
    But i want to display the result in ALV Format, in that place what can i do
    send any sample program or give any suggestion..
    Thanks in Advance
    Gowrishankar

    Hi,
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      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.
    *ALV data declarations
    data: fieldcatalog 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.
    *Start-of-selection.
    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.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      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'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    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_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           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 table it_ekko.
    endform.                    " DATA_RETRIEVAL
    http://www.erpgenie.com/abap/code/abap28.htm
    http://sap.niraj.tripod.com/id64.html
    http://www.erpgenie.com/abap/controls/alvgrid.htm
    Regards
    Sudheer

  • How to Convert Simple Report into ALV...

    Hi All,
    i have developed Simple now  i want to convert this report in ALV grid Report.
    how can i do it please Help..
    my code is..
    REPORT  ZGSTT_YVENDORDTL_REPORT.
    Tables :ZMSEG,LFA1.
    DATA: BEGIN OF struct occurs 100,
    MBLNR Type ZMSEG-MBLNR,
    BLDAT Type ZMSEG-BLDAT,
    LIFNR Type ZMSEG-LIFNR,
    BOENR Type ZMSEG-BOENR,
    name1 type lfa1-name1,
    END OF struct.
    types: comm2(16) type c.
    data: itab like  LFA1 occurs 1 with header line.
    data: ind type i.
    selection-screen: begin of block b1 with frame title comm2.
       parameters: matno like ZMSEG-MBLNR.
    select-options: ORDERDAT for ZMSEG-BLDAT.
    selection-screen: end of block b1.
    INITIALIZATION.
    comm2 = 'Selection Screen'.
    start-of-selection.
    if matno is not initial and orderdat is not initial.
    select * from ZMSEG into corresponding fields of table struct where MBLNR = matno and bldat in orderdat.
    elseif matno is initial and orderdat is not initial.
    select * from ZMSEG into corresponding fields of table struct where  bldat in orderdat.
    elseif matno is not initial and orderdat is initial.
    select * from ZMSEG into corresponding fields of table struct where MBLNR = matno.
    else.
    select * from ZMSEG into corresponding fields of table struct.
    endif.
    select * from lfa1 into table itab.
    loop at struct.
      ind = sy-tabix.
      read table itab with key lifnr = struct-lifnr.
    if sy-subrc = 0.
       move itab-name1 to struct-name1.
      endif.
      modify struct index ind transporting  name1.
    endloop.
    SKIP TO LINE 5.
    WRITE:SY-VLINE,(5) 'NO',SY-VLINE,(12) 'Bill of Date',SY-VLINE,(30) 'Vendor Name',SY-VLINE,(20) 'Material Document No.',SY-VLINE,(10) 'Bill of No.',SY-VLINE.
    FORMAT COLOR OFF.
    loop at struct.
      write: / SY-VLINE,(5) count UNDER 'NO',SY-VLINE,(12) struct-BLDAT UNDER 'Bill of Date',SY-VLINE,(30) struct-name1 UNDER 'Vendor Name',SY-VLINE,(20) struct-MBLNR UNDER 'Material Document No.',SY-VLINE,(10) struct-BOENR UNDER 'Bill of No.',SY-VLINE.
    endloop.
    Thanks In Advance...
    Yunus

    Hi,
    You can write your ALV programs in 2 methods by making use of classes or by making use of reuse function modules.
    You can go through the following standard programs.
    BCALV_FULLSCREEN_DEMO
    BCALV_FULLSCREEN_DEMO_CLASSIC
    regards,
    Sangram

  • In Standard Report Of ALV How Can Set PF Status.

    In Standard Report Of ALV How Can Set PF Status.
    Thanking in anticipation.

    in the call function module, you pass the PF status parameter.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = pgm
       <i> <u>  i_callback_pf_status_set = 'SET_PF_STATUS'</u></i>
          it_fieldcat              = fieldcat
          is_variant               = disvariant
          is_layout                = layout
          is_print                 = print
          i_save                   = 'A'
          it_events                = eventcat
          it_sort                  = sortcat
          i_callback_user_command  = 'USER_COMMAND'
        TABLES
          t_outtab                 = a_output
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    ENDFORM.                    "LIST_DISPLAY
    FORM SET_PF_STATUS *
    FORM set_pf_status USING extab TYPE slis_t_extab.
      SET PF-STATUS 'ZZSTD'.
    ENDFORM.                    "set_pf_status
    Here double Click on ZZSTD. IT will take you to a different screen and you have to set it.
    Ster.

  • How to generate interactive report in alv

    hi,
      how to generate interactive report in alv,for this what are the requirements,
    give me one sample report.
                                                 thankyou.

    Hi,
    Chk these helpful links..
    ALV
    http://www.geocities.com/mpioud/Abap_programs.html
    http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100
    Regards
    Anversha

  • Interactive report and ALV s in HR ABAP.

    hi all,
         can any one tell , how to do  Interactive reporting  and alv's in HR ABAP. with some example reports..

    Hi Rao
    Nothing changes for HR ABAP when it comes to ALV or Interactive Lists. Only the DATA fetching process is changed. To fetch HR data , you use Logical Database PNP or Clusters or just read a specific infotype using a method.
    Here is a sample program for ALV 'BALVST02_GRID'. For interactive list , use this demo program
    DEMO_LIST_INTERACTIVE_1. It is a series of Demo Programs which you can open in SE38.
    Reward Points, if helpful.
    Regards
    Waz

  • How we can get an interactive report  in alv grid display?

    Hi experts
    Plz tell me how we can get an interactive report in alv grid disply pls send me one sample code to understand this
    thanks in advance

    hi,
    check this one
    *& Report  ZALV_FIELD_GRID1
    REPORT  ZALV_FIELD_GRID1
            NO STANDARD PAGE HEADING.
    TABLES MARA.
    type-pools :slis.
    TYPES : BEGIN OF TMARA ,
            MATNR LIKE MARA-MATNR,
            MEINS LIKE MARA-MEINS,
            ERSDA LIKE MARA-ERSDA,
            color(4) type c,
            SEL type c,
            LIGHT TYPE C,
            END OF TMARA.
    TYPES: BEGIN OF TMAKT,
           MATNR LIKE MAKT-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           MAKTG LIKE MAKT-MAKTG,
           SEL TYPE C,
           COLOR(4),
           END OF TMAKT.
    DATA:  ITAB TYPE TMARA OCCURS 0 WITH HEADER LINE,
           ITAB1 TYPE TMAKT OCCURS 0 WITH HEADER LINE,
           wa_fieldcat type slis_fieldcat_alv,
           fieldcat type slis_fieldcat_alv occurs 0,
           i_layout type slis_layout_alv,
           WA_LISTHEADER TYPE SLIS_LISTHEADER,
           i_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 0,
           V_EVENTS TYPE SLIS_T_EVENT ,
           WA_EVENT TYPE SLIS_ALV_EVENT,
           I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED',
           I_TITLE_MAKT TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED',
           SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE,
           PRINT_CONT type slis_print_alv.
    SELECTION SCREE
    selection-screen  begin of block screen1  with frame title TEXT-001.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN COMMENT /32(35) COMM1.
    SELECTION-SCREEN ULINE /27(35).
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS MATNR FOR MARA-MATNR.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN COMMENT /30(50) COMM2.
    SELECTION-SCREEN ULINE /27(40).
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS ERSDA FOR MARA-ERSDA.
    SELECTION-SCREEN SKIP.
    selection-screen  end of block screen1.
        INITIALIZATION
    INITIALIZATION.
      MATNR-low = '23'.
      MATNR-high = '1000'.
      MATNR-option = 'BT'.
      MATNR-sign = 'I'.
      APPEND MATNR.
      ERSDA-low = '20030124'.
      ERSDA-high = '20050302' .
      APPEND ERSDA.
      PERFORM FILLFIELD.
      PERFORM FILLLAYOUT.
      PERFORM build_print_params.
      PERFORM FILL_SORT.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
            SELECTION-SCREEN OUTPUT
    AT SELECTION-SCREEN OUTPUT.
      comm1 ='SELECT MATERIAL NUMBER  RANGE'.
      comm2 ='SELECT MATERIAL CREATION DATE'.
               START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM READDATA.
      PERFORM POPDATA.
    *&      Form  READDATA
          text
    FORM READDATA .
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = MATNR-LOW
        IMPORTING
          OUTPUT = MATNR-LOW.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = MATNR-HIGH
        IMPORTING
          OUTPUT = MATNR-HIGH.
      SELECT MATNR
             ERSDA
             MEINS
             FROM MARA
             INTO CORRESPONDING FIELDS OF
            TABLE ITAB
            WHERE MATNR IN MATNR AND ERSDA IN ERSDA.
      LOOP AT ITAB.
        data id_color type i VALUE 1.
        data id_colors(2) type c.
        IF ITAB-MATNR < '000000000000000100'.
          ITAB-LIGHT = '1'.
        ELSEIF ITAB-MATNR < '000000000000000150' AND ITAB-MATNR >
       '000000000000000100' .
          ITAB-LIGHT = '2'.
        ELSE.
          ITAB-LIGHT = '3'.
        ENDIF.
        id_color = id_color + 1.
        if id_color > 7.
          id_color = 1.
        endif.
        id_colors = id_color.
        concatenate 'C' id_colors '10' into itab-color.
        modify itab.
        CLEAR ITAB.
      endloop.
    ENDFORM.                    " READDATA
         Form  FILLFIELD
    FORM FILLFIELD .
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-KEY = 'X'.
      WA_FIELDCAT-COL_POS = '1'.
      WA_FIELDCAT-outputlen   = 20.
      WA_FIELDCAT-HOTSPOT = 'X'.
      wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.
    *WA_FIELDCAT-EMPHASIZE = 'C210'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-COL_POS = '2'.
    *WA_FIELDCAT-EMPHASIZE = 'C510'.
      WA_FIELDCAT-outputlen   = 10.
      wa_fieldcat-seltext_m = 'UNIT'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'ERSDA'.
      WA_FIELDCAT-COL_POS = '3'.
      WA_FIELDCAT-outputlen   = 15.
    *WA_FIELDCAT-EDIT_MASK  = 'DD.MM.YYYY'.
    *WA_FIELDCAT-EMPHASIZE = 'C710'.
      wa_fieldcat-seltext_m = 'CREAT DATE'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
    ENDFORM.                    "FILLFIELD
          Setup print parameters
    form build_print_params.
      PRINT_CONT-reserve_lines = '3'.   "Lines reserved for footer
      PRINT_CONT-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
         Form  POPDATA
    FORM POPDATA .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                 =  sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND            = 'USER-COMMAND'
         I_CALLBACK_TOP_OF_PAGE             = 'TOPPAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                       = I_TITLE_MARA
      I_GRID_SETTINGS                   =
         IS_LAYOUT                          = I_LAYOUT
         IT_FIELDCAT                        = fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
        IT_SORT                           =  SORT[]
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
         IT_EVENTS                          = V_EVENTS
      IT_EVENT_EXIT                     =
       IS_PRINT                          = PRINT_CONT
        TABLES
          T_OUTTAB                          = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    ENDFORM.                    " POPDATA
         Form  TOPPAGE
    FORM TOPPAGE.
      REFRESH I_LISTHEADER.
      DATA: ld_lines type i,
            ld_linesc(10) type c,
            I_DATE(10) TYPE C,
            I_INFO LIKE WA_LISTHEADER-INFO.
      WA_LISTHEADER-TYP = 'H'.
      WA_LISTHEADER-INFO = 'MATERIAL DETAIL'.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'DATE :'.
      CONCATENATE SY-DATUM+6(2) '.'
                           SY-DATUM+4(2) '.'
                           SY-DATUM(4) INTO I_DATE.
      WA_LISTHEADER-INFO = I_datE.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      describe table ITAB lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc
                        into I_INFO separated by space.
      WA_LISTHEADER-TYP  = 'A'.
      WA_LISTHEADER-INFO = I_INFO.
      append WA_LISTHEADER to I_LISTHEADER.
      clear: WA_LISTHEADER , I_INFO.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_LISTHEADER
          I_LOGO             = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "TOPPAGE
         Form  FILLLAYOUT
    FORM FILLLAYOUT .
      i_layout-zebra = 'X'.
      i_layout-info_fieldname = 'COLOR'.
      i_layout-box_fieldname = 'SEL'.
      I_LAYOUT-lights_fieldname = 'LIGHT'.
      I_LAYOUT-EDIT ='X'.
      I_LAYOUT-colwidth_optimize = 'X'.
      I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.
      I_LAYOUT-no_totalline = 'X'.
    ENDFORM.                    "FILLLAYOUT
        Form  FILL_SORT
    FORM FILL_SORT .
      SORT-DOWN = 'X'.
      SORT-SPOS = 1.
      SORT-FIELDNAME = 'MATNR'.
      SORT-tabname = 'MARA'.
      APPEND SORT.
    ENDFORM.                    " FILL_SORT
         Form  EVENT_CALL
    FORM EVENT_CALL .
      DATA: I_EVENT LIKE V_EVENTS.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = V_EVENTS.
      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.                    " EVENT_CALL
        Form  POPULATE_EVENT
    FORM POPULATE_EVENT .
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'USER_COMMAND'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
        WA_EVENT-NAME.
    READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                                          INTO WA_EVENT.
    IF SY-SUBRC = 0.
       move 'END_OF_PAGE' to WA_EVENT-FORM.
       MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
       WA_EVENT-NAME.
      endif.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    FORM END_OF_PAGE.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    ENDFORM.
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          CASE RS_SELFIELD-FIELDNAME.
            when 'MATNR'.
              read table itab with key matnr = RS_SELFIELD-VALUE.
              if sy-subrc = 0.
                PERFORM DATA_RETRIEVAL_MAKT USING RS_SELFIELD-VALUE.
                PERFORM BUILD_FIELDCATLOG_MAKT.
                PERFORM FILLLAYOUT_MAKT.
                PERFORM DISPLAY_ALV_MAKT.
                CLEAR RS_SELFIELD.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                    "user_command
         Form  DATA_RETRIEVAL_MAKT
    FORM DATA_RETRIEVAL_MAKT USING TMATNR .
      SELECT MATNR
             MAKTX
             MAKTG
             UP TO 100 ROWS
             FROM MAKT
             INTO TABLE ITAB1
             WHERE SPRAS = 'EN' AND MATNR = TMATNR.
      LOOP AT ITAB1.
        data id_color type i VALUE 1.
        data id_colors(2) type c.
        id_color = id_color + 1.
        if id_color > 7.
          id_color = 1.
        endif.
        id_colors = id_color.
        concatenate 'C' id_colors '10' into itab1-color.
        modify itab1.
        CLEAR ITAB1.
      ENDLOOP.
    ENDFORM.                    "DATA_RETRIEVAL_MAKT
         Form  FILLLAYOUT_MAKT
    FORM FILLLAYOUT_MAKT .
      CLEAR I_LAYOUT.
      i_layout-zebra = 'X'.
      i_layout-info_fieldname = 'COLOR'.
      i_layout-box_fieldname = 'SEL'.
      I_LAYOUT-EDIT ='X'.
      I_LAYOUT-colwidth_optimize = 'X'.
      I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.
    ENDFORM.                    " LAYOUT_MAKT
        Form  BUILD_FIELDCATLOG_MAKT
    FORM BUILD_FIELDCATLOG_MAKT .
      REFRESH FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-KEY = 'X'.
      WA_FIELDCAT-COL_POS = '1'.
    *WA_FIELDCAT-EDIT_MASK  = 'DD.MM.YYYY'.
      WA_FIELDCAT-EMPHASIZE = 'C510'.
      wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MAKTX'.
      WA_FIELDCAT-COL_POS = '2'.
      WA_FIELDCAT-EMPHASIZE = 'C710'.
      wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MAKTG'.
      WA_FIELDCAT-COL_POS = '3'.
      WA_FIELDCAT-EMPHASIZE = 'C210'.
      wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATLOG_MAKT
         Form  DISPLAY_ALV_MAKT
    FORM TOP-OF-PAGE.
      REFRESH I_LISTHEADER.
      DATA: ld_lines type i,
            ld_linesc(10) type c,
            I_DATE(10) TYPE C,
            I_INFO LIKE WA_LISTHEADER-INFO.
      WA_LISTHEADER-TYP = 'H'.
      WA_LISTHEADER-INFO = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'DATE :'.
      CONCATENATE SY-DATUM+6(2) '.'
                           SY-DATUM+4(2) '.'
                           SY-DATUM(4) INTO I_DATE.
      WA_LISTHEADER-INFO = I_datE.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      describe table ITAB1 lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc
                        into I_INFO separated by space.
      WA_LISTHEADER-TYP  = 'A'.
      WA_LISTHEADER-INFO = I_INFO.
      append WA_LISTHEADER to I_LISTHEADER.
      clear: WA_LISTHEADER , I_INFO.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_LISTHEADER
          I_LOGO             = 'ENJOYSAP_LOGO'.
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.                    "TOP-OF-PAGE
    *&      Form  DISPLAY_ALV_MAKT
          text
    FORM DISPLAY_ALV_MAKT .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM     = SY-REPID
          I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
          I_GRID_TITLE           = I_TITLE_MAKT
          IS_LAYOUT              = I_LAYOUT
          IT_FIELDCAT                       = fieldcat
        TABLES
          T_OUTTAB               = ITAB1
        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_MAKT
    Rewards points

  • PO receiver report with ALV GRID

    Hello abpers,
    Can anyone gimme some guidance or sample code how to generate the PO receiver report with alv.... 
    input fields include..
    Vendor number, material number, PO number, Purchasing group/Buyer, PO creation date, PO delivery date, PO created by
    I should get the out put with the fields....
    PO, PO date, PO group/buyer, purchasing org, vendor, PO line, order quantity, Unit, Material, Description, ST LOC SHELF BIN, ST LOCBULK BIN, QTY TO BE RECV, QTY RECEVED.
    Thanks alot for your anticipation....
    SRI

    Here is a very simple ALV program which shows a basic skeleton of an ALV program,  you simply get the data from the database(usually passed on some parameters from the selection screen) and build the FC, then call the function module.
    report zrich_0003 .
    * Global ALV Data Declarations
    type-pools: slis.
    * Internal Tables
    data: begin of ialv occurs 0,
          test1(10) type c,
          test2(10) type c,
          end of ialv.
    data: fieldcat  type slis_t_fieldcat_alv.
    start-of-selection.
      perform get_data.
      perform call_alv.
    *      Form  GET_DATA
    form get_data.
      ialv-test1 = 'ABC'.
      ialv-test2 = 'DEF'.
      append ialv.
      ialv-test1 = 'GHI'.
      ialv-test2 = 'JKL'.
      append ialv.
      ialv-test1 = '123'.
      ialv-test2 = '456'.
      append ialv.
    endform.                    "GET_DATA
    *  CALL_ALV
    form call_alv.
      perform build_field_catalog.
    * Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          it_fieldcat  = fieldcat
        tables
          t_outtab     = ialv.
    endform.                    "CALL_ALV
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      clear fieldcat. refresh fieldcat.
      data: tmp_fc type slis_fieldcat_alv.
      clear tmp_fc.
      tmp_fc-reptext_ddic = 'Test1'.
      tmp_fc-fieldname    = 'TEST1'.
      tmp_fc-tabname      = 'IALV'.
      tmp_fc-outputlen    = '10'.
      append tmp_fc to fieldcat.
      clear tmp_fc.
      tmp_fc-reptext_ddic = 'Test2'.
      tmp_fc-fieldname    = 'TEST2'.
      tmp_fc-tabname      = 'IALV'.
      tmp_fc-outputlen    = '10'.
      append tmp_fc to fieldcat.
    endform.                    "BUILD_FIELD_CATALOG
    The use of selection screen is not use in this program, I assume that you know how to do that.
    Regards,
    Rich Heilman

  • How we add & grandtotal of sales order report in alv

    hi guru how we add & grandtotal of sales order report in alv
    regards
    subhasis

    hi subhasis,
    since u want the grand total in ALV use the following code...
    clear gs_fieldcat.
    gs_fieldcat-fieldname = field.
    gs_fieldcat-tabname = DB table
    gs_fieldcat-seltext_m = text.
    gs_fieldcat-do_sum = 'X'
    gs_fieldcat-datatype = data type (Curr or Quant)
    gs_fieldcat-ref_fieldname = reference field name
    gs_fieldcat-ref_tabname  = reference table name
    append gs_fieldcat to gt_fieldcat.
    hope this will work...
    please reward points in case usefull
    regards,
    prashant

  • How to use interactive internal report in alv

    hey expert i want to know who i will used interactive internal report in alv report by various tables in my one assingment.
    They have told us to do the various steps which i was giving down:
    1) In first step they have told me to use of call transaction 'XD03' in the report .I have got that problem solved.
    2)  In second they have told in this assingment to use of interactive internal report you have to prepare in alv format.
    a)I  want to know about this .They have told in assingment that in the customer details we have to click to the net value field record and go to the details of sales order detail in which it show the detail of all the details related net values .
    b) I want to know about this lines also from you:
    Qty field refers to the Target Qty field in the table VBAP.
    To get Price in the unit divide the price by Condition Pricing Unit.
    If SHKZG field is set, then multiply the amount by -1, making it negative. (understand why?).
    3) In the third step they have told to used of drill down which it is in the at line selection ,when i click to the list order of sales it go to  the next report and show me the detail of all the list order details. 
    But i have to use the  '2.b' condition there .
    cna u please send me reply for all this step.
    Edited by: AjaySAPmumbai on Nov 28, 2011 8:55 AM
    Moderator message : Spec / requirements dumping is not allowed, search for available information, read forum rules before posting.  Thread locked.
    Edited by: Vinod Kumar on Nov 28, 2011 1:26 PM

    hey expert i want to know who i will used interactive internal report in alv report by various tables in my one assingment.
    They have told us to do the various steps which i was giving down:
    1) In first step they have told me to use of call transaction 'XD03' in the report .I have got that problem solved.
    2)  In second they have told in this assingment to use of interactive internal report you have to prepare in alv format.
    a)I  want to know about this .They have told in assingment that in the customer details we have to click to the net value field record and go to the details of sales order detail in which it show the detail of all the details related net values .
    b) I want to know about this lines also from you:
    Qty field refers to the Target Qty field in the table VBAP.
    To get Price in the unit divide the price by Condition Pricing Unit.
    If SHKZG field is set, then multiply the amount by -1, making it negative. (understand why?).
    3) In the third step they have told to used of drill down which it is in the at line selection ,when i click to the list order of sales it go to  the next report and show me the detail of all the list order details. 
    But i have to use the  '2.b' condition there .
    cna u please send me reply for all this step.
    Edited by: AjaySAPmumbai on Nov 28, 2011 8:55 AM
    Moderator message : Spec / requirements dumping is not allowed, search for available information, read forum rules before posting.  Thread locked.
    Edited by: Vinod Kumar on Nov 28, 2011 1:26 PM

Maybe you are looking for

  • Can't import from Cannon HV20.

    I can't import from my Cannon HV20. The camera does not show up as an external camera. I just get the message "to import video, please connect a camera". I get the same message when connecting to my laptop and I have tried two different firewire cabl

  • Mandatory field in BP

    Dear SDN the need for me is to find a  badi or somehow a solution to make few address fields mandatory in t-code BP but i know that wa can customise BP for this requirement but the problem is if we customise BP for mandatory fields it doesn´t work fo

  •       Specifying class properties in MXML elements instead of attributes (e.g. DataGridColumns)

    Hi there, In all the examples I've seen so far, specifying the columns for a DataGrid is done as follows: <mx:DataGrid> <mx:columns> <mx:DataGridColumn /> <mx:DataGridColumn /> <mx:columns> </mx:DataGrid> However, I'm wonder whether there's a way to

  • IMovie crashes when editing text

    I am editing a project that is an hour long and I am just trying to add some text to different clips but everytime I try and edit any text iMovie crashes.  WHAT DO I DO???????

  • Defaulting DFF Segment Value using sql statement in SSHR gives error when using parameter

    Dear All, i am having an issue that i am making one segment in DFF (SEGMENT3) being defaulted by using sql statement Select MAX(SEGMENT7) FROM PER_ANALYSIS_CRITERIA cri, PER_PERSON_ANALYSES ana where cri.Analysis_Criteria_id = ana.ANALYSIS_CRITERIA_I