Alv report to have 2 lines for column header

How do I set the column header to have 2 lines?
eg
          Week Ending  --- 1st  line
           09.10.2007    ---  2nd line
My report always ends up with 2 detail lines when I tried to insert it into the catalog.

Try this it may help you for multiple values for one instance....
*Type-pools
TYPE-POOLS: slis.
Data declarations.
DATA: BEGIN OF t_vbak OCCURS 0,
vbeln TYPE vbeln,
bstnk TYPE vbak-bstnk,
erdat TYPE vbak-erdat,
kunnr TYPE vbak-kunnr,
END OF t_vbak.
DATA: BEGIN OF t_vbap OCCURS 0,
vbeln TYPE vbeln,
matnr TYPE vbap-matnr,
netpr TYPE vbap-netpr,
waerk TYPE vbap-waerk,
kwmeng TYPE vbap-kwmeng,
meins TYPE vbap-meins,
END OF t_vbap.
DATA: t_fieldcatalog1 TYPE slis_t_fieldcat_alv.
DATA: t_fieldcatalog2 TYPE slis_t_fieldcat_alv.
DATA: v_repid TYPE syrepid.
DATA: s_layout TYPE slis_layout_alv.
DATA: v_tabname TYPE slis_tabname.
DATA: t_events TYPE slis_t_event.
start-of-selection event.
START-OF-SELECTION.
v_repid = sy-repid.
Get the fieldcatalog for the first block
PERFORM get_fieldcat1 CHANGING t_fieldcatalog1.
Get the fieldcatalog for the second block
PERFORM get_fieldcat2 CHANGING t_fieldcatalog2.
Get the data for the first block
SELECT vbeln bstnk erdat kunnr UP TO 10 ROWS
INTO TABLE t_vbak
FROM vbak WHERE vbeln > '0060000100'.
Get the data for the second block
SELECT vbeln matnr netpr waerk kwmeng meins UP TO 10
ROWS
INTO TABLE t_vbap
FROM vbap WHERE vbeln > '0060000100'.
init
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid.
First block
v_tabname = 'ITAB1'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcatalog1
i_tabname = v_tabname
it_events = t_events
TABLES
t_outtab = t_vbak.
Second block
v_tabname = 'ITAB2'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = s_layout
it_fieldcat = t_fieldcatalog2
i_tabname = v_tabname
it_events = t_events
TABLES
t_outtab = t_vbap.
*Display
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
FORM GET_FIELDCAT1
Get the field catalog for the first block
FORM get_fieldcat1 CHANGING lt_fieldcatalog TYPE
slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
Order number
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'VBELN'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Customer purchase order.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BSTNK'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'BSTNK'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Creation date.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'ERDAT'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Customer
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'T_VBAK'.
s_fieldcatalog-ref_tabname = 'VBAK'.
s_fieldcatalog-ref_fieldname = 'KUNNR'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
ENDFORM.
FORM GET_FIELDCAT2
Get the field catalog for the second block
FORM get_fieldcat2 CHANGING lt_fieldcatalog TYPE
slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
Order number
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'VBELN'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Material number
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'MATNR'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Net price
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'NETPR'.
s_fieldcatalog-cfieldname = 'WAERK'.
s_fieldcatalog-ctabname = 'T_VBAP'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Currency.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'WAERK'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'WAERK'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
Quantity
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'KWMENG'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'KWMENG'.
s_fieldcatalog-qfieldname = 'MEINS'.
s_fieldcatalog-qtabname = 'T_VBAP'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
UOM
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'MEINS'.
s_fieldcatalog-tabname = 'T_VBAP'.
s_fieldcatalog-ref_tabname = 'VBAP'.
s_fieldcatalog-ref_fieldname = 'MEINS'.
APPEND s_fieldcatalog TO lt_fieldcatalog.
CLEAR s_fieldcatalog.
ENDFORM.
ALV Report to have two different Reports
Plz Reward points if contents are useful,,,

Similar Messages

  • Breaking line in column header

    Hi,everybody
    How can I break the line in column header for two lines?
    Regards,
    Michael

    Hi michael,
    As per my knowledge the webdynpro accomodates the text you given as column header.I did so many experiments on this in my previous developement.There is no option to break the column header.See one thing if the number of columns are more in your table and the headers are too large and if you restrict the table size then this might will break the column header because of  table width.I am not sure.But there is no options to control this by the developer.This is totally the results of my experiments.If you acheive this please give me the procedure.
    Thanks and regards
    venkatakalyan K

  • ALV report: How to merge 2 columns into 1 column?

    Hello,
    I have a list of data which I would like format the header to look as below:
    | -
    Quater 1---- | -
    Quater 2 -
    | -
    Quater 3---- | -
    Quater 4---- |  <--- header 1
    | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | <--- header 2
    | -
    F---- | -
    S- | -F-- | -
    S- | -F-- | -
    S- | -F-- | -
    S- | <- header 3
    xxxxxxx | xxxxxx | xxxxx | xxxxx | xxxxxx | xxxxx | xxxxxx | xxxxx |  <--- data lines start here....
    Is there anyway I able to achieve this layout?
    I found quite a numerous of "cell_merge" information on ALV but I do not know how exactly it work and how to modify it?
    Would be appreaciate if anyone of you able to guide me with sample code.
    Thanks in advance,
    Aish :P

    Hi,
    U can do this by using Row position in FIELD CATALOG.
    Steps are:
    u2022     First we have to declare an internal table of output type with few dummy character type fields.
    u2022     Use this structure when populating field catalog.
    u2022     When populating field catalog we have to change row position, column position, offset value, field length, text, reference table and field name (if required), justification etc.
    u2022     Pass this field catalog as exporting parameter into function module u2018REUSE_ALV_LIST_DISPALYu2019.
    Type declaration for Output table
         TYPES: BEGIN OF ty_address,
             add_detl(1)     TYPE c,            u201CDummy field
             add_init(1)     TYPE c,            u201CDummy field
             pers_detl(1)    TYPE c,            u201CDummy field
             res_detl(1)     TYPE c,            u201CDummy field
             off_detl(1)     TYPE c,            u201CDummy field
             addrnumber      TYPE ad_addrnum,   "Address number
             name1           TYPE ad_name1,     "First Name
             name2           TYPE ad_name2,     "Middle Name
             name3           TYPE ad_name3,     "Last Name
             home_city       TYPE ad_city3,     "Residential City
             city2           TYPE ad_city2,     "District
             post_code1      TYPE ad_pstcd1,    "Residential postal code
             city1           TYPE ad_city1,     "Office City
             post_code2      TYPE ad_pstcd2,    "Office postal code
             tel_number      TYPE ad_tlnmbr1,   "First telephone no.
             tel_extens      TYPE ad_tlxtns1,   "First Telephone No.: Extension
             fax_number      TYPE ad_fxnmbr1,   "First fax no.
           END OF ty_address.
    In the above type declaration first five fields are used to populate field catalog only for the first and second line headings. These fields do not contain any data.
    Main processing:
    To get multiple line ALV layout we have to declare few dummy fields. When we build field catalog, then we have to put those dummy fields in proper places. In our example last 12 fields are known as valid fields with data and first 5 fields (1 at first line and 4 at second line) are knows as invalid or dummy variables containing no data.
    When we build field catalog, we call a perform name CREATE_CATALOG using
                                                    Column position          Row position
                                         Field name                   Table name
                                         Justification             Text heading
                                         Reference table         Reference field
                                         Output length       Offset value
    For the first row, we have to set row position 1, column position 1. When we call the perform we have to pass, these two values in addition with dummy field name (ADD_DETL), table name (I_ADDRESS), justification (left or right), text (Address Details), Reference table and Reference field name (we can pass SPACE, if not required), Output length and Offset value (Length from left margin or last field, for the first row it is 225. Means the text u201CAddress Detailsu201D  will be printed at 225th char position).
      l_off    = 225.        "Offset Value
      l_pos    = 1.          "Column position
      l_row    = 1.          "Row position
      l_just   = u2018Lu2019.        "Allignment (u2018Lu2019 for Left)
      l_outlen = 50.         "Field length
    Address Details *****************
      PERFORM    create_catalog USING
      l_pos l_row 'ADD_DETL' 'I_ADDRESS' l_just text-002 space space l_outlen  
      l_off.
    Perform CREATE_CATALOG is used to append the field catalog table with the passing parameters.
    SUBROUTINE ***************************************
    FORM create_catalog  USING    p_pos     TYPE sycucol
                                  p_row     TYPE sycurow
                                  p_field   TYPE any
                                  p_tab     TYPE any
                                  p_just    TYPE char1
                                  p_text    TYPE reptext
                                  p_reftab  TYPE any
                                  p_reffld  TYPE any
                                  p_outlen  TYPE outputlen
                                  p_off     TYPE outputlen.
      s_fieldcat-col_pos            = p_pos.     "Column position
      s_fieldcat-row_pos            = p_row.     "Row position
      s_fieldcat-fieldname          = p_field.   "Field name
      s_fieldcat-tabname            = p_tab.     "Table name
      s_fieldcat-just               = p_just.    "Justification
      s_fieldcat-reptext_ddic       = p_text.    "Text heading
      s_fieldcat-ref_tabname        = p_reftab.  "Reference table
      s_fieldcat-ref_fieldname      = p_reffld.  "Reference field
      s_fieldcat-outputlen          = p_outlen.  "Output length
      s_fieldcat-offset             = p_off.     "Offset value
      APPEND s_fieldcat TO i_fieldcat.
      CLEAR  s_fieldcat.
    ENDFORM.                    " create_catalog
    Regards,
    Joy.

  • Background color for column heading

    Hi,
    I have 5 columns in my report and I would like to have different background color for column headings. How can I do this in report templates?
    I was looking at Column heading section-
    <th class="t10ReportHeader"#ALIGNMENT# id="#COLUMN_HEADER_NAME#">#COLUMN_HEADER#</th>
    How can I specify backgrund colors for all columns here?
    Thanks in advance

    G'day Karen,
    Thanks for ur reply.
    I have seen this note before, its not that the header colors have changed after latest SP was applied in our systems. Also the ABAP and JAVA stacks are in sync.
    Scenario is that we are trying to set up a new Portal theme for Enterprise Reporting with some specific color codes (hex codes).
    What i have observed is Characterstics Header background color is set up using the element "Background Color of Level 1 Column Heading ".
    While the Background color for Key Figures header is using element "Background Color of Level 2 Column Heading ".
    But the problem is element "Background Color of Level 2 Column Heading " is also used as the Background color for Standard Characterstics cell, so if we make it same the whole report of the same color, which we dont want.
    Requirement is to get the same Background color for Header cells (both Char. and Key Figure headers).
    Any further suggestions will be appreciated.
    Thanks
    CK

  • In BI Bex Query Designer output, dont want to have unit at column Heading..

    Hi
    I have a BI Bex Query Designer report showing output with Qty unit at Column Heading level. Even in KF's Text i didn't mention unit. I want unit to appear to column fields instead of column heading. Pls let me know how to do that.
    One more thing is: i have 2 reports exactly same except due date range is different. first report showing unit for each KF at the column heading level and for 2nd report showing column fields level... Surprising. Pls let me know what is the reason and how to control it.
    Thanks...

    Hi Harpal,
    Key figures can have scaling factors and units/currencies. Normally, units/currencies are displayed for every key figure, but not the scaling factors. If you activate the Display Scaling Factors for Key Figures, an additional header row is added to the row or column header. Information about the scaling factor and currency/unit appears in this additional header row, as long as it is consistent (for example, 1,000 EURO).
    For more information, You can go through
    http://help.sap.com/saphelp_nw04/helpdata/en/e0/52029f961aa84d869b9b20fa7f7646/frameset.htm
    Hope it helps & resolves your issue.
    Regards,
    Pavan

  • Missing horizontal lines in column header

    Post Author: cr101
    CA Forum: General
    I have a 5-page report, sometimes the lines that separates the column header and report content are missing. Does anyone know why?
    Thanks.

    Post Author: V361
    CA Forum: General
    Not from your description.   if you look in report preview, is it a group header or footer that is causing the hole.  Where do you have the line placed?  Where is it missing from ? and when.  Can you post some sample data ?

  • Reg: ALV report download to excel currency columns

    Hi All,
    While downloading the alv report to excel, currency fields with negative sign(less than 0) is downloading without negative sign.
    And field catalog wad declared as 'CURR' field for that particular column, if I declared as 'CHAR', i am getting shortdump.
    Can any one tell me how to get the negative sign.
    Thanks in advance.

    Hi,
    Do you use ALV to excel standard functionality or your own code to excel?
    Please provide more information.
    Thanks,

  • Report Painter - Format group for columns in more than one section

    How do have different decimals for columns in different sections.
    For. e.g I have three sections
    one for quantity (I do not need decimals)
    two for dollars (I do not need decimals)
    three for formula dollar upon quantity (I need to have two decimals)
    I made format group 0 (with no decimals) for first two sections and format group 1 (with two decimals) for the last section.
    4.6c does not consider format group 1 and makes every section look alike with format group 0 i.e, no decimals.
    How to overcome this?

    Anders,
    I replied earlier but after reading you post several times I realized that I probably misunderstood what you want. This is what I now understand. You have several resources, each of who may work on various parts of design tasks, assembly tasks, and test
    tasks. For example, let's say your resources are Joe, Bill & Tom. Joe is assigned to a design and test task, Bill is assigned to an assembly and test test task and Tom is assigned to a design task, an assembly task and a test task (Tom is very versatile).
    You would like to see a report showing just the assembly tasks and the amount of work each of the three resources is assigned on those tasks.
    Assuming the above is a correct interpretation, you will need to employ three processes, some VBA, grouping and filtering.
    1. First, designate a custom text field for group identification (e.g. use Task Text1 to enter "design", "assembly", or "test" for each task)
    2. In order to use grouping and filtering effectively,  you will need to translate the Task Text1 information to the Assignment Text1 field. To do that, go to the MVP website at: http://project.mvps.org/faqs.htm, and run the macro in FAQ 37.
    3. Now go to the Task Usage view and set up a group with Text1 as the first group by element and Name as the second group by element. Check the box to group assignments and not tasks. Then select "assignment" for field type of the second element
    (i.e. Name).
    4. Apply the group
    5. To show only the work hours for each resource in a specific group, autofilter on the desired group. Note, if you do not run the macro to populate the Assignment Text1 field with the Task Text1 field, the filter will yield nothing.
    Hope this helps
    John

  • How to download ALV report having more than 200 columns to Excel

    Dear Experts,
    I am facing the issue of line break during downloading ALV report into excel. I referred the lot of forums but i didn't get the proper solution to solve this issue..Please guide me to solve this issue....
    My output in ALV
    header1 header2..........header200
    but when i download that to spreadsheet i am getting like this
    header1 header2.....
    header65 header66....
    header199...
    Regards,
    Rathish
    Edited by: joerathish on Jun 3, 2011 9:53 AM

    joerathish wrote:
    not working well.
    Do you get a excel with empty sheet with excel in place ?
    Then you need to enable macro in trust center of excel sheet settings. The way you do this depends on the version of excel you are using.
    I am able to get 200+ columns perfectly this way.
    Regards

  • Tooltip for column header sorting

    If I enable column header sorting, is there a way to put a tooltip (HTML 'title' property, I guess) on the column header saying 'Click here to sort by this column'?
    The triangle image shows this alt text but that triangle image is shown only next to the column that is currently sorted, not all the columns.
    [My column headings come from a custom PL/SQL function, not declaratively on the Report Attributes page]
    Thanks

    See
    http://htmldb.oracle.com/pls/otn/f?p=24317:28
    The following seems to work.
    Add this javascript to the Page Attributes Header section
    <script type="text/javascript">
    function AddTooltip()
    var l_link;
    var l_hrefs=document.links;
    for (var i=0; i < l_hrefs.length; i++) {
       l_link=l_hrefs;
    if (l_link.href && l_link.href.indexOf('fsp_sort_')>=1) {
    l_link.title="This is a tooltip"
    </script>
    Then call it from the onLoad as follows
    onLoad="AddTooltip();"
    Seems to work like a charm.
    Thanks
    BTW, anyone know how to prevent the [ i ] inside a [ pre ] from being interpreted as an italic tag? I thought all text inside a PRE tag is left untouched?

  • ALV report shows fixed number of columns for a user ?

    Hello,
    I have an issue wherein I have created an ABAP ALV grid display in a WD ABAP application and hosted it onto portal. Now, all the users can see the correct number of columns for the report which are determined dynamically. But just for one user, irrespective of which report she launches it shows her only 4 columns.
    Can anybody suggest why this kind of behavior.
    Appreciate your help.
    Regards,
    Samta.

    Hi,
    Right, click the button "manage layout" or "save layout" and remove any default user settings...
    added: didn't read carefully sorry ;)... better check user settings in SU01 if no ALV parameter is used.
    Kr,
    m.
    Edited by: Manu D'Haeyer on Oct 21, 2011 8:53 PM

  • ALV Report to have two different Reports

    Hi All,
    I have a need to display two different reports for the same set of data selections, (Successful data and Error Data) in a Single ALV Layout using a Application tool bar Button. Does anyone have a sample code for this kind of requirement. Preferably using Objects.
    Also, how can we check if an object is already created? In other words, how to check for a null reference?
    Thanks in advance.
    Jr.

    Sample code for split alv using OOABAP.
    this would help you in ur requirement.
    go through this program where the screen is divided in two for two alv in different containers.
    DATA: save_ok LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CC1',
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          g_max TYPE i VALUE 100.
    declarations for top of page event
    Data:  gv_c_split type ref to cl_gui_splitter_container,
           gv_c_ptv type ref to cl_gui_container,
           gv_alv_ptv type ref to cl_gui_alv_grid,
           o_dd_doc TYPE REF TO cl_dd_document,
           text TYPE sdydo_text_element,
           o_split type ref to cl_gui_easy_splitter_container,
           o_top type ref to cl_gui_container,
           o_bot type ref to cl_gui_container,
           gv_c_vp type ref to cl_gui_container.
    end of declaration for top of page.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    *class lcl_application_dc definition deferred.
    DATA: o_event_receiver TYPE REF TO lcl_event_receiver.
         g_dc type ref to lcl_application_dc.
    DATA: gt_outtab TYPE TABLE OF sbook.
          CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS: handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
                   IMPORTING e_fieldname
                             es_row_no
                             er_event_data
                             et_bad_cells
                             e_display,
                handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid
                   IMPORTING e_dyndoc_id.
        METHODS: reset.
        METHODS: show_f4.
      PRIVATE SECTION.
    attributes for creating an own F4-Help
    (using a second ALV Grid Control
        DATA: f4_grid TYPE REF TO cl_gui_alv_grid,
              f4_custom_container TYPE REF TO cl_gui_custom_container.
        TYPES: BEGIN OF ty_f4.
        TYPES: value TYPE s_class.
        TYPES: descr(20) TYPE c.
        TYPES: END OF ty_f4.
        DATA: f4_itab TYPE TABLE OF ty_f4.
        DATA: f4_fieldcatalog TYPE lvc_t_fcat.
    attributes to store event parameters
    (after the CALL SCREEN command, the event parameters
    are not accessible)
        TYPES: BEGIN OF onf4_event_parameters_type.
        TYPES: c_fieldname     TYPE lvc_fname.
        TYPES: cs_row_no       TYPE lvc_s_roid.
        TYPES: cr_event_data   TYPE REF TO cl_alv_event_data.
        TYPES: ct_bad_cells    TYPE lvc_t_modi.
        TYPES: c_display       TYPE char01.
        TYPES: END OF onf4_event_parameters_type.
        DATA: f4_params TYPE onf4_event_parameters_type.
    Methods to create own F4-Help
    (This is done using a second ALV Grid Control)
        METHODS: init_f4.
        METHODS: build_fieldcatalog.
        METHODS: fill_f4_itab .
        METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
                        IMPORTING es_row_no.
    ENDCLASS.                    "lcl_application_f4 DEFINITION
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    *§2. Implement an event handler method for event ONF4.
      METHOD handle_f4.
    Save event parameter as global attributes of this class
    (maybe solved differently if you use a function module!)
        f4_params-c_fieldname = e_fieldname.
        f4_params-cs_row_no = es_row_no.
        f4_params-cr_event_data = er_event_data.
        f4_params-ct_bad_cells = et_bad_cells.
        f4_params-c_display = e_display.
    *§3. Call your own f4 help. To customize your popup check
       first if the cell is ready for input (event parameter E_DISPLAY).
    (parameter E_DISPLAY is checked later in method on_double_click)
    (Probably, you would call a function module at this point,
    pass the needed event parameter and call the popup screen
    within that function module. This is not done in this example
    to avoid scattering its code).
        CALL SCREEN 101 STARTING AT 10 10.
    *§7. Inform the ALV Grid Control that an own f4 help has been processed
       to suppress the standard f4 help.
        er_event_data->m_event_handled = 'X'.
      ENDMETHOD.                                                "on_f4
      METHOD show_f4.
       DATA: ls_outtab TYPE sbook.
    initialize own f4 help if needed
        IF f4_custom_container IS INITIAL.
          CALL METHOD init_f4.
        ENDIF.
        CALL METHOD fill_f4_itab.
    refresh list of values in f4 help and show it
        CALL METHOD f4_grid->refresh_table_display.
    CAUTION: Do not use method REFRESH_TABLE_DISPLAY for
    your editable ALV Grid instances while handling events
    DATA_CHANGED or ONf4. You would overwrite intermediate
    values of your output table on frontend.
    'f4_grid' is a non-editable ALV Grid Control for the
    application specific F4-Help. Therefore, calling
    REFRESH_TABLE_DISPLAY for this instance has no
    negative effect.
        CALL METHOD cl_gui_cfw=>flush.
      ENDMETHOD.                                                "show_f4
      METHOD init_f4.
        DATA: ls_f4_layout TYPE lvc_s_layo.
    build fieldcatalog entries for f4
        CALL METHOD build_fieldcatalog.
    create controls
        CREATE OBJECT f4_custom_container
                  EXPORTING container_name = 'CC_ONF4'.
        CREATE OBJECT f4_grid
                  EXPORTING i_parent = f4_custom_container.
    hide toolbar
        ls_f4_layout-no_toolbar = 'X'.
        CALL METHOD f4_grid->set_table_for_first_display
          EXPORTING
            is_layout       = ls_f4_layout
          CHANGING
            it_fieldcatalog = f4_fieldcatalog
            it_outtab       = f4_itab.
    register event double click on backend
        SET HANDLER me->on_double_click FOR f4_grid.
    flush since 'ls_layout' is local!
        CALL METHOD cl_gui_cfw=>flush.
      ENDMETHOD.                                                "init_f4
      METHOD fill_f4_itab.
        DATA ls_f4_itab TYPE ty_f4.
    Delete all entries in f4_itab to determine
    offered values dynamically
        CLEAR f4_itab[].
        ls_f4_itab-value = 'C'.
        ls_f4_itab-descr = text-t03. "Business Class
        APPEND ls_f4_itab TO f4_itab.
        ls_f4_itab-value = 'Y'.
        ls_f4_itab-descr = text-t04. "Economie Class
        APPEND ls_f4_itab TO f4_itab.
        ls_f4_itab-value = 'F'.
        ls_f4_itab-descr = text-t05. "First Class
        APPEND ls_f4_itab TO f4_itab.
      ENDMETHOD.                    "fill_f4_itab
      METHOD build_fieldcatalog.
        DATA: ls_fcat TYPE lvc_s_fcat.
        CLEAR ls_fcat.
        ls_fcat-fieldname = 'VALUE'.
        ls_fcat-coltext = text-t02.
       ls_fcat-inttype = 'S_CLASS'.
        ls_fcat-outputlen = 5.
        APPEND ls_fcat TO f4_fieldcatalog.
        CLEAR ls_fcat.
        ls_fcat-fieldname = 'DESCR'.
        ls_fcat-coltext = text-t01.
        ls_fcat-inttype = 'C'.
        ls_fcat-outputlen = 20.
        APPEND ls_fcat TO f4_fieldcatalog.
      ENDMETHOD.                    "build_fieldcatalog
      METHOD on_double_click.
    *§5. If not already caught by your own f4 help, check whether
       the triggered cell was ready for input by using E_DISPLAY
       and if not, exit.
        IF f4_params-c_display EQ 'X'.
          LEAVE SCREEN.
        ENDIF.
    *§6. After the user selected a value, pass it to the ALV Grid Control:
    *§  6a. Define a field symbol of type: LVC_T_MODI and a structure of
          type LVC_S_MODI to pass the value later on.
        FIELD-SYMBOLS  TYPE lvc_t_modi.
        DATA: ls_modi TYPE lvc_s_modi,
              ls_f4_itab TYPE ty_f4.
    *§  6b. Dereference attribute M_DATA into your field symbol and add
          the selected value to the table to which this symbol points to.
        ASSIGN f4_params-cr_event_data->m_data->* TO .
        LEAVE TO SCREEN 0.
      ENDMETHOD.                    "on_double_click
      METHOD reset.
        FIELD-SYMBOLS display_document
                 EXPORTING parent = o_top.
      ENDMETHOD.                    "handle_top_of_page
    ENDCLASS.                    "lcl_application_f4 IMPLEMENTATION
    END-OF-SELECTION.
      CALL SCREEN 100.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF g_custom_container IS INITIAL.
        PERFORM create_and_init_alv CHANGING gt_outtab[]
                                             gt_fieldcat.
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = sy-ucomm.
      CLEAR sy-ucomm.
      CASE save_ok.
        WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
          PERFORM exit_program.
        WHEN 'SWITCH'.
          PERFORM switch_edit_mode.
        WHEN OTHERS.
        do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
          FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    *&      Form  build_fieldcat
          text
         -->PT_FIELDCAT  text
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SBOOK'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
    Exchange smoker field with invoice field - just to
    make the dependance between SMOKER and CLASS more transparent
    (Smoking is only allowed in the first class).
        IF ls_fcat-fieldname EQ 'SMOKER'.
          ls_fcat-col_pos = 11.
          ls_fcat-outputlen = 10.
          ls_fcat-edit = 'X'.
    Field 'checktable' is set to avoid shortdumps that are caused
    by inconsistend data in check tables. You may comment this out
    when the test data of the flight model is consistent in your system.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
          ls_fcat-col_pos = 7.
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF    ls_fcat-fieldname EQ 'CLASS'.
          ls_fcat-edit = 'X'.
          ls_fcat-outputlen = 5.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          MODIFY pt_fieldcat FROM ls_fcat.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  create_and_init_alv
          text
         -->PT_OUTTAB    text
         -->PT_FIELDCAT  text
    FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
                                      pt_fieldcat TYPE lvc_t_fcat.
      DATA: lt_exclude TYPE ui_functions,
            ls_layout TYPE lvc_s_layo.
      CREATE OBJECT g_custom_container
              EXPORTING container_name = g_container.
    CREATE OBJECT g_grid
            EXPORTING i_parent = g_custom_container.
      CREATE OBJECT gv_c_split
         EXPORTING
          link_dynnr        = lv_dynnr
          link_repid        = lv_repid
          parent            = g_custom_container
          rows              = 2
          columns           = 1
         EXCEPTIONS
           cntl_error        = 1
           cntl_system_error = 2
           others            = 3    .
      CALL METHOD gv_c_split->set_border
       EXPORTING
         border            = space.
      CALL METHOD gv_c_split->get_container
         EXPORTING
           row       = 1
           column    = 1
         RECEIVING
           container = gv_c_ptv.
      CALL METHOD gv_c_split->set_row_height
        EXPORTING
          id                = 1
          height            = 20
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 6 .
      CALL METHOD gv_c_split->get_container
         EXPORTING
           row       = 2
           column    = 1
         RECEIVING
           container = gv_c_vp .
      CALL METHOD gv_c_split->set_row_height
        EXPORTING
          id                = 2
          height            = 10
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3 .
       CREATE OBJECT o_split
         EXPORTING
          parent            = gv_c_ptv
          with_border       = 1
         EXCEPTIONS
           cntl_error        = 1
           cntl_system_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.
      ENDIF.
    o_top = o_split->top_left_container.
    o_bot = o_split->bottom_right_container.
    CREATE OBJECT gv_alv_ptv
         EXPORTING
           i_parent          = o_bot
         EXCEPTIONS
           error_cntl_create = 1
           error_cntl_init   = 2
           error_cntl_link   = 3
           error_dp_create   = 4
           others            = 5    .
    CREATE OBJECT g_grid
            EXPORTING
              i_parent          = gv_c_vp
            EXCEPTIONS
              error_cntl_create = 1
              error_cntl_init   = 2
              error_cntl_link   = 3
              error_dp_create   = 4
              others            = 5    .
      PERFORM build_fieldcat CHANGING pt_fieldcat.
    Optionally restrict generic functions to 'change only'.
      (The user shall not be able to add new lines).
      PERFORM exclude_tb_functions CHANGING lt_exclude.
      PERFORM build_data CHANGING pt_outtab.
      ls_layout-grid_title = 'F4 help implemented for field CLASS'.
      CREATE OBJECT o_event_receiver.
      SET HANDLER o_event_receiver->handle_top_of_page FOR gv_alv_ptv.
      SET HANDLER o_event_receiver->handle_top_of_page FOR g_grid.
      CREATE OBJECT o_dd_doc EXPORTING style = 'ALV_GRID'
                                       no_margins = 'X'.
      CALL METHOD gv_alv_ptv->set_table_for_first_display
       EXPORTING
         is_layout                    = ls_layout
      CHANGING
        it_outtab                     = pt_outtab[]
        it_fieldcatalog               = pt_fieldcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
          is_layout            = ls_layout
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab[].
      CALL METHOD gv_alv_ptv->list_processing_events
        EXPORTING
          i_event_name      = 'TOP_OF_PAGE'
           i_dyndoc_id       = o_dd_doc.
    register f4 for field CLASS
      PERFORM register_events.
    Set editable cells to ready for input initially
      CALL METHOD g_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  exclude_tb_functions
          text
         -->PT_EXCLUDE text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    Only allow to change data not to create new entries (exclude
    generic functions).
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_data
          text
    -->  p1        text
    <--  p2        text
    FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
      DATA: ls_sbook TYPE sbook,
            l_index TYPE i.
      SELECT * FROM sbook INTO TABLE gt_outtab UP TO g_max ROWS.
      IF sy-subrc NE 0.
        PERFORM generate_entries CHANGING pt_outtab.
      ENDIF.
      LOOP AT pt_outtab INTO ls_sbook.
        l_index = sy-tabix.
        CLEAR ls_sbook-class.
    Alternate between smoker and non smoker to make
    it more obvious what this example is about
        l_index = l_index MOD 2.
        IF l_index EQ 1.
          ls_sbook-smoker = 'X'.
        ELSE.
          ls_sbook-smoker = ' '.
        ENDIF.
        MODIFY pt_outtab FROM ls_sbook.
      ENDLOOP.
    ENDFORM.                               " build_data
    *&      Form  generate_entries
          text
         -->PT_SBOOK   text
    FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
      DATA: ls_sbook TYPE sbook,
            l_month(2) TYPE c,
            l_day(2) TYPE c,
            l_date(8) TYPE c,
         l_prebookid TYPE i.
      ls_sbook-carrid = 'LH'.
      ls_sbook-connid = '0400'.
      ls_sbook-forcurkey = 'DEM'.
      ls_sbook-loccurkey = 'USD'.
      ls_sbook-custtype = 'B'.
      DO 110 TIMES.
        l_prebookid = sy-index.
        ls_sbook-forcuram = sy-index * 10.
        ls_sbook-loccuram = ls_sbook-loccuram * 2.
        ls_sbook-customid = sy-index.
        ls_sbook-counter = 18.
        ls_sbook-agencynum = 11.
        l_month = sy-index / 10 + 1.
        DO 2 TIMES.
          l_day = 3 + l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date+4(2) = l_month.
          l_date+6(2) = l_day.
          ls_sbook-fldate = l_date.
          SUBTRACT 3 FROM l_day.
          ls_sbook-order_date+0(6) = l_date+0(6).
          ls_sbook-order_date+6(2) = l_day.
          ls_sbook-bookid = l_prebookid * 2 + sy-index.
          IF sy-index EQ 1.
            ls_sbook-smoker = 'X'.
          ELSE.
            ls_sbook-smoker = space.
          ENDIF.
          ls_sbook-luggweight = l_prebookid * 10.
          IF ls_sbook-luggweight GE 1000.
            ls_sbook-wunit = 'G'.
            ls_sbook-class = 'C'.
          ELSE.
            ls_sbook-wunit = 'KG'.
            ls_sbook-class = 'Y'.
          ENDIF.
          IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
            ls_sbook-invoice = 'X'.
          ENDIF.
          IF ls_sbook-bookid EQ 2.
            ls_sbook-cancelled = 'X'.
            ls_sbook-class = 'F'.
          ENDIF.
          APPEND ls_sbook TO pt_sbook.
        ENDDO.
      ENDDO.
    ENDFORM.                               " generate_entries
    *&      Form  register_events
          text
    FORM register_events.
    *§1. Register event ONF4 at frontend using method
       register_f4_for_fields. For this purpose, you pass a table
       with all fields, for which you want to implement your own
       f4 help.
    remark: If you want to use an own f4 help for fields where
            no standard f4 help exists set field F4AVAILABL for
            this field in the fieldcatalog.
      DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
      CLEAR lt_f4.
      lt_f4-fieldname = 'CLASS'.
    If you would like to deregister the field again,
    pass value SPACE with field 'register'.
      lt_f4-register = 'X'.
    *§  1b. If the value range in your f4 help depends on other
          values of cells that are input enabled, set the
          GETBEFORE parameter.
    The consequence is that the ALV Grid Control raises
    event DATA_CHANGED before the f4 help is called to
    check values that the f4 help depends on.
      lt_f4-getbefore = 'X'.
    The next parameter is used to change values after onf4 has
    been processed. The ALV Grid Control will raise
    event DATA_CHANGED afterwards, if you set it.
      lt_f4-chngeafter = space.
      INSERT TABLE lt_f4.
      CALL METHOD g_grid->register_f4_for_fields
        EXPORTING
          it_f4 = lt_f4[].
    register events for abap objects (backend)
      SET HANDLER o_event_receiver->handle_f4 FOR g_grid.
    ENDFORM.                    " register_events
    MODULE status_0101 OUTPUT
    MODULE status_0101 OUTPUT.
      SET PF-STATUS 'POPUP'.
      SET TITLEBAR 'POPUP'.
      CALL METHOD o_event_receiver->show_f4.
    ENDMODULE.                 " STATUS_0101  OUTPUT
    *&      Module  USER_COMMAND_0101  INPUT
          text
    MODULE user_command_0101 INPUT.
      PERFORM user_command.
    ENDMODULE.                 " USER_COMMAND_0101  INPUT
    *&      Form  user_command
          text
    FORM user_command.
      DATA: save_ok TYPE sy-ucomm.
      save_ok = sy-ucomm.
      CLEAR sy-ucomm.
      CASE save_ok.
        WHEN 'CANCEL'.
          CALL METHOD o_event_receiver->reset.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  switch_edit_mode
          text
    FORM switch_edit_mode.
      IF g_grid->is_ready_for_input( ) EQ 0.
    set edit enabled cells ready for input
        CALL METHOD g_grid->set_ready_for_input
          EXPORTING
            i_ready_for_input = 1.
      ELSE.
    lock edit enabled cells against input
        CALL METHOD g_grid->set_ready_for_input
          EXPORTING
            i_ready_for_input = 0.
      ENDIF.
    ENDFORM.                    "switch_edit_mode

  • Alv report with varying number of columns

    hi all,
    I am new to abap. I am writing this to get a brief idea of what i wanted to do in system.
    I have to do a report using alv.  The format of the report looks like this.
    acc no     acc. name     amt_sum_april   amt_sum_may   amt_sum_june. ............. total_months
    the colum amt_sum_ depends on user input period(month interval).
    if the user selects 4 to 6 = 3 columns ,if the user selects 4 to 10 = 7 columns
    so on.......
    Anyone have idea how to do it, because in the
    initial structure or itab, the number of columns depends on the user input.. i am stucking here ...
    pls help.
    thanks and regards
    jose

    Hi friend,
    It's very complicated to do that, I'm sure there's a way to do it but I really don't know it. Once I had a similar requirement and I did something else that solved my problem without making a fussy complicated code. I added a colum MONTH or PERIOD (depending on your requirement) and then I make a subtotal by that column. So you need:
    acc no acc. name amt_sum_april amt_sum_may amt_sum_june. ............. total_months
    Now you would have:
    acc no acc. name    month     amount
    In the SORT table, in the sorting condition by MONTH you specify SUBTOTAL = 'X'. So the output will be:
    acc no acc. name    month     amount
    123123        John      2            100.00
    123124        Paul      2            200.00
    Month  2                                300.00
    123123        John      3            300.00
    123124        Paul      3            400.00
    123125        Jane      3            100.00
    Month  3                                 800.00
    123123        John      4            123.54
    Month   4                                123.54
    Total                                      1223.54
    You can change the subtotal text for a more adequate one (if you want). Also if you only need the subtotals you can specify in the layout that only those lines are to be output.
    I hope I've helped, I you have any question let me know!
    Regards,
    Pablo

  • Report  Writer not displaying the column heading correctly.

    Hi,
    We have generated the report writer using the transaction GR55 by logging in EN language.
    But when we executed the report, column headings are not displayed properly, instead it is displayed some thing like $ZR07##ZCO-OI# $.
    Please help us in solving this issue.
    Regards
    Shibin

    Hi,
    Problem solved. We need to generate the report writer in original language only and it will reflect in other languages. Directly if we execute in other language it will display correct headings.
    if we generate in other language it will display wrong heading even in original  language also.
    So generate report writer in original language only
    Regards
    Shibino.

  • Dynamic values for column header / "AS" using XMLFOREST

    Hello,
    I was wondering if it was possible to show data from a select statement into an AS column, e.g. SELECT col.a AS col.b.
    The reason I need this is for XMLFOREST, as I need the value of a SELECT statement to be the column name, so that it will be the value of the element. e.g. <col.b></col.b>
    Anyone know if/how I can do this?

    SQL> ed
    Wrote file afiedt.buf
      1  WITH t AS (SELECT 'fred' name FROM DUAL UNION SELECT 'bob' FROM DUAL)
      2* SELECT XMLELEMENT(EVALNAME name, name) FROM t
    SQL> /
    ERROR:
    ORA-19039: Keyword EVALNAME reserved for future use
    no rows selected
    SQL> ed
    Wrote file afiedt.buf**** Throws a bit of magic dust into SQL...... ****
    SQL> WITH t AS (SELECT 'fred' name FROM DUAL UNION SELECT 'bob' FROM DUAL)
      2  SELECT XMLELEMENT(EVALNAME name, name) FROM t
      3  /
    XMLELEMENT(EVALNAMENAME,NAME)
    <bob>bob</bob>
    <fred>fred</fred>
    SQL>This is an example of what you'll be able to do with 10.2.0.2 when it's released

Maybe you are looking for

  • IPod Touch is no longer under the devices list in 'My Computer' in a PC

    I've read many discussions here and all the replies say that you can't use the iPod touch as a disk to store other files but I was using it like that before. Now it is no longer appearing under the removable devices under 'my computer' and I really d

  • MBA and tv ...

    I just bought from the Apple store the 2 cables needed for sending video to tv from mac book air. but when I connect it through the HDMI, the only thing I see on the tv is the screensaver from my computer and not the movie!. what do I do?

  • Splitting of Cost into Fixed & Variable

    Hi, In our current scenario there is only one cost and there is no split between them. Now my customer wants the cost to be split between fixed & variable. At present we are using KP26 to plan the cost. Here my cost will hit only one cost element (sa

  • Changing names for compressor files, nothing works yet.

    I've read different posts on how people have to change the name of the file before compressor will complete any sort of compression. Happened to me too constantly. So I'd just change the name once I got that red exclamation mark and then it would jus

  • Updated Tiger, now get "no valid packages" waring

    Hello, My Macs are usually outstanding, but I have a problem that I can't solve. I recently used Software Update on three Mac computers to update to the latest version of Tiger (version 10.4.11). Now, all three Macs won't recognize blank media like C