Change output format of  MC45,key usage value report to ALV format?

Can someone please help me to change the change the Output of MC45 report to ALV format?
Please help!!!
Thanks!!!
Owais

I know i have to create a copy of MC45 to some z program but afterwards I am not sure where to look for to change the output format.
Our ababper is extremely busy so i wanted to do litle bit of chnages by myself. I do have couple of years of java experience several years back, I thought i could help our abaper and learn myself little bit also.
Thanks!!!
Owais

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

  • 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

  • HR Report in ALV format

    Hi All,
    I'm using a LDB 'PNP' and I'd like to select all the active employee in an internal table and display some info related to employee ( name , basic salary ...) in ALV.
    Can anybody help me coding it please.  Thanks

    Hi,
    I am herewith sending you the Report(Not ALV) for HR employee details.
    Modify it and use it.
    Use the respective Internal table to ALV list and display.
    report zporgr0030
           line-size 193
           line-count 60(1)
           no standard page heading.
    Database Tables
    tables:    pernr,    " Logical PNP
               t001p,    " Personnel Subarea
               t005t,    " Country Descriptions
               t500p,    " Personnel Area
               t501,     " Employee Group
               t503k,    " Employee Subgroup
               csks,     " Cost Centers
               cskt,     " Cost Center Texts
               t513c,    " Job (Previous) Texts
               t513s,    " Job Titles
               t517t,    " Edn Est.Text
               t518b,    " Discipline Text
               t519t,    " Certificate Text
               t528t,    " Positions Texts
               t538t,    " Unit Text
               pa0003.   " Payroll Status
    infotypes:
               0000,   " Actions
               0001,   " Organizational Assignment
               0002,   " Personal Data
               0007,   " Planned working time
               0008,   " Payroll Data
               0022,   " Education Data
               0023,   " Previous Employer data
               0025,   " Performance Appraisal Data
               0041,   " Date Spcifications
               2001.   " Absences
    Declaration of Internal Tables
    Internal Table for Personal Data
    data: begin of pers_tab occurs 0,
            pernr like pa0001-pernr,      " Personal Number
            ename like pa0001-ename,      " Employee Name
            trfgr like pa0008-trfgr,      " Grade
            natio like pa0002-natio,      " Nationality
            hdate like pa0041-dat01,      " Hire Date
            gbdat like pa0002-gbdat,      " Birth Date
            plans like pa0001-plans,      " Position
            werks like pa0001-werks,      " Pers.Area
            kostl like pa0001-kostl,      " Cost Center
            ctext(40),                    " Cost Center Text
            ptext(25),                    " Position Text
            ntext(15),                    " Nation Text
            name1(23),                    " Location
          end of pers_tab.
    Internal Table for Payroll Data
    data: begin of pay_tab occurs 0,
            pernr like pa0008-pernr,      " Personal Number
            waers like pbwla-waers,       " Grade
            basic like pa0008-bet01,      " Basic Pay
            hra_allow like pa0008-bet01,  " Housing Allowance
            sup_allow like pa0008-bet01,  " Supp. Allowance
            soc_allow like pa0008-bet01,  " Social Allowance
            chl_allow like pa0008-bet01,  " Child Allowance
            fix_allow like pa0008-bet01,  " Fixed Overtime
            ra_allow  like pa0008-bet01,  " RA Allowance
            per_allow like pa0008-bet01,  " Perform. Allowance
            pen_allow like pa0008-bet01,  " Pension Allowance
            oth_allow like pa0008-bet01,  " Other Allowances
            tot_allow like pa0008-bet01,  " Total Allowances
          end of pay_tab.
    Internal Table for Educational Data
    data: begin of edn_tab occurs 0,
            pernr like pa0022-pernr,      " Personal Number
            ausbi like pa0022-ausbi,      " Discipline Name
            slart like pa0022-slart,      " Edn Establishment
            insti like pa0022-insti,      " Institute
            sland like pa0022-sland,      " Country
            slabs like pa0022-slabs,      " Certificate
            anzkl like pa0022-anzkl,      " Duration
            anzeh like pa0022-anzeh,      " Unit for Duration
            atext like t518b-atext,       " Discipline Text
            stext like t517t-stext,       " Edn Est.Text
            landx like t005t-landx,       " Country Text
            ctext like t519t-stext,       " Certificate Text
            etext like t538t-etext,       " Unit Text
          end of edn_tab.
    Internal Table for Previous Employment Data
    data: begin of pemp_tab occurs 0,
            pernr like pa0023-pernr,      " Personal Number
            arbgb like pa0023-arbgb,      " Previous Employer
            begda like pa0023-begda,      " Start Date
            endda like pa0023-endda,      " End Date
            taete like pa0023-taete,      " Last Position
            land1 like pa0023-land1,      " Country
            stltx like t513s-stltx,       " Position Text
            landx like t005t-landx,       " Country Text
          end of pemp_tab.
    Internal Table for Job History Data
    data: begin of job_tab occurs 0,
            pernr like pa0001-pernr,      " Personal Number
            begda like pa0001-begda,      " Promotion Date
            plans like pa0001-plans,      " Position
            stell like pa0001-stell,      " Job Key
            stltx like t513s-stltx,       " Job Text
            ptext like t528t-plstx,       " Position Text
          end of job_tab.
    Internal Table for Performance Appraisal Data
    data: begin of app_tab occurs 0,
            pernr like pa0001-pernr,       " Personal Number
            year(4) type     c,            " Current Year
            appr(35) type    c,            " C Y Appraisal
           year1(4) type    c,            " Last Year
           appr1(35) type   c,            " Last Year Appraisal
           year2(4) type    c,
           appr2(35) type   c,
           year3(4) type    c,
           appr3(35) type   c,
           year4(4) type    c,
           appr4(35) type   c,
          end of app_tab.
    Internal Table for Performance Appraisal Data
    data: begin of app1_tab occurs 0,
            year(4) type     c,            " Year
            appr(35) type    c,            " Appraisal
          end of app1_tab.
    Internal Table to get the Payroll Amounts
    data  wage_tab like pbwla occurs 0 with header line.
    Internal table for retreiving Employee Appraisals
    data  app_in_tab  like hrsobid occurs 0 with header line .
    data  app_out_tab like hrpe_profa  occurs 0 with header line .
    Declaration of Variables
    data : v_year(4)  type c,
           v_ayear(4) type c,
           v_cyear(4) type c,
           v_year1(4) type c,
           v_year2(4) type c,
           v_year3(4) type c,
           v_year4(4) type c,
           v_year5(4) type c,
           v_year6(4) type c,
           v_mon(2)   type c,
           v_date2  like sy-datum,
           v_date3  like sy-datum,
           v_date   like sy-datum,
           v_date1  like sy-datum.
    Declaration of Constants
    constants : c_x       type c value 'X',              " Sign
                c_pernr(8) type n value '00000000',      " Pernr
                c_p   like hrp1007-otype  value 'P',     " Object Type
                c_01  like hrp1001-plvar  value '01',    " Version
                c_val1(2) type c value '31',             " Date Type
                c_val2(2) type c value '12',             " Date Type
                c_val    like p0041-dar01 value '01',    " Date Type
                c_1      like pernr-persg value '1',     " Emp Group
                c_type   like hrp1001-otype  value 'S',  " Object Type
                c_date1  like sy-datum value '18000101', " Date
                c_date2  like sy-datum value '99991231', " Date
                c_lga01 like pa0008-lga01 value '0101',  " Wage Type
                c_lga02 like pa0008-lga01 value '0102',  " Wage Type
                c_lga03 like pa0008-lga01 value '0103',  " Wage Type
                c_lga04 like pa0008-lga01 value '0105',  " Wage Type
                c_lga05 like pa0008-lga01 value '0109',  " Wage Type
                c_lga06 like pa0008-lga01 value '0110',  " Wage Type
                c_lga07 like pa0008-lga01 value '0114',  " Wage Type
                c_lga08 like pa0008-lga01 value '0116',  " Wage Type
                c_lga09 like pa0008-lga01 value '0267',  " Wage Type
                c_kokrs  like cskt-kokrs value '1000'.   " Controlling Area
    Selection Screen
    selection-screen begin of block b1 with frame title text-003.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-060.
    parameters: r_all radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-020.
    parameters: r_per radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-021.
    parameters: r_pay radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-022.
    parameters: r_edn radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-023.
    parameters: r_pemp radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-024.
    parameters: r_job radiobutton group rb1.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(33)   text-025.
    parameters: r_app radiobutton group rb1.
    selection-screen end of line.
    selection-screen end of block b1.
    At selection-screen
    at selection-screen.
    Validate the Selection Screen fields
      perform validate_screen.
    Start-of-Selection
    start-of-selection.
    Selection of Period
      perform get_period.
    Get PERNR from LDB
    get pernr.
      if pernr-persg eq c_1 or pernr-pernr ne c_pernr.
        if r_all eq c_x.
    Get the Personal data from PA0001,PA0002, PA0008, PA0041
          perform get_pers_data.
    Get the Payroll data from PA0008
          perform get_pay_data.
    Get the Education data from PA0022
          perform get_edn_data.
    Get the Previous Employment data from PA0023
          perform get_pemp_data.
    Get the Job History data
          perform get_job_data.
    Get the Performance Appraisal data
          perform get_app_data.
        elseif r_per eq c_x.
    Get the Personal data from PA0001,PA0002, PA0008, PA0041
          perform get_pers_data.
        elseif r_pay eq c_x.
    Get the Payroll data from PA0008
          perform get_pay_data.
        elseif r_edn eq c_x.
    Get the Education data from PA0022
          perform get_edn_data.
        elseif r_pemp eq c_x.
    Get the Previous Employment data from PA0023
          perform get_pemp_data.
        elseif r_job eq c_x.
    Get the Job History data
          perform get_job_data.
        elseif r_app eq c_x.
    Get the Performance Appraisal data
          perform get_app_data.
        endif.
      endif.
    Top-of-page
    top-of-page.
    Write the Report and Column Headings
      perform top_of_page.
    End-of-Page
    end-of-page.
      perform end_of_page.
    End-of-Selection
    end-of-selection.
    Display the Output Report.
      perform display_report.
    Form-Routines
    *&      Form  validate_screen
    Validation of selection Screen fields
    form validate_screen.
    Validation of Personnel Number
      clear pa0003.
      if not pnppernr[] is initial.
        select pernr
        from pa0003 up to 1 rows
          into pa0003-pernr
          where pernr in pnppernr.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personnel Number Entered'(001).
        endif.
      endif.
    Validation of Cost Center
      clear csks.
      if not pnpkostl[] is initial.
        select single kostl
          into csks-kostl
          from csks
          where kostl in pnpkostl.
        if sy-subrc <> 0.
          message e999 with 'Invalid Cost Center'(002).
        endif.
      endif.
    Validation of Personnel Area
      clear t500p.
      if not pnpwerks[] is initial.
        select persa
        from t500p up to 1 rows
          into t500p-persa
          where persa in pnpwerks.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personnel Area Entered'(004).
        endif.
      endif.
    Validation of Personnel Sub Area
      clear t001p.
      if not pnpbtrtl[] is initial.
        select btrtl
        from t001p up to 1 rows
          into t001p-btrtl
          where btrtl in pnpbtrtl.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personnel Sub Area Entered'(005).
        endif.
      endif.
    Validation of Employee Group
      clear t501.
      if not pnppersg[] is initial.
        select persg
        from t501 up to 1 rows
          into t501-persg
          where persg in pnppersg.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Employee Group Entered'(006).
        endif.
      endif.
    Validation of Employee Sub Group
      clear t503k.
      if not pnppersk[] is initial.
        select persk
        from t503k up to 1 rows
          into t503k-persk
          where persk in pnppersk.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Employee Sub Group Entered'(007).
        endif.
      endif.
    endform.                  "validate_screen
    *&      Form  get_period
    Get the Correct Period based on Selection screen selection
    form get_period.
      clear: v_year,v_mon, v_date, v_date1.
      v_year = sy-datum+0(4).
      v_mon  = sy-datum+4(2).
      if pnptimr1 = c_x.      " Current Date
        pnpbegda = sy-datum.
        pnpendda = sy-datum.
      elseif pnptimr2 = c_x.  " Current Month
        concatenate v_year v_mon c_val into v_date.
        concatenate v_year v_mon c_val1 into v_date1.
        pnpbegda = v_date.
        pnpendda = v_date1.
      elseif pnptimr3 = c_x.  " Current Year
        concatenate v_year c_val c_val into v_date.
        concatenate v_year c_val2 c_val1 into v_date1.
        pnpbegda = v_date.
        pnpendda = v_date1.
      elseif pnptimr4 = c_x.  " Upto Today
        pnpbegda = c_date1.
        pnpendda = sy-datum.
      elseif pnptimr5 = c_x.  " From Today
        pnpbegda = sy-datum.
        pnpendda = c_date2.
      else.
        if ( pnpbegda is initial and pnpendda is initial ).
          pnpbegda = c_date1.
          pnpendda = c_date2.
        elseif pnpbegda is initial and not pnpendda is initial.
          pnpbegda = c_date1.
          pnpendda = pnpendda.
        elseif not ( pnpbegda is initial and pnpendda is initial ).
          pnpbegda = pnpbegda.
          pnpendda = pnpendda.
        endif.
      endif.
    endform.              "get_period
    *&      Form  get_pers_data
    Get the Personal Data from PA0001,PA0002,PA0008, PA0041
    form get_pers_data.
    Get data from Respective Infotypes
      rp_provide_from_last p0001 space pnpbegda pnpendda.
      rp_provide_from_last p0002 space pnpbegda pnpendda.
      rp_provide_from_last p0008 space pnpbegda pnpendda.
      rp_provide_from_last p0041 space pnpbegda pnpendda.
      pers_tab-pernr    = p0001-pernr.
      pers_tab-ename    = p0001-ename.
      pers_tab-werks    = p0001-werks.
      pers_tab-plans    = p0001-plans.
      pers_tab-kostl    = p0001-kostl.
      pers_tab-gbdat    = p0002-gbdat.
      pers_tab-trfgr    = p0008-trfgr.
    Get the Engaged Date
      read table p0041 with key dar01 = c_val.
      if sy-subrc = 0.
        pers_tab-hdate = p0041-dat01.
      endif.
    Get the Cost Center Text
      clear cskt-ltext.
      select single ltext into cskt-ltext from cskt
              where spras = sy-langu and
                    kokrs = c_kokrs and
                    kostl = p0001-kostl.
      if sy-subrc = 0.
        pers_tab-ctext = cskt-ltext.
      endif.
    Get the Position Text
      clear t528t-plstx.
      select single plstx into t528t-plstx from t528t
              where plans = p0001-plans and
                    otype = c_type and
                    sprsl = sy-langu.
      if sy-subrc = 0.
        pers_tab-ptext = t528t-plstx.
      endif.
    Get the Nationality
      clear t005t-natio.
      select single natio into t005t-natio from t005t
              where spras = sy-langu and
                    land1 = p0002-natio.
      if sy-subrc = 0.
        pers_tab-ntext = t005t-natio.
      endif.
    Get the Location (Personal Area) Text
      clear t500p-name1.
      select single name1 into t500p-name1 from t500p
              where persa = p0001-werks.
      if sy-subrc = 0.
        pers_tab-name1 = t500p-name1.
      endif.
      append pers_tab.
      clear pers_tab.
      sort pers_tab by pernr.
    endform.          "get_pers_data
    *&      Form  get_pay_data
    Get the Payroll Data from Infotype 0008
    form get_pay_data.
    Get the Payroll data from Respective Infotypes
      rp_provide_from_last p0008 space pnpbegda pnpendda.
      pay_tab-pernr    = pernr-pernr.
      call function 'RP_FILL_WAGE_TYPE_TABLE_EXT'
        exporting
         appli                              = 'E'
         begda                              = p0008-begda
         endda                              = p0008-endda
         infty                              = '0008'
         objps                              = '  '
         tclas                              = 'A'
         pernr                              = pernr-pernr
         seqnr                              = '   '
         subty                              = '0   '
         dlspl                              = 'X'
         msgflg                             = ''
         nordct                             = ''
        tables
          pp0001                             = p0001
          pp0007                             = p0007
          pp0008                             = p0008
          ppbwla                             = wage_tab
      PP0230                             =
      PP0014                             =
      PP0015                             =
      PP0052                             =
    EXCEPTIONS
      ERROR_AT_INDIRECT_EVALUATION       = 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.
      loop at wage_tab.
        pay_tab-waers = wage_tab-waers.
        case wage_tab-lgart.
          when c_lga01.
            pay_tab-basic = wage_tab-betrg.
          when c_lga02.
            pay_tab-sup_allow = wage_tab-betrg.
          when c_lga03.
            pay_tab-hra_allow = wage_tab-betrg.
          when c_lga04.
            pay_tab-chl_allow = wage_tab-betrg.
          when c_lga05.
            pay_tab-soc_allow = wage_tab-betrg.
          when c_lga06.
            pay_tab-fix_allow = wage_tab-betrg.
          when c_lga07.
            pay_tab-ra_allow = wage_tab-betrg.
          when c_lga08.
            pay_tab-per_allow = wage_tab-betrg.
          when c_lga09.
            pay_tab-pen_allow = wage_tab-betrg.
          when others.
            pay_tab-oth_allow = pay_tab-oth_allow + wage_tab-betrg.
        endcase.
        pay_tab-tot_allow = pay_tab-basic + pay_tab-sup_allow +
                            pay_tab-hra_allow + pay_tab-chl_allow +
                            pay_tab-soc_allow + pay_tab-fix_allow +
                            pay_tab-ra_allow + pay_tab-per_allow +
                            pay_tab-oth_allow - pay_tab-pen_allow.
      endloop.
      append pay_tab.
      clear  pay_tab.
    endform.          "get_pay_data
    *&      Form  get_edn_data
    Get the Education Data from Infotype 0022
    form get_edn_data.
    Get the Education data from Respective Infotypes
      loop at p0022 where pernr = pernr-pernr.
        edn_tab-pernr    = pernr-pernr.
        edn_tab-ausbi    = p0022-ausbi.
        edn_tab-slart    = p0022-slart.
        edn_tab-insti    = p0022-insti.
        edn_tab-sland    = p0022-sland.
        edn_tab-slabs    = p0022-slabs.
        edn_tab-anzkl    = p0022-anzkl.
        edn_tab-anzeh    = p0022-anzeh.
    Get the Discipline Text
        clear t518b-atext.
        select single atext into t518b-atext from t518b
                where langu = sy-langu and
                      ausbi = p0022-ausbi.
        if sy-subrc = 0.
          edn_tab-atext = t518b-atext.
        endif.
    Get the Edn Establishment Text
        clear t517t-stext.
        select single stext into t517t-stext from t517t
                where slart = p0022-slart and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          edn_tab-stext = t517t-stext.
        endif.
    Get the Certificate Text
        clear t519t-stext.
        select single stext into t519t-stext from t519t
                where slabs = p0022-slabs and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          edn_tab-ctext = t519t-stext.
        endif.
    Get the Unit Text
        clear t538t-etext.
        select single etext into t538t-etext from t538t
                where zeinh = p0022-anzeh and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          edn_tab-etext = t538t-etext.
        endif.
    Get the Country Description
        clear t005t-landx.
        select single landx into t005t-landx from t005t
                where spras = sy-langu and
                      land1 = p0022-sland.
        if sy-subrc = 0.
          edn_tab-landx = t005t-landx.
        endif.
        append edn_tab.
        clear edn_tab.
      endloop.
    endform.              "edn_data
    *&      Form  get_pemp_data
    Get the Previous Employment Data from Infotype 0023
    form get_pemp_data.
    Get the Previous Employment data from Respective Infotypes
      loop at p0023 where pernr = pernr-pernr.
        pemp_tab-pernr    = pernr-pernr.
        pemp_tab-arbgb    = p0023-arbgb.
        pemp_tab-begda    = p0023-begda.
        pemp_tab-endda    = p0023-endda.
        pemp_tab-taete    = p0023-taete.
        pemp_tab-land1    = p0023-land1.
    Get the Last Job Text
        clear t513c-ltext.
        select single ltext into t513c-ltext from t513c
                where taete = pemp_tab-taete and
                      spras = sy-langu.
        if sy-subrc = 0.
          pemp_tab-stltx = t513c-ltext.
        endif.
    Get the Country Description
        clear t005t-landx.
        select single landx into t005t-landx from t005t
                where spras = sy-langu and
                      land1 = pemp_tab-land1.
        if sy-subrc = 0.
          pemp_tab-landx = t005t-landx.
        endif.
        append pemp_tab.
        clear pemp_tab.
      endloop.
      sort pemp_tab by pernr.
    endform.              "pemp_data
    *&      Form  get_job_data
    Get the Job History Data from Infotype
    form get_job_data.
    Get the Job History data from Respective Infotypes
      loop at p0001 where pernr = pernr-pernr.
        job_tab-pernr    = pernr-pernr.
        job_tab-begda    = p0001-begda.
        job_tab-plans    = p0001-plans.
        job_tab-stell    = p0001-stell.
    Get the Last Job Text
        clear t513s-stltx.
        select single stltx into t513s-stltx from t513s
                where stell = job_tab-stell and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          job_tab-stltx = t513s-stltx.
        endif.
    Get the Position Text
        clear t528t-plstx.
        select single plstx into t528t-plstx from t528t
                where plans = job_tab-plans and
                      otype = c_type and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          job_tab-ptext = t528t-plstx.
        endif.
        append job_tab.
        clear  job_tab.
      endloop.
      sort job_tab by pernr.
    endform.          "get_job_data
    *&      Form  get_app_data
    Get the Performance Appraisal Data from Infotype
    form get_app_data.
      clear: v_cyear, v_year1, v_year2, v_year3, v_year4,
             v_year5, v_year6, v_ayear, v_date2, v_date3.
      v_cyear = sy-datum+0(4) - 1.
      v_year1 = v_cyear - 1.
      v_year2 = v_cyear - 2.
      v_year3 = v_cyear - 3.
      v_year4 = v_cyear - 4.
      v_year5 = v_cyear - 5.
      v_year6 = v_cyear - 6.
      concatenate v_cyear c_date2+4(4) into v_date2.
      concatenate v_year6 c_date1+4(4) into v_date3.
      clear: app_in_tab, app_out_tab.
      refresh: app_in_tab, app_out_tab.
      app_in_tab-plvar = c_01.
      app_in_tab-otype = c_p.
      app_in_tab-sobid = pernr-pernr.
      append app_in_tab.
    Get Appraisals data from Respective Infotypes
      call function 'RHPA_APPRAISEES_APP_READ'
       exporting
         begda               =   v_date3
         endda               =   v_date2
      WITH_STEXT          = 'X'
      WITH_ADD_INFO       = 'X'
        tables
          appraisees          = app_in_tab
          appraisals          = app_out_tab
       exceptions
         no_authority        = 1
         undefined           = 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.
      sort app_out_tab  by sobid vbegd vendd appraisal_adate descending .
      delete adjacent duplicates from app_out_tab
                comparing  sobid vbegd vendd.
      loop at app_out_tab where appraisal_histo = 'X' .
        condense app_out_tab-appraisal_result.
        app1_tab-year = app_out_tab-vendd+0(4).
        app1_tab-appr = app_out_tab-appraisal_result_text.
        append app1_tab.
        clear app1_tab.
      endloop.
      sort app1_tab by year descending.
      loop at app1_tab.
        app_tab-pernr    = pernr-pernr.
        move-corresponding  app1_tab to app_tab.
        append app_tab.
        clear: app1_tab, app_tab.
      endloop.
      refresh app1_tab.
      sort app_tab by pernr.
      delete app_tab where year = ' ' and appr = ' ' .
    endform.          "get_app_data
    *&      Form  top_of_page
    Write the Report and Column Headings
    form top_of_page.
      skip.
      format color col_heading on.
      if r_all eq c_x.
        write: /1(193) 'NATIONAL DRILLING COMPANY'(009) centered,
               /1(193) 'Employee Details Report'(066) centered.
      elseif r_per eq c_x.
        write: /1(193) 'NATIONAL DRILLING COMPANY'(009) centered,
               /1(193) 'Employee Details - Personal Data'(010)
                                                centered.
      elseif r_pay eq c_x.
        write: /1(172) 'NATIONAL DRILLING COMPANY'(009) centered,
               /1(172) 'Employee Details - Payroll Data'(027)
                                                centered.
      elseif r_edn eq c_x.
        write: /1(172) 'NATIONAL DRILLING COMPANY'(009) centered,
               /1(172) 'Employee Details - Education Data'(028)
                                                centered.
      elseif r_pemp eq c_x.
        write: /1(97) 'NATIONAL DRILLING COMPANY'(009) centered,
              /1(97) 'Employee Details - Previous Employment Data'(029)
                                                centered.
      elseif r_job eq c_x.
        write: /1(75) 'NATIONAL DRILLING COMPANY'(009) centered,
              /1(75) 'Employee Details - Job History Data'(030)
                                                centered.
      elseif r_app eq c_x.
        write: /1(192) 'NATIONAL DRILLING COMPANY'(009) centered,
              /1(192) 'Employee Details - Performance Appraisal Data'(031)
                                                centered.
      endif.
      format color off.
      if pnptimr1 = c_x.      " Current Date
        write: /2 'Period From     :'(008), sy-datum,
                         'To:'(019), sy-datum.
      elseif pnptimr2 = c_x.  " Current Month
        write: /2 'Period From     :'(008), v_date, 'To:'(019), v_date1.
      elseif pnptimr3 = c_x.  " Current Year
        write: /2 'Period From     :'(008), v_date, 'To:'(019), v_date1.
      elseif pnptimr4 = c_x.  " Upto Today
        write: /2 'Period From     :'(008), c_date1, 'To:'(019), sy-datum.
      elseif pnptimr5 = c_x.  " From Today
        write: /2 'Period From     :'(008), sy-datum, 'To:'(019), c_date2.
      else.
        if ( pnpbegda is initial and pnpendda is initial ).
          write: /2 'Period From     :'(008), c_date1, 'To:'(019), c_date2.
        elseif pnpbegda is initial and not pnpendda is initial.
          write: /2 'Period From     :'(008), c_date1, 'To:'(019), pnpendda.
        elseif not ( pnpbegda is initial and pnpendda is initial ).
          write: /2 'Period From     :'(008), pnpbegda,
                   'To:'(019), pnpendda.
        endif.
      endif.
      if not ( r_pemp eq c_x or r_job eq c_x ).
        write: 140 'Report Run Date:'(073), sy-datum.
        if not pnpkostl[] is initial.
          if pnpkostl-high is initial.
            write: /2 'Cost Center     :'(074), pnpkostl-low,
                  125 'Time           :'(075), sy-uzeit.
          else.
            write: /2 'Cost Center From:'(076), pnpkostl-low+7(3),
                                      'To:'(019), pnpkostl-high,
                  140 'Time           :'(075), sy-uzeit.
          endif.
        else.
          write: /140  'Time           :'(075), sy-uzeit.
        endif.
        if not pnppernr[] is initial.
          if pnppernr-high is initial.
            write: /2 'Personal Number :'(077), pnppernr-low,
                   140 'User           :'(078), sy-uname.
          else.
            write: /2 'Personal No.From:'(079),  pnppernr-low,
                                      'To:'(019), pnppernr-high,
                   140 'User           :'(078), sy-uname.
          endif.
        else.
          write: /140 'User           :'(078), sy-uname.
        endif.
        write: /140 'Page No        :'(080), sy-pagno.
      else.
        write: 48 'Report Run Date:'(073), sy-datum.
        if not pnpkostl[] is initial.
          if pnpkostl-high is initial.
            write: /2 'Cost Center     :'(074), pnpkostl-low,
                  48 'Time           :'(075), sy-uzeit.
          else.
            write: /2 'Cost Center From:'(076), pnpkostl-low+7(3),
                                      'To:'(019), pnpkostl-high,
                  48 'Time           :'(075), sy-uzeit.
          endif.
        else.
          write: /48  'Time           :'(075), sy-uzeit.
        endif.
        if not pnppernr[] is initial.
          if pnppernr-high is initial.
            write: /2 'Personal Number :'(077), pnppernr-low,
                   48 'User           :'(078), sy-uname.
          else.
            write: /2 'Personal No.From:'(079),  pnppernr-low,
                                      'To:'(019), pnppernr-high,
                   48 'User           :'(078), sy-uname.
          endif.
        else.
          write: /48 'User           :'(078), sy-uname.
        endif.
        write: /48 'Page No        :'(080), sy-pagno.
      endif.
      skip.
      if r_per eq c_x.
        write /1(193) sy-uline.
        format color col_heading on.
        write:/1 sy-vline,  2(10) 'Employee #'(011),
              12 sy-vline, 13(40) 'Name'(012) centered,
              53 sy-vline, 54(8)  'Grade'(013) centered,
              62 sy-vline, 63(15) 'Nationality'(017) centered,
              78 sy-vline, 79(10) 'Eng.Date'(014) centered,
              89 sy-vline, 90(10) 'Birth Date'(016) centered,
             100 sy-vline,101(25) 'Location'(026) centered,
             126 sy-vline,127(25) 'Position'(015) centered,
             152 sy-vline,153(40) 'Division'(018) centered,
             193 sy-vline.
        format color off.
        write /1(193) sy-uline.
      elseif r_pay eq c_x.
        write /1(188) sy-uline.
        format color col_heading on.
        write:/1 sy-vline,  2(10) 'Employee #'(011),
              12 sy-vline, 13(15) 'Basic'(033) centered,
              28 sy-vline, 29(15) 'Housing Allow.'(034) centered,
              44 sy-vline, 45(15) 'Sup.Allow.'(035) centered,
              60 sy-vline, 61(15) 'Social Allow.'(036) centered,
              76 sy-vline, 77(15) 'Child Allow.'(037) centered,
              92 sy-vline, 93(15) 'Fixed Overtime'(038) centered,
             108 sy-vline,109(15) 'R.A.Allow.'(041) centered,
             124 sy-vline,125(15) 'Perform.Allow.'(039) centered,
             140 sy-vline,141(15) 'Pension.Allow.'(059) centered,
             156 sy-vline,157(15) 'Others'(040) centered,
             172 sy-vline,173(15) 'Total'(042) centered,
             188 sy-vline.
        format color off.
        write /1(188) sy-uline.
      elseif r_edn eq c_x.
        write /1(172) sy-uline.
        format color col_heading on.
        write:/1 sy-vline,  2(10) 'Employee #'(011),
              12 sy-vline, 13(25) 'Discipline'(043) centered,
              38 sy-vline, 39(20) 'Edu.Establishment'(044) centered,
              59 sy-vline, 60(45) 'Institute'(045) centered,
             105 sy-vline,106(15) 'Country'(046) centered,
             121 sy-vline,122(30) 'Certificate'(047) centered,
             152 sy-vline,153(19) 'Duration of Course'(048) centered,
             172 sy-vline.
        format color off.
        write /1(172) sy-uline.
      elseif r_pemp eq c_x.
        write /1(97) sy-uline.
        format color col_heading on.
        write:/1 sy-vline, 12 sy-vline,
              33 sy-vline, 34(21) 'Employment Period'(055) centered,
              55 sy-vline, 81 sy-vline,
              97 sy-vline.
        write:/1 sy-vline,  2(10) 'Employee #'(011),
              12 sy-vline, 13(20) 'Employer'(049) centered,
              33 sy-vline, 34(10) 'From'(050) centered,
              44 sy-vline, 45(10) 'To'(051) centered,
              55 sy-vline, 56(25) 'Last Position'(052) centered,
              81 sy-vline, 82(15) 'Country'(053) centered,
              97 sy-vline.
        format color off.
        write /1(97) sy-uline.
      elseif r_job eq c_x.
        write /1(75) sy-uline.
        format color col_heading on.
        write:/1 sy-vline,
              12 sy-vline,13(10) 'Date of'(054) centered,
              23 sy-vline,49 sy-vline,
              75 sy-vline.
        write:/1 sy-vline,2(10)  'Employee #'(011),
              12 sy-vline,13(10) 'Upgrading/'(058) centered,
              23 sy-vline,24(25) 'Position'(015) centered,
              49 sy-vline,50(25) 'Job'(056) centered,
              75 sy-vline.
        write:/1 sy-vline, 12 sy-vline,
              13(10) 'Promotion'(057) centered,
              23 sy-vline, 49 sy-vline,
              75 sy-vline.
        format color off.
        write /1(75) sy-uline.
      elseif r_app eq c_x.
        format color col_heading on.
         write: /1 sy-vline,2(56) sy-uline, 58 sy-vline,
                /1 sy-vline, 2(56) text-025 centered color 3, 58 sy-vline.
         write /1(58) sy-uline.
         format color col_heading on.
         write:/1 sy-vline,  2(10) 'Employee #'(011),
               12 sy-vline, 13(4)  'Year'(067),
               17 sy-vline, 18(40) 'Appraisal Text'(068) centered,
               58 sy-vline.
        format color off.
        write /1(58) sy-uline.
      endif.
    endform.               "top_of_page
    *&      Form  end_of_page
    Write the Page footers
    form end_of_page.
      if r_per eq c_x.
        write : /(193) sy-uline.
      elseif r_pay eq c_x.
        write : /(188) sy-uline.
      elseif r_edn eq c_x.
        write : /(172) sy-uline.
      elseif r_pemp eq c_x.
        write /1(97) sy-uline.
      elseif r_job eq c_x.
        write /1(75) sy-uline.
      elseif r_app eq c_x.
        write /1(217) sy-uline.
      endif.
    endform.               "end_of_page
    *&      Form  Display_report
    Write the Report Output
    form display_report.
      if r_all eq c_x.
        if pers_tab[] is initial.
          message i999 with
           'No Personal Data found'(061).
        else.
          write: /1 sy-vline,2(51) sy-uline, 53 sy-vline,
                 /1 sy-vline, 2(50) text-020 centered color 3, 53 sy-vline.
          write /1(193) sy-uline.
          format color col_heading on.
          write:/1 sy-vline,  2(10) 'Employee #'(011),
                12 sy-vline, 13(40) 'Name'(012) centered,
                53 sy-vline, 54(8)  'Grade'(013) centered,
                62 sy-vline, 63(15) 'Nationality'(017) centered,
                78 sy-vline, 79(10) 'Eng.Date'(014) centered,
                89 sy-vline, 90(10) 'Birth Date'(016) centered,
               100 sy-vline,101(25) 'Location'(026) centered,
               126 sy-vline,127(25) 'Position'(015) centered,
               152 sy-vline,153(40) 'Division'(018) centered,
               193 sy-vline.
          format color off.
          write /1(193) sy-uline.
          sort pers_tab by pernr.
          loop at pers_tab.
            format color col_normal.
            write:/1 sy-vline,  2(10) pers_tab-pernr,
                  12 sy-vline, 13(40) pers_tab-ename,
                  53 sy-vline, 56(6)  pers_tab-trfgr,
                  62 sy-vline, 63(15) pers_tab-ntext,
                  78 sy-vline, 79(10) pers_tab-hdate,
                  89 sy-vline, 90(10) pers_tab-gbdat,
                 100 sy-vline,101(25) pers_tab-name1,
                 126 sy-vline,127(25) pers_tab-ptext,
                 152 sy-vline,153(40) pers_tab-ctext,
                 193 sy-vline.
          endloop.
          write /1(193) sy-uline.
        endif.
        skip 3.
        if pay_tab[] is initial.
          message i999 with
           'No Standard Pay Data found'(062).
        else.
          write: /1 sy-vline,2(42) sy-uline, 44 sy-vline,
                 /1 sy-vline, 2(42) text-021 centered color 3, 44 sy-vline.
          format color col_heading on.
          write /1(188) sy-uline.
          write:/1 sy-vline,  2(10) 'Employee #'(011),
                12 sy-vline, 13(15) 'Basic'(033) centered,
                28 sy-vline, 29(15) 'Housing Allow.'(034) centered,
                44 sy-vline, 45(15) 'Sup.Allow.'(035) centered,
                60 sy-vline, 61(15) 'Social Allow.'(036) centered,
                76 sy-vline, 77(15) 'Child Allow.'(037) centered,
                92 sy-vline, 93(15) 'Fixed Overtime'(038) centered,
               108 sy-vline,109(15) 'R.A.Allow.'(041) centered,
               124 sy-vline,125(15) 'Perform.Allow.'(039) centered,
               140 sy-vline,141(15) 'Pension.Allow.'(059) centered,
               156 sy-vline,157(15) 'Others'(040) centered,
               172 sy-vline,173(15) 'Total'(042) centered,
               188 sy-vline.
          format color off.
          write /1(188) sy-uline.
          sort pay_tab by pernr.
          loop at pay_tab.
            format color col_normal.
            write:/1 sy-vline,  2(10) pay_tab-pernr,
                  12 sy-vline,
                  13(15) pay_tab-basic currency pay_tab-waers no-zero,
                  28 sy-vline,
                  29(15) pay_tab-hra_allow currency pay_tab-waers no-zero,
                  44 sy-vline,
                  45(15) pay_tab-sup_allow currency pay_tab-waers no-zero,
                  60 sy-vline,
                  61(15) pay_tab-soc_allow currency pay_tab-waers no-zero,
                  76 sy-vline,
                  77(15) pay_tab-chl_allow currency pay_tab-waers no-zero,
                  92 sy-vline,
                  93(15) pay_tab-fix_allow currency pay_tab-waers no-zero,
                 108 sy-vline,
                 109(15) pay_tab-ra_allow currency pay_tab-waers no-zero,
                 124 sy-vline,
                 125(15) pay_tab-per_allow currency pay_tab-waers no-zero,
                 140 sy-vline.
            pay_tab-pen_allow = pay_tab-pen_allow * -1.
            write: 141(15) pay_tab-pen_allow currency pay_tab-waers no-zero,
                   156 sy-vline,
                   157(15) pay_tab-oth_allow currency pay_tab-waers no-zero,
                   172 sy-vline,
                   173(15) pay_tab-tot_allow currency pay_tab-waers no-zero,
                   188 sy-vline.
      

  • LIS Reports in ALV format

    Dear All,
    IS it possible to create LIS Reports in ALV grid format,
    Let me know the way to generate report in above format in Standard SAP
    Thank u

    Experts plz give ur ideas on thisIts really a very important and untoched topic for many frnds
    cheers
    shasla007.........

  • ABAP Custom Report (ALV Format) in Background Processing

    Hi
    I am not the hardcore ABAP Person. But want to know about the detail fact of the ABAP Custome Reports. The question is can we do the background processing for the ABAP Custome Report in ALV Format.
    If Yes ..do we require to have any additional Function/code to get the spool in ALV Format. I saw the comments that the output will look like the mess.
    Please share your comment or any useful documenation on this. We are in ECC 6.0
    Thanks in advance..and yes it will be rewared by points.
    Navin

    You can use alv's in background using docking containers, but the display wont be interactive. If you search the forum you will see tons of threads which talk about running ALV's in background.
    For the output to be interactive, you can run the report in foreground and do the data processing in background.
    Refer this link:
    Displaying ALV Grid in Background Job

  • Please send HR ALV format programs

    hai all,
    if any body develop the hr report in alv format pls send the code that wiil be usefull to me.
    thanks,
    lakshma

    Have a look at http://www.sapdevelopment.co.uk/programs/custom/zp_postcode.htm
    *: Report:  ZP_POSTCODE                                                :
    *: Author:  www.SAPDev.co.uk                                           :
    *: Date  :  2004                                                       :
    *: Description: Displays report of employees by postcode area,         :
    *:              includes current travelling allowances (i.e. parking   :
    *:              permit or transport card etc..)                        :
    *: Use:         Help encourage the use of car sharing and public       :
    *:              transport where appropriate.                           :
    REPORT  zp_postcode.
    type-pools: slis.                                      "ALV Declarations
    NODES: pernr.
    INFOTYPES: 0000, 0001, 0002, 0006, 0008, 0014, 0105, 0121.
    SELECTION-SCREEN BEGIN OF BLOCK pcode WITH FRAME TITLE text-s01.
    SELECT-OPTIONS: so_pcode FOR p0006-pstlz.
    SELECTION-SCREEN END OF BLOCK pcode.
    TYPES: BEGIN OF t_output,
      pernr       TYPE p0001-pernr,   "personnel name
      anredtxt    TYPE t522t-atext,   "title (based on p0002-anred)
      fname       TYPE p0002-vorna,   "first name
      lname       TYPE p0002-nachn,   "last name
      orgtx       TYPE t527x-orgtx,   "dept
      fte         TYPE p0008-bsgrd,   "fte
      parking(20) TYPE c,
      payslip     TYPE t526-sachn,        "payslip address
      telno       TYPE p0105-usrid_long,  "tel number(p0105-usrty = 0020)
      email       TYPE p0105-usrid_long,  "email (p0105-usrty = MAIL)
      postcode    type p0006-pstlz,
    END OF t_output.
    DATA: it_output TYPE STANDARD TABLE OF t_output INITIAL SIZE 0,
          wa_output TYPE t_output.
    *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,
          gd_count(6)    type n,
          gd_outtext(70) type c,
          gd_lines       type i.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    clear: gd_count.
    GET pernr.
    Infotype 0121 is used to store multiple contracts for personnel.
    Field p0121-hpern contains the personnel number for the main contract.
      PROVIDE * from p0121 between pn-begda and pn-endda.
      Check if main contract
        if p0121-pernr ne p0121-hpern.
          reject.
        endif.
      ENDPROVIDE.
      add 1 to gd_count.
      concatenate 'Processing personnel data'(m10) gd_count into gd_outtext
                separated by ' '.
    Display indicator for employee count
      perform progress_indicator using gd_outtext.
    Retrieve datd from infotypes
      rp_provide_from_last p0000 space pn-begda pn-endda.
      rp_provide_from_last p0001 space pn-begda pn-endda.
      rp_provide_from_last p0002 space pn-begda pn-endda.
      rp_provide_from_last p0006 space pn-begda pn-endda.
      rp_provide_from_last p0008 space pn-begda pn-endda.
      rp_provide_from_last p0014 space pn-begda pn-endda.
    Check post code
      CHECK p0006-pstlz IN so_pcode.  "cp
    Post code
      wa_output-postcode = p0006-pstlz.
    Personnel number
      wa_output-pernr = pernr-pernr.
    Personnel title
      SELECT SINGLE atext
        FROM t522t
        INTO wa_output-anredtxt
       WHERE sprsl EQ sy-langu AND
             anred EQ p0002-anred.
    First name
      wa_output-fname = p0002-vorna.
    Last name
      wa_output-lname = p0002-nachn.
    Organizational Unit text (dept)
      SELECT SINGLE orgtx
        FROM t527x
        INTO wa_output-orgtx
       WHERE sprsl EQ sy-langu AND
             orgeh EQ p0001-orgeh AND
             endda GE sy-datum.
    FTE
      wa_output-fte = p0008-bsgrd.
    Parking / travel deducted?
      CASE p0014-lgart.
        WHEN '7180' OR '7181' OR '7182'.
          wa_output-parking = text-002.
        WHEN '7183'.
          wa_output-parking = text-001.
        WHEN '7171' OR '7172' or '7173' or '7174' or
             '7175' or '7176' or '7177' or '7178'.
          wa_output-parking = text-003.
      ENDCASE.
    Payslip Address
      SELECT SINGLE sachn
        FROM t526
        INTO wa_output-payslip
       WHERE werks EQ p0001-werks AND
             sachx EQ p0001-sacha.
      PROVIDE * from p0105 between pn-begda and pn-endda.
      Telephone numbers
        if p0105-usrty = '0020'.
           wa_output-telno = p0105-usrid_long.
        endif.
      Email address
        if p0105-usrty = 'MAIL'.
           wa_output-email = p0105-usrid_long.
        endif.
      ENDPROVIDE.
      append wa_output to it_output.
      clear: wa_output.
    *END-OF-SELECTION.
    END-OF-SELECTION.
    describe table it_output lines gd_lines.
    if gd_lines gt 0.
      perform build_fieldcatalog.
      perform build_layout.
      perform display_alv_report.
    else.
      message i003(zp) with 'No records found'.
    endif.
    *&      Form  PROGRESS_INDICATOR
          Displays progress indicator on SAP screen
    form progress_indicator using p_text.
      call function 'SAPGUI_PROGRESS_INDICATOR'
          exporting
            PERCENTAGE = 0
               text       = p_text.
    endform.                    " PROGRESS_INDICATOR
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      fieldcatalog-fieldname   = 'PERNR'.
      fieldcatalog-seltext_m   = 'Personnel No.'.
      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   = 'ANREDTXT'.
      fieldcatalog-seltext_m   = 'Title'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FNAME'.
      fieldcatalog-seltext_m   = 'First Name'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'LNAME'.
      fieldcatalog-seltext_m   = 'Last Name'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'ORGTX'.
      fieldcatalog-seltext_m   = 'Department'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FTE'.
      fieldcatalog-seltext_m   = 'FTE'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PARKING'.
      fieldcatalog-seltext_m   = 'Parking/Metrocard'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PAYSLIP'.
      fieldcatalog-seltext_m   = 'Payslip Add.'.
      fieldcatalog-col_pos     = 7.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'TELNO'.
      fieldcatalog-seltext_m   = 'Telephone'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EMAIL'.
      fieldcatalog-seltext_m   = 'E-mail'.
      fieldcatalog-col_pos     = 9.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'POSTCODE'.
      fieldcatalog-seltext_m   = 'Post code'.
      fieldcatalog-col_pos     = 10.
      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-zebra             = 'X'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_output
           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
    Best Regards,
    Vibha
    *Plz mark useful answers

  • Change Output format of standard program RFSZIS00

    Hi All,
    I want to change output format of standard program RFSZIS00 for this i copied this into Z program but i am not able to
    find out where final output table is populating because that program is not using any final internal table it's using EXRACT and
    another thing is all discription for field has given in German Language.
    It's a clasical report not an ALV.
    Edited by: Raj Singh on Jul 3, 2009 11:03 AM

    Dear Raj,
    as per the report mentioned by you, it is calling some subroutine to display the details.
    Just try to trace the WRITE statements and check if you can add your own include in this report to display the output as per your requirement.
    Regds,
    Anil

  • Document Evaluations - Usage value MC45

    Hi
    We are on R/3 Enterprise 470 and I am trying to get the Usage Value MC45 to give me valid results as we are using MC40 ABC to drive cycle counting.
    We seem to have OMJJ set up correctly against each movement type so as to update data for Document evaluations.
    Is there anywhere else to look for config regarding this or are there any OSS notes that may not have been included in our release.  BTW how do I check if the fix identified in an OSS note is included in our version ??
    Any guidance or info appreciated.
    Regards
    Daniel

    Answered

  • Can we change key field values in table maintenance

    Hi,
      I have created Z-table and table maintenance for the same...
    In table maintenance..Can we change key field values??
    Is there any posibility????
    Rayudu

    you can do it in this way.
    open sm30->tablname->edit
    snow select the row(s)->copy->change the keyfield values-back->save.
    no in that sm30, select records with old primary key and delete->save.
    so you got all field similar for those record under modification, only the key field changed.

  • Changeable, new rel. if new strat. or value change/outputted

    Hi There
    My understanding that when selecting "6  Changeable, new rel. if new strat. or value change/outputted" and setting the " % Value Change " to 0.5 the Purchase Order release strategy sould be restarted if the P/O value is changed and is greater that 5%, but what is happening is that even if the value is less than 5% the release strategy is reset. Why is this happenig?

    Transfered to the correct Forum

  • Generating reports in HTMLCSS format changes output in HP-UX

    Hi All,
    I'm using Oracle Report 6i in HP-UX, apparently my reports was generated fine in PDF format, but the reports output was awful when generated in HTMLCSS format. It seen that oracle reports was trying to squeeze the report horizontally and vertically. Therefore I do a simple test again, I create a simple report defination file in HP-UX, which only consist of a 15cm x 3cm box. When I generate this report in PDF format, it works fine, but when I generate it in HTMLCSS format, the box become smaller, for instance 12cm x 2.5cm. So I get the same rdf file and run again in Oracle Report 6i for NT, it works fine for both PDF and HTMLCSS.
    The command I used to generate the reports are.
    rwrun60 DESNAME="/tmp/emptyBox.html" DESTYPE=FILE PRINTJOB=NO BACKGROUND=YES PARAMFORM=NO DESFORMAT="HTMLCSS" USERID="scott/tiger@fms" REPORT="EmptyBox.rdf"
    and I do set REPORTS60_NO_DUMMY_PRINTER=true in the environment variables.
    Does anyone encounter this problem before?
    thanks,
    TengChun.

    Hi,
    Try setting the environment variable REPORTS60_DEFAULT_PIXEL_SIZE=true. This will use the default pixel resolution instead of screen surface resolution to generate HTML/HTMLCSS output.
    Thanks,
    Siva B

  • Key Field Value in FCC

    Hi Experts,
    I have a scenario in PI, where I have 1 Header, n Data Records and 1 Trailer in the source file. This data is coming in CSV format.
    I am using FCC to convert CSV into XML.
    In the FCC, I have used keyFieldValue parameter. For the Header Record, the Key Field Value is constant "H"; for Trailer Record the key field value is constant "T".
    However for Data Record, the key field value is not constant. The first character of Key field of Data Record will always be "D", but rest of the Alphabets can change.
    Sample File:
    "H","3.04",22/10/2009,16:31:12
    "D2S",21/10/2009,20:00:26,"20044",00666,"S",1
    "D2S",22/10/2009,14:26:20,"20044",00668,"S",1
    "D0S",22/10/2009,08:33:34,"00044",04165,"S",1
    "D0S",22/10/2009,11:59:59,"00044",04166,"S",1
    "T",1393.27,1393.27,8
    Here, first line is Header Line (Key Field Value "H"), Last Line is Trailer Line (Key Field Value "T") and all lines in between Header and Trailer are Data Records (Key Field Value starts with "D). I need to convert this file into XML.
    I have no clue, if this can be converted into XML through FCC.
    Any help will be highly appreciated.
    Regards,
    Varun

    >
    Varun Agarwal wrote:
    > Sample File:
    >
    "H","3.04",22/10/2009,16:31:12
    > "D2S",21/10/2009,20:00:26,"20044",00666,"S",1
    > "D2S",22/10/2009,14:26:20,"20044",00668,"S",1
    > "D0S",22/10/2009,08:33:34,"00044",04165,"S",1
    > "D0S",22/10/2009,11:59:59,"00044",04166,"S",1
    > "T",1393.27,1393.27,8
    >
    > Here, first line is Header Line (Key Field Value "H"), Last Line is Trailer Line (Key Field Value "T") and all lines in between Header and Trailer are Data Records (Key Field Value starts with "D). I need to convert this file into XML.
    >
    > I have no clue, if this can be converted into XML through FCC.
    > Any help will be highly appreciated.
    >
    >
    > Regards,
    > Varun
    Write a simple module. The module will do a replace of the Dxx fields to D (you can use simple regex function for this)
    After the module, use the messagetransformbean to do the FCC for you.
    The module might sound complex, but trust me its a simple logic you need to implement and you can easily do the FCC with the messagetransformbean

  • How can we hide the non key field values in the sm30 display

    hello experts,
    I have to protect the non key field values in the sm30 display , can u help me out wat changes i have to do in the layout.

    Hello Gopal,
    What do you mean by 'protecting' your non-key field value?
    1) You want to display it, but make it non-changeable
    A - Make the field as output-only in screen, as already answered by a preivous collegue
    2) You do not want to display this field at all
    A - Goto the DDIC definition of the view (not possible for a table directly), and maintain the required field as a Hidden. After activating, remember to re-generate the maintenance dialogue. Also, please maintain Event 21, in case you want to access/change the value of this field in background.
    3) You want to maintain special validations/checks for the field
    This can be easily done by introducing your modules within the CHAIN-FIELD commands in the PAI of the generated screens.
    Best Regards,
    Rekha

  • Usage value not getting calculated for equipment PRTs in production order

    Dear PP Gurus,
    I have assigned a PRT equipment to pouring production routing.
    I have assigned the followings:
              1. control key as "1" in the operation.
              2. usage value as 1 ea in standard value in the operation
              3. Formula maintained in the operation as ZAPF02= SAP_09 * SAP_16
                              SAP_09 (Operation quantity) -> general operation value , field name- MGVRG
                              SAP_16(PRT std value) -->  Value from PRT allocation , field name- EWVGW
    The production order is calculating the planned consumption of PRT usage, but when I confirm the operation, it is not calculating the actual usage usage value. Actual usage value should be number of moulds confirmed in the molding operation confirmation.
    Kindly help me urgently.
    Regards
    Amar

    Hi,
    I got the issue.
    In IE02- equipment measuring point change, we need to assign the same in the PRT screen also.
    But now a new error coming-
    Document 3 already entered for the measurement time specified
    Message no. IR027
    Diagnosis
    You are trying to enter a measurement document for a measuring point that has been defined as a counter.
    However, a measurement document that has not been reversed already exists at the measurement time you have entered.
    The system must be able to determine a unique sequence for the measurement documents to be able to recalculate the counter readings if necessary.
    System Response
    The system will not allow the existence of two measurement documents for a measuring point where the measurement times are the same to the exact second. The system must be able to order the measurement documents in a sequence if it has to to recalculate the counter readings.
    Procedure
    Check your entry.

Maybe you are looking for