Fixed and dynamic field headings in field catalog

i have to develop an ALV Report where certain column headings are fixed and other column heading will be changing from time to time.
is there any method to do so.
that is i have to show the report for 3 months and the names of months will be changing in due course.
Waiting for a reply.
A.Reshma

hi,
you have 4 texts
SELTEXT_L
SELTEXT_M
SELTEXT_S
and   DDIC_TEXT  (not sure about spelling)
change this text dynamicly with month of your choice.
Rgds

Similar Messages

  • Dynamic internal table and dynamic field catalog

    hi
    i need to decide the number of fields of the internal table at runtime
    and then need to pass value to this internal table.
    then i need to create the field catalog for this internal table (so here
    field catalog is also dynamic) to display in alv.
    how to achieve this dynamic internal table creation and dyanmic field catalog generation

    Hi Ajay,
      U can use the below code to create a dynamic internal table.
    *adding the field names only once for the dynamic table     .
          MOVE 'PRCTR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RCNTR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RACCT' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'RYEAR' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'YTDBAL' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
          MOVE 'OBAL' TO gw_component-name.
          gw_component-type ?= cl_abap_elemdescr=>get_string( ).
          INSERT gw_component INTO TABLE gt_components.
    *get structure descriptor -> GR_STRUCTDESCR
              gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
    create work area of structure GR_STRUCTDESCR -> GR_WA
              CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
              ASSIGN gr_wa->* TO <gw_wa>.
    determine key components -> GT_KEYS
              MOVE lv_value1 TO gw_key-name.
              INSERT gw_key INTO TABLE gt_keys.
    create descriptor for internal table -> GR_TABLEDESCR
              gr_tabledescr ?= cl_abap_tabledescr=>create( p_line_type  = gr_structdescr
                                                           p_table_kind = cl_abap_tabledescr=>tablekind_hashed
                                                           p_unique     = abap_true
                                                           p_key        = gt_keys
                                                           p_key_kind   = cl_abap_tabledescr=>keydefkind_user ).
    create internal table -> GR_ITAB
              CREATE DATA gr_itab TYPE HANDLE gr_tabledescr.
              ASSIGN gr_itab->* TO <gt_itab>.
              CREATE DATA gr_itab LIKE STANDARD TABLE OF <gw_wa>.
              ASSIGN gr_itab->* TO <gt_sttab>.
    Now u r internal table named <gt_sttab> has been created with fields like RCNTR, PRCTR,RACCT, RYEAR etc whatever the field u need u can go ahead and create dynamically.
    then by using the table <gt_sttab> u can create u r field catalog.
    Regards,
    Rose.

  • ALV display using dynamic field catalog and dynamic internal table

    hi ,
    please guide me for ALV display using dynamic field catalog and dynamic internal table.
    Thank you.

    Hi Rahul,
    maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
    Regards Rudi

  • Reg: Dynamic Field catalog in ALV

    Hi ,
    Can any one guide me to build a dynamic field catalog in ALV report?
    Below is the format which i expect..........
    Material    |     Plant1    |    Plant2    |    Plant3    | ....................|    Plant 20      |
    Qty
    Val
    Qty
    Val
    Qty
    Val
    Qty
    Val
    The plant 1 to 20 has to be brought dynamically as headings from T001W table. (Horizontally populate)
    Below each plant i need sub-headings "QTY" and "VAL".                                  (Horizontally populate)
    List of Materials should be brought vertically from MARA table.                          (Vertically populate)
    Can anyone suggest how to bring out this format for populating data accordingly into the o/p format?
    Ur help will be appreciated.
    Thanks,
    K.S.Kannan

    your part of the code is present in routine
    perform dynamic_table.
    *& Report ZCS_NAC_MAT_CHARACTERISTICS
    2/ Description ...: Business requirement is to get all materials
    without any characteristic values maintained in SAP
    which are given in the selection screen.
    REPORT znac_material_char.
    TYPE-POOLS : abap,
    slis.
    TABLES : kssk,
    klah,
    mara,
    makt,
    cabn,
    t134,
    t023.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv ,
    wa_fieldcat TYPE slis_fieldcat_alv.
    DATA : w_layout TYPE slis_layout_alv.
    DATA : st_layout TYPE slis_layout_alv.
    DATA : t_header TYPE slis_t_listheader,
    w_header TYPE slis_listheader.
    TYPES : BEGIN OF ty_cabn,
    atinn TYPE cabn-atinn,
    atnam TYPE cabn-atnam,
    END OF ty_cabn.
    DATA : i_cabn TYPE STANDARD TABLE OF ty_cabn WITH HEADER LINE.
    DATA : w_cabn LIKE i_cabn.
    TYPES : BEGIN OF ty_ausp,
    objek TYPE ausp-objek,
    atinn TYPE ausp-atinn,
    klart TYPE ausp-klart,
    END OF ty_ausp.
    DATA : i_ausp TYPE STANDARD TABLE OF ty_ausp WITH HEADER LINE.
    DATA : w_ausp LIKE i_ausp.
    TYPES : BEGIN OF ty_mara,
    matnr TYPE mara-matnr,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_mara.
    DATA : i_mara TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara LIKE i_mara.
    DATA : i_mara_temp TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara_temp LIKE i_mara_temp.
    TYPES :BEGIN OF ty_data,
    atnam TYPE cabn-atnam,
    atinn TYPE cabn-atinn,
    objek TYPE ausp-objek,
    klart TYPE ausp-klart,
    matnr TYPE mara-matnr,
    maktx TYPE makt-maktx,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_data.
    DATA : i_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
    DATA : w_data LIKE i_data.
    DATA : i_class TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class LIKE i_class.
    DATA : i_class_temp TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class_temp LIKE i_class_temp.
    DATA : i_objdata TYPE STANDARD TABLE OF clobjdat WITH HEADER LINE.
    DATA : w_objdata LIKE i_objdata.
    TYPES : BEGIN OF ty_objdata_temp.
    TYPES: matnr TYPE mara-matnr.
    TYPES: maktx TYPE makt-maktx.
    INCLUDE STRUCTURE clobjdat.
    TYPES : prdha TYPE mara-prdha.
    TYPES : mstde TYPE mara-mstde.
    TYPES : END OF ty_objdata_temp.
    DATA : i_objdata_temp TYPE STANDARD TABLE OF ty_objdata_temp WITH HEADER LINE.
    DATA : w_objdata_temp LIKE i_objdata_temp.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
    <fs_dyntable>,
    <fs_fldval> TYPE ANY.
    DATA: t_newtable TYPE REF TO data,
    t_newline TYPE REF TO data,
    fs_fldcat TYPE slis_t_fieldcat_alv,
    t_fldcat1 TYPE lvc_t_fcat,
    wa_it_fldcat TYPE lvc_s_fcat,
    wa_colno(2) TYPE n,
    wa_flname(30) TYPE c.
    DATA: fieldname(20) TYPE c.
    DATA: fieldvalue(40) TYPE c.
    DATA: index(3) TYPE c,
    v_time(60) TYPE c.
    DATA: wa_cat LIKE LINE OF fs_fldcat.
    CONSTANTS : c_nac TYPE klah-class VALUE 'NAC',
    c_klart TYPE ausp-klart VALUE '001',
    c_check TYPE c VALUE 'X' .
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (28) text-001 .
    SELECT-OPTIONS: s_atnam FOR cabn-atnam NO INTERVALS OBLIGATORY. " Characteristic name
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_matnr FOR mara-matnr. " material Number
    SELECT-OPTIONS: s_mtart FOR mara-mtart. " material type
    SELECT-OPTIONS: s_matkl FOR mara-matkl. " material type
    SELECT-OPTIONS: s_mstae FOR mara-mstae. " X-Plant material status
    PARAMETERS : s_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum . " date
    SELECTION-SCREEN END OF BLOCK b2 .
    AT SELECTION-SCREEN ON s_atnam.
    SELECT SINGLE * FROM cabn WHERE atnam IN s_atnam.
    IF sy-subrc 0.
    MESSAGE text-003 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matnr.
    SELECT SINGLE * FROM mara WHERE matnr IN s_matnr.
    IF sy-subrc 0.
    MESSAGE text-004 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_mtart.
    SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.
    IF sy-subrc 0.
    MESSAGE text-005 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matkl.
    SELECT SINGLE * FROM t023 WHERE matkl IN s_matkl.
    IF sy-subrc 0.
    MESSAGE text-006 TYPE 'E'.
    ENDIF.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM get_data_keydate.
    PERFORM material_all_charname.
    PERFORM get_classification.
    PERFORM dynamic_table.
    *& Form dynamic_table
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table.
    PERFORM fieldcatalog.
    PERFORM dynamic_table_create.
    PERFORM final_data.
    PERFORM final_fieldcatalog.
    PERFORM layout_build.
    PERFORM grid_display.
    ENDFORM. " fieldcat
    *& Form layout_build
    text
    FORM layout_build .
    st_layout-zebra = c_check.
    st_layout-no_vline = ''.
    st_layout-colwidth_optimize = c_check.
    st_layout-detail_popup = c_check.
    st_layout-detail_initial_lines = c_check.
    st_layout-detail_titlebar = text-021.
    ENDFORM. " layout_build
    *& Form alv_top_of_page
    text
    FORM alv_top_of_page.
    REFRESH t_header.
    CLEAR t_header.
    w_header-typ = 'H'. "H=Header, S=Selection, A=Action
    w_header-key = ' '.
    w_header-info = text-019.
    APPEND w_header TO t_header.
    CONCATENATE sy-datum4(2) '-' sy-datum6(2) '-' sy-datum0(4) ' / ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit4(2) INTO v_time.
    w_header-typ = 'S'. "H=Header, S=Selection, A=Action
    w_header-key = text-020.
    w_header-info = v_time.
    APPEND w_header TO t_header.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = t_header.
    ENDFORM. "alv_top_of_page
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    FORM grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
    it_fieldcat = fs_fldcat
    is_layout = st_layout
    i_default = c_check
    i_save = 'A'
    it_events = v_events[]
    TABLES
    t_outtab = <t_dyntable>.
    ENDFORM. " grid_display
    *& Form FINAL_FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM final_fieldcatalog .
    wa_cat-fieldname = text-009.
    wa_cat-seltext_m = text-015.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-011.
    wa_cat-seltext_m = text-016.
    wa_cat-outputlen = 40.
    APPEND wa_cat TO fs_fldcat.
    LOOP AT s_atnam.
    CLEAR wa_cat.
    wa_cat-fieldname = s_atnam-low.
    wa_cat-seltext_m = s_atnam-low.
    wa_cat-outputlen = '15'.
    APPEND wa_cat TO fs_fldcat.
    ENDLOOP.
    wa_cat-fieldname = text-012.
    wa_cat-seltext_m = text-017.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-013.
    wa_cat-seltext_m = text-018.
    wa_cat-outputlen = 8.
    APPEND wa_cat TO fs_fldcat.
    ENDFORM. " FINAL_FIELDCATALOG
    *& Form FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM fieldcatalog .
    wa_it_fldcat-fieldname = text-009.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-011.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 40.
    APPEND wa_it_fldcat TO t_fldcat1.
    LOOP AT s_atnam.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = s_atnam-low.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 30.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDLOOP.
    wa_it_fldcat-fieldname = text-012.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-013.
    wa_it_fldcat-datatype = text-014.
    wa_it_fldcat-intlen = 8.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDFORM. " FIELDCATALOG
    *& Form DYNAMIC_TABLE_CREATE
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table_create .
    Create dynamic internal table and assign to FS
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fldcat1
    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>.
    ENDFORM. " DYNAMIC_TABLE_CREATE
    *& Form FINAL_DATA
    text
    --> p1 text
    <-- p2 text
    FORM final_data .
    LOOP AT i_objdata_temp INTO w_objdata_temp.
    *assign w_objdata_temp-matnr to <fs_dyntable>.
    AT NEW matnr.
    wa_flname = text-009.
    fieldvalue = w_objdata_temp-matnr.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    ENDAT.
    wa_flname = text-011.
    fieldvalue = w_objdata_temp-maktx.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = w_objdata_temp-atnam.
    fieldvalue = w_objdata_temp-ausp1.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-012.
    fieldvalue = w_objdata_temp-prdha.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-013.
    fieldvalue = w_objdata_temp-mstde.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    AT END OF matnr.
    APPEND <fs_dyntable> TO <t_dyntable>.
    ENDAT.
    ENDLOOP.
    ENDFORM. " FINAL_DATA
    *& Form GET_CLASSIFICATION
    text
    --> p1 text
    <-- p2 text
    FORM get_classification .
    LOOP AT i_data INTO w_data.
    SELECT SINGLE * FROM klah WHERE class = c_nac.
    IF sy-subrc = 0.
    IF w_data-mstde >= klah-vondt.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
    EXPORTING
    class = c_nac
    classtext = c_check
    classtype = c_klart
    clint = 0
    features = c_check
    language = sy-langu
    object = w_data-objek
    TABLES
    t_class = i_class
    t_objectdata = i_objdata
    EXCEPTIONS
    no_classification = 1
    no_classtypes = 2
    invalid_class_type = 3
    OTHERS = 4.
    LOOP AT i_class INTO w_class.
    MOVE w_class TO w_class_temp.
    APPEND w_class_temp TO i_class_temp.
    ENDLOOP .
    LOOP AT s_atnam.
    READ TABLE i_objdata INTO w_objdata WITH KEY atnam = s_atnam-low.
    IF sy-subrc = 0.
    MOVE w_data-matnr TO w_objdata_temp-matnr.
    MOVE w_data-maktx TO w_objdata_temp-maktx.
    MOVE-CORRESPONDING w_objdata TO w_objdata_temp.
    MOVE w_data-prdha TO w_objdata_temp-prdha.
    MOVE w_data-mstde TO w_objdata_temp-mstde.
    APPEND w_objdata_temp TO i_objdata_temp.
    ENDIF.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_CLASSIFICATION

  • ALV and dynamic fields

    Hallo colleagues,
    I have to create a dynamic structure and show it within an ALV.
    Therefore I have created my stuctrure like this:
      MOVE 'COMP1' TO gw_component-name.
      gw_component-type ?= cl_abap_elemdescr=>get_string( ).
      INSERT gw_component INTO TABLE gt_components.
      MOVE 'COMP2' TO gw_component-name.
      gw_component-type ?= cl_abap_elemdescr=>get_i( ).
      INSERT gw_component INTO TABLE gt_components.
    get structure descriptor -> GR_STRUCTDESCR
      gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
    create work area of structure GR_STRUCTDESCR -> GR_WA
      CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
      ASSIGN gr_wa->* TO <gw_wa>.
    So now I have my dynamic structure, but how i can create a field catalog, which fit into the function module 'REUSE_ALV_FIELDCATALOG_MERGE' and 'REUSE_ALV_LIST_DISPLAY'?
    Any help?
    Thanks in advance
    Irian

    Hi,
    REPORT zmtable LINE-SIZE 255
                   LINE-COUNT 65.
    Program written by Vijay Chaitanya Raju
    Maintain Table dynamicly (Table name is entered on Selection Screen)
    Very powerfull program. Please maintain authorisation access and
    restrict maintenance to Z-tables
    Version 6.20 and up
    (can be used in 4.6C with some modifications to block try - endtry
    and classes)
    Enhanced functionality with dynamic selection screen
    TABLES: sscrfields.                "Fields on selection screens
    TYPE-POOLS rsds.
    DATA ds_clauses TYPE rsds_where.
    DATA: BEGIN OF ifield OCCURS 0,
          fieldname LIKE dd03l-fieldname,
          position  LIKE dd03l-position,
          keyflag   LIKE dd03l-keyflag,
          datatype  LIKE dd03l-datatype.
    DATA: END OF ifield.
    DATA: sl_step    LIKE sy-tabix,
          ss_step    LIKE sy-subrc,
          ss_act(1)  TYPE c,
          sl_lines   LIKE sy-tfill,
          sl_status  LIKE sy-subrc,
          sl_subrc   LIKE sy-subrc,
          sl_update(1) TYPE c,
          sl_mandt(1)  TYPE c,
          len(6)       TYPE n,
          f_value(255) TYPE c,
          sl_datum     LIKE sy-datum,
          sl_uzeit     LIKE sy-uzeit,
          price1(15)   TYPE c,
          price2(15)   TYPE c,
          mess(60)     TYPE c,
          d_stat   LIKE sy-subrc,
          m_stat   LIKE sy-subrc,
          slchar(6) TYPE c.
    DATA: ref_ptr TYPE REF TO cx_root.      "Root class more common
    DATA: text TYPE string.
    DATA: sl_index LIKE sy-tabix.
    DATA: zauth LIKE dd02l-tabname.
    DATA: num TYPE i,
          max_len TYPE i,
          check_len TYPE i,
          sl_sel(1) TYPE c.
    TYPE-POOLS: icon.
    SELECTION-SCREEN.
    SELECTION-SCREEN BEGIN OF LINE.
    text-012 - 'Table Name'
    SELECTION-SCREEN COMMENT 1(25) text-012.
    PARAMETERS: tabname LIKE dd02l-tabname DEFAULT 'ZSCARE'.
    text-003 - 'Selection'
    SELECTION-SCREEN PUSHBUTTON 75(9) text-003 USER-COMMAND sta1.
    SELECTION-SCREEN END OF LINE.
    numrows(text) - 'Max Number of ROWS'
    PARAMETERS: numrows LIKE sy-subrc DEFAULT '100'.
    At Selection-Screen                                                 *
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
        WHEN 'STA1'.
          CLEAR sl_sel.
          CALL FUNCTION 'ZSTAN_SELECTIONS'
            EXPORTING
              tabname         = tabname
            IMPORTING
              ds_clauses      = ds_clauses
            EXCEPTIONS
              table_not_valid = 1
              other_error     = 2
              OTHERS          = 3.
          IF sy-subrc = 0.
            sl_sel = 'X'.
          ENDIF.
      ENDCASE.
    *At Selection-Screen Output                                            *
    AT SELECTION-SCREEN OUTPUT.
      SELECT SINGLE tabname
        INTO tabname
        FROM dd02l
        WHERE tabname  = tabname
          AND as4local = 'A'
          AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
                OR tabclass = 'CLUSTER' ).
      IF sy-subrc <> 0.
        MESSAGE 'Table is not valid' TYPE 'S'.
        RETURN.
      ENDIF.
    START-OF-SELECTION.
    START-OF-SELECTION.
      DEFINE: acheck.
        zauth = 'ZTABAUTH'.
        select single statu
          into sl_update
          from (zauth)
          where tabname = tabname
            and bname   = sy-uname.
        if sy-subrc <> 0.
          message 'You are not authorized to view this table' type 'S'.
          return.
        endif.
      END-OF-DEFINITION.
      SELECT SINGLE tabname
        INTO tabname
        FROM dd02l
        WHERE tabname  = tabname
          AND as4local = 'A'
          AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
                OR tabclass = 'CLUSTER' ).
      IF sy-subrc <> 0.
        MESSAGE 'Table is not valid' TYPE 'S'.
        RETURN.
      ENDIF.
      DATA: ptr_itab TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itab> TYPE STANDARD TABLE. "ANY TABLE.
      CREATE DATA ptr_itab TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itab->* TO <fs_itab>.
    For DELETION
      DATA: ptr_itd TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itd> TYPE STANDARD TABLE.
      CREATE DATA ptr_itd TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itd->* TO <fs_itd>.
    For MODIFICATION
      DATA: ptr_itm TYPE REF TO data.
      FIELD-SYMBOLS: <fs_itm> TYPE STANDARD TABLE.
      CREATE DATA ptr_itm TYPE STANDARD TABLE OF (tabname).
      ASSIGN ptr_itm->* TO <fs_itm>.
      DATA: ptr_wtab TYPE REF TO data.
      FIELD-SYMBOLS: <fs_wtab> TYPE ANY.
      CREATE DATA ptr_wtab TYPE (tabname).
      ASSIGN ptr_wtab->* TO <fs_wtab>.
      DATA: itabname(15) TYPE c.
      itabname = '<fs_wtab>'.
    Standard list status with 'SAVE' button
      SET PF-STATUS 'STLI'.
      CLEAR sl_update.
    Maintain authorisation access in table ZTABAUTH
    Key fields:  tabname - Table name
                 bname   = sy-uname - User name
                 statu   = 'X' - maintain
                           ' ' - view
    Check authorisation access
      acheck.
      SELECT fieldname position keyflag datatype
        INTO TABLE ifield
        FROM dd03l
        WHERE tabname = tabname
          AND fieldname NOT LIKE '.INCLU%'
        ORDER BY position.
      FIELD-SYMBOLS: <f1> TYPE ANY.
      DATA: tab_field(60) TYPE c,
            sline LIKE sy-lisel.
      DATA: field_attr LIKE dfies.
      DATA: BEGIN OF tfield_attr OCCURS 0.
              INCLUDE STRUCTURE field_attr.
      DATA: END OF tfield_attr.
      LOOP AT ifield.
        CALL FUNCTION 'G_FIELD_READ'
          EXPORTING
            table      = tabname
            fieldname  = ifield-fieldname
            text_flag  = 'X'
          IMPORTING
            field_attr = field_attr.
        tfield_attr = field_attr.
        APPEND tfield_attr.
      ENDLOOP.
      IF sl_sel = 'X'.
        SELECT *
          FROM (tabname)
          INTO TABLE <fs_itab> UP TO numrows ROWS
          WHERE (ds_clauses-where_tab).
      ELSE.
        SELECT *
          FROM (tabname)
          INTO TABLE <fs_itab> UP TO numrows ROWS.
      ENDIF.
      DESCRIBE TABLE <fs_itab> LINES sl_lines.
    Show two extra lines to allow addition up to 2 new lines
      IF sl_update = 'X'.
        DO 2 TIMES.
          APPEND INITIAL LINE TO <fs_itab>.
        ENDDO.
      ENDIF.
      DATA: info(22) VALUE 'D - Delete, M - Modify'.
      WRITE: / icon_information AS ICON QUICKINFO info.
      WRITE ' '.
      CLEAR check_len.
      LOOP AT tfield_attr.
        IF tfield_attr-datatype = 'CLNT'.
          CONTINUE.
        ENDIF.
        len = tfield_attr-outputlen.
        IF tfield_attr-keyflag = 'X'.
          check_len = check_len + len + 1.
        ENDIF.
        IF tfield_attr-scrtext_m IS NOT INITIAL.
          WRITE: AT (len) tfield_attr-scrtext_m COLOR 1.
        ELSE.
          WRITE: AT (len) tfield_attr-fieldtext COLOR 1.
        ENDIF.
      ENDLOOP.
      CLEAR ss_step.
      CLEAR ss_act.
      LOOP AT <fs_itab> INTO <fs_wtab>.
        IF sy-tabix LE sl_lines.
          ss_step = 1.
        ELSE.
          CLEAR ss_step.
        ENDIF.
    In field SS_STEP put D -  to delete record
                         M -  to modify/add new record
        IF sl_update = 'X'.
          WRITE:/ icon_change AS ICON.
          IF ss_step = 1.
            WRITE:  ss_act INPUT ON.
          ELSE.
            ss_act = 'M'.
            WRITE:  ss_act.
            CLEAR ss_act.
          ENDIF.
        ELSE.
          WRITE:/ icon_display AS ICON.
          WRITE:  ss_act COLOR 2.
        ENDIF.
        LOOP AT ifield.
    Maintain client dependant tables in the same client
          IF ifield-datatype = 'CLNT'.
            sl_mandt = 'X'.
            CONTINUE.
          ENDIF.
          CONCATENATE itabname '-' ifield-fieldname INTO tab_field.
          ASSIGN (tab_field) TO <f1>.
          IF sl_update = 'X'.
            IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
              WRITE: <f1> COLOR 4.
            ELSE.
              WRITE: <f1> INPUT ON.
            ENDIF.
          ELSE.
            IF ifield-keyflag = 'X' AND ss_step IS NOT INITIAL.
              WRITE: <f1> COLOR 4.
            ELSE.
              WRITE: <f1> COLOR 2.
            ENDIF.
          ENDIF.
          UNASSIGN <f1>.
        ENDLOOP.
      ENDLOOP.
    END-OF-SELECTION.
    END-OF-SELECTION.
    AT USER-COMMAND.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'SAVE'.
          IF sl_update = 'X'.
            CLEAR: sl_step,
                   sl_status,
                   sl_subrc,
                   <fs_wtab>,
                   d_stat,
                   m_stat,
                   max_len.
            REFRESH <fs_itd>.
            REFRESH <fs_itm>.
            DO.
              IF sl_status <> 0.
                EXIT.
              ENDIF.
              ADD 1 TO sl_step.
              IF sl_subrc <> 0.
                EXIT.
              ENDIF.
              CLEAR ss_step.
              CLEAR ss_act.
              READ LINE sl_step
                   FIELD VALUE ss_act INTO f_value.
              sl_subrc = sy-subrc.
              IF f_value(1) EQ 'D' OR f_value(1) = 'd'.
                ss_step = 1.  "Delete
              ELSEIF f_value(1) EQ 'M' OR f_value(1) = 'm'.
                ss_step = 2.  "Modify
              ELSE.
                CLEAR ss_step.
              ENDIF.
              CHECK sy-lisel(3) = '0Z '.
              IF ss_step GT 0.
                CLEAR sline.
                sline = sy-lisel+5(250).
                max_len = 250.
                CHECK sline(check_len) <> ' '.
                LOOP AT tfield_attr.
                  CONCATENATE itabname '-' tfield_attr-fieldname
                                                  INTO tab_field.
                  ASSIGN (tab_field) TO <f1>.
                  IF tfield_attr-fieldname = 'MANDT'.
                    <f1> = sy-mandt.
                  ELSE.
                    CLEAR f_value.
                    IF max_len LT tfield_attr-outputlen.
                      max_len = 255.
                      ADD 1 TO sl_step.
                      READ LINE sl_step.
                      sline = sy-lisel.
                    ENDIF.
                    f_value = sline(tfield_attr-outputlen).
                    max_len = max_len - tfield_attr-outputlen - 1.
                    IF tfield_attr-inttype = 'D'.
                      IF f_value CO ' 0./-'.
                        CLEAR sl_datum.
                        <f1> = sl_datum.
                      ELSE.
                        CALL FUNCTION 'CONVERT_DATE_INPUT'
                          EXPORTING
                            input                     = f_value
                            plausibility_check        = 'X'
                          IMPORTING
                            output                    = sl_datum
                          EXCEPTIONS
                            plausibility_check_failed = 1
                            wrong_format_in_input     = 2
                            OTHERS                    = 3.
                        IF sy-subrc = 0.
                          <f1> = sl_datum.
                        ELSE.
                          text = 'Invalid Date'.
                          sl_status = 1.
                          EXIT.
                        ENDIF.
                      ENDIF.
                    ELSEIF tfield_attr-inttype = 'T'.
                      IF f_value CO ' 0:'.
                        CLEAR sl_uzeit.
                        <f1> = sl_uzeit.
                      ELSE.
                        CALL FUNCTION 'CONVERT_TIME_INPUT'
                          EXPORTING
                            input                     = f_value
                            plausibility_check        = 'X'
                          IMPORTING
                            output                    = sl_uzeit
                          EXCEPTIONS
                            plausibility_check_failed = 1
                            wrong_format_in_input     = 2
                            OTHERS                    = 3.
                        IF sy-subrc = 0.
                          <f1> = sl_uzeit.
                        ELSE.
                          text = 'Invalid Time'.
                          sl_status = 1.
                          EXIT.
                        ENDIF.
                      ENDIF.
                    ELSEIF tfield_attr-inttype = 'C'.
                      TRANSLATE f_value TO UPPER CASE.
                      <f1> = f_value.
                    ELSE.
                      TRANSLATE f_value USING ', '.
                      CONDENSE f_value NO-GAPS.
                      TRY.
                          <f1> = f_value.
                        CATCH cx_root INTO ref_ptr.
                          text = ref_ptr->get_text( ).
                          sl_status = 1.
                          EXIT.
                      ENDTRY.
                    ENDIF.
                    SHIFT sline BY tfield_attr-outputlen PLACES.
                    SHIFT sline LEFT.
                  ENDIF.
                  UNASSIGN <f1>.
                ENDLOOP.
                IF sl_status = 0.
                  CASE ss_step.
                    WHEN 1.  "Delete
                      ADD 1 TO d_stat.
                      APPEND <fs_wtab> TO <fs_itd>.
                    WHEN 2.  "Modify
                      ADD 1 TO m_stat.
                      APPEND <fs_wtab> TO <fs_itm>.
                  ENDCASE.
                ENDIF.
              ENDIF.
            ENDDO.
            IF sl_status = 0.
              IF d_stat IS NOT INITIAL.
                slchar = d_stat.
                CONCATENATE 'Deleted -' slchar 'record.' INTO text
                  SEPARATED BY space.
                DELETE (tabname) FROM TABLE <fs_itd>.
              ENDIF.
              IF m_stat IS NOT INITIAL.
                slchar = m_stat.
                CONCATENATE text 'Modified -' slchar 'record.' INTO text
                  SEPARATED BY space.
                MODIFY (tabname) FROM TABLE <fs_itm>.
              ENDIF.
              IF d_stat IS INITIAL AND m_stat IS INITIAL.
                MESSAGE 'No changes were done' TYPE 'S'.
              ELSE.
                MESSAGE text TYPE 'S'.
              ENDIF.
              LEAVE.
            ELSE.
              MESSAGE text TYPE 'I'.
              EXIT.
            ENDIF.
          ELSE.
            LEAVE.
          ENDIF.
      ENDCASE.
    *--END--
    Below is Function for a Dynamic Selection Screen
    FUNCTION zstan_selections.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(TABNAME) LIKE  DD02L-TABNAME DEFAULT 'ZSCARE'
    *"  EXPORTING
    *"     VALUE(DS_CLAUSES) TYPE  RSDS_WHERE
    *"  EXCEPTIONS
    *"      TABLE_NOT_VALID
    *"      OTHER_ERROR
      DATA texpr TYPE rsds_texpr.
      DATA twhere TYPE rsds_twhere.
      DATA trange TYPE rsds_trange.
      DATA BEGIN OF qcat.                    "Selections View for
              INCLUDE STRUCTURE rsdsqcat.    "Free Selectoptions
      DATA END OF qcat.
      DATA BEGIN OF tabs OCCURS 10.
              INCLUDE STRUCTURE rsdstabs.
      DATA END   OF tabs.
      DATA BEGIN OF fields OCCURS 10.
              INCLUDE STRUCTURE rsdsfields.
      DATA END   OF fields.
      DATA BEGIN OF efields OCCURS 10.
              INCLUDE STRUCTURE rsdsfields.
      DATA END   OF efields.
      DATA selid LIKE rsdynsel-selid.
      DATA actnum LIKE sy-tfill.
      DATA title LIKE sy-title VALUE 'Selection Screen'.
      DATA: maxnum LIKE sy-subrc VALUE '69'.
      CLEAR    tabs.
      tabs-prim_tab = tabname.
      COLLECT  tabs.
      DATA: position LIKE dd03l-position.
      DATA: keyflag  LIKE dd03l-keyflag.
      CLEAR fields.
      fields-tablename = tabname.
      fields-sign      = 'I'.
      DATA: step LIKE sy-subrc.
      SELECT fieldname keyflag position
        INTO (fields-fieldname, keyflag, position)
        FROM dd03l
        WHERE tabname = tabname
          AND fieldname NOT LIKE '.INCLU%'
          AND datatype NE 'CLNT'
        ORDER BY position.
        ADD 1 TO step.
        CHECK step LE maxnum.
        IF keyflag <> 'X'.
          efields = fields.
          APPEND efields.
        ENDIF.
        APPEND fields.
      ENDSELECT.
      IF sy-subrc <> 0.
        RAISE table_not_valid.
      ENDIF.
      CALL FUNCTION 'FREE_SELECTIONS_INIT'
        EXPORTING
          expressions              = texpr
          kind                     = 'F'
        IMPORTING
          selection_id             = selid
          expressions              = texpr
          where_clauses            = twhere
          field_ranges             = trange
          number_of_active_fields  = actnum
        TABLES
          tables_tab               = tabs
          fields_tab               = fields
          fields_not_selected      = efields
        EXCEPTIONS
          fields_incomplete        = 01
          fields_no_join           = 02
          field_not_found          = 03
          no_tables                = 04
          table_not_found          = 05
          expression_not_supported = 06
          incorrect_expression     = 07
          illegal_kind             = 08
          area_not_found           = 09
          inconsistent_area        = 10
          kind_f_no_fields_left    = 11
          kind_f_no_fields         = 12
          too_many_fields          = 13.
      IF sy-subrc = 0.
        CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
          EXPORTING
            selection_id            = selid
            title                   = title
          IMPORTING
            where_clauses           = twhere
            expressions             = texpr
            field_ranges            = trange
            number_of_active_fields = actnum
          TABLES
            fields_tab              = fields
          EXCEPTIONS
            internal_error          = 01
            no_action               = 02
            no_fields_selected      = 03
            no_tables_selected      = 04
            selid_not_found         = 05.
        IF sy-subrc = 0.
          CLEAR ds_clauses.
          MOVE tabname TO ds_clauses-tablename.
          READ TABLE twhere WITH KEY ds_clauses-tablename INTO ds_clauses.
          IF sy-subrc <> 0.
            RAISE other_error.
          ENDIF.
        ELSE.
          RAISE other_error.
        ENDIF.
      ELSE.
        RAISE other_error.
      ENDIF.
    ENDFUNCTION.
    Regards,
    Shiva

  • Fixed and sap field type

    Hi Gurus,
    Need your help.
    --In defining external web services ...i have given the URL and other parameters in the standard call structure.E.g we have defined the user name and password  as parameter values(fixed value).When a user clicks on the url from his/her browser,does the catalog ask for log-in details again or the above mentioned parameter values  will automatically give catalog access to the user?
    --I have read the 'help' on Fixed type and SAP field type.Can somebody explain me the diference clearly?
    If fixed...the parameter value remains the same/fixed.<b>Meaning?</b>
    If SAP field..."SAP fields are also permitted as single parameters during the catalog call. If, for example, a username has to be transferred, you can enter SY-UNAME in the Contents field. The system then automatically fills the parameter with the username."
    <b>What/where is a contents field?</b>I cannot see it anywhere.Does it mean, when a user clicks on the catalog,the UN will automatically populate in the field?
    Please let me know.
    Thanks
    Trey

    Hi Trey,
    -- you define user & password in the calling parameters to avoid logon when calling catalog, but also to control what he/she can see/order in the catalog, because this user ID is assigned some view IDs in the catalog
    -- fixed values are entered manually in the customizing (they are fixed, so for more complex needs, you can add parameters in a BADI just before calling the catalog). ex: the ~okcode is always ADDI; the user / password can be fixed.
    You can transfer additional parameters at runtime using BADI BBP_CAT_CALL_ENRICH.
    SAP fields are not fixed but are variables. ex: if you use SY-UNAME as the parameter value for , this will be valuated at the run time, with connected user ID.
    When you define the calling parameters for a catalog ID, (IMG Supplier Relationship Management --> SRM Server --> Master Data --> Define External Web Services  (Catalogs, Vendor Lists etc.) you enter the parameter name(ex: user) and its value (ex: SY-UNAME with type "SAP field" or THONNS with "Fixed value").
    Rgds
    Christophe

  • Dynamic Field Catalogs in ALV

    Hi ,
    I have a requirement in which the selection screen of the report contains a field called period .
    Suppose the report is run on say the month of December and the period value they entered in selection screen is 4 .
    The ALV should show the values for 4 months prior to december ie Aug,Nov,Sept,Oct,Nov,and Dec.
    How to dynamically modify the fieldcatalog in ALV in that case
    Thanks in advance
    Arshad.A

    Hello Arshad
    Assuming that the user cannot go back further than the current year the maximum value for period will be 11 (e.g. current month is December then show range January - December).
    Simply prepare your fieldcatalog contain 12 columns (1 for each month). Lets assume the columns are named: MONTH_01, MONTH_02, ..., MONTH_12.
    Let's take your example (December + 4 periods).
    * Get number for current month
      ld_current_month = syst-datum+4(2).
      ld_month_from     = ld_current_month - p_periods. " (= 12 - 4 = 8 = August)
      LOOP at gt_fcat INTO ls_fcat
                              WHERE ( fieldname CS 'MONTH' ).
        If ( ls_fcat-fieldname+6(2) BETWEEN ld_month_from AND ld_current_month ).
    *     keep
        ELSE.
          ls_fcat-tech = 'X'.  " no output on ALV list
       ENDIF.
         MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDLOOP.
    The restriction to the current year can be overcome the same way yet the coding will get somewhat more complex.
    Regards
      Uwe

  • Struts and Dynamic Fields of a Form

    Hi all,
    There's a form in a struts based web-application in which some fields will be made according to some variable parameters. I mean number of those text type fields may vary.
    Any idea for building ActionForm class such that fields of that formBean be set automatically? I tried following solution :
    <input type="text" name="varName" value="aaa" >
    <input type="text" name="varName" value="bbb" >
    <input type="text" name="varName" value="ccc" >
    class MyForm extends ..... {
    private String varName[];
    public String[] getVarName() {}
    public void setVarName(String[] varName) {
    this.varName = varName;
    In this case I am able to retrieve correct values in the Action Class. But when the form is populated with the values, it is not showing correct results. The reason behind this is I am unable to bind first text box with varName[0] and second with varName[1]. Please suggest solution.
    Thanks and regards,
    Sneha

    Why don't you create the text boxes dynamically in the jsp?
    <logic:iterate id="beanArray" name="yourBean">
    <input type="text" name='<bean:write name="beanArray" property="beanName"/>' value='<bean:write name="beanArray" property="beanName"/>'>
    </logic:iterate>

  • Lot sizing rule (Fixed and Exact) - Field controls

    Hi,
    In MRP1 view of material master, I observed the following:
    If Lot size rule: Fixed (FX), in the change mode of the material master, I am able to observe Min lot size, Max lot size, rounding profile and rounding value. Where as these fields are not visible in the display mode (Despite these fields having values in MARC table)
    However this is not true for exact lot size (EX)
    What is the business reason/logic for this?
    Please suggest.
    Thanks,
    Ravi

    In MM03 only the fields relevant to the lot size are being displayed, the other fields have no effect so are not displaying.  In MM02 all fields are displayed since if the change the lot size you may need to edit them.  In MM02 you will get a warning if you enter a field not relevant for the lot size.

  • Dynamic field catalog

    Hi all,
         i have a strange problem,
    in table WITH_ITEM the field ITT and wt_qbshh , we have different kinds of tax codes and tax amounts.
    i was displaying these as two columns in my report.
    but my client ask me to display the wt_qbshh field in different columns based on the witht value.
    i mean lets say for example there are 2 types of tax codes 1 and 2 in witht.
    and let  my report will display lik this
    tax amnt              tax code
    100.00 ;                   1
    150.00 ;                   2
    130.00 ;                   1
    120.00 ;                   2
    the client wants the report like this
    tax amnt-type1                      tax amnt-type 2
    100.00
                                                         150.00
    130.00 ; 
                                                         120.00
    is there any method for this kind of situation ?
    currently i defined all kinds of tax types as fields in my internal tables also in fieldcatalog
    and doing thie following
    loop at tbl into temp.
    case 'witht'.
        when '1'.
          temp-tax1 = temp-tax.
        when '2'.
          temp-tax2 = temp-tax.
    endcase.
    modify tbl from temp.
    endloop.
    i am asking for better way than this if exists
    thanks in advance.

    Hey check out this link
    http://wiki.sdn.sap.com/wiki/display/ABAP/DYNAMICFIELDCATALOGINALV
    May be you can modify your code lil bit.

  • Adding field in field catalog and to display in output

    Hi, In this below report i have newly added the user group field i.e' usr02-class ' and the field and data is coming up to internal table ' it_usr02 ' in 'REUSE_ALV_GRID_DISPLAY' and in field catalog it is not coming i have debugged and only the class field is not coming. plz suggest me how to add this in fieldcatalog .
    REPORT zrpbc_user_log.
    Declaration of Tables                                               *
    TABLES: usr02,usr03.
    DATA:
    BEGIN OF it_usr02 OCCURS 0,
      bname        LIKE usr02-bname, "EID
      class        LIKE usr02-class, "User Group
      trdat        LIKE usr02-trdat, "Last Logged in Date
    *Start of Change Charm 25971
      name1        LIKE usr03-name1, "First Name
      name2        LIKE usr03-name2, "Last Name
      e_mail       LIKE bapiaddr3-e_mail,"Emailid
    *End of Change Charm 25971
    END OF it_usr02.
    DATA:  w_address TYPE bapiaddr3,
           it_return   TYPE STANDARD TABLE OF bapiret2,
           w_name LIKE bapibname-bapibname.
    TYPE-POOLS: slis.
    DATA it_fcat TYPE slis_t_fieldcat_alv.
    DATA : w_fcat TYPE slis_fieldcat_alv.
    Declaration of Constants                                             *
    CONSTANTS: c_past_days TYPE i VALUE 90.
    Declaration of Variables                                             *
    DATA w_repid LIKE sy-repid.
    DATA w_no_lines LIKE sy-tabix.
    DATA w_idx TYPE sy-tabix.
    Selection Screen                                                     *
    SELECT-OPTIONS:
      s_trdat FOR usr02-trdat.
    INITIALIZATION                                                   *
    INITIALIZATION.
      PERFORM initialize_data.
    Start of Selection                                                   *
    START-OF-SELECTION.
    *Get the user details
      PERFORM get_user_details.
    End of Selection                                                     *
    END-OF-SELECTION.
      PERFORM get_alv_display.
    *&      Form  initialize_data
          text
    FORM initialize_data .
      "Initialize the select options with the appropriate date range
      s_trdat-low = sy-datum - c_past_days.
      s_trdat-high = sy-datum.
      s_trdat-sign = 'I'.
      s_trdat-option = 'BT'.
      APPEND s_trdat.
    ENDFORM.                    " initialize_data
    *&      Form  get_user_details
          text
    FORM get_user_details .
    read data into table it_usr02
      SELECT bname class trdat
      FROM usr02
      INTO TABLE it_usr02
      WHERE
        trdat IN s_trdat AND
        bname LIKE 'E%'.
      LOOP AT it_usr02.
        w_idx = sy-tabix.
        MOVE : it_usr02-bname TO w_name.
    *Start of Change Charm 25971
    Getting the First ,Last name & Emailid of the user
        CALL FUNCTION 'BAPI_USER_GET_DETAIL'
          EXPORTING
            username = w_name
          IMPORTING
            address  = w_address
          TABLES
            return   = it_return.
        MOVE : w_address-firstname TO it_usr02-name1,
               w_address-lastname  TO it_usr02-name2,
               w_address-e_mail    TO it_usr02-e_mail.
        MODIFY it_usr02 INDEX w_idx.
      ENDLOOP.
    *End of Change Charm 25971
    ENDFORM.                    " get_user_details
    *&      Form  get_alv_display
          text
    FORM get_alv_display.
      w_repid = sy-repid.
      PERFORM get_alv_fieldcat.
    Create Field-catalogue from internal table
    Call for ALV list display
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = w_repid
          it_fieldcat        = it_fcat
          i_save             = 'A'
        TABLES
          t_outtab           = it_usr02
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
        WRITE: /
        'Returncode'(001),
        sy-subrc,
        'from FUNCTION REUSE_ALV_LIST_DISPLAY'(002).
      ENDIF.
    ENDFORM.                    " get_alv_display
    *&      Form  get_alv_fieldcat
          text
    FORM get_alv_fieldcat .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = w_repid
          i_internal_tabname     = 'IT_USR02'
          i_inclname             = w_repid
        CHANGING
          ct_fieldcat            = it_fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        WRITE: /
        'Returncode'(001),
        sy-subrc,
        'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'(002).
      ENDIF.
    *Start of Change Charm 25971
      w_fcat-reptext_ddic = 'Firstname'(003).
      MODIFY it_fcat FROM w_fcat TRANSPORTING reptext_ddic
                                  WHERE fieldname = 'NAME1'.
      w_fcat-reptext_ddic = 'Lastname'(004).
      MODIFY it_fcat FROM w_fcat TRANSPORTING reptext_ddic
                                   WHERE fieldname = 'NAME2'.
    *End of Change Charm 25971
    ENDFORM.                    " get_alv_fieldcat

    Please dont DUPLICATE the Posts. Its against the Forum Rules.
    Close any one theard.
    Duplicate Post:
    In this Report i want to add class field in usr02 table
    Regards,
    Padma

  • Dynamic fields to be displayed in ALV

    Hi All,
    I've a requirement like this.
    I have table type with 10 fields and I use this to display data in ALV.  Now, I need to add few dynamic columns (based on customizing) and show in the same ALV.  Since these fields are dynamic and new fields can also be added in the future, I can not enhance the structure I am using at present.  So, the solution would be to add dynamic columns to the output table that is sent to ALV display.
    Adding fields to field catalogue is not a big ask and I am already done with that.  Moreover, I have tried enhancing the current structure with a field of type DATA and populated it. 
    But, technically, it is a single field and cannot be split into the different new fields at the time of output. 
    How is this possible?  Please provide me with example code also, if you have.
    Thanks in advance,
    Srinath.

    Hi Srinath,
    I for this purpose I use my own solution since a couple of years with success. It was originally developed for ALV functions module. In OO the field catalo has a slightly different structure, nut one can be easily converted into the other using function module (don't remember the name right now).
    Recently I created a class with static functional methods for this:
    METHOD fieldcat_alv .
      TYPE-POOLS:
        sydes.
      DATA:
        lv_desc                               TYPE sydes_desc,
        ls_alv_fieldcat                       TYPE slis_fieldcat_alv,
        lv_longfield                          TYPE dynfnam.
      FIELD-SYMBOLS:
        <typeinfo>                            TYPE sydes_typeinfo,
        <nameinfo>                            TYPE sydes_nameinfo.
      DESCRIBE FIELD it_table INTO lv_desc.                     "#EC *
      LOOP AT lv_desc-types
          ASSIGNING <typeinfo>
          WHERE NOT idx_name IS INITIAL
            AND table_kind IS INITIAL "no entries for deep table like color
            AND back                          = 2. "top-level-entries only.
        READ TABLE lv_desc-names INDEX <typeinfo>-idx_name
          ASSIGNING <nameinfo>.
        CHECK <nameinfo>-name                 <> 'INCLUDE'.
        ls_alv_fieldcat-fieldname             = <nameinfo>-name.
        WHILE NOT <nameinfo>-continue IS INITIAL.
          ADD 1 TO <typeinfo>-idx_name.
          READ TABLE lv_desc-names INDEX <typeinfo>-idx_name
            ASSIGNING <nameinfo>.
          CONCATENATE
            ls_alv_fieldcat-fieldname
            <nameinfo>-name
            INTO ls_alv_fieldcat-fieldname.
        ENDWHILE." not <nameinfo>-continue IS INITIAL.
        READ TABLE lv_desc-names INDEX <typeinfo>-idx_help_id
          ASSIGNING <nameinfo>.
        IF sy-subrc                           = 0.
    * Caution: Help-ID may be Tablename-Fieldname and thus longer
    * than 30 Chars; ls_alv_fieldcat-rollname is 30 Chars only
          ls_alv_fieldcat-rollname            = <nameinfo>-name.
          lv_longfield                        = <nameinfo>-name.
          WHILE NOT <nameinfo>-continue IS INITIAL.
            ADD 1 TO <typeinfo>-idx_help_id.
            READ TABLE lv_desc-names INDEX <typeinfo>-idx_help_id
              ASSIGNING <nameinfo>.
            CONCATENATE
              lv_longfield
              <nameinfo>-name
              INTO lv_longfield.
          ENDWHILE." not lv_desc-continue is initial.
    * help id may be data element or <table>-<field>
          IF lv_longfield CA '-'.
    * get datatype for table field
            CALL METHOD get_rollname_4_tabfield
              EXPORTING
                iv_fieldname    = lv_longfield
              CHANGING
                cs_alv_fieldcat = ls_alv_fieldcat.
          ENDIF." lv_longfield ca '-'.
        ELSE.
    * No Help-ID: Use Fieldname as text
          ls_alv_fieldcat-seltext_s           =
          ls_alv_fieldcat-seltext_m           =
          ls_alv_fieldcat-seltext_l           =
          ls_alv_fieldcat-reptext_ddic        =
          <nameinfo>-name.
        ENDIF." sy-subrc                      = 0.
    * Starting 4.7: get edit mask
        IF NOT <typeinfo>-idx_edit_mask IS INITIAL.
          READ TABLE lv_desc-names INDEX <typeinfo>-idx_edit_mask
            ASSIGNING <nameinfo>.
          ls_alv_fieldcat-edit_mask           = <nameinfo>-name.
          IF NOT <nameinfo>-continue IS INITIAL.
            ADD 1 TO <typeinfo>-idx_edit_mask.
            READ TABLE lv_desc-names INDEX <typeinfo>-idx_edit_mask
              ASSIGNING <nameinfo>.
            CONCATENATE
              ls_alv_fieldcat-edit_mask
              <nameinfo>-name
              INTO ls_alv_fieldcat-edit_mask.
          ENDIF." not <nameinfo>-continue IS INITIAL.
        ENDIF." not <typeinfo>-IDX_EDIT_MASK is initial.
    * assign length, output length and decimals
        ls_alv_fieldcat-intlen                = <typeinfo>-length.
        ls_alv_fieldcat-outputlen             = <typeinfo>-output_length.
        ls_alv_fieldcat-decimals_out          = <typeinfo>-decimals.
        ls_alv_fieldcat-inttype               = <typeinfo>-type.
        APPEND ls_alv_fieldcat TO rt_fieldcat.
        CLEAR:  "prevent anything 2 B  taken for subsequent fields
          ls_alv_fieldcat.
      ENDLOOP." at lv_desc-types where not IDX_NAME is in initial.
    ENDMETHOD.
    Parameters required
        importing
          IT_TABLE type STANDARD TABLE
        returning
          value(RT_FIELDCAT) type SLIS_T_FIELDCAT_ALV .
    and
    method GET_ROLLNAME_4_TABFIELD .
      FIELD-SYMBOLS:
        <dfies>                               TYPE dfies.
      DATA:
        lv_tabname                            TYPE tabname,
         lt_dfies                             TYPE TABLE OF dfies,
        lv_fieldname                          TYPE fieldname.
      SPLIT iv_fieldname AT '-'
        INTO lv_tabname lv_fieldname.
      CLEAR cs_alv_fieldcat-rollname.
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          tabname                             = lv_tabname
          fieldname                           = lv_fieldname
    *   LANGU                                 = SY-LANGU
    *   LFIELDNAME                            = ' '
    *   ALL_TYPES                             = ' '
    * IMPORTING
    *   X030L_WA                              =
    *   DDOBJTYPE                             =
    *   DFIES_WA                              =
    *   LINES_DESCR                           =
       TABLES
         dfies_tab                            =  lt_dfies
    *   FIXED_VALUES                          =
       EXCEPTIONS
         not_found                            = 1
         internal_error                       = 2
         OTHERS                               = 3
      IF sy-subrc                             <> 0.
        MESSAGE ID sy-msgid                   TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        READ TABLE   lt_dfies ASSIGNING <dfies> INDEX 1.
        cs_alv_fieldcat-rollname               = <dfies>-rollname.
    * Und wenn keinerlei Twexte gepflegt sind?
        IF <dfies>-reptext IS INITIAL AND
           <dfies>-scrtext_s IS INITIAL AND
           <dfies>-scrtext_m IS INITIAL AND
           <dfies>-scrtext_l IS INITIAL.
    * No Text: Use Fieldname as text
          cs_alv_fieldcat-seltext_s            =
          cs_alv_fieldcat-seltext_m            =
          cs_alv_fieldcat-seltext_l            =
          cs_alv_fieldcat-reptext_ddic         =
            cs_alv_fieldcat-fieldname.
        ENDIF." <dfies>-reptext IS INITIAL AND
      ENDIF.
    endmethod.
    parameters required
        importing
          IV_FIELDNAME type DYNFNAM
        changing
          value(CS_ALV_FIELDCAT) type SLIS_FIELDCAT_ALV .
    Put this into class Z_CL_UTIL using SE80 and generate field catalog dynamically using statement
    lt_fieldcat = Z_CL_UTIL=>fieldcat_alv( itab ).
    If you have any difficulties with implementation, let me know.
    Regards,
    Clemens Li

  • Dynamic field in select statment.

    Hello,
    I created a report in which i have two checkboxes in the selection screen. The first checkbox is for the option to bring or not, initial purchase requisitions (BANFN) from EKPO and the second is to bring initial or not, RFQs
    (ANFNR). I want the select statment to have this form:
    select ...
    from ekpo
    into g_table
    where ..
    and dynamic field = " ".
    Can this be done ?
    i tried to put it as a string but it didnt work. (data: dynamic field type string value "EKPO-BANFN")
    P.S i know that it can be by writing the same select code twice.
    I just wonder if this can be done by this way
    \Regards.

    Hey Nick,
    I have more conditions than the one i said before , should all be in the lv_where_clause ?
    check my code.
    DATA: G_CHBFLD type STRING.
    G_CHBFLD = 'P~BANFN = '' " '.
    FORM SELECT_DATA_EKPO_EKKO.
      SELECT  .....
          FROM EKPO AS P INNER JOIN EKKO AS K
            ON PEBELN = KEBELN
              INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
                WHERE K~EBELN IN S_EBELN
                AND K~AEDAT IN S_AEDAT
                AND K~BSTYP IN S_BSTYP
                and ( G_CHBFLD ) .   -
    > //DEBUGER ")" is not a valid comparison operator. comparison operator.

  • Field avaialble in field catalog but not when I try to create the condition

    Hi,
      I wanted to add a new table to a delivery output. I need the fields delivery type/ship point and destination country. I could see that destination country (LAND1) is not available in the field catalog. I added it from the list of available fields (in KOMKBV2) and can see it in the field catalog but not when I try to create the condition table. What else do I need to get this field ?
    Regards,
    Hari.

    Also add your new field to structure KOMBZ
    If you want to use a new field in the field catalog, you must add the field to KOMP or KOMK in the following INCLUDES:
    - header data in INCLUDE KOMKAZ in KOMK
    - item data in INCLUDE KOMPAZ in KOMP
    When you use INCLUDES, the field is automatically added to KOMG and the field catalog.
    The routines for assigning values to the new fields in order processing are found in member MV45AFZZ. Use the following user exits:
    - USEREXIT_PRICING_PREPARE_TKOMK (header fields)
    - USEREXIT_PRICING_PREPARE_TKOMP (item fields)

  • Field catalog issue using REUSE_ALV_FIELDCATALOG_MERGE

    Hello experts,
    I am using FM REUSE_ALV_FIELDCATALOG_MERGE and the field catalog is created fron the program.
    The field catalog finds the date field from the program but my internal table has been changed to make the date output YYYY/MM/DD.
    When I input the internal table in FM REUSE_ALV_GRID_DISPLAY the output displays the date as DD/MM/YYYY which is not what I want.
    How can I get FM REAUSE_ALV_GRID_DISPLAY to output the date in the format YYYY/MM/DD which is in my input table.
    I have spent a lot of time researching SDN on this but cannot find a similar solution however I did find some examples of changing the field catalogue. Can anybody suggest this is the way to go and if I would use the edit mask field in the field catalog or is there a better way.
    Thanks for any suggestions

    I think you can use a field exit for this.
    This means creating a field element and a domain in the data dictionary, the domain will need to have a conversion exit set by putting an entry in the 'Convers. Routine' field, eg MYDAT.
    You will need to create two function mdules as below:
    eg, CONVERSION_EXIT_MYDAT_OUTPUT
    and CONVERSION_EXIT_MYDAT_INPUT
    Your internal table will now need to refer to the data element you have created instead of the one you are currently using. ALV should automatically pick up the conversion exits and show the ouitput as you desire.
    FUNCTION CONVERSION_EXIT_MYDAT_OUTPUT.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(INPUT) TYPE  DATS
    *"  EXPORTING
    *"     REFERENCE(OUTPUT)
    concatenate input(4) '/' input4(2) '/' input6
    into output.
    ENDFUNCTION.
    FUNCTION CONVERSION_EXIT_MYDAT_INPUT.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(INPUT)
    *"  EXPORTING
    *"     REFERENCE(OUTPUT) TYPE  DATS
    data l_string type string.
    l_string = input.
    replace all occurrences of '/' in l_string with ' '.
    output = l_string.
    ENDFUNCTION.

Maybe you are looking for

  • Quick time not up to date

    can not download or even open itunes show error that quicktime is not up to date when i try to up date quicktime it says not update is needed HELP HELP !!!!! bizzynme

  • HECess on CVD amount not determined automatically in MIGO

    Hi, We are using ECC 6.0 and TAXINN. Condition type for HECess on CVD is 'J1CV'. CVD amount, ECess on CVD and Additional Custom Duty amount are determined automatically in MIGO. But HECess on CVD amount not determined automatically in MIGO. Regards,

  • Installed Itunes7 - now when conected can't see ipod in windows or itunes

    As per subject, i have just downloaded itunes 7. No problems. I have previously had no problems with connectivity but now I connect the ipod in the same way and nothing happens - not in windows or itunes. Anyone got any ideas, thanks

  • [SOLVED]can't start X after full upgrade

    I just recently updating arch linux on X41 Tablet (i686, cpu=pentium m).. after restarting, i can't startx. it says Loading extension GLX AIGLX: Suspending AIGLX clients for VT switch(EE) Server terminated with error (1). Closing log file.onal inform

  • Can you label pictures in Aperture?

    Can you put labels on pictures in Aperture?