ALV   diplay

Hello,
How to color a particuler column in ALV ?
I am sorry.....
How to color a particuler row in ALV ?
Message was edited by: Johnn Abraham

hi
good
tables used -
tables: mkpf,
        mseg,
        lfa1,
        makt.
global hashed tables used
data: begin of wa_mkpf, "header
      mblnr like mkpf-mblnr,
      mjahr like mkpf-mjahr,
      budat like mkpf-budat,
      xblnr like mkpf-xblnr,
      end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
      with unique key mblnr mjahr
      with header line.
data: st_mkpf like standard table of wa_mkpf
      with header line.
data: begin of wa_mseg, " line items
      mblnr like mseg-mblnr,
      mjahr like mseg-mjahr,
      zeile like mseg-zeile,
      bwart like mseg-bwart,
      charg like mseg-charg,
      matnr like mseg-matnr,
      lifnr like mseg-lifnr,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
      with unique key mblnr mjahr zeile
      with header line.
data st_mseg like standard table of wa_mseg
      with header line.
cache structure for lfa1 records
data: begin of wa_lfa1,
      lifnr like lfa1-lifnr,
      name1 like lfa1-name1,
      end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
      with unique key lifnr
      with header line.
cache structure for material related data
data: begin of wa_material,
      matnr like makt-matnr,
      maktx like makt-maktx,
      end of wa_material.
data: ht_material like hashed table of wa_material
        with unique key matnr
        with header line.
result table
data: begin of wa_lst, "
      budat like mkpf-budat,
      mblnr like mseg-mblnr,
      lifnr like mseg-lifnr,
      name1 like lfa1-name1,   
      xblnr like mkpf-xblnr,
      zeile like mseg-zeile,
      charg like mseg-charg,
      matnr like mseg-matnr,
      maktx like makt-maktx,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      mjahr like mseg-mjahr,
      end of wa_lst.
data: ht_lst like hashed table of wa_lst
        with unique key mblnr mjahr zeile
        with header line.
data: begin of wa_lst1, " sumary by material
      matnr like mseg-matnr,
      maktx like makt-maktx,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      color_line(4) TYPE c,           " Line color
      color_cell    TYPE lvc_t_scol,  " Cell color
      celltab type LVC_T_STYL,
      end of wa_lst1.
data: ht_lst1 like hashed table of wa_lst1
        with unique key matnr
        with header line.
structures for alv grid display.
itabs
type-pools: slis.
data: it_lst            like standard table of wa_lst with header line,
      it_fieldcat_lst   type slis_t_fieldcat_alv with header line,
      it_sort_lst       type slis_t_sortinfo_alv,
      it_lst1           like standard table of wa_lst1 with header line,
      it_fieldcat_lst1  type slis_t_fieldcat_alv with header line,
      it_sort_lst1      type slis_t_sortinfo_alv.
structures
data: wa_sort         type slis_sortinfo_alv,
      ls_layout       type slis_layout_alv.
color management.
DATA  : wa_color    TYPE lvc_s_scol.
Internal table for color management.
DATA : it_color    TYPE TABLE          OF lvc_s_scol.
itab for input enabling.
DATA: lt_celltab TYPE lvc_t_styl. "
global varialbes
data: g_lines type i.
data: g_repid like sy-repid,
      ok_code       like sy-ucomm.
selection-screen
"text: Dates:
select-options: so_budat for mkpf-budat default sy-datum.
"text: Material numbers.
select-options: so_matnr for mseg-matnr.
selection-screen uline.
selection-screen skip 1.
"Text: show summary by material.
parameters: gp_bymat as checkbox default ''.
parameters: gp_hier  as checkbox default 'X'.
start-of-selection.
  perform get_data.
  perform show_data.
end-of-selection.
      FORM get_data                                                 *
form get_data.
        select mblnr mjahr budat xblnr
            into table ht_mkpf
           from mkpf
          where budat in so_budat. " make use of std index.
have we retrieved data from mkpf?
  describe table ht_mkpf lines g_lines.
  if g_lines > 0.
if true then retrieve all related records from mseg.
Doing this way we make sure that the access is by primary key
of mseg.
The reason is that is faster to filter them in memory
than to allow the db server to do it.
    select mblnr mjahr zeile bwart charg
             matnr lifnr erfmg erfme
      into table ht_mseg
      from mseg
        for all entries in ht_mkpf
     where mblnr = ht_mkpf-mblnr
       and mjahr = ht_mkpf-mjahr.
  endif.
fill t_lst or t_lst1 according to user's choice.
  if gp_bymat = ' '.
    perform fill_ht_lst.
  else.
    perform fill_ht_lst1.
  endif.
endform.
form fill_ht_lst.
  refresh ht_lst.
Example: how to discard unwanted data in an efficient way.
  loop at ht_mseg.
  filter unwanted data
    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
    check ht_mseg-matnr in so_matnr.
  read header line.
    read table ht_mkpf with table key mblnr = ht_mseg-mblnr
    mjahr = ht_mseg-mjahr.
    clear ht_lst.
* note : this may be faster if you specify field by field.
    move-corresponding ht_mkpf to ht_lst.
    move-corresponding ht_mseg to ht_lst.
    perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
    perform read_material using ht_mseg-matnr changing ht_lst-maktx.
    insert table ht_lst.
  endloop.
endform.
form fill_ht_lst1.
data: colorear.
  refresh ht_lst1.
Example: how to discard unwanted data in an efficient way.
         hot to simulate a collect in a faster way
  loop at ht_mseg.
  filter unwanted data
    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
    check ht_mseg-matnr in so_matnr.
* note : this may be faster if you specify field by field.
    read table ht_lst1 with table key matnr = ht_mseg-matnr
    transporting erfmg.
    if sy-subrc <> 0. " if matnr doesn't exist in sumary table
    " insert a new record
      clear ht_lst1.
      ht_lst1-matnr = ht_mseg-matnr.
      perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
      ht_lst1-erfmg = ht_mseg-erfmg.
      ht_lst1-erfme = ht_mseg-erfme.
      if colorear = ''.
        colorear = 'X'.
        refresh it_color.
        ht_lst1-color_cell[] = it_color[].
        MOVE 'C410' TO ht_lst1-color_line.
      else.
        colorear = ' '.
        refresh it_color. clear it_color.
        MOVE 'MATNR' TO wa_color-fname.
        MOVE '6'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        MOVE 'MAKTX' TO wa_color-fname.
        MOVE '3'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        MOVE 'ERFMG' TO wa_color-fname.
        MOVE '5'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        ht_lst1-color_cell[] = it_color[].
        clear ht_lst1-color_line.
      endif.
      insert table ht_lst1.
    else." a record was found.
    " collect erfmg.  To do so, fill in the unique key and add
    " the numeric fields.
      ht_lst1-matnr = ht_mseg-matnr.
      add ht_mseg-erfmg to ht_lst1-erfmg.
      modify table ht_lst1 transporting erfmg.
    endif.
  endloop.
endform.
implementation of cache for lfa1.
form read_lfa1 using p_lifnr changing p_name1.
        read table ht_lfa1 with table key lifnr = p_lifnr
        transporting name1.
  if sy-subrc <> 0.
    clear ht_lfa1.
    ht_lfa1-lifnr = p_lifnr.
    select single name1
       into ht_lfa1-name1
      from lfa1
    where lifnr = p_lifnr.
    if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
    insert table ht_lfa1.
  endif.
  p_name1 = ht_lfa1-name1.
endform.
implementation of cache for material data
form read_material using p_matnr changing p_maktx.
  read table ht_material with table key matnr = p_matnr
  transporting maktx.
  if sy-subrc <> 0.
    ht_material-matnr = p_matnr.
    select single maktx into  ht_material-maktx
      from makt
     where spras = sy-langu
       and matnr = p_matnr.
    if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
    insert table ht_material.
  endif.
  p_maktx = ht_material-maktx.
endform.
form show_data.
  if gp_hier = 'X'. "no anda.
   perform show_hierarchicalALV.
  else.
    if gp_bymat = ' '.
      perform show_ht_lst.
    else.
      perform show_ht_lst1.
    endif.
  endif.
endform.
form show_hierarchicalALV.
st_mkpf[] = ht_mkpf[].
st_mseg[] = ht_mseg[].
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
  I_INTERFACE_CHECK              = ' '
  I_CALLBACK_PROGRAM             =
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  IS_LAYOUT                      =
  IT_FIELDCAT                    =
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
  IT_SORT                        =
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_SCREEN_START_COLUMN          = 0
  I_SCREEN_START_LINE            = 0
  I_SCREEN_END_COLUMN            = 0
  I_SCREEN_END_LINE              = 0
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
  IT_EVENTS                      =
  IT_EVENT_EXIT                  =
   i_tabname_header               =
   i_tabname_item                 =
  I_STRUCTURE_NAME_HEADER        =
  I_STRUCTURE_NAME_ITEM          =
   is_keyinfo                     =
  IS_PRINT                       =
  IS_REPREP_ID                   =
  I_BUFFER_ACTIVE                =
  I_BYPASSING_BUFFER             =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER        =
  ES_EXIT_CAUSED_BY_USER         =
  tables
    t_outtab_header                = st_mkpf
    t_outtab_item                  = st_mseg
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.
form show_ht_lst.
  "needed because the FM can't use a hashed table.
  it_lst[] = ht_lst[].
  perform fill_layout using 'full display'
                       changing ls_layout.
  perform fill_columns_lst.
perform sort_lst.
  g_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = g_repid
            i_callback_pf_status_set = 'SET_PF_STATUS'
            is_layout                = ls_layout
            it_fieldcat              = it_fieldcat_lst[]
           it_sort                  = it_sort_lst
       tables
            t_outtab                 = it_lst
       exceptions
            program_error            = 1
            others                   = 2.
endform.
form show_ht_lst1.
  "needed because the FM can't use a hashed table.
  it_lst1[] = ht_lst1[].
  perform fill_layout using 'Sumary by matnr'
                       changing ls_layout.
  perform fill_columns_lst1.
perform sort_lst.
  g_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = g_repid
            i_callback_pf_status_set = 'SET_PF_STATUS'
            is_layout                = ls_layout
            it_fieldcat              = it_fieldcat_lst1[]
           it_sort                  = it_sort_lst
       tables
            t_outtab                 = it_lst1
       exceptions
            program_error            = 1
            others                   = 2.
endform.
form fill_layout using p_window_titlebar
               changing cs_layo type slis_layout_alv.
  clear cs_layo.
  cs_layo-window_titlebar        = p_window_titlebar.
  cs_layo-edit                   = 'X'.
  cs_layo-edit_mode              = space.
  MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
Field that identify cell color in inetrnal table
  MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
move 'CELLTAB' TO cs_layo-stylefname.
endform.                    " armar_layout_stock
form set_pf_status using rt_extab type slis_t_extab.
create a new status
and then select extras -> adjust template -> listviewer
  set pf-status 'VISTA'.
endform.        "set_pf_status
define add_lst.
  clear it_fieldcat_lst.
  it_fieldcat_lst-fieldname     = &1.
  it_fieldcat_lst-outputlen     = &2.
  it_fieldcat_lst-ddictxt       = 'L'.
  it_fieldcat_lst-seltext_l       = &1.
  it_fieldcat_lst-seltext_m       = &1.
  it_fieldcat_lst-seltext_m       = &1.
  if &1 = 'MATNR'.
    it_fieldcat_lst-emphasize = 'C111'.
  endif.
  append it_fieldcat_lst.
end-of-definition.
define add_lst1.
  clear it_fieldcat_lst.
  it_fieldcat_lst1-fieldname     = &1.
  it_fieldcat_lst1-outputlen     = &2.
  it_fieldcat_lst1-ddictxt       = 'L'.
  it_fieldcat_lst1-seltext_l       = &1.
  it_fieldcat_lst1-seltext_m       = &1.
  it_fieldcat_lst1-seltext_m       = &1.
  append it_fieldcat_lst1.
end-of-definition.
form fill_columns_lst.
set columns for output.
  refresh it_fieldcat_lst.
  add_lst 'BUDAT' 10.
  add_lst   'MBLNR' 10.
  add_lst  'LIFNR' 10.
  add_lst  'NAME1' 35.
  add_lst  'XBLNR' 15.
  add_lst    'ZEILE' 5.
  add_lst    'CHARG' 10.
  add_lst   'MATNR' 18.
  add_lst   'MAKTX' 30.
  add_lst   'ERFMG' 17.
  add_lst   'ERFME' 5.
  add_lst   'MJAHR' 4.
endform.
form fill_columns_lst1.
set columns for output.
  refresh it_fieldcat_lst1.
  add_lst1 'MATNR' 18.
  add_lst1 'MAKTX' 30.
  add_lst1 'ERFMG' 17.
  add_lst1 'ERFME' 5..
endform.
Horacio Zapettini
Program to Calculate FI Opening Balance
How to find the Opening balance for a given period in FI Module for a Particular GL A/c.
I was calculated opening balance, code is below maybe it will be helpful.
*find period.
  CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    EXPORTING
      i_date         = s_budat-low
      i_periv        = i_tab-periv                          "'K4'
    IMPORTING
      e_buper        = v_donem
      e_gjahr        = v_gjahr
    EXCEPTIONS
      input_false    = 1
      t009_notfound  = 2
      t009b_notfound = 3
      OTHERS         = 4.
*calc opening balance hesabý
  SELECT * FROM knc1 WHERE kunnr = i_tab-kunnr
                     AND bukrs = i_tab-bukrs " s_bukrs
                     AND gjahr EQ v_gjahr.
    v_dnm = v_donem.
opening balance first calc > old year ,
    WHILE v_dnm > 1.
      v_dnm = v_dnm - 1.
      CONCATENATE 'knc1-um' v_dnm 's' INTO v_field_name_borc.
      CONCATENATE 'knc1-um' v_dnm 'h' INTO v_field_name_alacak.
      ASSIGN (v_field_name_borc) TO  old
add days which is from selected date-low month
    IF v_donem > 1.
      v_dnm = v_donem - 1.
    ELSE.
      v_dnm = v_donem.
    ENDIF.
    SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv    "'K4'
                                 AND bdatj = s_budat-low+0(4)
                                 AND poper = v_dnm.
    t009b-butag = t009b-butag + 1.
    IF s_budat-low+6(2) NE t009b-butag.
      v_date_high = s_budat-low - 1.
      IF v_donem = 1.
        v_date_low = s_budat-low.
        v_date_low+4(4)  = '0101'.
      ELSE.
        CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO
        v_date_low.
      ENDIF.
      SELECT *  FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
                            AND kunnr = i_tab-kunnr
                            AND budat BETWEEN v_date_low AND
                            v_date_high
                            AND umskz = space
                            AND blart IN s_blart.
        IF bsad-shkzg = 'S'.
          i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).
        ELSEIF bsad-shkzg = 'H'.
          i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr   ).
        ENDIF.
      ENDSELECT.
      SELECT *  FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
                           AND kunnr = i_tab-kunnr
                           AND budat BETWEEN v_date_low AND
                           v_date_high
                           AND umskz = space
                           AND blart IN s_blart.
                             AND gsber IN gsber.
        IF bsid-shkzg = 'S'.
          i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr   ).
        ELSEIF bsid-shkzg = 'H'.
          i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr   ).
        ENDIF.
      ENDSELECT.
    ENDIF.
    "opening balance ( þirket bazlý )z1 degeri
   i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).
for israel
    i_tab-dmbtril_s = i_tab-dmbtr_s .
    i_tab-dmbtril_h = i_tab-dmbtr_h .
  ENDSELECT.
THANKS
MRUTYUN^

Similar Messages

  • Column limit of an ALV diplay

    Hi All
    I have a report which is in ABAP classical report format
    since because of exceeding no. of columns of its limit(i.e. 1024) data is not getting displayed.
    To alleviate can can we go for ALV display??Kindly let
    me know what is column limit for ALVs.
    Thanks & Regards
    Vipin

    HI vipin,
    1. the limit is 90 columns
    regards,
    amit m.

  • How to convert this into alv display and also change parameterstoselect opt

    tables :mara,marc,stpo.
    parameters: p_werks like t001w-werks obligatory,
    p_matnr like mara-matnr obligatory.
    *select-options : p_matnr for mara-matnr obligatory.
    *parameters: p_werks like marc-werks obligatory,
    *p_matnr like marc-matnr obligatory.
    constants c_x value 'X'.
    data: begin of it_comp occurs 0,
    idnrk like stpox-idnrk,
    ojtxp like stpox-ojtxp,
    menge like stpox-menge,
    meins like stpox-meins,
    matkl like stpox-matmk,
    end of it_comp.
    data: w_topmat like cstmat.
    start-of-selection.
    perform explode_assembly.
    end-of-selection.
    perform write_report.
    top-of-page.
    perform print_header.
    form print_header.
    write: /(18) 'Component'(h00),
    (40) 'Description'(h01),
    'Mat.Group'(h02),
    (18) 'Quantity'(h03).
    uline.
    endform.
    form write_report.
    write: / w_topmat-matnr under text-h00 color col_heading,
    w_topmat-maktx under text-h01 color col_heading.
    loop at it_comp.
    write: /
    it_comp-idnrk under text-h00,
    it_comp-ojtxp under text-h01,
    it_comp-matkl under text-h02,
    it_comp-menge unit it_comp-meins under text-h03,
    it_comp-meins.
    endloop.
    uline.
    endform.
    form explode_assembly.
    data: it_stb like stpox occurs 0 with header line,
    it_stb2 like stpox occurs 0 with header line,
    it_stb3 like stpox occurs 0 with header line,
    w_msg(255) type c.
    Explode highest level:
    call function 'CS_BOM_EXPL_MAT_V2'
    exporting
    auskz = c_x
    capid = 'PP01'
    cuols = c_x
    datuv = sy-datum
    knfba = c_x
    ksbvo = c_x
    mbwls = c_x
    mdmps = c_x
    BGIXO = c_x
    MKMAT = c_x
    MMAPS = c_x
    FBSTP = c_x
    FTREL = c_x
    mtnrv = p_matnr
    werks = p_werks
    importing
    topmat = w_topmat
    tables
    stb = it_stb
    exceptions
    alt_not_found = 1
    call_invalid = 2
    material_not_found = 3
    missing_authorization = 4
    no_bom_found = 5
    no_plant_data = 6
    no_suitable_bom_found = 7
    conversion_error = 8
    others = 9.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into w_msg.
    write: / w_msg.
    exit.
    endif.
    Don't process documents
    delete it_stb where idnrk is initial.
    Don't process valid from furure:
    delete it_stb where datuv >= sy-datum.
    Explode phantom assemblies up to last level
    *do.
    it_stb2[] = it_stb[].
    *delete it_stb2 where dumps is initial.
    *if it_stb2[] is initial.
    *exit.
    *endif.
    *delete it_stb where not dumps is initial.
    delete it_stb where VPRSV <> 'S' OR MMSTA = '61'.
    loop at it_stb2.
    call function 'CS_BOM_EXPL_MAT_V2'
    exporting
    capid = 'PP01'
    auskz = c_x
    cuols = c_x
    datuv = sy-datum
    knfba = c_x
    ksbvo = c_x
    mbwls = c_x
    mdmps = c_x
    FBSTP = c_x
    FTREL = c_x
    mtnrv = it_stb2-idnrk
    werks = p_werks
    tables
    stb = it_stb3
    exceptions
    alt_not_found = 1
    call_invalid = 2
    material_not_found = 3
    missing_authorization = 4
    no_bom_found = 5
    no_plant_data = 6
    no_suitable_bom_found = 7
    conversion_error = 8
    others = 9.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
    into w_msg.
    write: / w_msg.
    else.
    delete it_stb3 where idnrk is initial.
    delete it_Stb3 where sobsl = 50.
    loop at it_stb3 .
    multiply it_stb3-menge by it_stb2-menge.
    modify it_stb3 transporting menge.
    endloop.
    append lines of it_stb3 to it_stb.
    endif.
    endloop.
    *enddo.
    Build table of components collecting the same components from
    all levels
    loop at it_stb.
    it_comp-matkl = it_stb-matmk.
    it_comp-idnrk = it_stb-idnrk.
    it_comp-ojtxp = it_stb-ojtxp.
    it_comp-menge = it_stb-menge.
    it_comp-meins = it_stb-meins.
    collect it_comp.
    clear it_comp.
    endloop.
    ENDFORM.
    using this i got the bom explosion and also i tried to use the following code
    to diplay alv diplay,but i got the errormsg,
    here  i got only one material input,instead of i want to use
    select options to from to ,if i give 1 to 10 material
    ouput is
    material 1
    descripn
    bom and components
    materials 2
    desc
    bom comp
    TYPE-POOLS : SLIS.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
    DATA : IT_EVENTCAT  TYPE SLIS_T_EVENT.
    DATA : WA_EVENTCAT_LN  LIKE LINE OF IT_EVENTCAT.
    DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: S_COL_POS TYPE I.
    FORM BUILD_FIELDCATALOG.
      PERFORM BUILD_FIELDCAT USING 'MATKL'.
      PERFORM BUILD_FIELDCAT USING 'IDNRK.
      PERFORM BUILD_FIELDCAT USING 'OJTXP.
    PERFORM BUILD_FIELDCAT USING 'MENGE'.
    PERFORM BUILD_FIELDCAT USING 'MEINS'.
    ENDFORM.
    FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
    FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME S_TEXT LIKE DD03P-SCRTEXT_M.
      CLEAR WA_FIELDCAT_LN.
      ADD 1 TO S_COL_POS.
      WA_FIELDCAT_LN-REF_TABNAME  = 'IT_COMP'.
      WA_FIELDCAT_LN-FIELDNAME    = L_FIELDNAME.
      WA_FIELDCAT_LN-SELTEXT_M    = S_TEXT.
      WA_FIELDCAT_LN-COL_POS      = S_COL_POS.
      WA_FIELDCAT_LN-QFIELDNAME   = SPACE.
      WA_FIELDCAT_LN-HOTSPOT      = SPACE.
      WA_FIELDCAT_LN-JUST         = 'R'.
      APPEND WA_FIELDCAT_LN TO IT_FIELDCAT.
    ENDFORM.
    FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
    FORM DATA_DISPLAY.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = TEXT-001
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = IT_FIELDCAT
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = IT_COMP
       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.
    GIVE ME SOLUTION FOR THAT ON, VERY URGENT
    THANKS IN ADVANCE
    regards
    ds

    Hi
    declare select-options instead of parameters
    for converting a report to ALV
    create a field catalog.
    for this two option declare a itab with       
    fcat    TYPE slis_t_fieldcat_alv
    and pass the field name,descr etc to fcat and append the same.
    or create structur same as your itab and pass the same with FM
    'REUSE_ALV_FIELDCATALOG_MERGE'
    use either <b>reuse_alv_grid_display or reuse_alv_list_display</b> .
    and pass the itab.
    thanks
    Shiva

  • Barcode reader in ALV report

    Hi,
      I want to display the barcode value for the given input at the top of  the alv diplay. Please let me if there is any functionality r we can do it alv itself.
    Regards,
    Senthil.

    You can't do that, even if you could get it displayed in the "header" of the grid, it wouln't show when you print.  And you can't scan it from a computer screen.   You can do barcodes in sapscripts/smartforms. 
    What is your requirement.
    Regards,
    Rich Heilman

  • Problem with FM  'REUSE_ALV_GRID_DISPLAY'

    Hi,
    I have a program which uses this FM 'REUSE_ALV_GRID_DISPLAY' and has a no of columns in the output display.
    One of my fields is message which is for diplaying message related to the record row.
    In the internal table for ALV the length of this field is 256 characters, set by me.
    When I use this internal table for ALV diplay in the 'REUSE_ALV_GRID_DISPLAY', the message gets truncated at 128 characters i.e. after 128 charaters the remaining part of the message is not shown. I've tried changing the display length for the column in the fieldcat but still the message is truncated and column shows blank in place of remaining characters.
    Is there a solution for this? Or is it the limitation for the FM?

    Hello Hitesh,
               Plz check out this
    http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm
    hope it will help you.
    Thanks
    Anirudh Saini

  • REUSE_ALV_GRID_DISPLAY - Set cell to EDITABLE

    Hi,
    I am using the fn REUSE_ALV_GRID_DISPLAY. User will be entering a range of document no in the report selection. ALV grid displays the document no and other info. I could able to display a checkbox as editable next to key field - document no.
    But the user wants only certain documents to have the Checkbox editable, meaning only certain documents in the ALV diplay should have the Checkbox editable and other documents in the ALV grid should have Checkbox Display only.
    Can this be done programatically? I appreciate your replies?
    Thanks,
    Sakthi
    Edited by: Sakthi Ganesan on Jan 17, 2011 9:16 PM

    You should be able to get a answer by searching with in SDN (as to whether it is feasible or not).. there is even a wiki entry to do this thru  LVC functions
    making some rows non-editable in ALV grid
    https://wiki.sdn.sap.com/wiki/display/Snippets/DisableorEnableInputfieldsConditionallyIn+ALV

  • ALV  to Excel diplay

    Dear SDN Members,
    I need to transfer my ALV display to an excel sheet.
    its an customary excel sheet not like normal excel sheet,
    can i use this method to design the excel display CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    if yes, send me a sample program.
    Thanx in Advance.
    Regards,
    Johnn.

    Johnn,
    Try this:
    REPORT Zsandbox_prog.
    tables: vbak.
    data: begin of lt_data_tab occurs 0,
            vbeln like vbak-vbeln,
            kunnr like vbak-kunnr,
            vdatu like vbak-vdatu,
           end of lt_data_tab.
    data: l_filename type STRING.
    data: outname type RLGRAP-FILENAME.
    data: sname type RLGRAP-FILENAME.
    data: begin of col_headers occurs 0,
            text(10),
          end of col_headers.
      select vbeln kunnr vdatu up to 50 rows
        from vbak into table lt_data_tab.
      move 'c:\fi_demo2' to outname.
      move 'Order #' to col_headers-text.
      append col_headers.
      move 'Sold-to #' to col_headers-text.
      append col_headers.
      move 'Req Del' to col_headers-text.
      append col_headers.
      CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          file_name                       = outname
          data_sheet_name                 = sname
       TABLES
         data_tab                        = lt_data_tab
         fieldnames                      = col_headers
       EXCEPTIONS
         file_not_exist                  = 1
         filename_expected               = 2
         communication_error             = 3
         ole_object_method_error         = 4
         ole_object_property_error       = 5
         invalid_pivot_fields            = 6
         download_problem                = 7
         OTHERS                          = 8.
      IF sy-subrc <> 0.
       MESSAGE s000(zz) WITH 'Export to Excel failed.'.
      ENDIF.

  • Alv Grid diplay

    HI ALL,
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
    I_BACKGROUND_ID    = space
    i_callback_program = gd_repid
    i_callback_user_command = 'USER_COMMAND'
    I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
    *is_layout_lvc = gd_layout
    it_fieldcat_lvc = it_fieldcat
    *it_fieldcat = it_fieldcat
    i_save = 'X'
    TABLES
    t_outtab = ITAB
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    The problem iam facing is when the alv grid is displayed on screen the background is blue & the first cell on which the cursor resides is yellow. i want the background colour to be white. Can anyone tell me how to achieve this. Points would be rewarded to all.
    Rgds.

    hi,
    Iam creating the field catalogue as follows:
    wa_fieldcat-fieldname = 'VBELN'.
    wa_fieldcat-scrtext_m = 'Sales Order No'.
    wa_fieldcat-col_pos = 0.
    wa_fieldcat-outputlen = 20.
    wa_fieldcat-emphasize = 'X'.
    wa_fieldcat-key = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    If iam commenting out emphasize still there is no effect???
    rgds.
    expecting an answer!!

  • Alv list diplay help needed

    Hi all,
    Is it possible to dispaly a list which is is selected from another alv list as a daiolog box.I mean i need to display all corresponding items which is selcted in a dailog box or as a dailog box. is it possible.
    Regards,
    Lisa.

    hi,
    check this example...
    REPORT  ZTEST_ALV_CHECK                         .
    TYPE-POOLS: SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          L_LAYOUT type slis_layout_alv.
    DATA: BEGIN OF ITAB OCCURS 0,
          VBELN LIKE VBAK-VBELN,
          POSNR LIKE VBAP-POSNR,
          CHK(1),
         END OF ITAB.
    SELECT VBELN
           POSNR
           FROM VBAP
           UP TO 20 ROWS
           INTO TABLE ITAB.
    X_FIELDCAT-FIELDNAME = 'CHK'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 1.
    X_FIELDCAT-INPUT = 'X'.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-CHECKBOX = 'X'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-SELTEXT_L = 'VBELN'.
    X_FIELDCAT-INPUT = 'X'.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 2.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-SELTEXT_L = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS = 3.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_LAYOUT-window_titlebar = 'Popup window'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM       = SY-REPID
        IS_LAYOUT                = L_LAYOUT
        I_CALLBACK_PF_STATUS_SET = 'STATUS'
        I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
        IT_FIELDCAT              = IT_FIELDCAT
        I_SCREEN_START_COLUMN    = 10
        I_SCREEN_START_LINE      = 1
        I_SCREEN_END_COLUMN      = 50
        I_SCREEN_END_LINE        = 20
      TABLES
        T_OUTTAB                 = ITAB
      EXCEPTIONS
        PROGRAM_ERROR            = 1
        OTHERS                   = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *&      Form  STATUS
    *       text
    *      -->P_EXTAB    text
    FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
    *- Pf status
      SET PF-STATUS 'STATUS'.
    ENDFORM.                 " STATUS
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.
    ENDFORM.                    "USER_COMMAND
    Regards
    Vijay

  • Alv reports:blocked list diplay

    can u brief about blocked list daisplay
    thanks and regards
    murali krishna

    hi,
    *& Report  ZLAXMI_ALVEXER3                                             *
    REPORT  ZLAXMI_ALVEXER3   MESSAGE-ID ZZ                      .
    *& TABLES DECLARATION                                                  *
    TABLES: MARA, MAKT, MARC.
    *& TYPE POOLS DECLARATION                                              *
    TYPE-POOLS: SLIS.
                          DATA DECLARATIONS                             *
    DATA: V_FLAG TYPE C.                        "Flag to display the header
    DATA: V_REPID TYPE SY-REPID.
    *& INTERNAL TABLE DECLARATION                                          *
    DATA: BEGIN OF I_MARA OCCURS 0,
           MATNR LIKE MARA-MATNR,
           MTART LIKE MARA-MTART,
           MATKL LIKE MARA-MATKL,
           MEINS LIKE MARA-MEINS,
           NTGEW LIKE MARA-NTGEW,
          END OF I_MARA.
    DATA: BEGIN OF I_MAKT OCCURS 0,
           MATNR LIKE MAKT-MATNR,
           SPRAS LIKE MAKT-SPRAS,
           MAKTX LIKE MAKT-MAKTX,
           MAKTG LIKE MAKT-MAKTG,
         END OF I_MAKT.
    DATA: BEGIN OF I_MARC OCCURS 0,
            MATNR LIKE MARC-MATNR,
            WERKS LIKE MARC-WERKS,
            LADGR LIKE MARC-LADGR,
            MTVFP LIKE MARC-MTVFP,
            DISPR LIKE MARC-DISPR,
            DISMM LIKE MARC-DISMM,
            DISPO LIKE MARC-DISPO,
          END OF I_MARC.
    *- Fieldcatalog
    DATA: IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV.
    *- For Events
    DATA:IT_EVENTS1 TYPE SLIS_T_EVENT,
         IT_EVENTS2 TYPE SLIS_T_EVENT.
    *- Fieldcatalog, Layout and Events
    DATA:X_FIELDCAT  TYPE SLIS_FIELDCAT_ALV,
         X_LAYOUT    TYPE SLIS_LAYOUT_ALV,
         X_EVENTS    TYPE SLIS_ALV_EVENT.
          Selection screen Declaration
    *--BLOCK1
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
                    S_MTART FOR MARA-MTART.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN                                                 *
    *- Validations
    AT SELECTION-SCREEN.
      PERFORM VALIDATE_SCREEN.
                  START OF SELECTION                                    *
    START-OF-SELECTION.
    *- To get data from mara
      PERFORM GET_DATA.
    *to get data from makt
      PERFORM GET_DATA_MAKT.
    *to get data from marc
      PERFORM GET_DATA_MARC.
    *fieldcatalog
    PERFORM FORM_FIELDCATALOG.
                  END OF SELECTION                                    *
    END-OF-SELECTION.
    PERFORM DISPLAY_REPORT.
    *&      Form  GET_DAta
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA .
    *to get data from mara table.
      SELECT MATNR
             MTART
             MATKL
             MEINS
             NTGEW FROM MARA
             INTO TABLE I_MARA
             WHERE MATNR IN S_MATNR
             AND MTART IN S_MTART.
      IF SY-SUBRC = 0.
        SORT I_MARA BY MATNR.
      ENDIF.
    ENDFORM.                    " GET_DAta
    *&      Form  get_data_makt
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA_MAKT .
      SELECT MATNR
             SPRAS
             MAKTX
             MAKTG FROM MAKT
             INTO TABLE I_MAKT
             FOR ALL ENTRIES IN I_MARA
             WHERE
             MATNR = I_MARA-MATNR.
      IF SY-SUBRC = 0.
        SORT I_MAKT BY MATNR SPRAS.
      ENDIF.
    ENDFORM.                    " get_data_makt
    *&      Form  get_data_marc
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA_MARC .
      SELECT MATNR
             WERKS
             LADGR
             MTVFP
             DISPR
             DISMM
             DISPO FROM MARC
             INTO TABLE I_MARC
             FOR ALL ENTRIES IN I_MARA
             WHERE MATNR = I_MARA-MATNR.
      IF SY-SUBRC = 0.
        SORT I_MARC BY MATNR WERKS.
      ENDIF.
    ENDFORM.                    " get_data_marc
    *&      Form  form_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM FORM_FIELDCATALOG .
      DATA:L_POS TYPE I VALUE 1.
      CLEAR: L_POS.
      L_POS = L_POS + 1.
      X_FIELDCAT-SELTEXT_M = 'MATERIAL NO'.
      X_FIELDCAT-FIELDNAME = 'MATNR'.
      X_FIELDCAT-TABNAME = 'I_MARA'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '15'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SELTEXT_M = 'MATERIAL TYPE'.
      X_FIELDCAT-FIELDNAME = 'MTART'.
      X_FIELDCAT-TABNAME = 'I_MARA'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SELTEXT_M = 'MATERIAL GRP'.
      X_FIELDCAT-FIELDNAME = 'MATKL'.
      X_FIELDCAT-TABNAME = 'I_MARA'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '9'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SELTEXT_M = 'UOM'.
      X_FIELDCAT-FIELDNAME = 'MEINS'.
      X_FIELDCAT-TABNAME = 'I_MARA'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '3'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SELTEXT_M = 'NET WEIGHT'.
      X_FIELDCAT-FIELDNAME = 'NTGEW'.
      X_FIELDCAT-TABNAME = 'I_MARA'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '13'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      L_POS = L_POS + 1.
      X_LAYOUT-ZEBRA         = 'X'.
      REFRESH:IT_EVENTS1,IT_EVENTS2.
      CLEAR:X_EVENTS,IT_EVENTS1,IT_EVENTS2.
    ENDFORM.                    " form_fieldcatalog
    *&      Form  DISPLAY_REPORT
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_REPORT .
      V_REPID = SY-REPID.
    Set Default GUI status
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          I_CALLBACK_PROGRAM = V_REPID.
    *- To display quantity not in SAP
      IF NOT I_MARA[] IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
          EXPORTING
            IS_LAYOUT                  = X_LAYOUT
            IT_FIELDCAT                = IT_FIELDCAT
            I_TABNAME                  = 'I_MARA'
            IT_EVENTS                  = IT_EVENTS2
          TABLES
            T_OUTTAB                   = I_MARA
          EXCEPTIONS
            PROGRAM_ERROR              = 1
            MAXIMUM_OF_APPENDS_REACHED = 2
            OTHERS                     = 3.
        IF SY-SUBRC <> 0.
          MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).
        ENDIF.
      ENDIF.
      IF NOT I_MAKT[] IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
          EXPORTING
            IS_LAYOUT                  = X_LAYOUT
            IT_FIELDCAT                = IT_FIELDCAT
            I_TABNAME                  = 'I_MAKT'
            IT_EVENTS                  = IT_EVENTS1
          TABLES
            T_OUTTAB                   = I_MAKT
          EXCEPTIONS
            PROGRAM_ERROR              = 1
            MAXIMUM_OF_APPENDS_REACHED = 2
            OTHERS                     = 3.
        IF SY-SUBRC <> 0.
          MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).
        ENDIF.
    ENDIF.
      IF NOT I_MARC[] IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
          EXPORTING
            IS_LAYOUT                  = X_LAYOUT
            IT_FIELDCAT                = IT_FIELDCAT
            I_TABNAME                  = 'I_MARC'
            IT_EVENTS                  = IT_EVENTS1
          TABLES
            T_OUTTAB                   = I_MARC
          EXCEPTIONS
            PROGRAM_ERROR              = 1
            MAXIMUM_OF_APPENDS_REACHED = 2
            OTHERS                     = 3.
        IF SY-SUBRC <> 0.
          MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).
        ENDIF.
    ENDIF.
    IF NOT I_MARA[] IS INITIAL OR NOT I_MAKT[] IS INITIAL
           OR I_MARC IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
          EXCEPTIONS
            PROGRAM_ERROR = 1
            OTHERS        = 2.
        IF SY-SUBRC <> 0.
          MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_DISPLAY'(003).
        ENDIF.
      ENDIF.
    ENDFORM.                    " DISPLAY_REPORT
    *&      Form  VALIDATE_SCREEN
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_SCREEN .
    DATA: LV_MATNR LIKE MARA-MATNR,
          LV_MTART LIKE MARA-MTART.
    *MATERIAL VALIDATION.
      IF NOT S_MATNR IS INITIAL.
        SELECT MATNR
        INTO LV_MATNR
        UP TO 1 ROWS
        FROM MARA
        WHERE MATNR IN S_MATNR.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID MATERIAL'(004).
        ENDIF.
      ENDIF.
    *MATERIAL TYPE VALIDATION
       IF NOT S_MTART IS INITIAL.
        SELECT MTART
        INTO LV_MTART
        UP TO 1 ROWS
        FROM MARA
        WHERE MTART IN S_MTART.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID MATERIAL TYPE'(005).
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_SCREEN
    block alv
    when two or more DIFFERENT internal tables,
    of different fields and size,
    whose data may not at all be related to each other,
    -- then block alv is used
    Regards,
    Laxmi.

  • Hiding fields in ALV report

    Hi all
    In ALV Report .The user must be able to adapt the result list (add hidden fields, remove columns) and save the layout as layout. The user must be able to select this layout when executing the selection.
      the user must hide the fields and can diplay when ever he needs in ALV report

    U have to use no_out = 'X'.
    fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-no_out   = 'X'.
      fieldcatalog-key         = 'X'.
    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_events 
                is_print                = gd_prntparams
    <b>            i_save                  = 'X'</b>
                is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_enhanced.htm

  • How to update data in the database through ALV grid

    Hi All,
    I diplayed an ALV grid with five fields in a classical report. I have already set the fieldcat for one field as wa_fcat_edit = 'X'. I am able to edit(modify) the data in that field. But I want to update the data into the database which is modified by me in that field. Can I update the data using BDC or any other procedure?
    This is an urgent require ment for me. Please help me ASAP.
    Thanks & Regards,
    Ramesh.

    Hi
    Please go through the link.
    Link: [http://www.****************/Tutorials/ALV/Edit/demo.htm]
    regards
    ravisankar

  • Re : ALV

    hi
       In normal ALV report I diplay all item sort by field F1. F1 contains repeated value. I want include Expand or collaps option in that. How to do this
    Thanks
    mani

    Hiiii....
    U can solve this by using the layout structure in the program ...in slis layout structure there u can give the fieldname and then make the expand field to be X ....depending on the reuirement ......hope this would solve ur problem ......
    regards
    chandu reddy

  • Sub Header In ALV Report

    Hi Experts,
    I want to dispaly a P/L acount in ALV report format as given below , the items will diplay should be in Excel format as:
    1.Current Month  and YTD should be under in current Year Column  it  and again in next column  Current
    month and YTD should be under Last Year Column.
                            Current Year                               Last Year
    ITEM          No     Current Month     YTD     Current Month     YTD
    Please reply me ASAP.
    Thanks

    example:
    REPORT  ZHIERSEQ_ALV.
    TYPE-POOLS: slis.                    " ALV Global types
    CONSTANTS :
      c_x VALUE 'X',
      c_gt_vbap TYPE slis_tabname VALUE 'GT_VBAP',
      c_gt_vbak TYPE slis_tabname VALUE 'GT_VBAK'.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
    PARAMETERS p_max(02) TYPE n DEFAULT '10' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_2 FOR FIELD p_expand. "#EC NEEDED
    PARAMETERS p_expand AS CHECKBOX DEFAULT c_x.
    SELECTION-SCREEN END OF LINE.
    TYPES :
    1st Table
      BEGIN OF ty_vbak,
        vbeln TYPE vbak-vbeln,             " Sales document
        kunnr TYPE vbak-kunnr,             " Sold-to party
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
        erdat TYPE vbak-erdat,             " Creation date
        waerk TYPE vbak-waerk,             " SD document currency
        expand TYPE xfeld,
      END OF ty_vbak,
    2nd Table
      BEGIN OF ty_vbap,
        vbeln TYPE vbap-vbeln,             " Sales document
        posnr TYPE vbap-posnr,             " Sales document
        matnr TYPE vbap-matnr,             " Material number
        arktx TYPE vbap-arktx,             " Material description
        netwr TYPE vbap-netwr,             " Net Value of the Sales Order
        waerk TYPE vbap-waerk,             " SD document currency
      END OF ty_vbap.
    DATA :
    1st Table
      gt_vbak TYPE TABLE OF ty_vbak,
    2nd Table
      gt_vbap TYPE TABLE OF ty_vbap.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
      v_2 = 'With ''EXPAND'' field'.
    START-OF-SELECTION.
    Read Sales Document: Header Data
      SELECT vbeln kunnr netwr waerk erdat
        FROM vbak
          UP TO p_max ROWS
        INTO CORRESPONDING FIELDS OF TABLE gt_vbak.
      IF gt_vbak[] IS NOT INITIAL.
      Read Sales Document: Item Data
        SELECT vbeln posnr matnr arktx netwr waerk
          FROM vbap
          INTO CORRESPONDING FIELDS OF TABLE gt_vbap
           FOR ALL ENTRIES IN gt_vbak
         WHERE vbeln = gt_vbak-vbeln.
      ENDIF.
    END-OF-SELECTION.
      PERFORM f_display.
          Form  F_DISPLAY
    FORM f_display.
    Macro definition
      DEFINE m_fieldcat.
        ls_fieldcat-tabname = &1.
        ls_fieldcat-fieldname = &2.
        ls_fieldcat-ref_tabname = &3.
        ls_fieldcat-cfieldname = &4.       " Field with currency unit
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        ls_sort-tabname = &1.
        ls_sort-fieldname = &2.
        ls_sort-up        = c_x.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_layout   TYPE slis_layout_alv,
        ls_keyinfo  TYPE slis_keyinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv," Sort table
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv." Field catalog
      ls_layout-group_change_edit = c_x.
      ls_layout-colwidth_optimize = c_x.
      ls_layout-zebra             = c_x.
      ls_layout-detail_popup      = c_x.
      ls_layout-get_selinfos      = c_x.
      IF p_expand = c_x.
        ls_layout-expand_fieldname  = 'EXPAND'.
      ENDIF.
    Build field catalog and sort table
      m_fieldcat c_gt_vbak 'VBELN' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'KUNNR' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'NETWR' 'VBAK' 'WAERK'.
      m_fieldcat c_gt_vbak 'WAERK' 'VBAK' ''.
      m_fieldcat c_gt_vbak 'ERDAT' 'VBAK' ''.
      m_fieldcat c_gt_vbap 'POSNR' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'MATNR' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'ARKTX' 'VBAP' ''.
      m_fieldcat c_gt_vbap 'NETWR' 'VBAP' 'WAERK'.
      m_fieldcat c_gt_vbap 'WAERK' 'VBAP' ''.
      m_sort c_gt_vbak 'KUNNR'.
      m_sort c_gt_vbap 'NETWR'.
      ls_keyinfo-header01 = 'VBELN'.
      ls_keyinfo-item01 = 'VBELN'.
      ls_keyinfo-item02 = 'POSNR'.
    Dipslay Hierarchical list
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = ls_layout
          it_fieldcat             = lt_fieldcat
          it_sort                 = lt_sort
          i_tabname_header        = c_gt_vbak
          i_tabname_item          = c_gt_vbap
          is_keyinfo              = ls_keyinfo
          i_save                  = 'A'
        TABLES
          t_outtab_header         = gt_vbak
          t_outtab_item           = gt_vbap
        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.                               " F_LIST_DISPLAY
          Form USER_COMMAND                                             *
    FORM user_command USING i_ucomm     TYPE sy-ucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
      DATA ls_vbak TYPE ty_vbak.
      CASE i_ucomm.
        WHEN '&IC1'.                       " Pick
          CASE is_selfield-tabname.
            WHEN c_gt_vbap.
            WHEN c_gt_vbak.
              READ TABLE gt_vbak INDEX is_selfield-tabindex INTO ls_vbak.
              IF sy-subrc EQ 0.
              Sales order number
                SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
              Display Sales Order
                CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND

  • Nee help on ALV report for Total of BSEG-BUZEI & F1 document in FB03

    Hi friends,
    I need to diplay line items total & when double clicked on BELNR field it should open the F1 document in FB03.
    Could anyone plz guide me on this.
    Waiting for response.
    below is my code,
    Kindly needed help.
    REPORT  YALV_1.
    TABLES : BKPF,BSEG.
    Data for ALV display
    TYPE-POOLS: SLIS.
    data : int_fcat type SLIS_T_FIELDCAT_ALV,
           fieldcatalog type slis_t_fieldcat_alv with header line.
    DATA:  wa_sortinfo TYPE slis_sortinfo_alv,
           i_sortcat TYPE slis_t_sortinfo_alv.
    TYPES  : BEGIN OF T_BKPF,
            BUKRS TYPE BKPF-BUKRS,
            BELNR TYPE BKPF-BELNR,
            GJAHR TYPE BKPF-GJAHR,
            BLART TYPE BKPF-BLART,
            BLDAT TYPE BKPF-BLDAT,
            BUDAT TYPE BKPF-BUDAT,
            END OF T_BKPF.
    types: begin of t_bseg,
           BUZEI TYPE BSEG-BUZEI,
           end of t_bseg.
    DATA : it_bkpf TYPE STANDARD TABLE OF t_bkpf with header line,
          wa_bkpf TYPE t_bkpf,
           it_bseg type standard table of t_bseg.
          wa_bseg type t_bseg.
    field to store report name
    DATA :  i_repid like sy-repid.
    select bukrs belnr gjahr blart bldat budat from bkpf into table
    it_bkpf where blart = 'AA'.
    field to check table length
    *data i_lines like sy-tabix.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    PERFORM sortcat_init CHANGING i_sortcat.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but
    *can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such
    *as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'BUKRS'.
      fieldcatalog-seltext_m   = 'Company Code'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 4.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'BELNR'.
      fieldcatalog-seltext_m   = 'Doc No'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'GJAHR'.
      fieldcatalog-seltext_m   = 'Fiscal Year'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'BLART'.
      fieldcatalog-seltext_m   = 'DOC Type'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'BLDAT'.
      fieldcatalog-seltext_m   = 'Doc Date'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'BUDAT'.
      fieldcatalog-seltext_m   = 'Popsting Date'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'BUZEI'.
      fieldcatalog-seltext_m   = 'Line Items'.
      fieldcatalog-col_pos     = 6.
      fieldcatalog-do_sum      = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'BUKRS'.
      wa_sortinfo-tabname = 'T_BKPF'.
      wa_sortinfo-spos = 1.            " First sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'BELNR'.
      wa_sortinfo-tabname = 'T_BKPF'.
      wa_sortinfo-spos = 2.            " Sec sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
    ENDFORM.                    " sortcat_init
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      i_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = i_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_sort                = i_sortcat
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = IT_BKPF
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    form data_retrieval.
    IF it_bkpf[] IS NOT INITIAL.
       select buzei from bseg into
         table it_bseg for all entries in it_bkpf
         where bukrs = it_bkpf-bukrs
         and belnr = it_bkpf-belnr
         and gjahr = it_bkpf-gjahr.
         endif.
    endform.                    " DATA_RETRIEVAL.

    Hello
    1.
    form display_alv_report.
    i_repid = sy-repid.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = i_repid
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat = fieldcatalog[]
    i_save = 'X'
    tables
    t_outtab = IT_BKPF
    exceptions
    program_error = 1
    others = 2.
    2.
    * FORM USER_COMMAND
    FORM user_command USING u_com LIKE sy-ucomm sel_lin TYPE slis_selfield.
    CASE u_com.
      WHEN '&IC1'. 
        CASE sel_lin.
          WHEN 'BELNR'.
          read TABLE IT_BKPF INDEX sel_lin-tabindex.
          SET PARAMETER ID 'BLN' FIELD IT_BKPF-BELNR.
          SET PARAMETER ID 'BUK' FIELD IT_BKPF-BUKRS.
          SET PARAMETER ID 'GJR' FIELD IT_BKPF-GJAHR.
          CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN. 
        ENDCASE.
    CLEAR u_com.
    ENDCASE.
    ENDFORM. "USER_COMMAND

Maybe you are looking for

  • Using iTunes Match on multiple devices

    I have iTunes Match but can't see TV shows on my Macbook Air. They are on my iPad and iPhone but not on the Macbook. Can anyone help?

  • How to unlock my verizon iPhone (contract over) to use it with straight talk?

    My contract with Verizon has expired I would like to use mi iPhone with straight talk some people told me that I have to unlock my phone-please help me with real solutions!!!

  • JTextField and PropertyChangeListener - listening to text changes

    I have added a PropertyChangeListener to a JTextField. The only changes that fire the event are the ancestor and Frame.active properties. Why doesn't changing the text property of the JTextField fire the Listener?

  • E4200 has major issues losing packets!

    Any one else having this issue?  For the top of the line router in this range it for sure should not be suffering from this and for me makes the router unbareable. % is loss.  I removed ips.  I am certain the issue is with the Cisco... same Rj45 conn

  • New SAP PP Business Analyst

    Hello All, I recently accepted a position at the company I've been at for 7 years. All of my prior experience with SAP has been at a user standpoint, mainly performing goods receipt, issuing components, performing TOs, and many different display scre