ALV grid is not displaying few fields of final internal table of type DMBTR

hello frnds,
i am displaying 10 fields in ALV grid using field catalog.
among them five fields are currency fields on which i doing some arithematic operations. but all these fields are not getting displayed in alv grid.
here is my code....
declaring final strucutre to generate report
TYPES:BEGIN OF ty_final,
          gjahr   TYPE gjahr,       " Year
          wwert   TYPE wwert_d,     " Traslation date
          bukrs   TYPE bukrs,       " company code
          hkont   TYPE hkont,       " General ledger account
          txt20   TYPE txt20_skat,  " Account name
          belnr   TYPE belnr_d,     " Purchase order number
          shkzg   TYPE shkzg,       " Dt/Cr indicator
          dmbtr1   TYPE dmbtr,       " Ammount in local currency
          v_alc   TYPE dmbtr,       " Ammount in local currency
          wrbtr   TYPE wrbtr,       " Ammount in foreign currency
          ebeln   TYPE ebeln,       " Purchase order number
          ebelp   TYPE ebelp,       " Item number
          matnr   TYPE matnr,       " Material number
          menge   TYPE menge_d,     " Qunatity
          meins   TYPE meins,       " Unit of measure
          stprs   TYPE stprs,       " Std material master
          v_iv    TYPE dmbtr,       " Invoice value
          pswsl   TYPE pswsl,       " Currency
          v_erc   TYPE dmbtr,       " Exchange rate calculated
          v_op    TYPE dmbtr,       " Order price
          v_uos   TYPE dmbtr,       " Unit order to stock
          v_io    TYPE dmbtr,       " Invoice to order
          v_uv    TYPE dmbtr,       " Unit value
          v_t     TYPE dmbtr,       " Total
          v_d     TYPE dmbtr,       " Differecne
          netpr   TYPE bprei,       " Net price in purchasing document
          v_total TYPE dmbtr,       " Total
          v_os    TYPE dmbtr,       " Order to stock
          v_ito   TYPE dmbtr,       " Invoice to order
          saknr   TYPE saknr,       " G/L account number
       END OF ty_final.
FORM move_data.
  IF NOT i_bseg[] IS INITIAL.
    LOOP AT i_bseg INTO wa_bseg.
      wa_final-gjahr  = wa_bseg-gjahr.
      wa_final-bukrs  = wa_bseg-bukrs.
      wa_final-hkont  = wa_bseg-hkont.
      wa_final-belnr  = wa_bseg-belnr.
      wa_final-shkzg  = wa_bseg-shkzg.
      wa_final-wrbtr  = wa_bseg-wrbtr.
      wa_final-ebeln  = wa_bseg-ebeln.
      wa_final-ebelp  = wa_bseg-ebelp.
      wa_final-matnr  = wa_bseg-matnr.
      wa_final-menge  = wa_bseg-menge.
      wa_final-meins  = wa_bseg-meins.
      wa_final-pswsl  = wa_bseg-pswsl.
      wa_final-dmbtr1  = wa_bseg-dmbtr.
      wa_final-saknr  = wa_bseg-saknr.
      wa_final-v_total = wa_bseg-dmbtr.
      READ TABLE i_bkpf INTO wa_bkpf WITH KEY bukrs = wa_bseg-bukrs.
      IF sy-subrc = 0.
        wa_final-wwert = wa_bkpf-wwert.
      ENDIF.
     CLEAR wa_bkpf.
      READ TABLE i_mbew INTO wa_mbew WITH KEY matnr = wa_bseg-matnr.
      IF sy-subrc = 0.
        wa_final-stprs = wa_mbew-stprs.
      ENDIF.
     CLEAR wa_mbew.
      READ TABLE i_ekpo INTO wa_ekpo WITH KEY ebeln = wa_bseg-ebeln.
      IF sy-subrc = 0.
        wa_final-netpr = wa_ekpo-netpr.
      ENDIF.
     CLEAR wa_ekpo.
      READ TABLE i_skat INTO wa_skat WITH KEY saknr = wa_bseg-saknr.
      IF sy-subrc = 0.
        wa_final-txt20 = wa_skat-txt20.
      ENDIF.
calculating output values
      IF wa_bseg-shkzg = 'H'.
        wa_final-v_alc = -1 * wa_bseg-dmbtr.
      ELSEIF wa_bseg-shkzg = 'S'.
        wa_final-v_alc = 1 * wa_bseg-dmbtr.
      ENDIF.
     DATA : l_c_v_alc TYPE p DECIMALS 2,
     l_c_v_iv TYPE p DECIMALS 2.
     l_c_v_alc = wa_final-v_alc.
      IF wa_bseg-menge NE 0.
        wa_final-v_iv = wa_bseg-dmbtr / wa_bseg-menge.
      ENDIF.
      IF wa_bseg-dmbtr NE 0.
        wa_final-v_erc  = wa_bseg-wrbtr   / wa_final-dmbtr1.
      ENDIF.
      IF wa_final-v_erc NE 0.
        wa_final-v_op   = wa_ekpo-netpr   / wa_final-v_erc.
      ENDIF.
      wa_final-v_uos  = wa_mbew-stprs   - wa_final-v_op.
      wa_final-v_io   = wa_final-v_iv   + wa_final-v_uos.
      wa_final-v_uv   = wa_final-v_uos  + wa_final-v_io.
      wa_final-v_t    = wa_final-v_uv   + wa_bseg-menge.
      wa_final-v_d    = wa_final-v_t    - wa_final-v_alc.
      wa_final-v_os   = wa_final-v_uos  * wa_bseg-menge.
      wa_final-v_ito  = wa_final-v_io   * wa_bseg-menge.
      CLEAR wa_bseg.
      APPEND wa_final TO i_final.
      CLEAR wa_final.
    ENDLOOP.
  ENDIF.
ENDFORM.                    "data_retrieval
*&      Form  build_fieldcat
      text
-->  p1        text
<--  p2        text
FORM build_fieldcat.
  CLEAR wa_fieldcat.
*  TYPES : v_alc TYPE dmbtr. "curr. " decimal 2.
DATA: l_c_v_alc TYPE p DECIMALS 2,
l_c_v_iv TYPE p DECIMALS 2 .
l_c_v_alc = v_alc.
l_c_v_iv = v_iv.
Constant Declarations.
  CONSTANTS:
            l_c_gjahr(5)   TYPE c VALUE 'GJAHR',      " Year
            l_c_wwert(5)   TYPE c VALUE 'WWERT',      " Traslation date
            l_c_bukrs(5)   TYPE c VALUE 'BUKRS',      " company code
            l_c_hkont(5)   TYPE c VALUE 'HKONT',      " General ledger account
            l_c_txt20(10)  TYPE c VALUE 'TXT20',      " Account name
            l_c_belnr(5)   TYPE c VALUE 'BELNR',      " Doc number
            l_c_shkzg(5)   TYPE c VALUE 'SHKZG',      " Dt/Cr indicator
            l_c_dmbtr(5)   TYPE c VALUE 'DMBTR1',      " Ammount in local currency
           " l_c_v_alc      TYPE c VALUE 'V_ALC',      " Ammount in local currency
            l_c_wrbtr(5)   TYPE c VALUE 'WRBTR',      " Ammount in foreign currency
            l_c_ebeln(5)   TYPE c VALUE 'EBELN',      " Purchase order number
            l_c_ebelp(5)   TYPE c VALUE 'EBELP',      " Item number
            l_c_matnr(5)   TYPE c VALUE 'MATNR',      " Material number
            l_c_menge(7)   TYPE c VALUE 'MENGE',      " Qunatity
            l_c_meins(5)   TYPE c VALUE 'MEINS',      " Unit of measure
            l_c_stprs(5)   TYPE c VALUE 'STPRS',      " Std material master
           " l_c_v_iv(4)    TYPE c VALUE 'V_IV',           " Invoice value
            l_c_pswsl(5)   TYPE c VALUE 'PSWSL',      " Currency
            l_c_v_erc(5)   TYPE c VALUE 'V_ERC',      " Exchange rate calculated
            l_c_v_op(4)    TYPE c VALUE 'V_OP',       " Order price
            l_c_v_uos(5)   TYPE c VALUE 'V_UOS',      " Unit order to stock
            l_c_v_io(4)    TYPE c VALUE 'V_IO',       " Invoice to order
            l_c_v_uv(4)    TYPE c VALUE 'V_UV',       " Unit value
            l_c_v_t(3)     TYPE c VALUE 'V_T',        " Total
            l_c_v_d(3)     TYPE c VALUE 'V_D',        " Differecne
            l_c_netpr(5)   TYPE c VALUE 'NETPR',      " Net price in purchasing document
            l_c_v_total(7) TYPE c VALUE 'V_TOTAL',    " Total
            l_c_v_os(4)    TYPE c VALUE 'V_OS',      " Order to stock
            l_c_v_ito(5)   TYPE c VALUE 'V_ITO',      " Invoice to order
            l_c_saknr(5)   TYPE c VALUE 'SAKNR',      " G/L account number
            l_c_i_final(7) TYPE c VALUE 'I_FINAL'.    " Final internal table
Fieldcat for fiscal year
  wa_fieldcat-col_pos   =  1.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_gjahr.
  wa_fieldcat-seltext_m = text-007.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Translation date
  wa_fieldcat-col_pos   =  2.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_wwert.
  wa_fieldcat-seltext_m = text-008.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Company code
  wa_fieldcat-col_pos   =  3.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_bukrs.
  wa_fieldcat-seltext_m = text-009.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for General ledger account
  wa_fieldcat-col_pos   =  4.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_hkont.
  wa_fieldcat-seltext_m = text-010.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Account name
  wa_fieldcat-col_pos   =  5.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_txt20.
  wa_fieldcat-seltext_m = text-011.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Doc number
  wa_fieldcat-col_pos   =  6.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_belnr.
  wa_fieldcat-seltext_m = text-012.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Dt/Cr indicator
  wa_fieldcat-col_pos   =  7.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_shkzg.
  wa_fieldcat-seltext_m = text-013.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Ammount in local currency
  wa_fieldcat-col_pos   =  8.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = 'DMBTR1'.
  wa_fieldcat-seltext_m = text-014.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Ammount in local currency
  wa_fieldcat-col_pos   =  9.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = 'V_ALC'.
  wa_fieldcat-seltext_m = text-015.
  wa_fieldcat-ref_fieldname = 'DMBTR'.
wa_fieldcat-no_sign   = 'X'.
wa_fieldcat-do_sum    =  c_x.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Ammount in foreign currency
  wa_fieldcat-col_pos   =  10.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_wrbtr.
  wa_fieldcat-seltext_m = text-016.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Purchse order number
  wa_fieldcat-col_pos   =  11.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_ebeln.
  wa_fieldcat-seltext_m = text-017.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Item No
  wa_fieldcat-col_pos   =  12.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_ebelp.
  wa_fieldcat-seltext_m = text-018.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Material number
  wa_fieldcat-col_pos   =  13.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_matnr.
  wa_fieldcat-seltext_m = text-019.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Qunatity
  wa_fieldcat-col_pos   =  14.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_menge.
  wa_fieldcat-seltext_m = text-020.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Unit of measure
  wa_fieldcat-col_pos   =  15.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_meins.
  wa_fieldcat-seltext_m = text-021.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Std material master
  wa_fieldcat-col_pos   =  16.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_stprs.
  wa_fieldcat-seltext_m = text-022.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Invoice value,
  wa_fieldcat-col_pos   =  17.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = 'V_IV'.
  wa_fieldcat-seltext_m = text-023.
  wa_fieldcat-ref_fieldname = 'DMBTR'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Currency
  wa_fieldcat-col_pos   =  18.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_pswsl.
  wa_fieldcat-seltext_m = text-024.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Exchange rate calculated
  wa_fieldcat-col_pos   =  19.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = 'V_ERC'.
  wa_fieldcat-seltext_m = text-025.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Order price
  wa_fieldcat-col_pos   =  20.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_op.
  wa_fieldcat-seltext_m = text-026.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Unit order to stock
  wa_fieldcat-col_pos   =  21.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_uos.
  wa_fieldcat-seltext_m = text-027.
  wa_fieldcat-do_sum    = c_x.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Invoice to order
  wa_fieldcat-col_pos   =  22.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_io.
  wa_fieldcat-seltext_m = text-028.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Unit value
  wa_fieldcat-col_pos   =  23.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_uv.
  wa_fieldcat-seltext_m = text-029.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Total
  wa_fieldcat-col_pos   =  24.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_t.
  wa_fieldcat-seltext_m = text-030.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Difference
  wa_fieldcat-col_pos   =  25.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_d.
  wa_fieldcat-seltext_m = text-031.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Net Price in Purchasing Document
  wa_fieldcat-col_pos   =  26.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_netpr.
  wa_fieldcat-seltext_m = text-032.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Total
  wa_fieldcat-col_pos   =  27.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_total.
  wa_fieldcat-seltext_m = text-033.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Order to stock
  wa_fieldcat-col_pos   =  28.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_os.
  wa_fieldcat-seltext_m = text-034.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
Fieldcat for Invoice to order
  wa_fieldcat-col_pos   =  29.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_v_ito.
  wa_fieldcat-seltext_m = text-035.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
fieldcat for invoice to order
  wa_fieldcat-col_pos   =  30.
  wa_fieldcat-tabname   = l_c_i_final.
  wa_fieldcat-fieldname = l_c_saknr.
  wa_fieldcat-seltext_m = text-035.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
ENDFORM.                    "build_fieldcat

Hi romanch,
defining the field catalog you must reference all currency fields to the respective currency key field (type CUKY).
<alv_fieldcat>-cfieldname         = 'HWAER'.
This is sample for alv output of a currency field. The alv structure has a field HWAER which carries the currency key, e.g. USD or so.
Obviously you do not provide a cutrrency key for your values. If they are initial (zero), ALV will not display them as 0,00 but leave the field empty if the reference too currency key is not established.
If you define a DDIC structure for the ALV output this refernce is enforced. You can pass the DDIC structure name to the ALV and don not have to create the field catalog manually.
Regards,
Clemens

Similar Messages

  • Moving the fields to final internal table

    hi experts,
       i have a single field in an internal table and i want to move it to final internal table.
    i tried this code but its not working.
      IF NOT it_ymmessr IS INITIAL.
        LOOP AT it_ymmessr into it_final..
          move it_ymmessr-srvpos to it_final-srvpos.
        ENDLOOP.
      ENDIF.
    there is dat in the it_ymmessr.
    i have five to six similar internal tables with 1 to 3 records and i have to move them to final internal table.
    regards,
    vinay

    Hi,
    IF NOT it_ymmessr IS INITIAL.
    LOOP AT it_ymmessr into it_final..
    <b>Have one more firld which is the common field for both the tables into it_ymmessr so that u can fill the record correctly.</b>
    READ TABLE it_ymmessr WITH key XXXX = it_final-XXXX.
    IF sy-subrc = 0.
    it_final-srvpos = it_ymmessr-srvpos.
    <b>MODIFY it_final.</b>
    ENDIF.
    CLAER it_final.
    ENDLOOP.
    ENDIF.

  • Moving fields to final internal table

    hi all,
    after i select
    elect         aufk~aufnr
                     aufk~objnr
                     aufk~ktext
                     vbap~vbeln
                     vbap~posnr
             from 
      inner join aufk
      on         vbapaufnr = aufkaufnr
      into       table t_contracts
      where      aufk~aufnr  in s_proj
      and        vbap~vbeln in s_vbeln
      and        vbap~matnr in s_matnr
      and        vbap~abgru = c_abgru.
      sort t_contracts by aufnr vbeln posnr.
    i select status from jest like below
    if t_contracts[] is not initial.
        t_contracts_temp =  t_contracts.
        delete ADJACENT DUPLICATES FROM t_contracts_temp COMPARING aufnr  objnr.
        select     stat
                   objnr
        from       jest
        into table it_jest
        for all entries in t_contracts_temp
        where      objnr = t_contracts_temp-objnr
        and        inact <> c_inact.
    Now i want for every objnr the value of jest-stat should move to my final internal table it_contracts.
    can you suggest the best way to do it?

    try:
    SELECT aufk~aufnr
    aufk~objnr
    aufk~ktext
    vbap~vbeln
    vbap~posnr
    jest~stat
    FROM ( vbap JOIN aufk
    ON vbapaufnr = aufkaufnr )
    JOIN  jest ON jestobjnr = aufkobjnr
    INTO TABLE t_contracts
    WHERE aufk~aufnr IN s_proj.
    A.

  • Dynamic ALV Grid is not displaying !!

    Hi all,
      I am trying to create dynamic alv grids and upto five levels(five grids) out put is displaying fine without any problem. But when I try to display the 6th grid, the program is going into infinite loop and getting timed out. Even I tried to increse the height of the grid even though it is not displaying.
    Please correct me if any thing is wrong in below code.
    *1st Level grid
    IF <table1> IS ASSIGNED AND <table1> IS NOT INITIAL.
       CREATE OBJECT ob_split1
           EXPORTING
             parent      = ob_custom
             orientation = cl_gui_easy_splitter_container=>orientation_vertical.
        PERFORM set_split_height USING ob_split1  '20'.
        CREATE OBJECT ob_grid1
          EXPORTING
            i_parent = ob_split1->top_left_container.
    ELSE.
        CREATE OBJECT ob_split1
           EXPORTING
             parent      = ob_custom
             orientation = cl_gui_easy_splitter_container=>orientation_vertical.
        PERFORM set_split_height USING ob_split1  '0'.
    ENDIF.
    *2nd Level grid
    IF <table2> IS ASSIGNED AND <table2> IS NOT INITIAL.
       CREATE OBJECT ob_split2
           EXPORTING
             parent      = ob_split1->bottom_right_container
             orientation = cl_gui_easy_splitter_container=>orientation_vertical.
          PERFORM set_split_height USING ob_split2   '20'.
        CREATE OBJECT ob_grid2
          EXPORTING
            i_parent = ob_split2->top_left_container.
      ELSE.
         CREATE OBJECT ob_split2
            EXPORTING
              parent      = ob_split1->bottom_right_container
              orientation = cl_gui_easy_splitter_container=>orientation_vertical.
         PERFORM set_split_height USING ob_split2    '0'.
      ENDIF.
    (Created 3rd,4th,5th same like above).
    *6th Level grid
    IF <table6> IS ASSIGNED AND <table6> IS NOT INITIAL.
    CREATE OBJECT ob_split6
           EXPORTING
             parent      = ob_split5->bottom_right_container
             orientation = cl_gui_easy_splitter_container=>orientation_vertical.
         PERFORM set_split_height USING ob_split6  '20'.
         CREATE OBJECT ob_grid6
           EXPORTING
             i_parent = ob_split6->top_left_container.
      ELSE.
         CREATE OBJECT ob_split6
           EXPORTING
             parent      = ob_split5->bottom_right_container
             orientation = cl_gui_easy_splitter_container=>orientation_vertical.
         PERFORM set_split_height USING ob_split6  '0'.
      ENDIF.
    Appreciated your reply. Please let me know for additional info.
    Thanks,
    Ranjith.
    Edited by: Thomas Zloch on Dec 8, 2010 5:44 PM - please use code tags

    Hi romanch,
    defining the field catalog you must reference all currency fields to the respective currency key field (type CUKY).
    <alv_fieldcat>-cfieldname         = 'HWAER'.
    This is sample for alv output of a currency field. The alv structure has a field HWAER which carries the currency key, e.g. USD or so.
    Obviously you do not provide a cutrrency key for your values. If they are initial (zero), ALV will not display them as 0,00 but leave the field empty if the reference too currency key is not established.
    If you define a DDIC structure for the ALV output this refernce is enforced. You can pass the DDIC structure name to the ALV and don not have to create the field catalog manually.
    Regards,
    Clemens

  • ALV Grid is not Displaying after executing?

    Hi Guys,
                 I am using ALV grid in my program with OO Concepts.I was not able to see the final o/p after entering the data into the selection Screen.Can anybody tell me what's the reason.I am sending u the code.
         Call Method grid1->set_table_for_first_display
                Exporting I_Structure_name = 'T_FINAL_OUT'
                 Changing it_outtab = i_final_out1[]
                          it_fieldcatalog = I_FCAT
                 Exceptions
                          Invalid_parameter_combination = 1
                          program_error                 = 2
                          too_many_lines                = 3
                          Others                        = 4.
                 If sy-subrc <> 0.
                 ENDIF.
    Please respond to this mail
    Thanks,
    Gopi.

    Hi Ashish,
                  I tried like what u told. but its  not working.
    I am sending u the complete code.
      My only doubt is regarding Container does i need to crerate a conatiner .I created a custome control also but same problem
    Data : grid1 type ref to cl_gui_alv_grid,
           g_custom_container type ref to cl_gui_custom_container,
           i_FCAT TYPE  LVC_T_FCAT,
           i_FCAT_str type lvc_s_fcat,
    Structure  for layout
          i_layout_s   TYPE  lvc_s_layo,
          i_lvccat TYPE lvc_t_fcat,
    INITIALIZATION of Fields
    Initialization.
      v_repid = sy-repid.
      set screen '101'.
      MODULE STATUS_0101 output.
    if g_custom_container is initial .
         create object g_custom_container
             Exporting
                 Container_name = 'CCCONTAINER'
             Exceptions
                 cntl_error = 1
                 cntl_system_error = 2
                 create_error = 3
                 lifetime_error = 4
                 Others = 5.
                 If sy-subrc <> 0.
                 ENDIF.
         Create Object grid1
             Exporting
                 I_Parent = g_custom_container
             Exceptions
                 error_cntl_create = 1
                 error_cntl_init   = 2
                 error_cntl_link   = 3
                 error_dp_create   = 4
                 Others            = 5.
                 If sy-subrc <> 0.
                 ENDIF.
    Start-OF-Selection
    i_FCAT_str-col_pos = 1.
      i_FCAT_str-fieldname = 'MATNR'.
      i_FCAT_str-tabname = 'I_FINAL_OUT1'.
      i_fcat_str-seltext = Text-024.
      append i_FCAT_str to i_FCAT.
      clear i_FCAT_str.
      i_FCAT_str-col_pos = 2.
      i_FCAT_str-fieldname = 'GJAHR'.
      i_FCAT_str-tabname = 'I_FINAL_OUT1'.
      i_fcat_str-seltext = Text-012.
      append i_FCAT_str to i_FCAT.
      clear i_FCAT_str.
      i_FCAT_str-col_pos = 3.
      i_FCAT_str-fieldname = 'PERIO'.
      i_FCAT_str-tabname = 'I_FINAL_OUT1'.
      i_fcat_str-seltext = Text-013.
      append i_FCAT_str to i_FCAT.
      clear i_FCAT_str.
      i_FCAT_str-col_pos = 4.
      i_FCAT_str-fieldname = 'LIFNR_ND1'.
      i_FCAT_str-tabname = 'I_FINAL_OUT1'.
      i_fcat_str-seltext = Text-014.
      append i_FCAT_str to i_FCAT.
      clear i_FCAT_str.
    if  not grid1 is Initial.
      If sy-SUBRC = 0.
         Call Method grid1->set_table_for_first_display
                 Exporting
                          I_STRUCTURE_NAME = 'I_FCAT'
                          IS_LAYOUT = i_layout_s
                 Changing it_outtab = i_final_out1[]
                          it_fieldcatalog = I_FCAT
                 Exceptions
                          Invalid_parameter_combination = 1
                          program_error                 = 2
                          too_many_lines                = 3
                          Others                        = 4.
                 If sy-subrc <> 0.
                 ENDIF.
    ENDIF.
    Else.
    if g_custom_container is initial .
          create object g_custom_container
              Exporting
                  Container_name = 'CCCONTAINER'
              Exceptions
                  cntl_error = 1
                  cntl_system_error = 2
                  create_error = 3
                  lifetime_error = 4
                  Others = 5.
                  If sy-subrc <> 0.
                  ENDIF.
          Create Object grid1
              Exporting
                  I_Parent = g_custom_container
              Exceptions
                  error_cntl_create = 1
                  error_cntl_init   = 2
                  error_cntl_link   = 3
                  error_dp_create   = 4
                  Others            = 5.
                  If sy-subrc <> 0.
                  ENDIF.
         Call Method grid1->set_table_for_first_display
                 Exporting
                 I_STRUCTURE_NAME = 'I_FCAT'
                 IS_LAYOUT = i_layout_s
                 Changing it_outtab = i_final_out1[]
                          it_fieldcatalog = I_FCAT
                 Exceptions
                          Invalid_parameter_combination = 1
                          program_error                 = 2
                          too_many_lines                = 3
                          Others                        = 4.
                 If sy-subrc <> 0.
                 ENDIF.
       Endif.
       ENDIF.
    Thanks,
    Gopi.

  • Dynamic field selection in internal table

    hello,
           I want to display the fields in the internal table dynamically.
    In myReport i am  giving plant as the input. On the basis of plant i want to dislpay work centres as the heading and for the particular plant i want to display the pieces for the confirmed operation of the particular work centre.
    workcentre1 workcentre2 workcenter3 ...........workcentren
       12               10             9               ............  4
    in my report i have to include these fields with my earlier fields
    Please help.

    hello,
           I want to display the fields in the internal table dynamically.
    In myReport i am  giving plant as the input. On the basis of plant i want to dislpay work centres as the heading and for the particular plant i want to display the pieces for the confirmed operation of the particular work centre.
    workcentre1 workcentre2 workcenter3 ...........workcentren
       12               10             9               ............  4
    in my report i have to include these fields with my earlier fields
    Please help.

  • Help on ALV GRID display outputting format for 2 internal tables

    Hi,
        I have requirement in ALV GRID where I need to display the data from 2 internal tables. The first internal table has the content of Delivery due list data and second the internal table has the corresponding stock transfer data of the Delivery Due list. I have a checbox on my selection screen, when unchecked it should output the 1st internal table data, i.e for Delivery due list. When it is checked then it should output 1st Internal table data + 2nd internal table data of stock transfer. For example, 1 document delivery due list data and 2nd line for that document should show the stock transfer data. You can also check the transaction code VL10E for that will show a delivery due list...and for stock tranfer,you need to check with Purchase order in in the USer Role tabstrip. Pls suggest.
    Regards,
    Mira

    Hi,
    U can try out this code
    REPORT zzz_test NO STANDARD PAGE HEADING
                           MESSAGE-ID zz.
    The Data Declarations
    INCLUDE zzm_test_alv_data.
    The Selection Screen Definition
    INCLUDE zzm_test_alv_selscrn.
    The definition and implementation of the event reciever class
    INCLUDE zzm_test_alv_class.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM f1000_load_itabs.
    END-OF-SELECTION
    END-OF-SELECTION.
      IF NOT cb_disp IS INITIAL.
        CALL SCREEN 9001.
      ENDIF.
    Include for getting data
      INCLUDE zzm_test_alv_forms.
    Include for PAI and PBO of screen
      INCLUDE zzm_test_alv_screen.
      INCLUDE ZZM_TEST_ALV_DATA                                          *
    This include has all the data declaration defined
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    Table Declarations:
    TABLES: mara,
            makt.
    Internal Tables:
    The following structure type must be defined in the data dictionary
    DATA:  i_fieldcat  TYPE lvc_t_fcat,
           i_fieldcat1 TYPE lvc_t_fcat,
           i_output1   TYPE STANDARD TABLE OF mara,
           i_output2   TYPE STANDARD TABLE OF makt,
    Work Areas:
           w_output1   TYPE STANDARD TABLE OF mara,
           w_output2   TYPE STANDARD TABLE OF makt.
    Variable:
    DATA: lv_repid    LIKE sy-repid.
    lv_repid = sy-repid.
      INCLUDE ZZM_TEST_ALV_SELSCRN                                       *
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    SELECTION-SCREEN BEGIN OF BLOCK b_main WITH FRAME TITLE text-001.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS: cb_disp AS CHECKBOX.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN END OF BLOCK b_main.
      INCLUDE ZZM_TEST_ALV_CLASS                                         *
    This include has all the data declaration defined for ALV
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    INCLUDE <icon>.
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    DATA : o_alvgrid1 TYPE REF TO cl_gui_alv_grid ,
           o_alvgrid2 TYPE REF TO cl_gui_alv_grid ,
           cont_for_cognos1   TYPE scrfname VALUE 'BCALC_GRID_01_9100',
           cont_for_cognos2   TYPE scrfname VALUE 'BCALC_GRID_01_9200',
           custom_container1 TYPE REF TO cl_gui_custom_container,
           custom_container2 TYPE REF TO cl_gui_custom_container,
          Work Area
           w_layout TYPE lvc_s_layo ,
           w_variant TYPE disvariant.
          Constants
    CONSTANTS : c_lay(1) TYPE c VALUE 'A' .                  " All Layouts
    CONSTANTS: BEGIN OF c_main_tab,
               tab1 LIKE sy-ucomm VALUE 'MAIN_TAB_FC1',   "
               tab2 LIKE sy-ucomm VALUE 'MAIN_TAB_FC2',   "
               END OF c_main_tab.
      INCLUDE ZZM_TEST_ALV_FORMS                                         *
    This Include has the various forms used in the program
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    *&      Form  f9001_build_field_cat
          To Build Field Catalog
         -->P_I_FIELDCAT  text
         -->P_0021   text
    FORM f9001_build_field_cat TABLES   p_fieldcat STRUCTURE lvc_s_fcat
                          USING value(p_structure).
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name       = p_structure
           CHANGING
                ct_fieldcat            = p_fieldcat[]
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE i005 WITH 'Error in ALV field catalogue creation'.
                                                                " text-e05.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " f9001_build_field_cat
    *&      Form  f9000_objects_create
          For creating Custom Containers
    -->  p1        text
    <--  p2        text
    FORM f9000_objects_create.
      CREATE OBJECT custom_container1
          EXPORTING
              container_name = cont_for_cognos1
          EXCEPTIONS
              cntl_error = 1
              cntl_system_error = 2
              create_error = 3
              lifetime_error = 4
              lifetime_dynpro_dynpro_link = 5.
      CREATE OBJECT custom_container2
          EXPORTING
              container_name = cont_for_cognos2
          EXCEPTIONS
              cntl_error = 1
              cntl_system_error = 2
              create_error = 3
              lifetime_error = 4
              lifetime_dynpro_dynpro_link = 5.
      IF sy-subrc NE 0.
    add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = lv_repid
                  txt2  = sy-subrc
                  txt1  = 'The control could not be created'(510).
      ENDIF.
      CREATE OBJECT o_alvgrid1
           EXPORTING i_parent = custom_container1.
      CREATE OBJECT o_alvgrid2
           EXPORTING i_parent = custom_container2.
    ENDFORM.                    " f9000_objects_create
    *&      Form  f9003_layout
          To define the layout
         -->P_SY_TITLE  text
         -->P_0030   text
         -->P_0031   text
         -->P_0032   text
    FORM f9003_layout USING  value(ptitle)
                             value(pzebra)
                             value(pmode)
                             value(pwidth).
      w_layout-grid_title  = ptitle.
      w_layout-zebra       = pzebra.
      w_layout-sel_mode    = pmode.
      w_layout-cwidth_opt  = pwidth.
      w_variant-report     = sy-repid.
    ENDFORM.                    " f9003_layout
    *&      Form  f9006_error_handle
         To handle event
         -->P_PTEXT  text
    FORM f9006_error_handle USING value(ptext).
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e03 " Error Note
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    ENDFORM.                    " f9006_error_handle
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      CALL METHOD custom_container1->free.
      CALL METHOD custom_container2->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = lv_repid
                  txt2  = sy-subrc
                  txt1  = 'Error in FLush'(500).
      ENDIF.
    ENDFORM.
    *&      Form  f1000_load_itabs
          Select from Database
    -->  p1        text
    <--  p2        text
    form f1000_load_itabs.
      SELECT * FROM mara
               INTO TABLE i_output1
               UP TO 50 rows.
      SELECT * FROM makt
               INTO TABLE i_output2
               UP TO 50 rows.
    endform.                    " f1000_load_itabs
      INCLUDE ZZM_TEST_ALV_SCREEN                                        *
    2/ Description / Include functions
    This include contains PBO and PAI events for the screen of report
    ZZZJJ_TEST_ALV
    3/ Responsibility
    Author............: Judith Jessie Selvi
    Creation Date.....: 28/03/2005
    DATA FOR TABSTRIP 'MAIN_TAB'
    CONTROLS:  main_tab TYPE TABSTRIP.
    DATA:      BEGIN OF i_main_tab,
                 subscreen   LIKE sy-dynnr,
                 prog        LIKE sy-repid VALUE
                                  'ZZZ_TEST',
                 pressed_tab LIKE sy-ucomm VALUE c_main_tab-tab1,
               END OF i_main_tab.
    *&      Module  STATUS_9001  OUTPUT
          text
    MODULE status_9001 OUTPUT.
    IF custom_container1 IS INITIAL.
      SET PF-STATUS 'ZSTATUS'.
      SET TITLEBAR 'ZTITLE'.
      Creating Object
        PERFORM f9000_objects_create.
      Building the field catalog
        PERFORM f9001_build_field_cat TABLES i_fieldcat
                                USING 'MARA'.
        PERFORM f9001_build_field_cat TABLES i_fieldcat1
                                USING 'MAKT'.
      Modifying the field catalog
       PERFORM f9002_modify_field_cat TABLES i_fieldcat.
      For Layout
        PERFORM f9003_layout USING sy-title 'X' 'B' 'X'.
    ENDIF.
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&      Module  MAIN_TAB_ACTIVE_TAB_SET  OUTPUT
          Call method to display in the output grid
    MODULE main_tab_active_tab_set OUTPUT.
      main_tab-activetab = i_main_tab-pressed_tab.
      CASE i_main_tab-pressed_tab.
        WHEN c_main_tab-tab1.
      To display report
         i_main_tab-subscreen = '9100'.
          CALL METHOD o_alvgrid1->set_table_for_first_display
          EXPORTING
             is_variant                    = w_variant
             i_save                        = c_lay
             is_layout                     = w_layout
          CHANGING
             it_outtab                     = i_output1[]
             it_fieldcatalog               = i_fieldcat[]
          EXCEPTIONS
             invalid_parameter_combination = 1
             program_error                 = 2
             too_many_lines                = 3
             OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
        WHEN c_main_tab-tab2.
      To display report
          i_main_tab-subscreen = '9200'.
          CALL METHOD o_alvgrid2->set_table_for_first_display
          EXPORTING
             is_variant                    = w_variant
             i_save                        = c_lay
             is_layout                     = w_layout
          CHANGING
             it_outtab                     = i_output2[]
             it_fieldcatalog               = i_fieldcat1[]
          EXCEPTIONS
             invalid_parameter_combination = 1
             program_error                 = 2
             too_many_lines                = 3
             OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE i005 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
    WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_SET OUTPUT
    *&      Module MAIN_TAB_ACTIVE_TAB_GET INPUT
          Check & Process the selected Tab
    MODULE main_tab_active_tab_get INPUT.
      CASE sy-ucomm.
        WHEN c_main_tab-tab1.
          i_main_tab-pressed_tab = c_main_tab-tab1.
        WHEN c_main_tab-tab2.
          i_main_tab-pressed_tab = c_main_tab-tab2.
        WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_GET INPUT
    *&      Module USER_COMMAND_9001 INPUT
          User Command
    MODULE user_command_9001 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          PERFORM exit_program.
          SET SCREEN '0'.
        WHEN 'EXIT' OR  'CANC'.
          PERFORM exit_program.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 “USER_COMMAND_9000 INPUT
    *&      Module MAIN_TAB_ACTIVE_TAB_SET INPUT
          Set sunscreen
    MODULE main_tab_active_tab_set INPUT.
      main_tab-activetab = i_main_tab-pressed_tab.
      CASE i_main_tab-pressed_tab.
        WHEN c_main_tab-tab1.
            i_main_tab-subscreen = '9100'.
        WHEN c_main_tab-tab2.
            i_main_tab-subscreen = '9200'.
        WHEN OTHERS.
         DO NOTHING
      ENDCASE.
    ENDMODULE.                 “MAIN_TAB_ACTIVE_TAB_SET INPUT
    Thanks & Regards,
    Judith.

  • ALV GRID AND LIST DISPLAY

    Hi experts, how are you.
    What is the difference between ALV Grid Display and ALV List Display?

    ALV LIST Can be coded using only FMs
    ALV GRID Can be coded using FMs and object oriented concepts
    ALV LIST Can be displayed hieraicharlly
    ALV GRID cannot be displayed hierarichally
    ALV grid uses ActiveX controls
    present on the Presentation Server.
    Hence, it consumes More Memory
    on the presentation server.
    ALV LIST is Display Only.
    Whereas
    ALV Grid Can Be made EDITABLE for entry purpose.
    In alv grid, these options are possible,
    but not in alv list.
    without horizontal lines
    without vertical lines
    without cell merging during sorts
    display total lines above the entries
    Thanks
    Seshu

  • Field catalog for internal table in ALV

    In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
    In order to get output in ALV grid following FM has been used
    REUSE_ALV_GRID_DISPLAY
    for field catalog the fields are defined specifically.
      l_fieldcat-fieldname  = 'VBELN'.
      l_fieldcat-outputlen  = 10.
      l_fieldcat-seltext_l  = 'Billing doc'.
      l_fieldcat-no_zero = 'X'.
      l_fieldcat-hotspot = 'X'.
      append l_fieldcat to p_fieldtab.
    ..............and so on for all the fields.
    Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
    anya

    Hi
    Try this instead:
    *& Form  create_fieldcatalog
    * Create a field catalogue from any internal table
    *      -->PT_TABLE     Internal table
    *      -->PT_FIELDCAT  Field Catalogue
    FORM  create_fieldcatalog
           USING     pt_table     TYPE ANY TABLE
           CHANGING  pt_fieldcat  TYPE lvc_t_fcat.
      DATA:
        lr_tabdescr TYPE REF TO cl_abap_structdescr
      , lr_data     TYPE REF TO data
      , lt_dfies    TYPE ddfields
      , ls_dfies    TYPE dfies
      , ls_fieldcat TYPE lvc_s_fcat
      CLEAR pt_fieldcat.
      CREATE DATA lr_data LIKE LINE OF pt_table.
      lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
      lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
      LOOP AT lt_dfies
      INTO    ls_dfies.
        CLEAR ls_fieldcat.
        MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
        APPEND ls_fieldcat TO pt_fieldcat.
      ENDLOOP.
    ENDFORM.                    "create_fieldcatalog

  • Error when displaying a field on Screen with Table Control

    Hi,
    It is going to 'Dump' when I am trying to display data on the screen with the help of Table Control. From the dump, What I have observed is , there is a field 'ZTSV_FSRDATA-ANZFEHLER'. If this field has negative value, then it is going to 'Dump' saying that the length is not enough. If it has a positive value then it is working fine. But the type of the field in the Internal table & on the screen are same.
    Please help me to resolve this error.
    I am posting here the Dump message also:
    A conversion error occurred while the program was trying todisplay data on the screen.
    The ABAP output field and the screen field may not have the same format.
    Some field types require more characters on the screen thanin the ABAP program. For example, a date field on a screen needstwo characters more than it would in the program. When attempting to display the date on the screen, an error will occur that triggers the error message.
    Thanks,
    Sreenivas Reddy Maddi.

    Hi Sreenivas,
       Refer this thread:
    how to display negative values in a screen field of a screen
    Re: negative values not allowed
    Regards,
    Sampath

  • I need to add check whether 21 fields of a internal table are empty or not.

    Hello,
    I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
    I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.

    Hi,
    After the select quiery.
    If not itab is initial.
    Message 'Table is not empty'    type 'I'.
    Endif.
    Regards,
    Jagadish.

  • How to join  fields from different internal tables and display into one int

    hai i have one doubt...
    how to join  fields from different internal tables and display into one internal table..
    if anybody know the ans for this qus tell me......

    hii
    you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
    SELECT bwkey                         " Valuation Area
             bukrs                         " Company Code
        FROM t001k
        INTO TABLE i_t001k
       WHERE bukrs IN s_bukrs.
      IF sy-subrc EQ 0.
        SELECT bwkey                       " Valuation Area
               werks                       " Plant
          FROM t001w
          INTO TABLE i_t001w
           FOR ALL ENTRIES IN i_t001k
         WHERE bwkey = i_t001k-bwkey
           AND werks IN s_werks.
        IF sy-subrc EQ 0.
          LOOP AT i_output INTO wa_output.
            READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
            READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
            wa_output-bukrs = wa_t001k-bukrs.
            MODIFY i_output FROM wa_output.
            CLEAR wa_output.
          ENDLOOP.                         " LOOP AT i_output
        ENDIF.                             " IF sy-subrc EQ 0
    regards
    twinkal

  • Usage of field-symbol to internal table generically.

    Hi gurus,
    please tell the usage of field symbol to an internall table.
    how do i use field symbol generically , so that i can use same field symbol for many different internal tables.
    regards,
    krishna
    TABLES: EKKO.
    DATA: ITAB TYPE STANDARD TABLE OF EKKO INITIAL SIZE 1.
    SELECT-OPTIONS: P_EBELN FOR EKKO-EBELN OBLIGATORY.
    FIELD-SYMBOLS <FS> TYPE any.
    SELECT *
    FROM EKKO
    INTO TABLE ITAB
    WHERE EBELN IN P_EBELN.
    LOOP AT ITAB ASSIGNING <FS> casting ekko.
      WRITE:/ <FS>-EBELN, <FS>-BUKRS, <FS>-LIFNR, <FS>-AEDAT, <FS>-EKGRP, <FS>-STATU, <FS>-SPRAS.
    ENDLOOP.

    How about something SIMPLE like this.
    This creates a dynamic table and displays it in an editable grid.
    The key to a real Generic internal table is to use the RTTI  functionality to generate a field catalog of the structure you want to use as an internal table and then create a dynamic table based on the FCAT created from your structure.
    For the code shown below code a simple screen ( SE51) with a custom container on it  called CCONTAINER1.
    Code also a standard status (SE41) with just the BACK, EXIT and CANCEL buttons on it.
    You can use this type of program as a model for ANY dynamic table. Note however that you still can't include DEEP structure in your dynamic table.
    With the program shown below you can edit the grid but you'll have to add your own functionality such as cell selection, double click etc etc.
    All the code is showning you really is how to take any user defined structure and simply without a whole load of fuss, buld an FCAT, a DYNAMIC TABLE, Populate it and display a grid.
    DO NOT EVER USE AGAIN THE OLD SLIS MODULES SUCH AS FM REUSE_ALV_etc.   Go for OO either cl_gui_alv_grid or if you don't need to edit anything the new SALV class.
    If you are still on 4.6 then the SALV class won't exist but the cl_gui_alv_grid class is fine.
    You can see also just by changing a few lines of codeyou can   display a grid of almost any structure you can think of (or populate another dynamic table).
    Note also if you have an actual table defined you can also always code something like your_itab[] = <dyn_table>  so you can retrieve your data easily enough via standard abap.
    All you need to do is define your structure, create the fcat and populate the dynamic table.
    Even if you don't want a a GRID you've got your data in a dynamic table which is what I believe you wanted in the first place. You don't have to display or use a GRID if you don't need to but I've added the code here as lots of applications need to display data in just these types of lists.
    Now surprise your Boss by coding in 10 mins a program he / she thought would take you 1 week. !!!!!.
    program zzz_simple_editable_grid.
    * Define any structure
    types:  begin of s_elements,
      vbeln   type vapma-vbeln,
      posnr   type vapma-posnr,
      matnr   type vapma-matnr,
      kunnr   type vapma-kunnr,
      werks   type vapma-werks,
      vkorg   type vapma-vkorg,
      vkbur   type vapma-vkbur,
      status  type c,
    end of  s_elements.
    * end of your structure
    data lr_rtti_struc type ref to cl_abap_structdescr .
    data:
        zog                     like line of lr_rtti_struc->components .
    data:
      zogt                    like table of zog,
    wa_it_fldcat type lvc_s_fcat,
    it_fldcat type lvc_t_fcat ,
    dy_line            type ref to data,
    dy_table           type ref to data.
    data:  dref               type ref to data.
    field-symbols: <fs> type any,
       <dyn_table>    type  standard table,
       <dyn_wa>.
    data grid_container1 type ref to cl_gui_custom_container .
    data grid1 type ref to cl_gui_alv_grid .
    data: ok_code type sy-ucomm.
    data: struct_grid_lset type lvc_s_layo.
    *now I want to build a field catalog
    * First get your data structure into a field symbol
    create data dref type s_elements.
    assign dref->* to <fs>.
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
    * Now get the structure details into a table.
    * table zogt[] contains the structure details
    * From which we can build the field catalog
    zogt[]  = lr_rtti_struc->components.
    loop at zogt into zog.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype = zog-type_kind.
      wa_it_fldcat-inttype = zog-type_kind.
      wa_it_fldcat-intlen = zog-length.
      wa_it_fldcat-decimals = zog-decimals.
      wa_it_fldcat-coltext = zog-name.
      wa_it_fldcat-lowercase = 'X'.
      append wa_it_fldcat to it_fldcat .
    endloop.
    * You can perform any modifications / additions to your field catalog
    * here such as your own column names etc.
    * Now using the field catalog created above we can
    * build a dynamic table
    * and populate it
    * First build the dynamic table
    * the table will contain entries for
    * our structure defined at the start of the program
    call method cl_alv_table_create=>create_dynamic_table
           exporting
                it_fieldcatalog = it_fldcat
           importing
                ep_table = dy_table.
    assign dy_table->* to <dyn_table>.
    create data dy_line like line of <dyn_table>.
    assign dy_line->* to <dyn_wa>.
    * Now fill our table with data
    select vbeln posnr matnr kunnr werks vkorg vkbur
           up to 200 rows
           from vapma
           into  corresponding fields of table <dyn_table>.
    * Call the screen to display the grid
    call screen 100.
    * PBO module
    module status_0100 output.
    data: off type int4.
    break-point 1.
    if sy-batch = 'X'.
    call method cl_gui_alv_grid=>offline
    receiving
    e_offline = off.
    endif.
    if sy-batch = 'X'.
    if ( off is initial ).
        create object grid_container1
                exporting
                   container_name = 'CCONTAINER1'.
        create object  grid1
           exporting
              i_parent = grid_container1.
    endif.
    endif.
    if sy-batch ne 'X'.
       if grid_container1 is initial.
         create object grid_container1
                 exporting
                    container_name = 'CCONTAINER1'.
      endif.
        create object  grid1
           exporting
              i_parent = grid_container1.
       if sy-batch ne 'X'.
        struct_grid_lset-edit = 'X'.    "To enable editing in ALV
      endif.
      endif.
        call method grid1->set_table_for_first_display
          exporting is_layout =  struct_grid_lset
          changing
                     it_outtab       = <dyn_table>
                     it_fieldcatalog = it_fldcat.
      set pf-status '001'.
      set titlebar '000'.
    endmodule.
    * PAI module
    module user_command_0100 input.
      case sy-ucomm.
        when 'BACK'.
          leave program.
        when 'EXIT'.
          leave program.
        when 'RETURN'.
          leave program.
        when others.
      endcase.
    endmodule.
    Cheers
    jimbo

  • Colour to field in an internal table

    how to colour a particular data in a particular field of an internal table.

    See this
    1. add one more field to ur final internal table say COLOR(4)
    2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
    wa_layout-style_fieldname = 'COLOR'. "if its list
    3. read table itab index 3.
    itab-color = 'C410'.
    modify itab index 3
    4. see program SHOWCOLO for all color codes
    1. Add a field of data type CHAR(3) to the internal output table.
    2. Enter the color code in the appropriate field of the row to be colored in the internal
    output table:
    Code: 'Cxy'
    C = Color (all codes begin with 'C')
    x = color number ('1' - '9')
    y = highlight ('0' = off, '1' = on)
    3. Assign the internal output table color code field name to the IS_LAYOUT importing
    structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
    interface.
    To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, let’s modify declaration of our list data table “gt_list”.
    you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field “INFO_FNAME” of the layout structure.
    e.g.
    ps_layout-info_fname = <field_name_containing_color_codes>. “e.g. ‘ROWCOLOR’
    You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
    You can color an entire row as described in the next section. However, this method is less time consuming.
    Coloring Individual Cells
    This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by “more” is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
    The structure that should be included must be of type “LVC_T_SCOL”. If you want to color the entire row, this inner table should contain only one row with field “fname” is set to space, some color value at field “col”, “0” or “1” at fields “int” (intensified) and “inv” (inverse).
    If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field “fname”. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
    If it is in ALv refer the following code:
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display each row in a different     *
    *& colour                                                              *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) type c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
      gd_layout-info_fieldname =      'LINE_COLOR'.
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
              i.e. wa_ekko-line_color = 'C410'
      ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    Please give me reward points...

  • How to add new field into dynamic internal table

    Hello Expert.
    how to add new field into dynamic internal table.
    PARAMETERS: P_TABLE(30).    "table name
    DATA: I_TAB TYPE REF TO DATA.
    FIELD-SYMBOLS: <TAB> TYPE standard TABLE.
    *Create dynamic FS
    create DATA I_TAB TYPE TABLE OF (p_table).
      ASSIGN I_TAB->* TO <TAB>.
    SELECT * FROM (p_table) INTO TABLE <TAB>.
       here i want to add one more field into <TAB> at LAST position and my 
       Field name  =  field_stype     and
       Field type    =  'LVC_T_STYL'
    could you please helpme out .

    Hi,
    Please find the code below.You can add the field acc to your requirement.
    Creating Dynamic internal table
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,  u201C Dynamic internal table name
                   <fs_dyntable>,                     u201C Field symbol to create work area
                   <fs_fldval> type any.              u201C Field symbol to assign values 
    PARAMETERS: p_cols(5) TYPE c.                     u201C Input number of columns
    DATA:   t_newtable TYPE REF TO data,
            t_newline  TYPE REF TO data,
            t_fldcat   TYPE slis_t_fldcat_alv,
            t_fldcat   TYPE lvc_t_fcat,
            wa_it_fldcat TYPE lvc_s_fcat,
            wa_colno(2) TYPE n,
            wa_flname(5) TYPE c. 
    Create fields .
      DO p_cols TIMES.
        CLEAR wa_it_fldcat.
        move sy-index to wa_colno.
        concatenate 'COL'
                    wa_colno
               into wa_flname.
        wa_it_fldcat-fieldname = wa_flname.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-intlen = 10.
        APPEND wa_it_fldcat TO t_fldcat.
      ENDDO. 
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = t_fldcat
        IMPORTING
          ep_table        = t_newtable. 
      ASSIGN t_newtable->* TO <t_dyntable>. 
    Create dynamic work area and assign to FS
      CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
      ASSIGN t_newline->* TO <fs_dyntable>.
    Populating Dynamic internal table 
      DATA: fieldname(20) TYPE c.
      DATA: fieldvalue(10) TYPE c.
      DATA: index(3) TYPE c. 
      DO p_cols TIMES. 
        index = sy-index.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
    Set up fieldvalue
        CONCATENATE 'VALUE' index INTO
                    fieldvalue.
        CONDENSE    fieldvalue NO-GAPS. 
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue. 
      ENDDO. 
    Append to the dynamic internal table
      APPEND <fs_dyntable> TO <t_dyntable>.
    Displaying dynamic internal table using Grid. 
    DATA: wa_cat LIKE LINE OF fs_fldcat. 
      DO p_cols TIMES.
        CLEAR wa_cat.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
        wa_cat-fieldname = wa_flname.
        wa_cat-seltext_s = wa_flname.
        wa_cat-outputlen = '10'.
        APPEND wa_cat TO fs_fldcat.
      ENDDO. 
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = fs_fldcat
        TABLES
          t_outtab    = <t_dyntable>.

Maybe you are looking for