Err in dynamic alv (rich prog)

if i add a parameter lgort and made select buy lgort only i get dump when he arrived to the metod why????
report zrich_0001.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
data: imard type table of mard with header line.
selection-screen begin of block b1 with frame title text-001.
parameters: p_matnr type mard-matnr.
parameters: p_werks type mard-werks.
selection-screen end of block b1.
start-of-selection.
select * into table imard from mard
where matnr = p_matnr
and werks = p_werks.
build the dynamic internal table
perform build_dyn_itab.
perform build_report.
call the alv grid.
perform call_alv.
Build_dyn_itab
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
tot_lines type i.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'MATNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = 'Material Number'.
wa_it_fldcat-intlen = 18.
append wa_it_fldcat to it_fldcat .
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'WERKS'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = 'Plant'.
wa_it_fldcat-intlen = 4.
append wa_it_fldcat to it_fldcat .
loop at imard.
clear wa_it_fldcat.
concatenate 'LGORT' imard-lgort into
wa_it_fldcat-fieldname.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = wa_it_fldcat-fieldname.
wa_it_fldcat-intlen = 4.
append wa_it_fldcat to it_fldcat .
clear wa_it_fldcat.
concatenate 'LABST' imard-lgort into
wa_it_fldcat-fieldname.
wa_it_fldcat-datatype = 'QUAN'.
wa_it_fldcat-seltext = wa_it_fldcat-fieldname.
wa_it_fldcat-intlen = 15.
append wa_it_fldcat to it_fldcat .
endloop.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
Form build_report
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
assign component 'MATNR' of structure <dyn_wa> to <fs1>.
<fs1> = p_matnr.
assign component 'WERKS' of structure <dyn_wa> to <fs1>.
<fs1> = p_werks.
loop at imard.
index = sy-index.
Set the LGORT
concatenate 'LGORT' imard-lgort into
fieldname.
condense fieldname no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = imard-lgort.
Set the LABST
concatenate 'LABST' imard-lgort into
fieldname.
condense fieldname no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = imard-labst.
endloop.
Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
CALL_ALV
form call_alv.
data: wa_cat like line of alv_fldcat.
loop at it_fldcat into wa_it_fldcat.
wa_cat-fieldname = wa_it_fldcat-fieldname.
wa_cat-seltext_s = wa_it_fldcat-seltext.
wa_cat-outputlen = wa_it_fldcat-outputlen.
append wa_cat to alv_fldcat.
endloop.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.

That is because you are not providing quantity <b>unit reference field</b> in field catalog for field LABST. With quantity fields, you are also supposed to fill <b>QFIELDNAME</b> and this field should also exist in field catalog. I hope it will help

Similar Messages

  • DYNAMIC  ALV(rich PROG)

    1.how i can add lgort to the parameters and the prog will select by lgort.
    2.how i change the title to sap dictonary
    report zrich_0001.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>.
    data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat,
           wa_it_fldcat type lvc_s_fcat.
    data: imard type table of mard with header line.
    selection-screen begin of block b1 with frame title text-001.
    parameters: p_matnr type mard-matnr.
    parameters: p_werks type mard-werks.
    selection-screen end of block b1.
    start-of-selection.
      select * into table imard from mard
                where matnr = p_matnr
                  and werks = p_werks.
    build the dynamic internal table
      perform build_dyn_itab.
      perform build_report.
    call the alv grid.
      perform call_alv.
    Build_dyn_itab
    form build_dyn_itab.
      data: new_table type ref to data,
            new_line  type ref to data,
            tot_lines type i.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = 'MATNR'.
      wa_it_fldcat-datatype = 'CHAR'.
      wa_it_fldcat-seltext  = 'Material Number'.
      wa_it_fldcat-intlen = 18.
      append wa_it_fldcat to it_fldcat .
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = 'WERKS'.
      wa_it_fldcat-datatype = 'CHAR'.
      wa_it_fldcat-seltext  = 'Plant'.
      wa_it_fldcat-intlen = 4.
      append wa_it_fldcat to it_fldcat .
      loop at imard.
        clear wa_it_fldcat.
        concatenate 'LGORT' imard-lgort into
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 4.
        append wa_it_fldcat to it_fldcat .
        clear wa_it_fldcat.
        concatenate 'LABST' imard-lgort into
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        append wa_it_fldcat to it_fldcat .
      endloop.
    Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
    endform.
         Form  build_report
    form build_report.
      data: fieldname(20) type c.
      data: fieldvalue(5) type c.
      data: index(3) type c.
      field-symbols: <fs1>.
      assign component  'MATNR'  of structure <dyn_wa> to <fs1>.
      <fs1> = p_matnr.
      assign component  'WERKS'  of structure <dyn_wa> to <fs1>.
      <fs1> = p_werks.
      loop at imard.
        index = sy-index.
    Set the LGORT
        concatenate 'LGORT' imard-lgort into
                 fieldname.
        condense   fieldname no-gaps.
        assign component  fieldname  of structure <dyn_wa> to <fs1>.
        <fs1> =  imard-lgort.
    Set the LABST
        concatenate 'LABST' imard-lgort into
                 fieldname.
        condense   fieldname no-gaps.
        assign component  fieldname  of structure <dyn_wa> to <fs1>.
        <fs1> =  imard-labst.
      endloop.
    Append to the dynamic internal table
      append <dyn_wa> to <dyn_table>.
    endform.
    CALL_ALV
    form call_alv.
      data: wa_cat like line of alv_fldcat.
      loop at it_fldcat into wa_it_fldcat.
        wa_cat-fieldname = wa_it_fldcat-fieldname.
        wa_cat-seltext_s = wa_it_fldcat-seltext.
        wa_cat-outputlen = wa_it_fldcat-outputlen.
        append wa_cat to alv_fldcat.
      endloop.
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat = alv_fldcat
           tables
                t_outtab    = <dyn_table>.
    endform.

    here is the full code
    if you dont understand me
    REPORT zytest1.
    TYPE-POOLS: slis.
    TABLES: mard, t023t, marc,makt, mara, t001l,mdbs, vbup,vbfa,mvke,
            vbep, vbap, vbak.
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa>.
    DATA: alv_fldcat TYPE slis_t_fieldcat_alv,
          it_fldcat TYPE lvc_t_fcat,
           wa_it_fldcat TYPE lvc_s_fcat.
    *data: imard type table of mard with header line.
    DATA: BEGIN OF imard OCCURS 0,
            werks    LIKE marc-werks,
           matkl    LIKE t023t-matkl,
           matnr    LIKE ekpo-matnr,
           lgort    LIKE mard-lgort,
           labst    LIKE mard-labst,
           diskz    LIKE mard-diskz,
           insme    LIKE mard-insme,
           wgbez    LIKE t023t-wgbez,
           meins    LIKE mara-meins,
           speme LIKE  mard-speme,
           retme LIKE  mard-retme,
           umlme LIKE  mard-umlme,
        werks LIKE  mard-werks,
           maktx LIKE  makt-maktx,
           eislo LIKE  marc-eislo,
          END OF imard.
    SELECT-OPTIONS: matnr FOR mara-matnr  MATCHCODE OBJECT mat1,
               werks FOR mard-werks,  " MATCHCODE OBJECT  t001w,
               lgort FOR mard-lgort, " MATCHCODE OBJECT tl001,
               mtart FOR mara-mtart, "MATCHCODE OBJECT mara,
               matkl FOR mara-matkl." MATCHCODE OBJECT mara.
    START-OF-SELECTION.
      SELECT mardeinme mardinsme mardlabst mardmatnr mard~retme
             mardspeme mardumlme mardwerks maramatnr mara~meins
             maktmaktx maktmatnr marceislo marcmatnr  mard~lgort
             mard~werks
      INTO (mard-einme , mard-insme , mard-labst , mard-matnr , mard-retme
           , mard-speme , mard-umlme , mard-werks , mara-matnr , mara-meins
          , makt-maktx , makt-matnr , marc-eislo , marc-matnr  , mard-lgort
          , mard-werks
      FROM ( mard
             INNER JOIN mara
             ON maramatnr = mardmatnr
             INNER JOIN makt
             ON maktmatnr = maramatnr
             INNER JOIN marc
             ON marcmatnr = maktmatnr )
             WHERE  mara~matnr IN matnr
             AND    mard~werks IN werks
             AND    mard~lgort IN lgort
             AND    mara~mtart IN mtart
             AND    mara~matkl IN matkl
             AND    makt~spras = 'B'.
        IF sy-subrc = 0.
          MOVE mard-einme TO imard-insme.
          MOVE mard-insme  TO imard-insme.
          MOVE mard-labst  TO imard-labst.
          SHIFT mard-matnr LEFT  DELETING LEADING  '0'.
          MOVE mard-matnr  TO imard-matnr.
          MOVE mard-retme  TO imard-retme.
          MOVE mard-speme TO imard-speme.
          MOVE mard-umlme TO imard-umlme.
          MOVE mard-werks  TO imard-werks.
          MOVE mara-matnr TO imard-matnr.
          MOVE mara-meins TO imard-meins.
          MOVE makt-maktx TO imard-maktx.
          MOVE makt-matnr TO imard-matnr.
          MOVE marc-eislo TO imard-eislo.
          MOVE marc-matnr  TO imard-matnr.
          MOVE mard-lgort  TO imard-lgort.
          APPEND imard.
        ENDIF.
      ENDSELECT.
    select * into table imard from mard
               where matnr = p_matnr
                 and werks = p_werks.
    build the dynamic internal table
      PERFORM build_dyn_itab.
      PERFORM build_report.
    call the alv grid.
      PERFORM call_alv.
    Build_dyn_itab
    FORM build_dyn_itab.
      DATA: new_table TYPE REF TO data,
            new_line  TYPE REF TO data,
            tot_lines TYPE i.
      CLEAR wa_it_fldcat.
      wa_it_fldcat-fieldname = 'MATNR'.
      wa_it_fldcat-datatype = 'CHAR'.
      wa_it_fldcat-seltext  = 'Material Number'.
      wa_it_fldcat-intlen = 25.
      APPEND wa_it_fldcat TO it_fldcat .
      CLEAR wa_it_fldcat.
      wa_it_fldcat-fieldname = 'WERKS'.
      wa_it_fldcat-datatype = 'CHAR'.
      wa_it_fldcat-seltext  = 'Plant'.
      wa_it_fldcat-intlen = 4.
      APPEND wa_it_fldcat TO it_fldcat .
      LOOP AT imard.
        CLEAR wa_it_fldcat.
       concatenate 'LGORT' imard-lgort into
       wa_it_fldcat-fieldname.
       wa_it_fldcat-datatype = 'CHAR'.
       wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
       wa_it_fldcat-intlen = 4.
       append wa_it_fldcat to it_fldcat .
        CLEAR wa_it_fldcat.
        CONCATENATE 'LABST' imard-lgort INTO
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        APPEND wa_it_fldcat TO it_fldcat .
        CLEAR wa_it_fldcat.
        CONCATENATE 'INSME' imard-lgort INTO
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        APPEND wa_it_fldcat TO it_fldcat .
        CLEAR wa_it_fldcat.
        CONCATENATE 'RETME' imard-lgort INTO
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        APPEND wa_it_fldcat TO it_fldcat .
        CLEAR wa_it_fldcat.
        CONCATENATE 'UMLME' imard-lgort INTO
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        APPEND wa_it_fldcat TO it_fldcat .
        CLEAR wa_it_fldcat.
        CONCATENATE 'SPEME' imard-lgort INTO
        wa_it_fldcat-fieldname.
        wa_it_fldcat-datatype = 'QUAN'.
        wa_it_fldcat-seltext  = wa_it_fldcat-fieldname.
        wa_it_fldcat-intlen = 15.
        APPEND wa_it_fldcat TO it_fldcat .
      ENDLOOP.
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
                   EXPORTING
                      it_fieldcatalog = it_fldcat
                   IMPORTING
                      ep_table        = new_table.
      ASSIGN new_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA new_line LIKE LINE OF <dyn_table>.
      ASSIGN new_line->* TO <dyn_wa>.
    ENDFORM.
         Form  build_report
    FORM build_report.
      DATA: fieldname(20) TYPE c.
      DATA: fieldvalue(5) TYPE c.
      DATA: index(3) TYPE c.
      FIELD-SYMBOLS: <fs1>.
      ASSIGN COMPONENT  'MATNR'  OF STRUCTURE <dyn_wa> TO <fs1>.
      call function 'CONVERSION_EXIT_MATN1_OUTPUT'
         exporting
              input  = matnr
         importing
              output = matnr.
    SHIFT matnr-low LEFT  DELETING LEADING  '0'.
      <fs1> = matnr-low.
      ASSIGN COMPONENT  'WERKS'  OF STRUCTURE <dyn_wa> TO <fs1>.
      <fs1> = werks.
      LOOP AT imard.
        index = sy-index.
    Set the LGORT
       concatenate 'LGORT' imard-lgort into
                fieldname.
       condense   fieldname no-gaps.
       assign component  fieldname  of structure <dyn_wa> to <fs1>.
       <fs1> =  imard-lgort.
    Set the LABST
        CONCATENATE 'LABST' imard-lgort INTO
                 fieldname.
        CONDENSE   fieldname NO-GAPS.
        ASSIGN COMPONENT  fieldname  OF STRUCTURE <dyn_wa> TO <fs1>.
        <fs1> =  imard-labst.
    INSME
        CONCATENATE 'INSME' imard-lgort INTO
                     fieldname.
        CONDENSE   fieldname NO-GAPS.
        ASSIGN COMPONENT  fieldname  OF STRUCTURE <dyn_wa> TO <fs1>.
        <fs1> =  imard-insme .
    *******RETEME
        CONCATENATE 'RETME' imard-lgort INTO
                     fieldname.
        CONDENSE   fieldname NO-GAPS.
        ASSIGN COMPONENT  fieldname  OF STRUCTURE <dyn_wa> TO <fs1>.
        <fs1> =  imard-retme.
    ******UMLME
        CONCATENATE 'UMLME' imard-lgort INTO
                     fieldname.
        CONDENSE   fieldname NO-GAPS.
        ASSIGN COMPONENT  fieldname  OF STRUCTURE <dyn_wa> TO <fs1>.
        <fs1> =  imard-umlme.
    ****SPEME
        CONCATENATE 'SPEME' imard-lgort INTO
                     fieldname.
        CONDENSE   fieldname NO-GAPS.
        ASSIGN COMPONENT  fieldname  OF STRUCTURE <dyn_wa> TO <fs1>.
        <fs1> =  imard-speme.
      ENDLOOP.
    Append to the dynamic internal table
      APPEND <dyn_wa> TO <dyn_table>.
    ENDFORM.
    CALL_ALV
    FORM call_alv.
      DATA: wa_cat LIKE LINE OF alv_fldcat.
      LOOP AT it_fldcat INTO wa_it_fldcat.
        wa_cat-fieldname = wa_it_fldcat-fieldname.
        wa_cat-seltext_s = wa_it_fldcat-seltext.
        wa_cat-outputlen = wa_it_fldcat-outputlen.
        APPEND wa_cat TO alv_fldcat.
      ENDLOOP.
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                it_fieldcat = alv_fldcat
           TABLES
                t_outtab    = <dyn_table>.
    ENDFORM.

  • Dynamic table (rich prog)

    how can i use this prog to download tables with ';'between every field any idea?
    report z_dynamic.
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
          dy_line  type ref to data,
          xfc type lvc_s_fcat,
          ifc type lvc_t_fcat.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    start-of-selection.
      perform get_structure.
      perform create_dynamic_itab.
      perform get_data.
      perform write_out.
    form get_structure.
    data : idetails type abap_compdescr_tab,
           xdetails type abap_compdescr.
    data : ref_table_des type ref to cl_abap_structdescr.
    Get the structure of the table.
      ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
      loop at idetails into xdetails.
        clear xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
      endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
      assign dy_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    Select Data from table.
      select * into table <dyn_table>
                 from (p_table).
    endform.
    form Write_Out.
    Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index
             of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    endform.

    report zrich_0001.
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
    <dyn_wa>,
    <dyn_field>.
    data: dy_table type ref to data,
    dy_line type ref to data,
    xfc type lvc_s_fcat,
    ifc type lvc_t_fcat.
    selection-screen begin of block b1 with frame.
    <b>parameters: p_table as listbox visible length 30.</b>
    selection-screen end of block b1.
    <b>at selection-screen output.
      perform build_table_drop_down_list.</b>
    start-of-selection.
      perform get_structure.
      perform create_dynamic_itab.
      perform get_data.
      perform download_data.
    * build table_drop_down_list
    <b>form build_table_drop_down_list.
    type-pools: vrm.
      data: name type vrm_id,
            list type vrm_values,
            value like line of list.
      clear list. refresh list.
      name = 'P_TABLE'.
      clear value.
      value-key = 'T000'.
      value-text = 'T000'.
      append value to list.
      clear value.
      value-key = 'T001'.
      value-text = 'T001'.
      append value to list.
      clear value.
      value-key = 'T001A'.
      value-text = 'T001A'.
      append value to list.
      clear value.
      value-key = 'T001B'.
      value-text = 'T001B'.
      append value to list.
      clear value.
      value-key = 'T001C'.
      value-text = 'T001C'.
      append value to list.
      clear value.
      value-key = 'T001D'.
      value-text = 'T001D'.
      append value to list.
      clear value.
      value-key = 'T001E'.
      value-text = 'T001E'.
      append value to list.
    * Set the values
      call function 'VRM_SET_VALUES'
           exporting
                id     = name
                values = list.
    endform.</b>
    *       FORM get_structure                                            *
    form get_structure.
      data : idetails type abap_compdescr_tab,
      xdetails type abap_compdescr.
      data : ref_table_des type ref to cl_abap_structdescr.
    * Get the structure of the table.
      ref_table_des ?=
      cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
      loop at idetails into xdetails.
        clear xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
      endloop.
    endform.
    *       FORM create_dynamic_itab                                      *
    form create_dynamic_itab.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
      exporting
      it_fieldcatalog = ifc
      importing
      ep_table = dy_table.
      assign dy_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    endform.
    *       FORM get_data                                                 *
    form get_data.
    * Select Data from table.
      select * into table <dyn_table>
      from (p_table).
    endform.
    *       FORM download_data                                            *
    form download_data.
    data: iout type table of string with header line.
    loop at <dyn_table> into <dyn_wa>.
      do.
        assign component sy-index
        of structure <dyn_wa> to <dyn_field>.
        if sy-subrc <> 0.
          exit.
        endif.
        if sy-index = 1.
          iout = <dyn_field>.
        else.
          concatenate iout <dyn_field> into iout separated by ';'.
        endif.
      enddo.
      append iout.
    endloop.
    call function 'GUI_DOWNLOAD'
         exporting
              filename = 'C:text.txt'
         tables
              data_tab = iout.
    endform.
    Regards,
    Rich Heilman

  • DYNAMIC  ALV(RAVI PROG)

    DATA: T_OUTPUT TYPE REF TO DATA
    FIELD-SYMBOLS: <T_OUTPUT> TYPE TABLE
    Call Method CL_ALV_TABLE_CREATE->CREATE_DYNAMIC_TABLE
    Exporting
    IT_FIELDCATALOG = T_FIELDCAT
    Importing
    EP_TABLE = T_OUTPUT
    ASSIGN T_OUTPUT->* TO <T_OUTPUT>.
    DO YOU AN EXPAND EXAMPLE FOR THIS
    IT'S VERY INTERESTING

    Hi,
    Check this working code:
    REPORT  y_test  LINE-SIZE 250                           .
    TYPE-POOLS: slis.                      " ALV Global Types
    DATA: BEGIN OF ty_work ,
           buffer(30000),
           END OF ty_work.
    DATA : work        LIKE ty_work OCCURS 0 WITH HEADER LINE,
           ws_rec      LIKE sy-tabix,
           ws_repname  LIKE tbprogref-progname,
           ws_tabname  LIKE dd03l-tabname,
           i_fields LIKE dd03l OCCURS 0 WITH HEADER LINE,
           ws_flag(1) TYPE c.
    FIELD-SYMBOLS <d>.
    ASSIGN COMPONENT 0 OF STRUCTURE work TO <d>.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
    PARAMETERS : p_mandt LIKE t000-mandt,
                 p_rows LIKE rseumod-tbmaxsel DEFAULT 100.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN: FUNCTION KEY 1.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS :  p_tab LIKE dd03l-tabname OBLIGATORY MEMORY ID dtb,
                 p_opt LIKE rfc_db_opt-text.
    SELECTION-SCREEN END OF BLOCK b1.
    FIELD-SYMBOLS :
       <lt_data> TYPE table.              " Data to display
    DATA:
        lp_table  TYPE REF TO data,
          ls_layout TYPE slis_layout_alv.
    FIELD-SYMBOLS: <wa> TYPE ANY, <comp> TYPE ANY.
    ASSIGN work TO <wa> CASTING TYPE (p_tab).
    Create internal table
    CREATE DATA lp_table TYPE STANDARD TABLE OF (p_tab)
                         WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN lp_table->* TO <lt_data>.
    START-OF-SELECTION.
      TRANSLATE p_opt TO UPPER CASE.                          "#EC SYNTCHAR
    Read data
      SELECT * FROM (p_tab)
              CLIENT SPECIFIED
       INTO CORRESPONDING FIELDS OF TABLE <lt_data>
              UP TO p_rows ROWS
        WHERE mandt = p_mandt
                     AND (p_opt)
       ORDER BY PRIMARY KEY.
      DESCRIBE TABLE <lt_data>  LINES ws_rec.
      ls_layout-zebra = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_structure_name = p_tab
          is_layout        = ls_layout
        TABLES
          t_outtab         = <lt_data>.
    Laxman

  • Problem in Data Display in Dynamic ALV Report

    Hi all,
    I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
    REPORT  zdynamic_test                           .
    *REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS: slis.
    *TABLES
    TABLES: zjpack_base.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *INTERNAL TABLE
    DATA: BEGIN OF it_itab OCCURS 0.
            INCLUDE STRUCTURE zjpack_base.
    DATA: END OF it_itab.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
    SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
    SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
    SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
    SELECTION-SCREEN END OF BLOCK b1.
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM select_data.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
    DO 20 TIMES.
       DO p_colms TIMES.
         l_index = sy-index.
         CONCATENATE 'FIELD' l_index INTO l_fieldname.
         ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
         <l_field> = sy-index.
       ENDDO.
       INSERT <fs_dyntable> INTO TABLE <gt_table>.
    ENDDO.
      LOOP AT it_itab.
        l_index = sy-tabix.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
        <l_field> = it_itab-matnr.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDLOOP.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
    CLEAR: l_fieldname,
            l_tabname,
            l_fieldtext,
            l_index.
    DO  p_colms TIMES.
       CLEAR l_index.
       l_index = sy-index.
       CONCATENATE 'FIELD' l_index INTO l_fieldname.
       CONCATENATE 'Field' l_index INTO l_fieldtext.
       l_tabname = '<GT_TABLE>'.
       PERFORM fieldcatalog USING: l_fieldname
                                   l_tabname
                                   l_fieldtext.
    ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1
    *&      Form  SELECT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM select_data .
    DATA: v_srlno TYPE i.
      SELECT matnr charg blqty
      INTO CORRESPONDING FIELDS OF it_itab
      FROM zjpack_base
      WHERE matnr IN s_matnr
      AND   charg IN s_charg
      AND   fdate IN s_fdate.
        COLLECT it_itab.
      ENDSELECT.
    v_srlno.
    LOOP AT it_itab.
       v_srlno = v_srlno + 1.
    ENDLOOP.
      CLEAR: l_fieldname,
              l_tabname,
              l_fieldtext,
              l_index.
    1st Field
    l_index = sy-tabix.
      CONCATENATE 'FIELD' '1' INTO l_fieldname.
      l_fieldtext = 'MATNR'.
      l_tabname = '<GT_TABLE>'.
      PERFORM fieldcatalog USING: l_fieldname
                                  l_tabname
                                  l_fieldtext.
    Other fields
      LOOP AT it_itab.
        CLEAR l_index.
        l_index = sy-tabix + 1.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDLOOP.
    Please guide me how my problem will solve.
    Thanks & Regards
    Nirmal

    Hi all, I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
    *& Report  ZDYNAMIC_TEST                                               *
    REPORT  zdynamic_test                           .
    *REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS: slis.
    *TABLES
    TABLES: zjpack_base.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *INTERNAL TABLE
    DATA: BEGIN OF it_itab OCCURS 0.
            INCLUDE STRUCTURE zjpack_base.
    DATA: END OF it_itab.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
    SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
    SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
    SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
    SELECTION-SCREEN END OF BLOCK b1.
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM select_data.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
    *  DO 20 TIMES.
    *    DO p_colms TIMES.
    *      l_index = sy-index.
    *      CONCATENATE 'FIELD' l_index INTO l_fieldname.
    *      ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
    *      <l_field> = sy-index.
    *    ENDDO.
    *    INSERT <fs_dyntable> INTO TABLE <gt_table>.
    *  ENDDO.
      LOOP AT it_itab.
        l_index = sy-tabix.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
        <l_field> = it_itab-matnr.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDLOOP.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
    *  CLEAR: l_fieldname,
    *         l_tabname,
    *         l_fieldtext,
    *         l_index.
    *  DO  p_colms TIMES.
    *    CLEAR l_index.
    *    l_index = sy-index.
    *    CONCATENATE 'FIELD' l_index INTO l_fieldname.
    *    CONCATENATE 'Field' l_index INTO l_fieldtext.
    *    l_tabname = '<GT_TABLE>'.
    *    PERFORM fieldcatalog USING: l_fieldname
    *                                l_tabname
    *                                l_fieldtext.
    *  ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    * Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1
    *&      Form  SELECT_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM select_data .
    *  DATA: v_srlno TYPE i.
      SELECT matnr charg blqty
      INTO CORRESPONDING FIELDS OF it_itab
      FROM zjpack_base
      WHERE matnr IN s_matnr
      AND   charg IN s_charg
      AND   fdate IN s_fdate.
        COLLECT it_itab.
      ENDSELECT.
    *  v_srlno.
    *  LOOP AT it_itab.
    *    v_srlno = v_srlno + 1.
    *  ENDLOOP.
      CLEAR: l_fieldname,
              l_tabname,
              l_fieldtext,
              l_index.
    * 1st Field
    *  l_index = sy-tabix.
      CONCATENATE 'FIELD' '1' INTO l_fieldname.
      l_fieldtext = 'MATNR'.
      l_tabname = '<GT_TABLE>'.
      PERFORM fieldcatalog USING: l_fieldname
                                  l_tabname
                                  l_fieldtext.
    * Other fields
      LOOP AT it_itab.
        CLEAR l_index.
        l_index = sy-tabix + 1.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDLOOP.
    ENDFORM.                    " SELECT_DATA

  • Dynamic ALV and cl_abap_structdescr Create method

    Hi
    In the process of creation of Dynamic ALV, as I have char_name and char_descr fields, I have to use char_descr as column header of ALV because char_name which has entries something like DVS_******(that do not make any sense to user). I am facing 2 problems here using the scenario above.
    1. char_descr contains characters like '[', ']', ' /', '.', space which are invalid characters for method cl_abap_structdescr=>create(). How to handle scenario like this?
    2. assign (lv_value) to <value>.
            if sy-subrc = 0.
              <value> = ls_bapi_char_value-charvalue.
              if <value> is assigned.
                move ls_bapi_char_value-charvalue to <value>.
    where-> concatenate '<table_dyn_wa>-' ls_bapi_char-char_descr into lv_value
                   <value> type any
                  <table_dyn_wa>- is dynamic table with structure created with cl_abap_tabledescr=>create( p_line_type = stru_type )
    with above code for few fields data is being assigned and for few sy-subrc = 4. The table from where I am reading the field contains char_name associated with it and not char_descr. For the fields whose char_name and char_descr matches exactly, ALV displays data for it.
    How to resolve the issue so that I could get all the data?
    Let me know if further details are needed.
    Thanks, in advance
    Trupti
    Edited by: TRUPTI KALLURWAR on Jul 9, 2010 7:08 PM

    Hello Srikanth,
    CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE( ) uses the GENERATE SUBROUTINE POOL technique to create the dynamic internal tables.
    And as per the SAP documentation,
    In an internal mode, a maximum of 36 temporary subroutine pools may be created.
    Source: [http://help.sap.com/abapdocu_702/en/abapgenerate_subroutine_pool.htm]
    Btw why are you crating 36 dynamic internal table? That's way too far-fetched even for the RTTC classes
    BR,
    Suhas

  • Problem in Dynamic ALV - inserting values in proper field of a table.

    Hi gurus,
    As per the user requirement I need to create a dynamic alv report. The fields will be display according to the period entered.
    I have already build the alv and it is working fine. But My questio is how can I append data into internal table in its proper field.
    suppose I have enter period 1 to 3 in selection screen. Then my table structure will be
    JAN |  FEB | MAR
    Upto this is is working fine, fields are generated dynamically , but how can I insert data only in perticular field.
    like
    itab-JAN = 001.
    itab-FEB = 002.
    itab-MAR = 003.
    append itab
    JAN |  FEB | MAR
    001    002   003
    Please give me a solution of that. waiting for reply.

    hI,
    loop at <dyn_table> assigning <wa>.
    lv_count = 001.
    *perform get_short_tet of month in a varibale say lv_var
    assign component LV_VAR of structure <wa> to <dyn_field1>.
    <dyn_field1> = lv_count.
    lv_count = lv_count + 1.
    endloop.
    Regards,
    mrunal
    Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:53 AM
    Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:54 AM

  • Problem in print out of Dynamic ALV

    Hi ,
    I am using dynamic ALV to address a requirement. The ALV is working fine and the output is also coming corretly, even in spool.
    But if the width of dynamic table exceeds a limit, then nothing is coming in the print out.
    If anyone has faced similar problem or knows how to tackle this problem, please advise what can be done here.
    Thanks,
    Sonal

    Hi,
    Can you try to increase field with to maximun as per your requirement.
    Regards,
    Sai

  • Color Cell in Dynamic ALV

    Hi all
    i try to put color in the dynamic alv, but i become a dump message
    Runtime Errors         OBJECTS_MOVE_NOT_SUPPORTED
    Date and Time          28.10.2010 08:46:49
    Short text
         Conversion of type "h" to type "g" not supported.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLSLVC" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    Error analysis
         You attempted to move one data object to another.
         This is not possible here because the conversion of a data object
         of type "h" to type "g" is not supported.
    my code implementation looks like
      method validate_order_deli.
        data ls_scol        type lvc_s_scol.
        data ls_colo        type lvc_s_colo.
        data ls_aoc_percent type zsd_aoc_percent.
        data lf_deliv       type lifmg.
        data lf_db_percent  type f.
        data lf_calc_perc   type f.
        refresh et_color.
        select single *
          from zsd_aoc_percent
          into corresponding fields of ls_aoc_percent
          where acin = 'X'.
        if sy-subrc <> 0.
          exit.
        endif.
        lf_db_percent = ls_aoc_percent-percent.
    *    ls_scol-fname = if_fieldname.
        ls_scol-fname = 'MATNR'.
        if if_deliv <> 0.
          me->calc_amour_unit(
            exporting
              if_matnr  = if_matnr
              if_amount = if_deliv
              if_input  = if_deliv_unit
              if_output = if_order_unit
            importing
              ef_amount = lf_deliv
          lf_calc_perc = ( lf_deliv * 100 ) / if_order.
          if lf_calc_perc < lf_db_percent.
            ls_colo-col = cl_gui_resources=>list_col_positive.
          else.
            ls_colo-col = cl_gui_resources=>list_col_negative.
          endif.
          ls_scol-color = ls_colo.
          append ls_scol to et_color.
        else.
          exit.
        endif.
      endmethod.                    "validate_order_deli
      method add_color_field.
        data ls_fcat type lvc_s_fcat.
        ls_fcat-fieldname = 'COLOR'.
        ls_fcat-ref_field = 'COLTAB'.
        ls_fcat-ref_table = 'CALENDAR_TYPE'.
        append ls_fcat to ct_fcat.
      endmethod.                    "add_color_field
          ls_lvc_s_layo-cwidth_opt = 'X'.
          ls_lvc_s_layo-ctab_fname  = 'COLOR'.
    i don't no, what's wrong...
    thx for help

    *&      Form  generate_alv
    *       text
    form generate_alv.
      field-symbols <lt_any_table> type any table.
      if lrf_gui_custom_container is initial.
        create object lrf_gui_custom_container
          exporting
            container_name = lf_container.
        create object lrf_gui_alvgrid
          exporting
            i_parent = lrf_gui_custom_container.
        ls_lvc_s_layo-cwidth_opt = 'X'.
        ls_lvc_s_layo-ctab_fname  = 'COLOR'.
        check sy-subrc = 0.
        call method lrf_gui_alvgrid->set_table_for_first_display
             exporting
    *             i_buffer_active               =
    *             i_bypassing_buffer            =
    *             i_consistency_check           =
    *             i_structure_name              = 'ZAM_CELL_COLOR'
    *             is_variant                    = ls_disvariant
    *             i_save                        = 'A'
    *             i_default                     = 'X'
               is_layout                     = ls_lvc_s_layo
    *             is_print                      =
    *             it_special_groups             =
    *             it_toolbar_excluding          =
    *             it_hyperlink                  =
    *             it_alv_graphics               =
    *             it_except_qinfo               =
    *             ir_salv_adapter               =
              changing
                it_outtab                     = <gt_table>
                it_fieldcatalog               = gt_dyn_fcat
    *             it_filter                     =
             exceptions
               invalid_parameter_combination = 1
               program_error                 = 2
               too_many_lines                = 3
               others                        = 4.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
      endif.
    endform.                    "generate_alv
    *&      Module  STATUS_0100  OUTPUT
    *       text
    module status_0100 output.
      set pf-status 'ZAM_CELL_STATUS'.
      set titlebar 'ZAM_CELL_TIT'.
      perform generate_alv.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    module user_command_0100 input.
      data lf_okcode type syucomm.
      call method cl_gui_cfw=>dispatch.
      lf_okcode = ok_code.
      case lf_okcode.
        when 'EXIT'.
          set screen 0.
          leave screen.
        when 'CANCEL'.
          leave program.
        when 'BACK'.
          set screen 0.
          leave screen..
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT

  • Subtotal in Dynamic ALV

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

  • I want  to create dynamic ALV report

    Hi great abapers,
    I want  to create dynamic ALV report.Please help me.
    Regards,
    Billa

    Hi,
    Please check the code below:
    REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
    Short description:
    To Display and sum up the Quantity of scanned materials on pallet for*
    each Shipment number for the Packaging Materials. *
    TYPE-POOLS : SLIS.
    TABLES: YYLE0003. " Scanned SSCC No.
    --Structure Declaration--
    Structure for Shipment No. and Date.
    TYPES : BEGIN OF T_VTTK_TAB ,
    TKNUM LIKE VTTK-TKNUM, " Shipment number
    ERDAT LIKE VTTK-ERDAT, " created Date
    END OF T_VTTK_TAB .
    Structure for Shipment No., Packaging Materials and Date.
    TYPES: BEGIN OF T_ITAB2,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P,
    ERDAT LIKE YYLE0003-ERDAT, " created Date
    COUNT TYPE I,
    END OF T_ITAB2.
    Structure for Shipment No. and Packaging Materials.
    TYPES: BEGIN OF T_ITAB3,
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF T_ITAB3.
    --Internal table Declaration--
    *Internal tables for the above Declared structures
    DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
    G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
    G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
    G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
    *Internal table Holding Shipment No.and quantity
    DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
    TKNUM TYPE YYLE0003-TKNUM, " Shipment number
    QUANTITY TYPE P,
    COUNT TYPE I,
    END OF G_TOTAL_TAB .
    *Internal table for selection screen data
    DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF G_SCANDATA_TAB.
    DATA: BEGIN OF ST_SCANDATA_TAB,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    EXIDV TYPE EXIDV, " External Handling Unit
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    END OF ST_SCANDATA_TAB.
    DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    TKNUM LIKE YYLE0003-TKNUM, " Shipment number
    QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
    COUNT TYPE I,
    END OF G_SCANDATA_COUNT_TAB.
    DATA: L_COUNT TYPE I.
    *Internal table for Packaging Materials and quantity
    DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
    VHILM LIKE YYLE0003-VHILM, " Packaging Materials
    QUANTITY TYPE P, " Quantity
    END OF G_ITAB6_TAB.
    *- Field catalog
    DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
    --Work area Declaration--
    DATA: WA_VTTK TYPE T_VTTK_TAB,
    WA_ITAB3 TYPE T_ITAB2,
    WA_ITAB5 TYPE T_ITAB2,
    WA_ITAB4 TYPE T_ITAB3,
    WA_ITAB1 LIKE G_SCANDATA_TAB,
    WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
    ----Variable Defnition -
    DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
    G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
    G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
    G_WA TYPE REF TO DATA.
    DATA: G_VAR TYPE I, " No of records
    G_VAR1 TYPE CHAR20. " Variable
    --field symbols Declaration--
    FIELD-SYMBOLS : <F_FS> TYPE TABLE,
    <F_FS3> TYPE ANY,
    <F_FS4> TYPE ANY,
    <F_FS5> TYPE ANY,
    <F_WA> TYPE ANY,
    <F_FS15> TYPE ANY,
    <F_FS16> TYPE SY-DATUM,
    <F_FS2> TYPE T_ITAB2,
    <F_FS6> TYPE ANY,
    <F_FS7> TYPE ANY,
    <F_FS12> TYPE ANY,
    <F_FS13> TYPE ANY.
    --Selection Parameters--
    SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
    "Select options
    SELECT-OPTIONS :
    S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
    S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
    S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
    S_EXIDV FOR YYLE0003-EXIDV, " External HU
    S_MATNR FOR YYLE0003-MATNR, " Material number
    S_VBELN FOR YYLE0003-VBELN, " SD number
    S_POSNR FOR YYLE0003-POSNR, " Item number
    S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
    S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
    S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
    S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
    S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
    S_STATUS FOR YYLE0003-STATUS, " Packing status
    S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
    S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
    S_ERDAT FOR YYLE0003-ERDAT , " Date
    S_ERZET FOR YYLE0003-ERZET, " Entry time
    S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
    S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
    S_AEZET FOR YYLE0003-AEZET, " Time last change
    S_AENAM FOR YYLE0003-AENAM. " Name of person
    SELECTION-SCREEN: END OF BLOCK BLCK01.
    --INITIALIZATION--
    INITIALIZATION.
    Clear the variables and workarea
    CLEAR :G_VAR,
    G_VAR1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1,
    WA_VTTK,
    WA_ITAB3,
    WA_ITAB5,
    WA_ITAB4,
    WA_ITAB1.
    --AT SELECTION-SCREEN--
    AT SELECTION-SCREEN.
    To validate the data entered in selection screen
    PERFORM SUB_VALIDATE.
    --START-OF-SELECTION--
    START-OF-SELECTION.
    *To fetch the data from table yyle0003
    PERFORM GET_INPUT_DATA.
    *To create the Dynamic Field Catalog
    PERFORM GET_FIELDCAT.
    To populate the data to final table
    PERFORM GET_FINAL_DATA.
    MODULE status_0100 OUTPUT *
    MODULE STATUS_0100 OUTPUT.
    *set title bar and PF status.
    SET PF-STATUS 'ZVKS'.
    SET TITLEBAR 'ZVKS'.
    CHECK SY-UCOMM IS INITIAL.
    SORT G_SCANDATA_TAB BY TKNUM VHILM.
    *Create object for Custom container
    CREATE OBJECT G_CUSTOM_CONTAINER_0100
    EXPORTING
    CONTAINER_NAME = G_CONTAINER_0100
    EXCEPTIONS
    CNTL_ERROR = 1
    CNTL_SYSTEM_ERROR = 2
    CREATE_ERROR = 3
    LIFETIME_ERROR = 4
    LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    *Create object for ALV grid
    CREATE OBJECT G_ALV_GRID_0100
    EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
    G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
    *Call method for table Display
    CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
    CHANGING
    IT_OUTTAB = <F_FS>
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR = 2
    TOO_MANY_LINES = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    User Interaction
    MODULE USER_COMMAND_0100 INPUT.
    CALL METHOD CL_GUI_CFW=>DISPATCH.
    *To exit , back or cancel
    CASE SY-UCOMM.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
    LEAVE PROGRAM.
    WHEN OTHERS.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Form get_input_data
    This sub routine will get the data from yyle0003 table.
    FORM GET_INPUT_DATA.
    CONSTANTS: C_DOT TYPE C VALUE '.',
    C_CHAR TYPE C VALUE 'D'.
    CLEAR G_SCANDATA_TAB.
    Get the data from yyle0003
    SELECT VHILM " Packaging Materials
    EXIDV " External Handling Unit
    TKNUM " Shipment number
    QUANTITY " Quantity
    FROM YYLE0003
    INTO TABLE G_SCANDATA_TAB
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    If VHILM contains any Decimal '.', replace it with D
    LOOP AT G_SCANDATA_TAB.
    REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
    IF SY-SUBRC = 0.
    MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
    ENDIF.
    CLEAR G_SCANDATA_TAB.
    ENDLOOP.
    *To get the Shipment No Creation date from VTTK.
    SELECT TKNUM
    ERDAT
    FROM VTTK
    INTO TABLE G_VTTK_TAB
    WHERE TKNUM IN S_TKNUM.
    SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
    *To get the repeatition of Pacakaging material for each Shipment.
    *--- to find the count of packaging materials under each shipment
    LOOP AT G_SCANDATA_TAB.
    READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
    AT END OF EXIDV.
    L_COUNT = L_COUNT + 1.
    MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
    G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
    CLEAR: ST_SCANDATA_TAB, L_COUNT.
    COLLECT G_SCANDATA_COUNT_TAB.
    ENDAT.
    CLEAR : G_SCANDATA_TAB.
    ENDLOOP.
    ENDFORM. " get_input_data
    *& Form sub_validate
    *This subroutine will validate the data eneterd in the selection screen
    FORM SUB_VALIDATE.
    *Varaiable declaration for Shipment number
    DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
    *- Condition will not qualify all primary key (IDENT)
    SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
    INTO L_TKNUM "wa_scandata
    WHERE TKNUM IN S_TKNUM " Shipment number
    AND YY_REFERENCE IN S_YYREF " Packing reference
    AND YY_REFTP IN S_YYREFT " Reference type
    AND EXIDV IN S_EXIDV " External Handling Unit
    AND MATNR IN S_MATNR " Material number
    AND VBELN IN S_VBELN " SD number
    AND POSNR IN S_POSNR " Item number
    AND LGTOR IN S_LGTOR " Door for warehouse No
    AND VHILM IN S_VHILM " Packaging Materials
    AND YY_MEINH IN S_YYMEIN " Indicator for UOM
    AND QUANTITY IN S_QUANTI " Quantity
    AND YYCHECKED IN S_YCHECK " Destination_door
    AND STATUS IN S_STATUS " Packing status
    AND STATUSSHIPTO IN S_STASHI " Status on ship-to
    AND LOADTRUCK IN S_LOADTR " Load truck
    AND ERDAT IN S_ERDAT " Date
    AND ERZET IN S_ERZET " Entry time
    AND AEDAT IN S_AEDAT " Last changed on
    AND ERNAM IN S_ERNAM " Name of Person
    AND AEZET IN S_AEZET " Time last change
    AND AENAM IN S_AENAM. " Name of person
    ENDSELECT.
    IF SY-SUBRC <> 0.
    MESSAGE E987 . " No data found for these selection criterias
    ENDIF.
    ENDFORM. " sub_validate
    *& Form get_fieldcat
    Preparing Field catalog
    FORM GET_FIELDCAT.
    DATA: L_REF TYPE REF TO DATA,
    L_I TYPE I. " Variable
    CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
    LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
    APPEND WA_ITAB3 TO G_ITAB3_TAB.
    MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
    COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
    *To sum up the qunatity field for each TKNUM.
    AT END OF TKNUM.
    SUM.
    MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
    MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
    APPEND G_TOTAL_TAB.
    CLEAR G_TOTAL_TAB.
    ENDAT.
    CLEAR : WA_ITAB1,
    WA_ITAB3,
    WA_ITAB4.
    ENDLOOP.
    *--- Begin of change - SKR.EXT - EBDK986377
    SORT G_ITAB4_TAB BY TKNUM.
    *--- End of change - SKR.EXT - EBDK986377
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
    MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
    *---- to get the count
    READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
    VHILM = WA_ITAB5-VHILM.
    IF SY-SUBRC EQ 0.
    WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
    ENDIF.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    COLLECT G_ITAB6_TAB.
    ENDLOOP.
    CLEAR : WA_ITAB3.
    SORT G_ITAB4_TAB BY TKNUM VHILM.
    DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
    *To get the Number of fields to be displayed
    DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
    L_I = '3'.
    *Field catalog
    WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
    WA_ALV_CAT1-COL_POS = 1.
    WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
    WA_ALV_CAT1-COL_POS = 2.
    WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR : WA_ALV_CAT1.
    Create field catalog for each of VHILM
    LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
    IF G_VAR >= 1.
    CONDENSE WA_ITAB4-VHILM NO-GAPS.
    WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
    WA_ALV_CAT1-JUST = C_CENTER. "'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    L_I = L_I + 1.
    ENDIF.
    *TOTAL-last column in the field catalog
    AT LAST.
    WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
    WA_ALV_CAT1-COL_POS = L_I.
    WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
    WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
    APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
    CLEAR WA_ALV_CAT1.
    ENDAT.
    SORT L_ALV_CAT1_TAB BY FIELDNAME.
    *Non of the field name should not get repeated
    DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
    ENDLOOP.
    SORT L_ALV_CAT1_TAB BY COL_POS.
    *Creating Dynamic Internal table
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
    IT_FIELDCATALOG = L_ALV_CAT1_TAB
    IMPORTING
    EP_TABLE = L_REF.
    Assigning the Dynamic field Catalog to field symbol.
    ASSIGN L_REF->* TO <F_FS>.
    CREATE DATA G_WA LIKE LINE OF <F_FS>.
    ASSIGN G_WA->* TO <F_WA>.
    DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
    ENDFORM. " get_fieldcat
    *& Form display_data
    FORM GET_FINAL_DATA.
    *variable declaration
    DATA: L_TOTAL TYPE I, " Row wise total
    L_FILL TYPE I, " Count
    L_TOT TYPE I. " Grand total
    *To get the TOTAL qunatity in the last line of out put.
    LOOP AT G_ITAB6_TAB.
    CLEAR WA_ITAB5.
    WA_ITAB5-TKNUM = 'TOTAL'(004).
    WA_ITAB5-ERDAT = SPACE.
    MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
    LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
    WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
    ENDLOOP.
    APPEND WA_ITAB5 TO G_ITAB5_TAB.
    CLEAR WA_ITAB5.
    ENDLOOP.
    DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
    *>>>>>>>>
    ****To get total qunatity of all TKNUM
    LOOP AT G_TOTAL_TAB .
    L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
    ENDLOOP.
    *>>>>>>>>
    *To assign ERDAT to g_itab5_tab
    LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
    READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
    IF SY-SUBRC = 0.
    WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
    MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
    ENDIF.
    ENDLOOP.
    *Assigning value in each field to respective Field symbols.
    LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
    CLEAR G_TOTAL_TAB-QUANTITY.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
    ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
    <F_FS7> = <F_FS6>.
    CONDENSE <F_FS2>-VHILM NO-GAPS.
    ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
    ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
    MOVE <F_FS3> TO G_VAR1.
    ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
    <F_FS5> = <F_FS4>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
    ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
    WRITE <F_FS16> TO <F_FS15> .
    Inorder not to display the date '00/00/000',
    if there is no DATE .
    IF ( <F_FS15> CP '00/*' )
    OR ( <F_FS15> CP '00.*' )
    OR ( <F_FS15> CP '00-*' ).
    <F_FS15> = SPACE.
    ELSEIF ( <F_FS15> CO ' / /' )
    OR ( <F_FS15> CO ' . .' )
    OR ( <F_FS15> CO ' - -' ) .
    <F_FS15> = SPACE.
    ENDIF.
    READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
    IF SY-SUBRC = 0.
    ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
    ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS13> + <F_FS12>.
    L_TOTAL = L_TOTAL + <F_FS12>.
    ENDIF.
    L_FILL = L_FILL + 1.
    IF L_FILL = L_TOT.
    ASSIGN L_TOTAL TO <F_FS12>.
    ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
    <F_FS13> = <F_FS12>.
    ENDIF.
    AT END OF <F_FS2>-TKNUM.
    APPEND <F_WA> TO <F_FS>.
    CLEAR <F_WA>.
    ENDAT.
    ENDLOOP.
    CLEAR: <F_FS6>,
    <F_FS7>,
    <F_WA>.
    *Call the screen where Custom container is defined
    CALL SCREEN 0100.
    ENDFORM. " display_data
    Regards
    Kannaiah

  • Dynamic Alv for Dynamic Internal Table

    Hi All,
    I am new for abap dynpro.
    How can i create a dynamic alv table in abap dynpro withoud ddic structure??
    My requirement is as follows:
    I have a table having some field e.g MATNR WERKS NETWR.
    I want to pivot data werks and to display in webdynpro alv.
    Thnx:
    N. N. Tiwari

    You can use the RTTI to build up a dynamic structure in memory:
    Something like this - where both the data and its structure and meta data all come from an external source (which happens to be MDM in this case):
    ****ALV
          data:
             rootnode_info type ref to if_wd_context_node_info,
             dyn_node type ref to if_wd_context_node,
             dyn_node_info type ref to if_wd_context_node_info,
             tabname_node type ref to if_wd_context_node,
             current_tablename type string,
             tablename type string,
             struct_type type ref to cl_abap_structdescr,
              table_type  type ref to cl_abap_tabledescr,
              comp_tab    type cl_abap_structdescr=>component_table,
              comp        like line of comp_tab,
              my_table    type ref to data,
              my_row      type ref to data.
          field-symbols: <table> type table,
                         <row> type data,
                         <f>   type any,
                         <wa_string>     type string,
                         <wa_date_time>  type mdm_cdt_date_time,
                         <wa_integer>    type mdm_gdt_integervalue.
          rootnode_info = wd_context->get_node_info( ).
    * create subnode_info
          try.
              rootnode_info->remove_child_node( 'MDM_DATA' ).
            catch cx_wd_context.
          endtry.
          field-symbols <wa_detail> like line of field_details.
          field-symbols <wa_result> like line of result_set.
          field-symbols <wa_pair>   type mdm_name_value_pair.
          read table result_set assigning <wa_result> index 1.
          loop at field_details assigning <wa_detail>.
    * build a structure description from the list of single fields
            if strlen( <wa_detail>-field_code ) > 30.
              comp-name = <wa_detail>-field_code+0(30).
            else.
              comp-name = <wa_detail>-field_code.
            endif.
            if <wa_result> is assigned.
              read table <wa_result>-name_value_pairs assigning <wa_pair>
                            with key code = <wa_detail>-field_code.
              if sy-subrc = 0.
                case <wa_pair>-type.
                  when `MDM_CDT_DATE_TIME`.
                    comp-type ?= cl_abap_datadescr=>describe_by_name( 'TZNTSTMPL' ).
                  when `MDM_GDT_INTEGERVALUE`.
                    if <wa_detail>-field_lookup_table is not initial.
                      comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
                    else.
                      comp-type ?= cl_abap_datadescr=>describe_by_name( 'INT4' ).
                    endif.
                  when others.
                    comp-type ?= cl_abap_datadescr=>describe_by_name( <wa_pair>-type ).
                endcase.
              else.
                comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
              endif.
            else.
              comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
            endif.
            append comp to comp_tab.
          endloop.
          struct_type = cl_abap_structdescr=>create( comp_tab ).
          dyn_node_info = rootnode_info->add_new_child_node(
             name                   = 'MDM_DATA'
             is_mandatory           = abap_false
             is_mandatory_selection = abap_false
             static_element_rtti    = struct_type
             is_multiple            = abap_true
             is_static              = abap_false ).
    *  get instance of new node
          dyn_node = wd_context->get_child_node( name = 'MDM_DATA' ).
    ****Process Table Data
          data content_string type string.
          data l_tabix type sytabix.
          table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
          create data my_table type handle table_type.
          assign my_table->* to <table>.
          loop at result_set assigning <wa_result>.
            create data my_row type handle struct_type.
            assign my_row->* to <row>.
            loop at field_details assigning <wa_detail>.
              l_tabix = sy-tabix.
              read table <wa_result>-name_value_pairs assigning <wa_pair>
                                      with key code = <wa_detail>-field_code.
    *        loop at <wa_result>-name_value_pairs assigning <wa_pair>.
              if sy-subrc = 0 and <wa_pair>-value is not initial.
                assign component l_tabix of structure <row> to <f>.
    *            READ TABLE field_details ASSIGNING <wa_detail> INDEX sy-tabix.
                case <wa_pair>-type.
                  when 'STRING'.
                    assign <wa_pair>-value->* to <wa_string>.
                    if <wa_string> is assigned.
    *                DATA: int TYPE i VALUE 258.
    *                DATA: buffer TYPE xstring,
    *                      text_buffer TYPE string,
    *                      conv TYPE REF TO cl_abap_conv_out_ce.
    *                conv = cl_abap_conv_out_ce=>create(
    *                         encoding = 'UTF-8'
    *                         endian = 'L' ).
    *                CALL METHOD conv->write( data = <wa_string> ).
    *                buffer = conv->get_buffer( ).
    *                DATA: convin  TYPE REF TO cl_abap_conv_in_ce.
    *                CALL METHOD cl_abap_conv_in_ce=>create
    *                  EXPORTING
    *                    input = buffer
    *                  RECEIVING
    *                    conv  = convin.
    *                CALL METHOD convin->read
    *                  IMPORTING
    *                    data = text_buffer.
    *                MOVE text_buffer TO <f>.
                      move <wa_string> to <f>.
                    endif.
                  when 'MDM_CDT_DATE_TIME'.
                    assign <wa_pair>-value->* to <wa_date_time>.
                    if <wa_date_time> is assigned.
                      move <wa_date_time>-content to <f>.
                    endif.
                  when 'MDM_GDT_INTEGERVALUE'.
                    assign <wa_pair>-value->* to <wa_integer>.
                    if <wa_integer> is assigned.
                      if <wa_detail>-field_lookup_table is not initial.
                        content_string = wd_assist->perform_value_lookup(
                            i_lookup_table = <wa_detail>-field_lookup_table
                            i_lookup_key   = <wa_integer> ).
                        move content_string to <f>.
                      else.
                        move <wa_integer> to <f>.
                      endif.
                    endif.
                endcase.
              endif.
            endloop.
            append <row> to <table>.
          endloop.
          dyn_node->bind_table( <table> ).
    * Connect to the component Usage of the ALV
          data: l_ref_cmp_usage type ref to if_wd_component_usage.
          l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
          if l_ref_cmp_usage->has_active_component( ) is initial.
            l_ref_cmp_usage->create_component( ).
          endif.
    * Through the interface controller of the ALV Component set the DATA node dynamically
          data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
          l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
          l_ref_interfacecontroller->set_data(
            r_node_data = dyn_node  ).
          data alv_model type ref to cl_salv_wd_config_table.
          alv_model = l_ref_interfacecontroller->get_model( ).
          data columns type salv_wd_t_column_ref.
          field-symbols <wa_column> like line of columns.
          columns = alv_model->if_salv_wd_column_settings~get_columns( ).
          data column_id type string.
          data header type ref to cl_salv_wd_column_header.
          data l_text type string.
          loop at field_details assigning <wa_detail>.
    * build a structure description from the list of single fields
            if strlen( <wa_detail>-field_code ) > 30.
              column_id = <wa_detail>-field_code+0(30).
            else.
              column_id = <wa_detail>-field_code.
            endif.
            translate column_id to upper case.
            read table columns assigning <wa_column> with table key id = column_id.
            if sy-subrc = 0.
              header = <wa_column>-r_column->get_header( ).
              header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none ).
    *      if <wa_detail>-field_lookup_table is initial.
              header->set_text( <wa_detail>-field_name1 ).
    *      else.
    *        l_text = wd_assist->read_table_desc_for_lookup( <wa_detail>-field_lookup_table ).
    *        header->set_text( l_text ).
    *      endif.
            endif.
          endloop.
        catch cx_root into o_except.
          data: l_current_controller type ref to if_wd_controller,
                l_message_manager    type ref to if_wd_message_manager.
          l_current_controller ?= wd_this->wd_get_api( ).
          l_message_manager = l_current_controller->get_message_manager( ).
          l_message_manager->report_exception(
              message_object           = o_except ).
      endtry.

  • Colors in Dynamic ALV table display

    Hello All,
    I have dynamic ALV table display in which i created the columns dynamically and finally binded that created node and diplayed the table ..
    Now what i want to do is depending on some condition i need to change the colors in the table display..
    I tried to set the color in this way inside the loop .
                     if lv_phase  = '3'.
                   lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-badvalue_medium ).
                     else.
                    lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-standard ).
                   endif.
    This piece of code either changes all the coloumns into one color only why it is not changing the color based upon the condition . I am unable to understand..
    Please help me in this...Do i need to some thing else..

    Solved by creating a new column called cell design ... and settign the set_cell_design_fieldname ...
    This solved my Problem ..

  • Create dynamic internal table with deep structure;cell coloring dynamic ALV

    Hi,
    My requirement is to do cell colouring for a dynamic ALV.
    So I am creating a dynamic internal table using the following method.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcatalog[]
        IMPORTING
          ep_table        = i_output.
    But how do I define field COLORS which should be again an internal table ?
    Is there any other way for cell colouring?
    Putting my problem in another way:
    How do I create a dynamic internal table with one field as another internal table.
    Quick replies are highly appreciated.
    Thanks,
    Nisha Vengal.

    halo Nisha
    Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
    1 Create a global structute say ZEXTEND_FIELDCAT
    2 Have fields like STYLE type lvc_t_styl
                             COLOR type LVC_T_SCOL.
    3 Now you have to extend ur fieldcatalog
      l_fieldcat-fieldname = COLOR'.
      l_fieldcat-ref_field = 'COLOR'.
      l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
      APPEND l_fieldcat TO lt_field_catalog.
      CLEAR l_fieldcat.

  • Dynamic ALV as per the periods on the selection screen

    Hello Experts
    I am new to dynamic ALV , Please help me to sought out my confusion.
    I want to create a dynamic ALV , based on the period mentioned at selection screen.
    for example I want to display the movement type  ( sum of the quantity ) for materials for the full month.
    I want the ALV output as below.
    Material  .........qty 01.04.2011..... qty 02.04.2011... qty 03.04.2011 ........ qty 30.04.2011
    AB1........................... 30.................... 20............................. 50......................... 200
    AB2.................................................... 50 ............................. 80 ..........................10
    I create an internal table itab with there fields to selact the data
    MATNR
    date
    qty
    select MATNR
           date
           qty
    into itab
    from mseg
    where based on the selection screen.
    then collect the data to other table date wise , now i have summrise data of material quantity
    now the results after collection data into table itab2 is as follows
    Material  ................... date ................................   qty
    AB1  ....................    01.04.2011.......................  30
    AB1  ...................     02.04.2011 ....................... 20
    AB1  ...................   03.04.2011.......................  50
    AB1  ...................   .30.04.2011.......................  200
    AB2 ....................   02.04.2011.......................   50
    AB2 .......................   03.04.2011.......................   80
    AB2 .......................   30.04.2011 .......................   10
    How can I display these fields horizontally instead of vertically ,
    and to the exact column as per the field catalog column header belongs to date.
    it would be so helpful if somebody explain with code by taking the above example.
    Thanks in Advance

    Hello Both Experts ,
    I write the below code and it is working for the requirement.
    Can you please check
    REPORT  z_test_dynamic                          .
    TABLES : mkpf , mseg .
    TYPES : BEGIN OF t_mseg ,
          mblnr TYPE mblnr ,
          bwart TYPE bwart ,
          matnr TYPE matnr ,
          werks TYPE werks_d ,
          menge TYPE menge_d ,
          budat TYPE budat ,
      END OF t_mseg.
    TYPES : BEGIN OF t_mseg_1 ,
          matnr TYPE matnr ,
          menge TYPE menge_d ,
          budat TYPE budat ,
      END OF t_mseg_1.
    DATA : gt_mseg TYPE STANDARD TABLE OF t_mseg ,
           gs_mseg TYPE t_mseg,
           gt_mseg_1 TYPE STANDARD TABLE OF t_mseg_1 ,
           gs_mseg_1 TYPE t_mseg_1,
           gt_mseg_2 TYPE STANDARD TABLE OF t_mseg_1 ,
           gs_mseg_2 TYPE t_mseg_1..
    DATA : gt_date TYPE STANDARD TABLE OF sy-datum ,
          gs_date TYPE sy-datum..
    DATA: ok_code LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CONTAINER_01',
          grid1  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    DATA: gt_fieldcat TYPE lvc_t_fcat.
    DATA: gp_table TYPE REF TO data.
    FIELD-SYMBOLS: <gt_table> TYPE table.
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_matnr FOR mseg-matnr ,
                     s_bwart FOR mseg-bwart NO INTERVALS,
                     s_werks FOR mseg-werks ,
                     s_budat FOR mkpf-budat .
    PARAMETERS   : p_mjahr TYPE mjahr OBLIGATORY.
    SELECTION-SCREEN : END OF BLOCK b1.
    PERFORM field_catalog.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = gt_fieldcat
      IMPORTING
        ep_table        = gp_table.
    ASSIGN gp_table->* TO <gt_table>.
    PERFORM select_main_data.
    PERFORM move_data.
    *&      Form  select_main_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM select_main_data .
      SELECT      mseg~mblnr
          mseg~bwart
          mseg~matnr
          mseg~werks
          mseg~menge
          mkpf~budat
        INTO TABLE gt_mseg
        FROM mseg AS mseg INNER JOIN mkpf AS mkpf
        ON mseg~mblnr = mkpf~mblnr AND
           mseg~mjahr = mkpf~mjahr
        WHERE matnr IN s_matnr AND
             budat IN s_budat AND
             werks IN s_werks AND
             bwart IN s_bwart AND
             mseg~mjahr EQ p_mjahr .
      IF  gt_mseg IS NOT INITIAL.
        LOOP AT gt_mseg INTO gs_mseg.
          gs_mseg_1-matnr = gs_mseg-matnr.
          gs_mseg_1-budat = gs_mseg-budat.
          gs_mseg_1-menge = gs_mseg-menge.
          COLLECT gs_mseg_1 INTO gt_mseg_1.
        ENDLOOP.
      ENDIF.
      gt_mseg_2 = gt_mseg_1.
      DELETE ADJACENT DUPLICATES FROM gt_mseg_2  COMPARING matnr.
    ENDFORM.                    " select_main_data
    *&      Form  field_catalog
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM field_catalog .
      DATA : lt_day_attributes TYPE STANDARD TABLE OF casdayattr ,
             ls_day_attributes TYPE casdayattr .
      DATA: ls_fieldcat TYPE lvc_s_fcat ,
            lv_fieldname TYPE lvc_fname.
      IF s_budat-high IS INITIAL.
        s_budat-high = s_budat-low.
      ENDIF.
      CALL FUNCTION 'DAY_ATTRIBUTES_GET'
       EXPORTING
    *   FACTORY_CALENDAR                 = ' '
    *   HOLIDAY_CALENDAR                 = ' '
         date_from                        = s_budat-low
         date_to                          = s_budat-high
         language                         = sy-langu
    * IMPORTING
    *   YEAR_OF_VALID_FROM               =
    *   YEAR_OF_VALID_TO                 =
    *   RETURNCODE                       =
        TABLES
          day_attributes                   = lt_day_attributes
    * EXCEPTIONS
    *   FACTORY_CALENDAR_NOT_FOUND       = 1
    *   HOLIDAY_CALENDAR_NOT_FOUND       = 2
    *   DATE_HAS_INVALID_FORMAT          = 3
    *   DATE_INCONSISTENCY               = 4
    *   OTHERS                           = 5
      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 lt_day_attributes INTO ls_day_attributes.
        gs_date = ls_day_attributes-date.
        APPEND gs_date TO gt_date.
      ENDLOOP.
      ls_fieldcat-fieldname = 'MATNR'.
      ls_fieldcat-inttype    = 'CHAR18'.
      ls_fieldcat-coltext    = 'MATERIAL'.
    *   ls_fieldcat-decimals_o   = '2'.
      ls_fieldcat-outputlen = 18.
      APPEND ls_fieldcat TO gt_fieldcat.
      LOOP AT gt_date INTO gs_date.
        CONCATENATE 'QTY_' gs_date INTO lv_fieldname.
        ls_fieldcat-fieldname = lv_fieldname.
        ls_fieldcat-inttype    = 'QUAN'.
        ls_fieldcat-coltext    = gs_date.
        ls_fieldcat-decimals_o   = '2'.
    *    ls_fieldcat-outputlen = 18.
        APPEND ls_fieldcat TO gt_fieldcat.
      ENDLOOP.
    ENDFORM.                    " field_catalog
    *&      Form  move_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM move_data .
      DATA: l_row TYPE sy-index.
      FIELD-SYMBOLS: <ls_table>.
      FIELD-SYMBOLS: <l_field> ,
                     <l_mseg_1> TYPE t_mseg_1.
      DATA: ls_fieldcat TYPE lvc_s_fcat .
      ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <ls_table>.
      SORT gt_mseg_1 BY matnr.
      LOOP AT gt_mseg_1 ASSIGNING <l_mseg_1> .
        IF <l_field> IS ASSIGNED.
          UNASSIGN <l_field>.
        ENDIF.
        MOVE-CORRESPONDING <l_mseg_1> TO <ls_table>.
          READ TABLE gt_fieldcat INTO ls_fieldcat WITH KEY coltext = <l_mseg_1>-budat.
          IF sy-subrc EQ 0.
            ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <ls_table> TO <l_field>.
            <l_field> = <l_mseg_1>-menge.
          ELSE.
            <l_field> =  0.
          ENDIF.
        AT end of matnr.
          APPEND <ls_table> TO <gt_table>.
    clear <ls_table>.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " move_data
    your answers help me lot . I am awarding the points.
    Very Very Thanks
    Edited by: Dilraj Singh on Apr 13, 2011 3:58 PM
    Edited by: Dilraj Singh on Apr 13, 2011 4:09 PM
    Edited by: Dilraj Singh on Apr 13, 2011 4:23 PM

Maybe you are looking for

  • How I can format my MacBook Pro 2012 without loosing anything

    Since a couple of months I am noticing that my laptop is getting slower on booting   Plus when I am doing  repair disk it stating that I need to do it from recovery & once I scan it  from recovery it will not find any error. I think it's time to refo

  • Parallel Execution of  Sub Queries using WITH clause ?

    Hi , For the below query is it that Oracle Optimizer executes "sum_data" and "avg_data" queries parallely ? WITH sum_data AS SELECT deptno, sum(sal) AS S FROM emp GROUP BY deptno ), avg_data AS SELECT deptno, avg(sal) AS A FROM emp GROUP BY deptno )

  • Interface inheritance and Generics

    Hello! For an application I need several 'stores' (classes which contain some elements) which share certain characteristics. I would like to create a general StoreInterface, and some specialized interfaces which inherit from this, e.g. a 'KwicStoreIn

  • How can I eliminate shadows?

    How can I eleminate shadows?

  • Error 1722 on Windows XP Install

    I have Windows XP Home and tried to install the Java 2 Runtime Environment (JRE) automatic and JRE manual offline. Every time the program installs it fails with a Error 1722 before it finishes. I viewed the help file and tried using the Custom option