ALV GRID , no relevant data

Hi there i am not getting the relvant data in o/p, also data is not getting populated in the internal table, can ny one plz go thru the code.
REPORT ztst_chin_alv3.
TABLES : lfb1.
   Declarations                                                     *
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
SELECT-OPTIONS : bukrs FOR lfb1-bukrs.
PARAMETERS : lifnr LIKE lfb1-lifnr.
SELECTION-SCREEN END OF BLOCK a.
DATA: r_container     TYPE REF TO cl_gui_custom_container.
DATA: r_grid          TYPE REF TO cl_gui_alv_grid.
DATA: g_fieldcat      TYPE lvc_t_fcat.
DATA: w_fieldcat      LIKE LINE OF g_fieldcat.
DATA: g_layout        TYPE lvc_s_layo.
DATA: ok_code         LIKE sy-ucomm.
DATA: gs_variant      TYPE disvariant.
DATA: t_selected      TYPE lvc_t_row.
DATA  wa_selected     LIKE LINE OF t_selected.
DATA: it_items        LIKE eban OCCURS 0.
DATA: BEGIN OF it_lfb1 OCCURS 0,
lifnr LIKE lfb1-lifnr,
bukrs LIKE lfb1-bukrs,
akont LIKE lfb1-akont,
fdgrv LIKE lfb1-fdgrv,
zwels LIKE lfb1-zwels,
END OF it_lfb1.
   Initialization                                                   *
INITIALIZATION.
AT SELECTION-SCREEN.
  ok_code = sy-ucomm.
  CASE ok_code.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'ONLI' OR 'CRET'.
      CALL SCREEN 100.
    WHEN OTHERS.
  ENDCASE.
    GetData                                                         *
MODULE getdata OUTPUT.
  IF sy-ucomm <> 'STOP'.
    SELECT lifnr bukrs akont fdgrv zwels
      INTO CORRESPONDING FIELDS OF  TABLE it_lfb1
      FROM lfb1
      WHERE
      bukrs IN bukrs
      AND lifnr EQ lifnr.
  ENDIF.
ENDMODULE.
      Create ALV                                                    *
MODULE create_alv OUTPUT.
  gs_variant-report = sy-repid.
  IF r_container IS INITIAL.
    CREATE OBJECT r_container
             EXPORTING container_name = 'CONTAINER_1'.
    CREATE OBJECT r_grid
          EXPORTING i_parent = r_container.
*modify the headings in the field catalogue
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
         EXPORTING
              i_structure_name = 'ZCATSDBALVM'
         CHANGING
              ct_fieldcat      = g_fieldcat[].
    LOOP AT g_fieldcat INTO w_fieldcat.
      CASE w_fieldcat-fieldname.
        WHEN 'ZCURSTAT'.
          w_fieldcat-scrtext_l = 'Prev.RelCode'.
          w_fieldcat-scrtext_m = 'Prev.RelCode'.
          w_fieldcat-scrtext_s = 'Prev.RelCode'.
          w_fieldcat-reptext   = 'Prev.RelCode'.
      ENDCASE.
      MODIFY g_fieldcat FROM w_fieldcat.
    ENDLOOP.
    CALL METHOD r_grid->set_table_for_first_display
                        EXPORTING i_structure_name     = 'ZCATSDBALVM'
                                  is_layout            = g_layout
                                  is_variant           = gs_variant
                                  i_save               = 'A'
                        CHANGING it_outtab = it_lfb1[]
                                 it_fieldcatalog  = g_fieldcat[].
*ELSE.
CALL METHOD r_grid->refresh_table_display
EXPORTING i_soft_refresh = ' '.
  ENDIF.
ENDMODULE.
   STATUS                                                           *
MODULE status OUTPUT.
  SET PF-STATUS '0100'.
ENDMODULE.
     User Commands                                                  *
MODULE user_command INPUT.
  ok_code = sy-ucomm.
  CASE ok_code.
    WHEN 'BACK'.
      CALL SCREEN '1000'.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.
     ALV Layout                                                     *
MODULE layout OUTPUT.
  g_layout-zebra = 'X'.
  g_layout-sel_mode = 'A'.
  g_layout-grid_title = ''.
  g_layout-detailtitl = ''.
ENDMODULE.
     Select Rows                                                    *
FORM get_selected_rows.
  CALL METHOD r_grid->get_selected_rows
  IMPORTING et_index_rows = t_selected.
  IF t_selected IS INITIAL.
    CALL FUNCTION 'WS_MSG'
         EXPORTING
              msg_type = 'E'
              text     = 'Select Line'
              titl     = 'Select Line'.
    sy-ucomm = 'STOP'.
  ENDIF.
ENDFORM.

Hi,
Here is the simplest way.
In the layout that you pass - set the EDIT field to 'X'. This puts all the fields in the EDIT mode and automatically the toolbar will have new buttons to add / delete new rows.
If you are looking at adding new rows manually, you will have append a blank row to the table and REFRESH_TABLE_DISPLAY. This will add a blank row, however you will have to do this on a specific action of the user. I am not aware of your requirements there. Here also, you can set the EDIT field in the LAYOUT to 'X' so that all the fields are in edit mode. If you want specific fields in the EDIT mode, do the same in the FIELDCAT.
Regards,
Ravi
Note : Please mark the helpful answers

Similar Messages

  • OO Splitter  ALV  grid's  Header  data Download

    Guys ,
       I  have OO Splitter  ALV  grid   but   unable  to  download Upper section( Splitter  ALV ) Header  data .....I  am  only  able  to  download  Lower part  data ...
      How  do  i  download  even  Upper section ( Splitter  ALV ) Header  data ...
      Please   help...OO Splitter  ALV  grid's  Header  data Download

    hi,
    when you use the splitter you cannot download both. You will be to download the data of that container on which you press download functionality. You need to add the button to download and add the logic to it.

  • ALV Grid Control -  Modifiy data in total and subtotal lines

    Hello all,
    I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
    Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
    Material delivered returned quote
    ..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
    ..4711 . . . 400 . . . 10 . . . . 2,5
    . SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
    Is there a possibility to modify data in the total and subtotal lines.
    Thank you for your answer
    Best regards
    Thomas

    you said instead of 3.5 you want to show 1,667 ..
    how is it possible...
    3,5 become 1,667
    i thought you are doing any conversions...
    vijay

  • ALV grid - not saving data withoutpressing 'Enter'.

    hi,
    I have an ALV grid (OO). I have written the code to update the final internal table in the method handle_data_changed.
    So If the user presses SAVE without hitting 'Enter' key, it is not saving the data .
    How can I handle this.
    Regards,
    Beena.

    hi,
    u can refresh it using method refresh_table_display.
    regards,
    janakiram.

  • ALV Grid - capturing the data of checked records

    Hi All,
    I have a report with ALV Grid display and it displays the contents of a custom table. Each record has a CHBOX, and I want to capture the data of all checked records in to an internal table when 'create Order' button is pressed.  Please help me.
    Thanks,
    Neelu.

    Hi neelu,
      Find attached complete code for the check box in ALV
    REPORT ZTESTPRG .
    TABLES AND DATA DECLARATION.
    *TABLES: mara,makt.",marc.
    data syrepid like sy-repid.
    data sydatum(10). " LIKE sy-datum.
    data sypagno(3) type n.
    WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
    GROUP (TYPE-POOLS--------->SLIS)
    type-pools : slis.
    INTERNAL TABLE DECLARATION.
    INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    mtart like mara-mtart,
    matkl like mara-matkl,
    end of t_mara.
    INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
    data : begin of t_marc occurs 0,
    matnr like mara-matnr,
    werks like marc-werks,
    minbe like marc-minbe.
    data: end of t_marc.
    INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
    data : begin of t_makt occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    spras like makt-spras,
    end of t_makt.
    INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
    data: begin of itab1 occurs 0,
    chkbox(1) type c,
    matnr like mara-matnr,
    meins like mara-meins,
    maktx like makt-maktx,
    spras like makt-spras,
    werks like marc-werks,
    minbe like marc-minbe,
    end of itab1.
    THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
    AND THE LAYOUT FOR THE ALV.
    HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
    WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
    OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
    THIS IS DONE TO MAKE THE CODE SIMPLER.
    OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
    PROGRAMS.
    IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
    MORE TABLES AND CREATE A STRUCTURE
    IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
    LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    fieldlayout type slis_layout_alv.
    DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
    TOP-OF-PAGE ETC.
    data : eventstab type slis_t_event with header line.
    DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
    data : heading type slis_t_listheader with header line.
    data : heading1 type slis_t_listheader with header line.
    data : heading2 type slis_t_listheader with header line.
    data : heading3 type slis_t_listheader with header line.
    data : heading4 type slis_t_listheader with header line.
    data : heading5 type slis_t_listheader with header line.
    data : heading6 type slis_t_listheader with header line.
    data : heading7 type slis_t_listheader with header line.
    data : heading8 type slis_t_listheader with header line.
    STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
    data : colorstruct type slis_coltypes.
    INITIALIZATION. *
    initialization.
    syrepid = sy-repid.
    sypagno = sy-pagno.
    clear fieldcatalog.
    START-OF-SELECTION. *
    start-of-selection.
    SUBROUTINE TO POPULATE THE COLORSTRUCT
    perform fill_colorstruct using colorstruct.
    SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
    perform populate_fieldcatalog.
    SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
    INTERNAL TABLE.
    perform selectdata_and_sort.
    SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
    perform populate_layout using fieldlayout.
    SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    perform merge_fieldcatalog.
    SUBROUTINE TO POPULATE THE EVENTSTAB.
    perform fill_eventstab tables eventstab.
    SUBROUTINE TO POPULATE THE HEADING TABLES.
    perform fill_headingtable tables heading using 'HEADING'.
    perform fill_headingtable tables heading1 using 'HEADING1'.
    perform fill_headingtable tables heading2 using 'HEADING2'.
    perform fill_headingtable tables heading3 using 'HEADING3'.
    perform fill_headingtable tables heading4 using 'HEADING4'.
    perform fill_headingtable tables heading5 using 'HEADING5'.
    perform fill_headingtable tables heading6 using 'HEADING6'.
    perform fill_headingtable tables heading7 using 'HEADING7'.
    perform fill_headingtable tables heading8 using 'HEADING8'.
    SUBROUTINE TO DISPLAY THE LIST.
    perform display_alv_list.
    FORMS
    IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
    OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
    COLUMN JUSTIFICATION.
    form populate_fieldcatalog.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATNR' 'X' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MEINS' ' '.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MAKTX' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MTART' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATKL' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'SPRAS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'WERKS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MINBE' ' ' .
    endform. " POPULATE_FIELDCATALOG
    FORM FILL_FIELDS_OF_FIELDCATALOG *
    --> FIELDCATALOG *
    --> P_TABNAME *
    --> P_FIELDNAME *
    --> P_KEY *
    --> P_KEY *
    form fill_fields_of_fieldcatalog tables fieldcatalog
    structure fieldcatalog
    using p_tabname
    p_fieldname
    p_key.
    p_no_out.
    fieldcatalog-tabname = p_tabname.
    fieldcatalog-fieldname = p_fieldname.
    fieldcatalog-key = p_key.
    fieldcatalog-emphasize = '1234'.
    *fieldcatalog-no_out = p_no_out.
    append fieldcatalog.
    endform. " FILL_FIELDSOFFIELDCATALOG
    FORM POPULATE_LAYOUT *
    --> FIELDLAYOUT *
    form populate_layout using fieldlayout type slis_layout_alv.
    fieldlayout-f2code = '&ETA' .
    fieldlayout-zebra = 'X'.
    FOR THE WINDOW TITLE.
    fieldlayout-window_titlebar = 'ALV with Events'.
    fieldlayout-colwidth_optimize = 'X'.
    fieldlayout-no_vline = ' '.
    *fieldlayout-no_input = 'X'.
    fieldlayout-confirmation_prompt = ''.
    fieldlayout-key_hotspot = 'X'.
    This removes the column headings if the flag is set to 'X'
    fieldlayout-no_colhead = ' '.
    *fieldlayout-hotspot_fieldname = 'MAKTX'.
    fieldlayout-detail_popup = 'X'.
    fieldlayout-coltab_fieldname = 'X'.
    fieldlayout-box_fieldname = 'CHKBOX'.
    fieldlayout-edit_mode = 'X'.
    endform. " POPULATE_LAYOUT
    FORM SELECTDATA_AND_SORT *
    form selectdata_and_sort.
    select matnr meins mtart matkl from mara
    into corresponding fields of t_mara
    up to 500 rows .
    select matnr maktx spras from makt
    into corresponding fields of t_makt
    where matnr = t_mara-matnr and
    spras = sy-langu.
    select matnr werks minbe from marc
    into corresponding fields of t_marc
    where matnr = t_mara-matnr.
    append t_marc.
    endselect.
    append t_makt.
    endselect.
    append t_mara.
    endselect.
    perform populate_itab1.
    sort itab1 by matnr.
    endform. " SELECTDATA_AND_SORT
    FORM MERGE_FIELDCATALOG *
    form merge_fieldcatalog.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = syrepid
    i_internal_tabname = 'ITAB1'
    i_structure_name = 'COLORSTRUCT'
    I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = syrepid
    changing
    ct_fieldcat = fieldcatalog[]
    exceptions
    inconsistent_interface = 1
    program_error = 2
    others = 3.
    endform. " MERGE_FIELDCATALOG
    IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
    FOLLOWS:-
    i_callback_program --> CALLING PROGRAM NAME
    i_structure_name --> STRUCTURE NAME.
    is_layout --> LAYOUT NAME.
    it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
    form display_alv_list.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    i_callback_program = syrepid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = fieldlayout
    it_fieldcat = fieldcatalog[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
    TOOL BAR
    i_save = 'A'
    IS_VARIANT = ' '
    it_events = eventstab[]
    IT_EVENT_EXIT =
    IS_PRINT =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab1
    exceptions
    program_error = 1
    others = 2.
    endform. " DISPLAY_ALV_LIST
    *& Form POPULATE_ITAB1
    text
    --> p1 text
    <-- p2 text
    form populate_itab1.
    loop at t_mara.
    loop at t_makt where matnr = t_mara-matnr.
    loop at t_marc where matnr = t_mara-matnr.
    move-corresponding t_mara to itab1.
    move-corresponding t_makt to itab1.
    move-corresponding t_marc to itab1.
    append itab1.
    endloop.
    endloop.
    endloop.
    endform. " POPULATE_ITAB1
    *& Form FILL_EVENTSTAB
    text
    -->P_EVENTSTAB text *
    form fill_eventstab tables p_eventstab structure eventstab.
    WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
    INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
    AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
    EVENTS NAME.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_eventstab[]
    exceptions
    list_type_wrong = 1
    others = 2.
    BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
    THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
    WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
    FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
    IS DYNAMICALY CALLED.
    read table p_eventstab with key name = slis_ev_top_of_page.
    if sy-subrc = 0 .
    move 'TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_coverpage.
    if sy-subrc = 0 .
    move 'TOP_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_coverpage .
    if sy-subrc = 0 .
    move 'END_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_top_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_end_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_list_modify.
    if sy-subrc = 0 .
    move 'LIST_MODIFY' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_list.
    if sy-subrc = 0 .
    move 'TOP_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_page.
    if sy-subrc = 0 .
    move 'END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_list .
    if sy-subrc = 0 .
    move 'END_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    endform. " FILL_EVENTSTAB
    *& Form FILL_HEADINGTABLE
    text
    -->P_HEADING text *
    form fill_headingtable tables p_heading structure heading
    using tablename.
    case tablename.
    when 'HEADING'.
    p_heading-typ = 'H'.
    concatenate
    ' REPORT NAME:-' syrepid
    ' ABB Industry Pte Ltd' into p_heading-info.
    append p_heading.
    write sy-datum using edit mask '__/__/____' to sydatum.
    concatenate
    ' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
    into p_heading-info.
    append p_heading.
    when 'HEADING1'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING2'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING3'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
    append p_heading.
    when 'HEADING4'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-END-OF-PAGE'.
    append p_heading.
    WHEN 'HEADING5'.
    P_HEADING-TYP = 'H'.
    P_HEADING-INFO = 'LIST-MODIFY'.
    APPEND P_HEADING.
    when 'HEADING6'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-PAGE'.
    append p_heading.
    when 'HEADING7'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-LIST'.
    append p_heading.
    when 'HEADING8'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-LIST'.
    append p_heading.
    endcase.
    endform. " FILL_HEADINGTABLE
    FORM TOP_OF_PAGE *
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading[]
    exceptions
    others = 1.
    endform.
    *& Form FILL_COLORSTRUCT
    text
    -->P_COLORSTRUCT text *
    form fill_colorstruct using p_colorstruct type slis_coltypes .
    p_colorstruct-heacolfir-col = 6.
    p_colorstruct-heacolfir-int = 1.
    p_colorstruct-heacolfir-inv = 1.
    endform. " FILL_COLORSTRUCT
    FORM TOP_OF_COVERPAGE *
    form top_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading1[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_COVERPAGE *
    form end_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading2[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_TOP_OF_PAGE *
    form foreign_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading3[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_END_OF_PAGE *
    form foreign_end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading4[]
    exceptions
    others = 1.
    endform.
    FORM LIST_MODIFY *
    *FORM LIST_MODIFY.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEADING5[]
    EXCEPTIONS
    OTHERS = 1.
    *ENDFORM.
    FORM END_OF_PAGE *
    form end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading6[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_LIST *
    form end_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading7[]
    exceptions
    others = 1.
    endform.
    FORM TOP_OF_LIST *
    form top_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading8[]
    exceptions
    others = 1.
    endform.
    *--- End of Program
    Thanks
    Mahesh

  • Web Dynpro ALV grid filter on date

    Hi,
    I want to set a "view" on my web dynpro alv grid that uses the current date.  Is there a way to specify the current date in the filter values?  Thanks,
    Samir

    Thanks Thomas.  I will certainly look into using POWL in the future.
    A related question - Its possible to use a filter by entering something like " .01. " but it doesnt seem to allow me to save that value as its not a date.  Is there any way around this?  Thanks

  • Problem with ALV Grid Not Displaying Data

    Hi Gurus,
    I have a report program, when i run it I display an output summary on ALV Grid, and when i click on each of the row in the output summary, I'm suppose to see the item detail of each record.
    This item detail is showing for some record and is not showing for some other records (when i use different selections). I debugged it and observed that the table populating the ALV grid actually has records in it. The ALV grid is not just displaying the records.
    I debugged the 2 examples (one showing record and the other not showing), I found out that nothing is different in the way they run till they populate the final internal record to passed to the ALV Grid.
    Please any suggestions on this:
    This is the function code for the ALV grid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = g_program_id
          i_callback_pf_status_set = c_detail_status
          i_callback_user_command  = c_detail_user_comm
          i_grid_title             = lv_grid_title
          is_layout                = w_detail_layout
          it_fieldcat              = i_detail_fieldcat
          it_sort                  = i_detail_sort
        TABLES
          t_outtab                 = i_faglflexa[]   "NEM - detail
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE e064
          WITH sy-subrc.
    Function REUSE_ALV_GRID_DISPLAY failed on detail view SY-SUBRC = &
      ENDIF.

    This is the full code:
    ***INCLUDE ZFIGL_HYPERION_F01.
    *&      Form  open_files
    Open files used by the program.
    FORM open_files.
      OPEN DATASET p_fileot FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
        MESSAGE g_message.
      IF sy-subrc <> 0.
        MESSAGE e056
          WITH g_message.
    Unable to open output file &
      ENDIF.
    ENDFORM.                    " open_files
    *&      Form  close_files
    Close files used by the program.
    FORM close_files.
      CLOSE DATASET p_fileot.
    ENDFORM.                    " close_files
    *&      Form  extract_data
    Extract data from database needed to generate output file and report.
    FORM extract_data.
    Get the required general ledger totals records.
      PERFORM get_faglflext_data.
    Derive any other necessary fields for I_FAGLFLEXT.
      PERFORM derive_add_fields_faglflext.
    Split records by fiscal period.
      PERFORM split_records_by_period.
    Summarize the detail records to allow for creation of the file and
    reporting.
      PERFORM summarize_records_by_period.
    Get the required general ledger actual line items records.
      PERFORM get_faglflexa_data.
    Derive any other necessary fields for I_FAGLFLEXA.
      PERFORM derive_add_fields_faglflexa.
    Sort the detail and summary output tables into key sequence.
      PERFORM sort_output_tables.
    ENDFORM.                    " extract_data
    *&      Form  process_data
    Create the requested file and report.
    FORM process_data.
    Create the local file if requested by the user or the month-end file
    at month-end.
      IF cb_test = c_not_selected.
        PERFORM create_pc_file.
      ELSEIF sy-uname = c_user_batch_admin.
        PERFORM create_output_file.
      ENDIF.
    Create the necessary tables for summary ALV report.
      PERFORM build_summary_layout.
      PERFORM build_summary_field_catalog.
      PERFORM build_summary_sort_table.
    Check to see that there is data in the summary output table.  If yes,
    generate report, if not, then give a message to the user.
      READ TABLE i_output_summary INDEX 1 TRANSPORTING NO FIELDS.
      IF sy-subrc <> 0.
        MESSAGE s062.
        STOP.
    No data extracted for selection criteria entered
      ENDIF.
    Generate the summary ALV report view.
      PERFORM generate_summary_alv_report.
    ENDFORM.                    " process_data
    *&      Form  verify_user_selections
    Verify data input by the user.
    FORM verify_user_selections.
      IF NOT p_ryear IS INITIAL.
        IF p_ryear < 2006 OR
           p_ryear > 2100.
          MESSAGE e057.
    Fiscal year is invalid
        ENDIF.
      ENDIF.
    If program is being run in a non-test mode and the user has left the
    fiscal year selection blank, display a error message.
      IF cb_test IS INITIAL AND
         p_ryear IS INITIAL.
        MESSAGE e058.
    A fiscal year must be entered when generating the file
      ENDIF.
    If program is being run in a non-test mode and the user has left the
    period selection blank, display a error message.
      IF cb_test IS INITIAL AND
         s_rpmax IS INITIAL.
        MESSAGE e132.
    A period must be entered when generating the file
      ENDIF.
      IF cb_test IS INITIAL AND
         p_lfile IS INITIAL.
        MESSAGE e071.
    Local filename is required when generating the file
      ENDIF.
    ****Basil Balogun's addition to include the hyperion acct in selection. (10/03/2007)***
      IF s_rhype IS NOT INITIAL.
        LOOP AT s_rhype.
          CLEAR r_hyper.
          r_hyper-sign = 'I'.
          r_hyper-option = 'CP'.
          CONCATENATE '' s_rhype-low '' INTO r_hyper-low.
          APPEND r_hyper.
        ENDLOOP.
        SELECT bukrs saknr hyper
               FROM zall_gl_hype INTO TABLE i_zall_gl
               WHERE hyper IN r_hyper.
        LOOP AT i_zall_gl INTO w_zall_gl.
          w_zall_gl1-saknr = w_zall_gl-saknr.
          w_zall_gl2-bukrs = w_zall_gl-bukrs.
          APPEND w_zall_gl1-saknr TO i_zall_gl1.
          APPEND w_zall_gl2-bukrs TO i_zall_gl2.
          CLEAR: w_zall_gl, w_zall_gl1, w_zall_gl2.
        ENDLOOP.
        SORT i_zall_gl1 BY saknr.
        SORT i_zall_gl2 BY bukrs.
        DELETE ADJACENT DUPLICATES FROM i_zall_gl1 COMPARING saknr.
        DELETE ADJACENT DUPLICATES FROM i_zall_gl2 COMPARING bukrs.
        IF s_racct IS INITIAL.
          LOOP AT i_zall_gl1 INTO w_zall_gl1.
            r_saknr-sign = 'I'.
            r_saknr-option = 'EQ'.
            r_saknr-low = w_zall_gl1.
            APPEND r_saknr.
            CLEAR r_saknr.
            CLEAR w_zall_gl1.
          ENDLOOP.
        ELSE.
          r_saknr[] = s_racct[].
        ENDIF.
        IF s_rbukrs IS INITIAL.
          LOOP AT i_zall_gl2 INTO w_zall_gl2.
            r_bukrs-sign = 'I'.
            r_bukrs-option = 'EQ'.
            r_bukrs-low = w_zall_gl2-bukrs.
            APPEND r_bukrs.
            CLEAR r_bukrs.
            CLEAR w_zall_gl2.
          ENDLOOP.
        ELSE.
          r_bukrs[] = s_rbukrs[].
        ENDIF.
      ELSE.
        r_saknr[] = s_racct[].
        r_bukrs[] = s_rbukrs[].
        SELECT bukrs saknr hyper
               FROM zall_gl_hype INTO TABLE i_zall_gl.
      ENDIF.
    ****Basil Balogun's addition to include the hyperion acct in selection. (10/03/2007)***
    ENDFORM.                    " verify_user_selections
    *&      Form  get_faglflext_data
    Get FAGLFLEXT (General Ledger: Totals) data from the database.
    FORM get_faglflext_data .
    Use the fiscal year for the selection, if it was populated by the
    user.
      IF NOT p_ryear IS INITIAL.
        SELECT ryear rldnr rvers racct rbukrs prctr rfarea kokrs segment
               zzsarea zzsareaim rassc hsl01 hsl02 hsl03 hsl04 hsl05 hsl06
               hsl07 hsl08 hsl09 hsl10 hsl11 hsl12 hsl13 hsl14 hsl15 hsl16
               hslvt
          INTO TABLE i_faglflext
          FROM faglflext
          WHERE rldnr = c_run_ledger    AND
                rbukrs IN r_bukrs       AND
                racct  IN r_saknr       AND
                rfarea IN s_rfarea      AND
                prctr  IN s_prctr       AND
                ryear  =  p_ryear       AND
                rvers  = c_run_version.
      ELSE.
        SELECT ryear rldnr rvers racct rbukrs prctr rfarea kokrs segment
             zzsarea zzsareaim rassc hsl01 hsl02 hsl03 hsl04 hsl05 hsl06
             hsl07 hsl08 hsl09 hsl10 hsl11 hsl12 hsl13 hsl14 hsl15 hsl16
             hslvt
        INTO TABLE i_faglflext
        FROM faglflext
        WHERE rldnr = c_run_ledger    AND
              rbukrs IN r_bukrs       AND
              racct  IN r_saknr       AND
              rfarea IN s_rfarea      AND
              prctr  IN s_prctr       AND
              rvers  = c_run_version.
      ENDIF.
    ENDFORM.                    " get_faglflext_data
    *&      Form  derive_add_fields_faglflext
    Derive additional fields needed for the I_FAGLFLEXT.
    FORM derive_add_fields_faglflext.
    Get needed company code and profit center data from the database.
      PERFORM get_t001_data.
      PERFORM get_t880_data.
      READ TABLE i_faglflext INDEX 1 TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        PERFORM get_cepc_data.
      ENDIF.
      SORT i_zall_gl BY bukrs saknr.
      LOOP AT i_faglflext INTO w_faglflext.
    Get necessary company code data.
        READ TABLE i_t001 INTO w_t001
          WITH KEY bukrs = w_faglflext-rbukrs
                   BINARY SEARCH.
        IF sy-subrc <> 0.
          MESSAGE e059
            WITH w_faglflext-rbukrs.
    Company code & not found on table T001
        ENDIF.
    Determine the entity.
        PERFORM derive_entity USING w_t001-rcomp
                           CHANGING w_faglflext-entity.
    Determine the strategic segment.
        PERFORM derive_strategic_segment USING w_faglflext-rassc
                                               w_faglflext-prctr
                                      CHANGING w_faglflext-strat_seg
                                               w_faglflext-zzsareaim
                                               w_faglflext-zzsarea.
    Determine the strategic segment channel.
        PERFORM derive_strat_seg_chnl USING w_faglflext-rassc
                                            w_faglflext-prctr
                                   CHANGING w_faglflext-strat_seg_chnl.
    Determine the all item ID and all products.
        PERFORM derive_all_item_id USING w_t001-waers
                                CHANGING w_faglflext-all_item_id
                                         w_faglflext-all_products.
    Determine the all customers and all customers channel.
       PERFORM derive_all_customers_fields USING w_faglflext-strat_seg
    *w_faglflext-strat_seg_chnl
                                        CHANGING w_faglflext-all_cust
    *w_faglflext-all_cust_chnl.
    Determine the sub account using the company ID of the trading partner.
       PERFORM derive_sub_account USING w_faglflext-rassc
                               CHANGING w_faglflext-sub_acct.
        PERFORM derive_sub_account USING w_t001-rcomp
                                         w_faglflext-rassc
                           CHANGING w_faglflext-sub_acct.
    ****Begin Basil changes to include hyperion acct in selection (10/03/2007).
        READ TABLE i_zall_gl INTO w_zall_gl
                     WITH KEY bukrs = w_faglflext-rbukrs
                              saknr = w_faglflext-racct
                          BINARY SEARCH.
        IF sy-subrc = 0.
    ****End Basil changes to include hyperion acct in selection (10/03/2007).
    Determine the Hyperion account number from G/L account long text.
          PERFORM derive_hyperion_account USING w_faglflext-racct
                                                w_faglflext-rfarea
                                                "KMK5/22/06 ITR: 20592
                                                w_faglflext-sub_acct
                                                w_faglflext-rassc
                                                w_faglflext-prctr
                         CHANGING w_faglflext-hyperion_acct
                                  w_faglflext-reverse_sign "NEM8/21/06 ITR: 24286
                                  w_faglflext-balance_sheet "NEM8/21/06 ITR: 24286
                                  w_faglflext-zzsarea
                                  w_faglflext-zzsareaim
                                  w_faglflext-strat_seg.
        ENDIF.
    Determine the all customers and all customers channel.
        PERFORM derive_all_customers_fields USING w_faglflext-strat_seg
                                                  w_faglflext-strat_seg_chnl
                                         CHANGING w_faglflext-all_cust
                                                  w_faglflext-all_cust_chnl.
    Update i_FAGLFLEXT with the newly derive fields.
        MODIFY i_faglflext FROM w_faglflext
          TRANSPORTING entity
                       strat_seg
                       strat_seg_chnl
                       all_item_id
                       all_products
                       all_cust
                       all_cust_chnl
                       hyperion_acct
                       sub_acct
                       fiscal_period
                       zzsarea
                       zzsareaim
                       reverse_sign        "NEM8/21/06 ITR: 24286
                       balance_sheet.      "NEM8/21/06 ITR: 24286
      ENDLOOP.
      CHECK s_rhype IS NOT INITIAL.
      SORT s_rhype BY low.
      LOOP AT i_faglflext INTO w_faglflext.
        READ TABLE s_rhype WITH KEY low = w_faglflext-hyperion_acct.
        IF sy-subrc NE 0.
          CLEAR w_faglflext-hyperion_acct.
          MODIFY i_faglflext FROM w_faglflext.
        ENDIF.
      ENDLOOP.
      DELETE i_faglflext WHERE hyperion_acct IS INITIAL.
    ENDFORM.                    " derive_add_fields_faglflext
    *&      Form  derive_entity
    Derive the entity using the company code.
         -->RCOMP  - Company code.
         <--ENTITY - Entity
    FORM derive_entity USING rcomp  TYPE t_t001-rcomp
                    CHANGING entity TYPE t_faglflext-entity.
      CLEAR:
        entity.
    Get necessary global company code data.
      READ TABLE i_t880 INTO w_t880
        WITH KEY rcomp = rcomp
                 BINARY SEARCH.
      IF sy-subrc = 0.
        entity  = w_t880-name2+0(3).
        TRANSLATE entity TO UPPER CASE.
      ELSE.
        MESSAGE e060
          WITH w_t001-rcomp.
    Company code & not found on table T880
      ENDIF.
    ENDFORM.                    " derive_entity
    *&      Form  get_t001_data
    Get T001 (Company Codes) data from the database.
    FORM get_t001_data.
      SELECT bukrs waers rcomp
        INTO TABLE i_t001
        FROM t001
        CLIENT SPECIFIED
        WHERE mandt = sy-mandt.
      SORT i_t001 BY bukrs.
    ENDFORM.                    " get_t001_data
    *&      Form  get_t880_data
    Get T880 (Global Company Data (for KONS Ledger)) data from the
    database.
    FORM get_t880_data.
      SELECT rcomp name2
        INTO TABLE i_t880
        FROM t880
        CLIENT SPECIFIED
        WHERE mandt = sy-mandt.
      SORT i_t880 BY rcomp.
    ENDFORM.                    " get_t880_data
    *&      Form  derive_all_item_id
    Derive the all item ID from the company code currency key.
         -->WAERS       - Currency key.
         <--ALL_ITEM_ID - All item ID.
         <--ALL_ITEM_ID - All item ID.
    FORM derive_all_item_id USING waers        TYPE t_t001-waers
                         CHANGING all_item_id  TYPE t_faglflext-all_item_id
                                  all_products TYPE t_faglflext-all_products
      CLEAR:
        all_item_id.
    Populate all item ID.
      all_item_id = c_all_item_id.
      IF waers = c_us_dollars.
        REPLACE '*' WITH c_united_states INTO all_item_id.
      ELSE.
        REPLACE '*' WITH c_local         INTO all_item_id.
      ENDIF.
    Populate all products.
      all_products   = c_all_products.
      TRANSLATE all_products TO UPPER CASE.
    ENDFORM.                    " derive_all_item_id
    *&      Form  derive_all_customers_fields
    Derive the all customers and all customer channel fields from
    the strategic segment and strategic segment channel respectively.
         -->STRAT_SEG      - Strategic segment.
         -->STRAT_SEG_CHNL - Strategic segment channel.
         <--ALL_CUST       - All customers.
         <--ALL_CUST_CHNL  - All customers channel.
    FORM derive_all_customers_fields USING strat_seg      TYPE
    t_faglflext-strat_seg
                                           strat_seg_chnl TYPE
                                           t_faglflext-strat_seg_chnl
                                  CHANGING all_cust       TYPE
                                  t_faglflext-all_cust
                                           all_cust_chnl  TYPE
                                           t_faglflext-all_cust_chnl.
      CLEAR:
        all_cust,
        all_cust_chnl.
      all_cust        = strat_seg.
      all_cust+2(1)   = c_all_customers.
      TRANSLATE all_cust TO UPPER CASE.
      all_cust_chnl   = strat_seg_chnl.
      TRANSLATE all_cust_chnl TO UPPER CASE.
    ENDFORM.                    " derive_all_customers_fields
    *&      Form  derive_hyperion_account
    Read G/L account long text to get the Hyperion account number.
         -->RACCT         - SAP G/L account number.
         <--HYPERION_ACCT - Hyperion account number.
    FORM derive_hyperion_account USING racct         TYPE t_faglflext-racct
                                       farea         TYPE t_faglflext-rfarea
                                       "KMK5/22/06 ITR 20592
                                       sub_account   TYPE
                                       t_faglflext-sub_acct
                                       rassc         TYPE t_faglflext-rassc
                                       prctr         TYPE t_faglflext-prctr
                          CHANGING hyperion_acct TYPE t_faglflext-hyperion_acct
                                   reverse_sign  TYPE t_faglflext-reverse_sign "NEM8/21/06 ITR: 24286
                                   balance_sheet TYPE t_faglflext-balance_sheet "NEM8/21/06 ITR: 24286
                                   zzsarea       TYPE t_faglflext-zzsarea
                                   zzsareaim     TYPE t_faglflext-zzsareaim
                                   strat_seg     TYPE t_faglflext-strat_seg.
      DATA:
        lv_text_name          TYPE thead-tdname,
        l_strl                TYPE i VALUE 0,
        l_hyperion_acct(10),                       "KMK5/20/06 ITR 20527
        l_farea(10)           VALUE '0000000000',  "KMK5/22/06 ITR 20592
        l_balance_sheet(1),                        "NEM8/17/06 ITR 25792
        l_string              TYPE tline-tdline.   "NEM8/17/06 ITR 25792
      DATA: l_hyp_account_1 TYPE tline-tdline,
            l_hyp_account_2 TYPE tline-tdline,
            l_hyp_account_3 TYPE tline-tdline.
      reverse_sign = '1'.
      SELECT SINGLE bilkt xbilk
        FROM ska1
        INTO (l_hyperion_acct,l_balance_sheet)
        WHERE ktopl = c_global_tcoa
          AND   saknr = racct.
      balance_sheet = l_balance_sheet.
      l_string = w_zall_gl-hyper.
      SEARCH l_string FOR '-'.
      IF sy-subrc = '0'.
        reverse_sign = -1.
      ELSE.
        reverse_sign = 1.
      ENDIF.
      CHECK w_zall_gl-hyper IS NOT INITIAL.
      CLEAR: l_hyp_account_1, l_hyp_account_2, l_hyp_account_3.
      SPLIT w_zall_gl-hyper
        AT ';'
        INTO l_hyp_account_1 l_hyp_account_2 l_hyp_account_3.
      IF l_hyp_account_2 IS INITIAL.      " Only one hyperion account
        hyperion_acct = l_hyp_account_1+0(7).
        l_strl = STRLEN( hyperion_acct ) - 1.
        IF hyperion_acct+l_strl(1) EQ '1'.
          CLEAR sub_account.
          PERFORM repopulate_strategic_segment
            USING rassc prctr
            CHANGING strat_seg.
          zzsareaim = g_hold_sales_type.
          zzsarea = g_hold_sales_area.
        ENDIF.
      ELSE.                                " Two or more hyperion accounts
        IF sub_account > ''.
          hyperion_acct = l_hyp_account_2+0(7).
        ELSE.
          hyperion_acct = l_hyp_account_1+0(7).
        ENDIF.
      ENDIF.
      CLEAR: w_hyperion.
      w_hyperion-racct           = racct.
      w_hyperion-hyperion_acct   = hyperion_acct.
      w_hyperion-reverse_sign    = reverse_sign.
    ENDFORM.                    " derive_hyperion_account
    *&      Form  derive_sub_account
    Determine the sub account based on the company ID of the trading
    partner.
         -->RASSC    - Company ID of trading partner.
         <--SUB_ACCT - Sub account.
    *FORM derive_sub_account USING rassc    TYPE t_faglflext-rassc
                        CHANGING sub_acct TYPE t_faglflext-sub_acct.
    IF rassc IS INITIAL.
       CLEAR: sub_acct.
    ELSE.
       sub_acct  = rassc.
       TRANSLATE sub_acct TO UPPER CASE.
    ENDIF.
    *ENDFORM.                    " derive_sub_account
    FORM derive_sub_account USING rcomp  TYPE t_t001-rcomp
                                  rassc  TYPE t_faglflext-rassc
                    CHANGING sub_acct TYPE t_faglflext-sub_acct.
      IF rassc IS INITIAL.
        CLEAR: sub_acct.
      ELSE.
        READ TABLE i_t880 INTO w_t880
          WITH KEY rcomp = rassc
                   BINARY SEARCH.
        IF sy-subrc = 0.
          sub_acct  = w_t880-name2.
          TRANSLATE sub_acct TO UPPER CASE.
        ELSE.
       MESSAGE e060
         WITH w_t001-rcomp.
    Company code & not found on table T880
        ENDIF.
      ENDIF.
    ENDFORM.                    " derive_sub_account
    *&      Form  repopulate_strategic_segment
    Derive the strategic segment based on the company ID of the trading
    partner or the profit center.
         -->RASSC     - Company ID of trading partner.
         -->PRCTR     - Profit center.
         <--STRAT_SEG - Strategic segment.
    FORM repopulate_strategic_segment USING rassc     TYPE t_faglflext-rassc
                                        prctr     TYPE t_faglflext-prctr
                               CHANGING strat_seg TYPE t_faglflext-strat_seg
      DATA:
        lv_segment              TYPE cepc-segment.
      CLEAR:
        strat_seg.
    Find the valid profit center record.
      LOOP AT i_cepc INTO w_cepc
        WHERE prctr =  prctr    AND
              datab <= sy-datum AND
              datbi >= sy-datum.
    Pad segment with leading zeros if necessary.
        lv_segment      = w_cepc-segment.
        SHIFT lv_segment RIGHT DELETING TRAILING ' '.
        TRANSLATE lv_segment USING ' 0'.
    Get the segment name from FAGL_SEGMT (Master Data for Segments).
        SELECT SINGLE *
          FROM fagl_segmt
          WHERE langu   = sy-langu AND
                segment = lv_segment.
        IF sy-subrc = 0.
          strat_seg      = fagl_segmt-name+0(3).
          TRANSLATE strat_seg TO UPPER CASE.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "repopulate_strategic_segment
    " repopulate_strategic_segment&----
    *&      Form  derive_strategic_segment
    Derive the strategic segment based on the company ID of the trading
    partner or the profit center.
         -->RASSC     - Company ID of trading partner.
         -->PRCTR     - Profit center.
         <--STRAT_SEG - Strategic segment.
    FORM derive_strategic_segment USING rassc     TYPE t_faglflext-rassc
                                        prctr     TYPE t_faglflext-prctr
                               CHANGING strat_seg TYPE t_faglflext-strat_seg
                                        sales_type TYPE t_faglflext-zzsareaim
                                        sales_area TYPE t_faglflext-zzsarea.
      DATA:
        lv_segment              TYPE cepc-segment.
      CLEAR:
        strat_seg.
    *Hold values in Sales Type and Sales area before setting to default
    *values
    In case need to use them later
      g_hold_sales_type = sales_type.
      g_hold_sales_area = sales_area.
    If the company ID of the trading partner is populated, then set the
    strategic segment to a default value.
    And set Sales Type and Sales area to default values     **NEM 07/13/06
      IF NOT rassc IS INITIAL.
        strat_seg   = c_def_strat_seg.
        sales_type  = c_sales_type.
        sales_area  = c_sales_area.
        TRANSLATE strat_seg TO UPPER CASE.
        TRANSLATE sales_type TO UPPER CASE.
        TRANSLATE sales_area TO UPPER CASE.
        EXIT.
      ENDIF.
    Find the valid profit center record.
      LOOP AT i_cepc INTO w_cepc
        WHERE prctr =  prctr    AND
              datab <= sy-datum AND
              datbi >= sy-datum.
    Pad segment with leading zeros if necessary.
        lv_segment      = w_cepc-segment.
        SHIFT lv_segment RIGHT DELETING TRAILING ' '.
        TRANSLATE lv_segment USING ' 0'.
    Get the segment name from FAGL_SEGMT (Master Data for Segments).
        SELECT SINGLE *
          FROM fagl_segmt
          WHERE langu   = sy-langu AND
                segment = lv_segment.
        IF sy-subrc = 0.
          strat_seg      = fagl_segmt-name+0(3).
          TRANSLATE strat_seg TO UPPER CASE.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " derive_strategic_segment
    *&      Form  get_cepc_data
    Get CEPC (Profit Center Master Data Table) data from the database.
    FORM get_cepc_data.
      SELECT prctr datbi kokrs datab khinr segment
        INTO TABLE i_cepc
        FROM cepc
        FOR ALL ENTRIES IN i_faglflext
        WHERE prctr = i_faglflext-prctr.
      SORT i_cepc BY prctr datab.
    ENDFORM.                    " get_cepc_data
    *&      Form  derive_strat_seg_chnl
    Derive the strategic segment channel based on the company ID of the
    trading partner or the profit center area.
         -->RASSC          - Company ID of trading partner.
         -->PRCTR          - Profit center.
         <--STRAT_SEG_CHNL - Strategic segment channel.
    FORM derive_strat_seg_chnl USING rassc          TYPE t_faglflext-rassc
                                     prctr          TYPE t_faglflext-prctr
                            CHANGING strat_seg_chnl TYPE
                            t_faglflext-strat_seg_chnl.
      CLEAR:
        g_setclass,
        g_subclass,
        g_setname,
        strat_seg_chnl.
    If the company ID of the trading partner is populated, then set the
    strategic segment to a default value.
      IF NOT rassc IS INITIAL.
        strat_seg_chnl  = c_def_strat_seg_chnl.
        TRANSLATE strat_seg_chnl TO UPPER CASE.
        EXIT.
      ENDIF.
    Check for SETNAME = 2*** in setleaf table.
      PERFORM get_setleaf_data USING c_prctr_group
                                       prctr
                              CHANGING g_subrc.
      IF g_subrc NE c_no_record.
        PERFORM find_setleaf_record CHANGING g_subrc.
        SELECT SINGLE *
        FROM setheadert
        WHERE  setclass = g_setclass AND
               subclass = g_subclass AND
               setname  = g_setname  AND
               langu    = sy-langu.
        IF sy-subrc = 0.
          strat_seg_chnl    = setheadert-descript+0(2).
          TRANSLATE strat_seg_chnl TO UPPER CASE.
        ENDIF.
      ELSE.
    Find the valid profit center record.
        LOOP AT i_cepc INTO w_cepc
          WHERE prctr =  prctr    AND
                datab <= sy-datum AND
                datbi >= sy-datum.
    Get the correct SETNODE (Lower-level sets in sets) record.
          PERFORM get_setnode_data USING c_prctr_group
                                         w_cepc-khinr
                                CHANGING g_subrc.
          PERFORM find_setnode_record CHANGING g_subrc.
          IF g_subrc = c_no_record.
            EXIT.
          ENDIF.
    If an appropriate SETNODE record still has not been found, then
    keep looking.
          IF g_subrc = c_wrong_record.
            DO.
              PERFORM get_setnode_data USING c_prctr_group
                                             w_setnode-setname
                                    CHANGING g_subrc.
              PERFORM find_setnode_record CHANGING g_subrc.
              IF g_subrc = c_no_record OR
                 g_subrc = c_correct_record.
                EXIT.
              ENDIF.
            ENDDO.
          ENDIF.
    In the end, there was no SETNODE record to find.
          IF g_subrc = c_no_record.
            EXIT.
          ENDIF.
          SELECT SINGLE *
            FROM setheadert
            WHERE  setclass = g_setclass AND
                   subclass = g_subclass AND
                   setname  = g_setname  AND
                   langu    = sy-langu.
          IF sy-subrc = 0.
            strat_seg_chnl    = setheadert-descript+0(2).
            TRANSLATE strat_seg_chnl TO UPPER CASE.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " derive_strat_seg_chnl
    *&      Form  get_setnode_data
    Get SETNODE (Lower-level sets in sets) data from the database.
         -->SETCLASS   - Set class.
         -->SUBSETNAME - Subordinate set ID.
         <--SUBRC      - Return code.
    FORM get_setnode_data USING setclass   TYPE c
                                subsetname TYPE c
                       CHANGING subrc      TYPE sy-subrc.
      SELECT setclass subclass setname
        INTO TABLE i_setnode
        FROM setnode
        WHERE setclass   = c_prctr_group AND
              subsetname = subsetname.
      subrc  = sy-subrc.
    ENDFORM.                    " get_setnode_data
    *&      Form  get_setleaf_data
    Get SETLEAF (Values in Sets) data from the database.
         -->SETCLASS   - Set class.
         -->VALFROM    - Subordinate set ID.
         <--SUBRC      - Return code.
    FORM get_setleaf_data USING setclass   TYPE c
                                valfrom    TYPE c
                       CHANGING subrc      TYPE sy-subrc.
      subrc = c_correct_record.
      SELECT setclass setname valfrom subclass
        INTO TABLE i_setleaf
        FROM setleaf
        WHERE setclass   = c_prctr_group AND
              valfrom = valfrom AND
              setname GE '2000' AND
              setname LE '2999'.
      IF sy-subrc <> 0.
        subrc  = c_no_record.
        EXIT.
      ENDIF.
    ENDFORM.                    " get_setleaf_data
    *&      Form  find_setleaf_record
    Find the appropriate SETLEAF record.
         <--SUBRC      - Return code.
    FORM find_setleaf_record CHANGING subrc TYPE sy-subrc.
      subrc  = c_wrong_record.
    If no records were found during selection, then exit the routine.
      READ TABLE i_setleaf INDEX 1 TRANSPORTING NO FIELDS.
      IF sy-subrc <> 0.
        subrc  = c_no_record.
        EXIT.
      ENDIF.
    Check to see if one of the records has a setname in the 2000 series of
    numbers.
      LOOP AT i_setleaf INTO w_setleaf.
        g_setclass = w_setleaf-setclass.
        g_subclass = w_setleaf-subclass.
        g_setname  = w_setleaf-setname.
        subrc  = c_correct_record.
      ENDLOOP.
    ENDFORM.                    " find_setleaf_record
    *&      Form  find_setnode_record
    Find the appropriate SETNODE record.
         <--SUBRC      - Return code.
    FORM find_setnode_record CHANGING subrc TYPE sy-subrc.
      subrc  = c_wrong_record.
    If no records were found during selection, then exit the routine.
      READ TABLE i_setnode INDEX 1 TRANSPORTING NO FIELDS.
      IF sy-subrc <> 0.
        subrc  = c_no_record.
        EXIT.
      ENDIF.
    Check to see if one of the records has a setname in the 2000 series of
    numbers.
      LOOP AT i_setnode INTO w_setnode.
        IF w_setnode-setname+0(1) = c_valid_number.
          g_setclass = w_setnode-setclass.
          g_subclass = w_setnode-subclass.
          g_setname  = w_setnode-setname.
          subrc  = c_correct_record.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " find_setnode_record
    *&      Form  split_records_by_period
    Split the i_FAGLFLEXT records by fiscal period.  This is necessary
    because all (16) fiscal periods are on one record.
    FORM split_records_by_period .
      REFRESH:
        i_output_detail.
      LOOP AT i_faglflext INTO w_faglflext.
    START OF CHANGES BY BAYAPV on 07/07/2007**********************
    *SELECT SINGLE BUKRS
          SAKNR
          XOPVW
          into w_skb1
          from skb1
          FOR ALL ENTRIES IN I_FAGLFLEXT
          where bukrs = w_faglflext-rbukrs
            and SAKNR = w_faglflext-racct.
    *IF w_skb1-XOPVW = 'X'.
    *SELECT BUKRS
          HKONT

  • ALV Grid with out data in editable mode

    Hi,
    I need an ALV Grid , which only contains empty cells. User should be able to enter data in the cells later.
    Thanks
    Satya

    REPORT sapmz_hf_alv_grid .
       TABLES: zsflight.
    G L O B A L   I N T E R N  A L   T A B L E S
       DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    G L O B A L   D A T A
       DATA: ok_code LIKE sy-ucomm,
             g_wa_sflight LIKE sflight.
    Declare reference variables to the ALV grid and the container
       DATA:
         go_grid             TYPE REF TO cl_gui_alv_grid,
         go_custom_container TYPE REF TO cl_gui_custom_container.
    S T A R T - O F - S E L E C T I O N.
       START-OF-SELECTION.
         SET SCREEN '100'.
       *&      Module  USER_COMMAND_0100  INPUT
       MODULE user_command_0100 INPUT.
         CASE ok_code.
           WHEN 'EXIT'.
             LEAVE TO SCREEN 0.
         ENDCASE.
       ENDMODULE.                 " USER_COMMAND_0100  INPUT
       *&      Module  STATUS_0100  OUTPUT
       MODULE status_0100 OUTPUT.
    Create objects
         IF go_custom_container IS INITIAL.
           CREATE OBJECT go_custom_container
             EXPORTING container_name = 'ALV_CONTAINER'.
           CREATE OBJECT go_grid
             EXPORTING
               i_parent = go_custom_container.
           PERFORM load_data_into_grid.
         ENDIF.
       ENDMODULE.                 " STATUS_0100  OUTPUT
       *&      Form  load_data_into_grid
       FORM load_data_into_grid.
    Read data from table SFLIGHT
         SELECT *
           FROM zsflight
           INTO TABLE gi_sflight.
    Load data into the grid and display them
         CALL METHOD go_grid->set_table_for_first_display
           EXPORTING i_structure_name = 'SFLIGHT'
           CHANGING  it_outtab        = gi_sflight.
       ENDFORM.                    " load_data_into_grid

  • Alv grid data

    Hi All,
       I developed alv grid.I passed data from it_final table into grid.In our it_final table, there is 10 rows and when I execute report then it comes 10 line item.It is perfect. Now I do subtotal in any field.Then In the
    grid total 15 line item comming.Now I want that 15 line item should come in a table.eithe it_final or
    either any defined table.is it possible?please help me.I want just output alv grid after subtotal(15 lines item) should come in table after pressing in any button.
    Thanks,
    Rakesh

    You will have to manually loop at it_final and calculate the subtotal for the fields and append this into the it_final while displaying.
    If you r calculating subtotal in sort table by subtos = 'X'. this entry cannot be put into final internal table.
    Regards,
    Mansi.

  • How to Transfer Data from editable ALV grid control to internal table?

    Hi,
    Can anyone give me a simple example by which I can transfer data from editable alv grid control back to the internal table. The ALV has been created by OO approach.
    I would appreciate if the solution is provided without handling any events.
    Regards,
    Auro

    Hello Auro
    You simply need to call method <b>go_grid->check_changed_data</b> at PAI of the dynpro displaying the ALV grid. If data have been changed on the editable ALV grid then this method will raise event DATA_CHANGED. If you do not want or need to handle this event (e.g. for validating the edited values) then you do not define any event handler method.
    Regards
      Uwe

  • Delete row in OO ALV grid toolbar

    Hello;
    I am using OO ALV grid to display data. On the standard toolbar when delete row button is activated the relevant row is removed from the screen. The program catches this event only when Enter is pressed. Is it possible to catch it as soon as delete row is pressed?
    Thx in advance.
    Ali

    Hi Ali,
            You have to handle standard ALV toolbar. Even you can use Custom Toolbar. But you can handle it from Standard toolbar user command. Register events..
    Thanks and Regards,
    Sampath

  • How to remove values formatting in export to excel from ALV grid

    Hi all,
    I have small issue, I have ALV Grid with some data, but the problem is with columns containing e.g. gross amounts, because it is displayed in the grid as e.g. 1.764,81, and after export to excel it is still in this format (with dot and comma), so excel doesn't treat it as numeric value but as text, and then when I try to calculate total on the column then this values are not taken to the total. Do you know if that is possible to remove column formatting?
    kind regards,
    Marcin

    I replied too soon to Peter's suggestions.  For some reason, I was able to add new info. to my first new row, but not the second.  However, I finally figured out the problem.
    I found the Help Center page on: "Here are ways to change custom formats and apply changes to table cells:"
    To change the elements associated with a custom format that’s been applied to cells, select the cells and click Show Format in the Format pane of the Table inspector.
    I saw that the "cell format" was listed as "automatic," so I changed it to "Custom;" then left the new custom window at it's default settings. Now my cells would accept pasted info. without spreading it through the lower rows.  Whatever automatic was in the table, it was not what I wanted. Doing this to other new cells, solved my problem.  Thanks again.

  • F4 help for a field in alv grid

    hello friends,
                        i want to make one of the fields of my alv grid as editable and i want f4 help option also available for it, can v do it, if yes how??? pls explain through code
                  thanks

    check this example
    REPORT  ztest440.
    TABLES : mara.
    TYPES: BEGIN OF t_mara,
            matnr TYPE mara-matnr,
            lvorm TYPE mara-lvorm,
            mtart TYPE mara-mtart,
            mbrsh TYPE mara-mbrsh,
            matkl TYPE mara-matkl,
            meins TYPE mara-meins,
            brgew TYPE mara-brgew,
            ntgew TYPE mara-ntgew,
            gewei TYPE mara-gewei,
           END OF t_mara.
    TYPES: BEGIN OF t_equk,
            matnr TYPE equk-matnr,
            werks TYPE equk-werks,
            bdatu TYPE equk-bdatu,
            vdatu TYPE equk-vdatu,
            qunum TYPE equk-qunum,
           END OF t_equk.
    CLASS : lcl_alv_grid DEFINITION DEFERRED.
    DATA : gi_mara TYPE STANDARD TABLE OF t_mara,
           gi_equk TYPE STANDARD TABLE OF t_equk,
           gs_mara TYPE t_mara,
           gs_equk TYPE t_equk.
    *-- Global data definitions for ALV
    *--- ALV Grid instance reference
    DATA : gw_alvgrid  TYPE REF TO cl_gui_alv_grid,
           gw_alvgrid1 TYPE REF TO cl_gui_alv_grid .
    *--- Custom container instance reference
    DATA gw_container      TYPE REF TO cl_gui_custom_container.
    DATA gw_event_handler  TYPE REF TO lcl_alv_grid.
    DATA gw_event_handler1 TYPE REF TO lcl_alv_grid.
    DATA gw_container1     TYPE REF TO cl_gui_custom_container.
    *--- Field catalog table
    DATA : gi_fieldcat  TYPE lvc_t_fcat,
           gi_fieldcat1 TYPE lvc_t_fcat,
           gs_fieldcat  TYPE lvc_s_fcat,
           gs_fieldcat1 TYPE lvc_s_fcat.
    *--- Layout structure
    DATA : gs_layout  TYPE lvc_s_layo,
           gs_layout1 TYPE lvc_s_layo.
          CLASS lcl_alv_grid DEFINITION
    CLASS lcl_alv_grid DEFINITION.
      PUBLIC SECTION.
        METHODS :
      Handle_double_click
          handle_double_click
             FOR EVENT double_click OF cl_gui_alv_grid
                IMPORTING e_row e_column,
      Handle_double_click
          handle_onf4
             FOR EVENT onf4 OF cl_gui_alv_grid
                IMPORTING e_fieldname,
      Handle_double_click
          handle_hotspot_click
             FOR EVENT hotspot_click OF cl_gui_alv_grid
                IMPORTING e_row_id.
      PRIVATE SECTION.
    ENDCLASS.                          " lcl_alv_grid DEFINITION
                    CLASS LCL_ALV_GRID IMPLEMENTATION                   *
    CLASS lcl_alv_grid IMPLEMENTATION.
                        METHOD handle_double_click                      *
      METHOD handle_double_click.
        READ TABLE gi_mara INTO gs_mara INDEX e_row.
        IF sy-subrc = 0.
          SELECT matnr
                 werks
                 bdatu
                 vdatu
                 qunum
            FROM equk
            INTO TABLE gi_equk
           WHERE matnr = gs_mara-matnr.
          IF sy-dbcnt NE 0.
            SORT gi_equk BY matnr werks bdatu.
          ENDIF.
          CALL SCREEN 0002.
        ENDIF.
      ENDMETHOD.                    "handle_double_click
                        METHOD handle_onf4                              *
      METHOD handle_onf4.
        PERFORM f4_help USING e_fieldname.
      ENDMETHOD.                    "handle_double_click
                        METHOD handle_double_click                      *
      METHOD handle_hotspot_click.
        READ TABLE gi_mara INTO gs_mara INDEX e_row_id.
        IF sy-subrc = 0.
          SELECT matnr
                 werks
                 bdatu
                 vdatu
                 qunum
            FROM equk
            INTO TABLE gi_equk
           WHERE matnr = gs_mara-matnr.
          IF sy-dbcnt NE 0.
            SORT gi_equk BY matnr werks bdatu.
          ENDIF.
          CALL SCREEN 0002.
        ENDIF.
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                          " lcl_alv_grid IMPLEMENTATION
                      SELECTION SCREEN DEFINITION                       *
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    SELECT-OPTIONS : s_matnr FOR mara-matnr NO INTERVALS,
                     s_mtart FOR mara-mtart NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK b1.
                           START-OF-SELECTION                           *
    START-OF-SELECTION.
      SELECT matnr
             lvorm
             mtart
             mbrsh
             matkl
             meins
             brgew
             ntgew
             gewei
             FROM mara
             INTO TABLE gi_mara
             WHERE matnr IN s_matnr
               AND mtart IN s_mtart.
      IF sy-dbcnt NE 0.
        SORT gi_mara BY matnr.
      ENDIF.
      CALL SCREEN 0001.
    *&      Module  STATUS_0001  OUTPUT
          text
    MODULE status_0001 OUTPUT.
      SET PF-STATUS '0001'.
      SET TITLEBAR  '001'.
      PERFORM build_alv_display.
    ENDMODULE.                 " STATUS_0001  OUTPUT
    *&      Module  USER_COMMAND_0001  INPUT
          text
    MODULE user_command_0001 INPUT.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'SAVE'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0001  INPUT
    *&      Form  build_alv_display
          text
    -->  p1        text
    <--  p2        text
    FORM build_alv_display .
      PERFORM build_fieldcat.
      PERFORM build_layout.
      PERFORM create_alv_grid.
      PERFORM display_alv_grid.
    ENDFORM.                    " build_alv_display
    *&      Form  build_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat .
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MATNR'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Material Number'.
      gs_fieldcat-outputlen = '18'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '1'.
      gs_fieldcat-hotspot   = 'X'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'LVORM'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Deletion'.
      gs_fieldcat-outputlen = '8'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '2'.
      gs_fieldcat-checkbox  = 'X'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MTART'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Material Type'.
      gs_fieldcat-outputlen = '13'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '3'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MBRSH'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Industry sector'.
      gs_fieldcat-outputlen = '15'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '4'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MATKL'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Material group'.
      gs_fieldcat-outputlen = '14'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '5'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MEINS'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Base Unit of Measure'.
      gs_fieldcat-outputlen = '20'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '6'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'BRGEW'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Gross weight'.
      gs_fieldcat-outputlen = '13'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '7'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'NTGEW'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Net weight'.
      gs_fieldcat-outputlen = '13'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '8'.
      APPEND gs_fieldcat TO gi_fieldcat.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'GEWEI'.
      gs_fieldcat-tabname   = 'MARA'.
      gs_fieldcat-coltext   = 'Weight Unit'.
      gs_fieldcat-outputlen = '11'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '9'.
      APPEND gs_fieldcat TO gi_fieldcat.
    ENDFORM.                    " build_fieldcat
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    FORM build_layout .
      gs_layout-sel_mode   = 'A'.
      gs_layout-edit       = ' '.
      gs_layout-no_toolbar = ' '.
      gs_layout-grid_title = 'Material Data'.
      gs_layout-no_headers = ' '.
      gs_layout-weblook    = 'X'.
    ENDFORM.                    " build_layout
    *&      Form  create_alv_grid
          text
    -->  p1        text
    <--  p2        text
    FORM create_alv_grid .
      IF gw_container IS INITIAL.
        CREATE OBJECT gw_container
            EXPORTING
               container_name = 'CC_ALV'.
    Display ALV grid
        IF gw_alvgrid IS INITIAL.
          CREATE OBJECT gw_alvgrid
             EXPORTING
                i_parent = gw_container.
        ENDIF.
      ENDIF.
      IF gw_event_handler IS INITIAL.
        CREATE OBJECT gw_event_handler.
        SET HANDLER gw_event_handler->handle_double_click
                FOR gw_alvgrid.
        SET HANDLER gw_event_handler->handle_onf4
                FOR gw_alvgrid.
        SET HANDLER gw_event_handler->handle_hotspot_click
                FOR gw_alvgrid.
      ENDIF.
    ENDFORM.                    " create_alv_grid
    *&      Form  display_alv_grid
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv_grid .
      CALL METHOD gw_alvgrid->set_table_for_first_display
        EXPORTING
          i_buffer_active    = ' '
          i_bypassing_buffer = ' '
          i_structure_name   = 'T_MARA'
          is_layout          = gs_layout
        CHANGING
          it_outtab          = gi_mara[]
          it_fieldcatalog    = gi_fieldcat[]
        EXCEPTIONS
          OTHERS             = 0.
    ENDFORM.                    " display_alv_grid
    *&      Module  STATUS_0002  OUTPUT
          text
    MODULE status_0002 OUTPUT.
      SET PF-STATUS '0002'.
      SET TITLEBAR '002'.
      PERFORM build_alv_display1.
    ENDMODULE.                 " STATUS_0002  OUTPUT
    *&      Module  USER_COMMAND_0002  INPUT
          text
    MODULE user_command_0002 INPUT.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0002  INPUT
    *&      Form  build_alv_display1
          text
    -->  p1        text
    <--  p2        text
    FORM build_alv_display1 .
      PERFORM build_fieldcat1.
      PERFORM build_layout1.
      PERFORM create_alv_grid1.
      PERFORM display_alv_grid1.
    ENDFORM.                    " build_alv_display1
    *&      Form  build_fieldcat2
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat1.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'MATNR'.
      gs_fieldcat-tabname   = 'EQUK'.
      gs_fieldcat-coltext   = 'Material Number'.
      gs_fieldcat-outputlen = '18'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '1'.
      gs_fieldcat-f4availabl = 'X'.
      APPEND gs_fieldcat TO gi_fieldcat1.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'WERKS'.
      gs_fieldcat-tabname   = 'EQUK'.
      gs_fieldcat-coltext   = 'Plant'.
      gs_fieldcat-outputlen = '4'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '2'.
      APPEND gs_fieldcat TO gi_fieldcat1.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'BDATU'.
      gs_fieldcat-tabname   = 'EQUK'.
      gs_fieldcat-coltext   = 'Valid Untill'.
      gs_fieldcat-outputlen = '12'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '3'.
      APPEND gs_fieldcat TO gi_fieldcat1.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'VDATU'.
      gs_fieldcat-tabname   = 'EQUK'.
      gs_fieldcat-coltext   = 'Valid From'.
      gs_fieldcat-outputlen = '10'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '4'.
      APPEND gs_fieldcat TO gi_fieldcat1.
      CLEAR gs_fieldcat.
      gs_fieldcat-fieldname = 'QUNUM'.
      gs_fieldcat-tabname   = 'EQUK'.
      gs_fieldcat-coltext   = 'Quota'.
      gs_fieldcat-outputlen = '10'.
      gs_fieldcat-edit      = ' '.
      gs_fieldcat-just      = 'C'.
      gs_fieldcat-col_pos   = '5'.
      APPEND gs_fieldcat TO gi_fieldcat1.
    ENDFORM.                    " build_fieldcat2
    *&      Form  build_layout2
          text
    -->  p1        text
    <--  p2        text
    FORM build_layout1.
      gs_layout1-sel_mode   = 'A'.
      gs_layout1-edit       = ' '.
      gs_layout1-no_toolbar = ' '.
      gs_layout1-grid_title = 'Quota Header Data'.
      gs_layout1-no_headers = ' '.
    ENDFORM.                    " build_layout1
    *&      Form  create_alv_grid2
          text
    -->  p1        text
    <--  p2        text
    FORM create_alv_grid1.
      IF gw_container1 IS INITIAL.
        CREATE OBJECT gw_container1
            EXPORTING
               container_name = 'CC_ALV1'.
    Display ALV grid
        IF gw_alvgrid1 IS INITIAL.
          CREATE OBJECT gw_alvgrid1
             EXPORTING
                i_parent = gw_container1.
        ENDIF.
      ENDIF.
      IF gw_event_handler1 IS INITIAL.
        CREATE OBJECT gw_event_handler1.
        SET HANDLER gw_event_handler1->handle_onf4
                FOR gw_alvgrid1.
      ENDIF.
    ENDFORM.                    " create_alv_grid1
    *&      Form  display_alv_grid2
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv_grid1 .
      DATA : li_f4 TYPE lvc_t_f4,
             ls_f4 TYPE lvc_s_f4.
      CALL METHOD gw_alvgrid1->set_table_for_first_display
        EXPORTING
          i_buffer_active    = ' '
          i_bypassing_buffer = ' '
          i_structure_name   = 'T_EQUK'
          is_layout          = gs_layout1
        CHANGING
          it_outtab          = gi_equk[]
          it_fieldcatalog    = gi_fieldcat1[]
        EXCEPTIONS
          OTHERS             = 0.
      IF li_f4[] IS INITIAL.
        MOVE 'MATNR' TO ls_f4-fieldname.
        MOVE 'X'     TO ls_f4-register.
        MOVE 'X'     TO ls_f4-getbefore.
        APPEND ls_f4 TO li_f4.
        CLEAR  ls_f4.
        CALL METHOD gw_alvgrid1->register_f4_for_fields
          EXPORTING
            it_f4 = li_f4.
      ENDIF.
    ENDFORM.                    " display_alv_grid1
    *&      Form  f4_help
          text
         -->P_FIELDNAME  text
    FORM f4_help  USING    p_fieldname.
      TYPES : BEGIN OF t_values,
                matnr TYPE mara-matnr,
              END OF t_values.
      DATA : li_fields        TYPE TABLE OF dfies,
             li_select_values TYPE TABLE OF ddshretval,
             li_values        TYPE TABLE OF t_values,
             ls_fields        TYPE dfies,
             ls_values        TYPE t_values.
      REFRESH : li_fields,
                li_select_values.
      SELECT matnr
        FROM equk
        INTO TABLE li_values.
      CASE p_fieldname.
        WHEN 'MATNR'.
          ls_fields-tabname    = 'EQUK'.
          ls_fields-fieldname  = 'MATNR'.
          APPEND ls_fields TO li_fields.
          CLEAR ls_fields.
          SORT li_values BY matnr.
          DELETE ADJACENT DUPLICATES FROM li_values COMPARING matnr.
          CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
            EXPORTING
              retfield   = 'MATNR'
            TABLES
              value_tab  = li_values
              field_tab  = li_fields
              return_tab = li_select_values.
          IF sy-subrc = 0.
           LOOP AT li_select_values WHERE fieldname = 'MATNR'.
             clear gs_mara.
             gs_mara in
          ENDIF.
      ENDCASE.
    ENDFORM.                                                    " f4_help

  • List box in alv grid control  through slis and reuse_alv grid_display metho

    hello,
    i want to display list box in one column of alv by slis method.can u suggest me how to do it?
    neon

    Hi,
    plz check below code :
    TYPE-POOLS : slis.
    *data declarations for ALV container,ALV grid, Fieldcatalogues & layout
    DATA: 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,
          gs_layout TYPE lvc_s_layo.
    *INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
    DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
          wa_outtab TYPE t517a.
    *initialisation event
    INITIALIZATION.
    *Start of selection event
    START-OF-SELECTION.
    *Call to ALV
      CALL SCREEN 600.
    *On this statement double click  it takes you to the screen painter SE51.
    *Create a Custom container and name it CCONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    *Now a normal screen with number 600 is created which holds the ALV grid.
    PBO of the actual screen , Here we can give a title and customized menus
    Here we also call the subroutine for ALV output.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
    set pf-status 'xxx'.
    set titlebar 'MAIN100'.
    Subroutine to display the output in alv
      PERFORM alv_output.
    ENDMODULE.                    "pbo OUTPUT
    PAI module of the screen created. In case we use an interactive ALV or
    *for additional functionalities we can create OK codes and
    based on the user command we can do the coding.
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    ENDMODULE.                    "pai INPUT
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat.
      DATA ls_fcat TYPE lvc_s_fcat.
    *Build the field catalogue
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'T517A'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    To assign dropdown in the fieldcataogue
      LOOP AT gt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'SLART'.
    *drdn-hndl = '1' is the first list box
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
    *drdn-hndl = '2' is the second list box
          WHEN 'ABART'.
            ls_fcat-drdn_hndl = '2'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  ALV_OUTPUT
    FORM alv_output .
    *Create object for container
      CREATE OBJECT g_custom_container
             EXPORTING container_name = 'CCONT'.
    *create object for grid
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Build fieldcat and set column
    *Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat.
    *Build layout
      PERFORM build_layout.
    Define a drop down table.
      PERFORM dropdown_table.
    *fetch values from the T517A table
      SELECT * FROM t517a INTO TABLE gt_outtab.
    *Display ALV output
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = gt_outtab.
    ENDFORM.                               "ALV_OUTPUT
    *&      Form  dropdown_table
          text
    -->  p1        text
    <--  p2        text
    FORM dropdown_table.
    *Declarations for drop down lists in ALV.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    First SLART listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 Primary school'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 Lower Secondary'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '03 Upper Secondary'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '04 Professional School'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '05 College'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '06 University'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '09 Other Establishment'.
      APPEND ls_dropdown TO lt_dropdown.
    Second ABART listbox (handle '2').
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '10 Primary School certificate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '20 Lower secondary/Junior high'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '30 High school diploma(B-levels)'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '31 Vocational'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '32 Matriculation'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '40 Specialist vocational certificate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '50 College degree Level1'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '51 College degree Level2'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '52 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '60 Univ Degree level1'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '61 Bachelors degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '62 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '63 Licenciate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '64 Doctors Degree Ph.D'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '89 None'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '90 Unknown'.
      APPEND ls_dropdown TO lt_dropdown.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " dropdown_table
    *&      Form  build_layout
          text
    *layout for ALV output
    FORM build_layout .
      gs_layout-cwidth_opt = 'X'.
      gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
      gs_layout-no_toolbar = 'X'.
    ENDFORM.                    " build_layout
    reference : wiki.

  • Reg: Export To Excel From an ALV Grid

    Hi All,
    I am exporting data from an ALV Grid (FM: REUSE_ALV_GRID_DISPLAY).
    By Clicking the Standard 'Local File' button --> Spreadsheet
    Output Internal table is having data of around 300 Chars in a particular field but in exported Excel sheet it is displaying upto some what less then 240 chars only.
    Is there any maximum limit (for a particular field in ALV grid) till what data can be exported to an Excel sheet ?
    Regards,
    Pankaj.

    Hello ,
    this is possible, Add import button your gui status and you can use "GUI_DOWNLOAD" FM module.
    Regards
    İrfan.

Maybe you are looking for

  • How do I get ringtones to work in IOS 5?

    My iPhone 4 won't recognise three ringtones that I made using Garageband that worked before the latest upgrade.  They work on my wife's.  Any suggestions on how to get them to work on my phone?

  • Netflix not working with composite video to tv anymore.

    Netflix requires AirPlay mirroring to be turned off when connecting to TV via composite video.  However the AirPlay menu does not show up.

  • UpdateDate to Access

    I have tried many approaches to getting a date (java.sql.Date) into my Access Database, but with no success. I want to leave it as a date field, so converting it to a string is less than optimal. 'updateDate' gives me an error when I try to updateRow

  • Different error messages from different env while fetching ref cursor

    Hi<br> I have a package where i need to call one of the procedure.I this <br> procedure i am returning a refcursor as out parameter.Before returning refcursor i <br> am doing i am checking a condition if it is satisfied then I am saying return or els

  • E900 chained routers - double NAT

    I understand double and triple NAT is unstable. How do I configure the routers to fix this issue?  DMZ?  port-forwarding? Here is my setup: ---comcast modem--->E900 router--->Netgear router I want to split internet access from a single DHCP IP from C