Dynamic field names in ALV (referencing to the month)

Hi,
I have 12 fields in my ALV, named Monthly Sales 1, Monthly Sales 2 and so on until Monthly Sales 12.
Monthly Sales 12 corresponds to the current month and Monthly Sales 1 is the current month minus 11 months (in terms of the month.)
So the user has requested that instead of Monthly Sales 12, it should display M 06/2007 as the field name.
Or Monthly Sales 11 should display M 05/2007 and so on.
How can this be done?
Please help.
Points will be awarded and all responses will be greatly appreciated.
Thanks,
John

Hi,
I have done some coding for this which is as follows:
TYPE-POOLS : abap, slis.
DATA : BEGIN OF itab OCCURS 0,
        month1 TYPE char2,
        month2 TYPE char2,
        month3 TYPE char2,
        month4 TYPE char2,
        month5 TYPE char2,
        month6 TYPE char2,
        month7 TYPE char2,
        month8 TYPE char2,
        month9 TYPE char2,
        month10 TYPE char2,
        month11 TYPE char2,
        month12 TYPE char2,
        month13 TYPE char2,
       END OF itab.
DATA wa LIKE LINE OF itab.
DATA : it_fieldcat     TYPE     slis_t_fieldcat_alv WITH HEADER LINE.
DATA : is_layout     TYPE     slis_layout_alv.
DATA : len TYPE i VALUE 0,
        text TYPE string,
        date TYPE sy-datum,
        index TYPE numc3.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
DATA : l_t_fields TYPE abap_compdescr_tab.
DATA : fs_fields  TYPE abap_compdescr.
*To get the fields of internal table
ref_table_des ?=
        cl_abap_typedescr=>describe_by_data( wa ).
APPEND LINES OF ref_table_des->components TO l_t_fields.
DESCRIBE TABLE l_t_fields LINES len.
DO len TIMES.
  index = sy-index - 1.
  CLEAR date.
  READ TABLE l_t_fields INTO fs_fields INDEX sy-index.
  CALL FUNCTION 'CCM_GO_BACK_MONTHS'
    EXPORTING
      currdate   = sy-datum
      backmonths = index
    IMPORTING
      newdate    = date.
  CONCATENATE date4(2) date0(4) INTO text SEPARATED BY '/'.
  it_fieldcat-fieldname = fs_fields-name.
  it_fieldcat-tabname = 'ITAB'.
  it_fieldcat-seltext_l = text.
  APPEND it_fieldcat.
ENDDO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    it_fieldcat   = it_fieldcat[]
  TABLES
    t_outtab      = itab[]
  EXCEPTIONS
    program_error = 1
    OTHERS        = 2.
I feel this is bit generic.
Copy & execute this program.
Reward if its useful.
Regards,
Sail

Similar Messages

  • 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

  • Need to display Long Text as field Name in ALV

    Hi,
    I am using an ALV Grid Display. Even though i have kept the output field length to be 30 char, the Column header that is being selected is the short name. I would like the Column header to display the long name.
    For example: Field "MAKTX"
    l_seltext_l = "Description"
    L_seltext_s = "Descr"
    I want to display "Description" as the field name but it is displaying the short length even though the field is 30 characters wide.
    Please help.
    Thanks,
    Urmila

    Hi,
    along with <b>fieldcat-SELTEXT_L  = 'long text'.</b>
       try to pass this also..
    <b>fieldcat-DDICTXT = 'L'.</b>
    so this will allow only long text.
    Regards
    vijay

  • This field name is not known. on the server

    I have an issue using RPT file to generate a report using my .NET web app on the server, locally the report is generated fine, but on the server it's giving me the error "The field name is not known":
    [COMException (0x80041019): This field name is not known.
    Details: errorKind
    Error in File FormListAddons {74708A80-A1B6-494F-A141-C83C61F45047}.rpt:
    Error in formula Object_Visibility:
    '{visa_clients.addon1} = ""'
    This field name is not known.
    Details: errorKind]
      CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) +0
      CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +362
    [FormulaException: This field name is not known.
    Details: errorKind
    Error in File FormListAddons {74708A80-A1B6-494F-A141-C83C61F45047}.rpt:
    Error in formula Object_Visibility:
    '{visa_clients.addon1} = ""'
    This field name is not known.
    The line mentioned above causing the error, is a script on crystal report to suppress the field if this condition is met:
    {visa_clients.addon1} = ""
    My PC is running Crystal Report version 11, however the Crystal Report runtime on the server running the version 10.5.1.0
    Both locally and on the server, i'm using the same datasource. Even locally i'm connecting the database on the Server.
    I would appreciate your help.

    It seems i'm posting in the wrong forum, please guide where can I post this question, to find someone who could have experience with Visual Studio and Crystal Report.
    I have 3 RPT files on my project, 2 generated successfully, only one is failing, because i'm using a script on the RPT file to suppress a field if the value is null or empty.
    So the statement of Crystal Report version 11.x not working with SQL Server 2012 is totally out of the subject.
    here is my code, for someone who knows how to read it:
    CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
    System.IO.DirectoryInfo TemplatesPath = new System.IO.DirectoryInfo(System.Web.Hosting.HostingEnvironment.MapPath("~/rptTemplates"));
    string templateFile = TemplatesPath + "/" + "FormListAddons.rpt";
    rpt.Load(templateFile);
    var table = dbmgr.listClients(in_group_id);
    rpt.SetDataSource(table);
    System.IO.DirectoryInfo FilePath = new System.IO.DirectoryInfo(System.Web.Hosting.HostingEnvironment.MapPath("~/UserGeneratedReports"));
    string FileName = "FormList_" + in_group_id.ToString() + ".pdf";
    if (System.IO.File.Exists(FilePath + "/" + FileName))
    System.IO.File.Delete(FilePath + "/" + FileName);
    rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, FilePath + "/" + FileName);
    rpt.Dispose();
    rpt.Close();

  • Dynamic field name in an assignment statement

    Greetings,
    Is it possible to make the field name of an assignment dynamic?
    For example if I have two text fields called P1_F1 and P1_F2. Is it possible to
    do something like this?
    declare
    X number := 0;
    begin
    X := 1;
    :P1_F || X   = 'value1';
    X := 2;
    :P1_F || X   = 'value2';
    end;Any suggestions would be appreciated.
    Thanks
    Larry

    Use the <tt>apex_util.set_session_state</tt> API method.

  • 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

  • Dynamic field names in internal operations

    Dear experts,
    I have a period range in selection screen (peri_from and peri_to); I have to work on an internal table (defined like COSP) where I have amount1 amount2...amount16, in other words one field for each period...
    I have to sum up only amounts within the period range as in selection screen...
    How can I do this dynamic summation ?
    Example:
    peri_from = 004
    peri_to = 006
    Then my code must calculate:
    result = amount4 + amount5 + amount6.
    Thanks in advance for any useful suggestion (field symbol ?)
    Bye,
    Roberto

    Hi roberto,
    1. We have to use
       a) field-symbols
       b) dynamic variable name (for field1,field2)
    2. Just as u want.
       (just copy paste)
    3. It will ask
        a) from , to
        b) print the sum
    4.
    report abc.
    DATA : AMOUNT1 TYPE I,
           AMOUNT2 TYPE I,
           AMOUNT3 TYPE I,
           AMOUNT4 TYPE I,
           AMOUNT5 TYPE I.
    DATA : VARNAME(30) TYPE C.
    FIELD-SYMBOLS : <fs>.
    DATA : CTR TYPE I.
    DATA : CTRC(2) TYPE C.
    DATA : TOT TYPE I.
    PARAMETERS : MYFROM TYPE I DEFAULT 2.
    PARAMETERS : MYTO TYPE I DEFAULT 5.
    start of selection
    START-OF-SELECTION.
      AMOUNT1 = 1.
      AMOUNT2 = 2.
      AMOUNT3 = 3.
      AMOUNT4 = 4.
      AMOUNT5 = 5.
      CTR = MYFROM - 1.
      DO.
        CTR = CTR + 1.
        IF CTR > MYTO.
          EXIT.
        ENDIF.
        CTRC = CTR.
        CONCATENATE 'AMOUNT' CTRC INTO VARNAME.
        ASSIGN (VARNAME) TO <FS>.
        TOT = TOT + <FS>.
        WRITE :/ <FS>.
      ENDDO.
    WRITE TOTAL
    WRITE :/ TOT.
    regards,
    amit m.

  • Is there a way to rename multiple form field names with a "b" at the end?

    I have a two page form, both are identical.  I need to rename all the field names on page 2 with a "b" at the end of the file name so they dont conflict with that of the first page.  Is there any fast way of doing this without renaming each individual one at at time?  I have a LOT to do!

    It's not possible with JavaScript. The name property of a field is read-only.
    I would suggest making a template from the first page and then spawn a new page from it.
    If you do it from a script make sure you set the bRename property to true and the form fields will be automatically renamed, but you can't specify the name, it will be in following pattern:
    P<Page Number>.<Template Name>.<Original Field Name>

  • Displaying Field Names in a list on the next page

    In my BIP template I have a table that lists field names and underneath I have a for-each statement that lists values.
    Is there anyway that I can list the field names on the next page when the number of records start to run onto the next page?
    Thanks
    Steve

    Select the field names row, right click -> table properties and check the 'Repeat as header row at the top of each page'

  • Accessing dynamic field names?

    I want to be able to create text fields with unique names and
    set values in them within a For-loop without having to reference
    the field names in the code.
    Consider the following code snippet:
    this.createTextField("field" + i, this.getNextHighestDepth(),
    x1, y1, 250, 20);
    It places a text field into a movie clip with name that is a
    composite of a literal value and a variable value resulting in
    names like field1, field2, etc. My question: Is there anyway to use
    a composite field name to access the field properties? For example:
    Can I set the text for the field using the same composite name
    without having to express it as a literal field name? If I can't
    then what is the point of having the composite name capability?

    You can drop the last question because the answer to the
    prior one(s) is "yes".
    this["field"+i].text = "whatever";
    the bracket notation causes a string to be evaluated as an
    object/instance.

  • Inserting Field Names as Header while downloading the file

    Hi,
    I am downloading one file using CALL METHOD cl_gui_frontend_services=>gui_download and wanted to add field names as header while downloading.I have the filed names in one internal table and have written the code as follows:
       LOOP AT gt_import INTO gw_import.
          gw_fldname-field_name = gw_import-field_name.
          APPEND gw_fldname TO gt_fldname.
        ENDLOOP.
    Here gt_fldname has the field names.
          l_descr_ref ?= cl_abap_typedescr=>describe_by_data( gt_fldname ).
          CLEAR : l_counter.
          LOOP AT l_descr_ref->components[] ASSIGNING <lfs_comp_wa>.
            l_counter = l_counter + 1.
            ASSIGN COMPONENT sy-index OF STRUCTURE gt_fldname TO <lfs_comp>.
            IF sy-subrc = 0.
              <lfs_comp> = <lfs_comp_wa>-name.
            ENDIF.
          ENDLOOP.
       CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            filename                = pdir1
            filetype                = text-038
            append                  = ''
            write_field_separator   = 'X'
          CHANGING
            data_tab                = <lfs_comp>
          EXCEPTIONS
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
            not_supported_by_gui    = 22
            error_no_gui            = 23
            OTHERS                  = 24.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            filename                = pdir1
            filetype                = text-038
            append                  = 'X'
            write_field_separator   = 'X'
          CHANGING
            data_tab                = <gfs_table1>
          EXCEPTIONS
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
            not_supported_by_gui    = 22
            error_no_gui            = 23
            OTHERS                  = 24.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
    But it goes to dump at       l_descr_ref ?= cl_abap_typedescr=>describe_by_data( gt_fldname ) where I am trying to make the filed names horizontal.
    Can anyone help on this?

    The issue has been resolved after writting:
          l_ref_table ?= cl_abap_tabledescr=>describe_by_data( gt_fldname ).
          l_descr_ref ?= l_ref_table->get_table_line_type( ).
    Thanks.

  • Create dynamic field names

    I'm creating a PDF form using iText which takes information from a webpage which has multiple order entries. On my PDF i need to loop through this list and create individual PdfFormFields. The problem is I do not know how many items are ordered. How can I create different form fields?
    i.e.
    for(int i=0; i<orderVector.size(); i++) {
    PdfFormField qty = text.getTextField();
    // each time it loops i need qty to be a different name like qty1, qty2....
    // how do I accomplish this?
    Thanks for you help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    How can I create different form fields?You can't dynamically set variable names. But the good news is that you don't
    have to.PdfFormField[] qtyArr = new PdfFormField[orderVector.size()];
    for(int i = 0; i < orderVector.size(); i++) {
        qtyArr[i] = text.getTextField();
    }This creates just the right number of form fields, referred to as qtyArr[0], qtyArr[1], etc.
    Is there some reason why you are using Vector and not ArrayList?

  • Displaying Field Names in ALV GRID

    hi,
         I have a requirement that i have to display the type of the GL Indicators.
         Now i want the corressponding name/desc of that GL indicator to be displayed down in the ALV GRID.Can any one tell how can i solve this issue..
    For Ex.
    This is my ALV GRID.
        Comp_Code     Vendor_Id       GL_indicator 1          GL_indicator 2
                                                          ABC                         EDF                 
         1000                1000001           20000.00                    500.00
    In this ABC and EDF are the desc of GL_indicator 1 and GL_indicator 2 resp..
    How can i display such type of ALV..
    Rewards points will be given
    Thank You.

    Hi,
    Check the below test code......You will understand.
    TYPE-POOLS: SLIS.
    DATA: GT_OUTTABH TYPE SCARR OCCURS 0 WITH HEADER LINE,
          GT_OUTTAB TYPE SFLIGHT OCCURS 0 WITH HEADER LINE,
          GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE ,
          GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
          GS_KEYINFO  TYPE SLIS_KEYINFO_ALV,
          G_REPID LIKE SY-REPID.
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE .
    DATA:
        GT_EVENTS      TYPE SLIS_T_EVENT,
        GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
        G_STATUS_SET   TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
        G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
        G_TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
        G_TOP_OF_LIST  TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
        G_END_OF_LIST  TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
    INITIALIZATION.
    define keyinfo
      CLEAR GS_KEYINFO.
      GS_KEYINFO-HEADER01 = 'CARRID'.
      GS_KEYINFO-ITEM01   = 'CARRID'.
      GS_KEYINFO-HEADER02 = SPACE.
      GS_KEYINFO-ITEM02   = 'CONNID'.
      G_REPID = SY-REPID.
      GS_LAYOUT-GROUP_CHANGE_EDIT = 'X'.
      GT_SORT-FIELDNAME = 'CURRCODE'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 1.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = '*'.
      APPEND GT_SORT.
      GT_SORT-FIELDNAME = 'CARRID'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 2.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = ' '.
      APPEND GT_SORT.
      GT_FIELDCAT-FIELDNAME    = 'PRICE'.
      GT_FIELDCAT-tabname    = '2'.
      GT_FIELDCAT-outputlen    = 12.
      GT_FIELDCAT-DO_SUM       = 'X'.
      APPEND GT_FIELDCAT.
      GT_FIELDCAT-FIELDNAME    = 'CARRID'.
      GT_FIELDCAT-tabname    = '1'.
      GT_FIELDCAT-outputlen    = 6.
      GT_FIELDCAT-DO_SUM       = space.
      APPEND GT_FIELDCAT.
      PERFORM EVENTTAB_BUILD USING GT_EVENTS[].
    START-OF-SELECTION.
      SELECT * FROM SCARR INTO CORRESPONDING FIELDS
           OF TABLE GT_OUTTABH.
      SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS
      OF TABLE GT_OUTTAB.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM      = G_REPID
                I_STRUCTURE_NAME_HEADER = 'SCARR'
                I_STRUCTURE_NAME_ITEM   = 'SFLIGHT'
                IS_KEYINFO              = GS_KEYINFO
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
                I_TABNAME_HEADER        = '1'
                I_TABNAME_ITEM          = '2'
                IT_EVENTS               = GT_EVENTS[]
                IT_SORT                 = GT_SORT[]
           TABLES
                T_OUTTAB_HEADER         = GT_outtabh
                T_OUTTAB_ITEM           = GT_outtab.
          FORM EVENTTAB_BUILD                                           *
    FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
    *"Registration of events to happen during list display
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = RT_EVENTS.
      READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO RT_EVENTS.
      ENDIF.
    ENDFORM.
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
      REFRESH GT_LIST_TOP_OF_PAGE.
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'H'.
      LS_LINE-INFO = '<Header>'.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
    STATUS LINE: TYPE S
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = '<Status1>'.
      LS_LINE-INFO = GT_OUTTABH-CURRCODE.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.
    Regards,
    Omkar.

  • Materialized view with dynamic column names !

    hello,
    i need some help , i'm trying ( i got no where so far :) ) to create a materialized
    view that has dynamic field name values , so every time the view is refreshed
    the fields are renamed.
    i have been asked to create a decade summary view and to assign year values to field names,the years should be table columns ( not rows !? ) and thus i should reflect this fact to the column names.
    i know its a wierd request but is there anway to do it ?
    i dunno about it at least,
    Thanks !

    ...or you could define the materialised view neutrally e.g. with columns like YEAR1, YEAR2 etc.
    Then create a dynamically-defined view on top of this view, after it's refreshed, using the relevant years as column names. SELECT year1 AS "1991", year2 AS "1992" etc.
    I still don't see how anybody is going to use these views as they won't know what the "year" columns are called.
    And if the same materialised view is going to have different sets of data each time it's refreshed i.e. different sets of years, are you re-defining the selection criteria each time? If so, why not just define separate views?
    It's a weird world out there...

  • Output Technical Field Names in the SAP query Output

    Hi Experts,
    I am new to SAP Query/ABAP Query or Quick Viewer. Just would like to know if there is a way whereby I can print the technical field names as opposed to the English field headers. For example I want to print BUKRS in the place of CoCode.
    I have a vague feeling this could be possible through custom coding in SQ02 but have no idea which code section to choose.Any inputs greatly appreciated.
    thanks in advance,

    Hi Sreegopalan,
    Open your infoset in SQ02, by default in the left hand side you'll be having the tables that you have selected, double click the field name which you want change the long text, it will open a attributes window below your field group. Change the header data text as you wish.
    Please find the query documentation in the below link.
    [http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVQUE/BCSRVQUE.pdf]
    Regards,
    Nandha

Maybe you are looking for

  • How to find the user who created record on PA_TRANSACTION_INTERFACE_ALL ?

    We are trying to develop a custom workflow to send Project WebADI transactions through workflow approval. My problem is, from the PA_TRANSACTION_INTERFACE_ALL table where the interface records are populated, I cant find the user responsibile. (Notifi

  • Why Can't I play videos

    I watch nfl.com on my pc, but when I click on one of the video highlights, the screen comes up, says video is loading but nothing happens. Just blank screen

  • Master Grid in SAP AFS

    Hi, Can someone provide some info on Master Grid data related to AFS ? What are the sample Master Grid tables, Sales Grid tables, etc...

  • Error in BODS and SAP connectivity

    Hi, We are trying to fetch the data from SAP thru ETL tool BODS; while doing so we are facing the following issues : 1.        While connecting to SAP RFCu2019s through BODS, we are getting the following error u2018RFC CallReceive error <Function RFC

  • HELP V_V2 ATP

    Hello Experts, I created two sales order. The value of stock is zero. I confirmed the dates of ATP.  I created a purchase order. Example SALES ORDER      QTY      SHIP DATE 140024379              50         23.07.2010 140024380              250