Filed in the ALV report in which user can enter text manually

Hi,
Is it possible to enter a field in the report where user can enter data manually and save it in a ALV report?
If yes then let

Hi, SATYA
Test the following Sample Report it hope it will solve out your Problems related to ALV.
REPORT  zfsl_alv_test.
TYPES: BEGIN OF t_it,
  mname(10),
  amount1 TYPE p,
  amount2 TYPE p,
END OF t_it.
*TABLES : it1_sum.
TYPE-POOLS : slis.
*VARIABLES
DATA : check(1),
       rep_id TYPE sy-repid.
*INTERNAL TABLE TYPE OF t_name
DATA: it1_sum TYPE STANDARD TABLE OF t_it WITH HEADER LINE,
      wa_it1_sum TYPE t_it,
      it2_sum TYPE STANDARD TABLE OF t_it WITH HEADER LINE,
      wa_it2_sum TYPE t_it.
*List Header
DATA : it_listheader TYPE STANDARD TABLE OF slis_listheader WITH HEADER LINE,
       wa_listheader TYPE slis_listheader.
*Event Raising to Display Heading.
DATA: event TYPE slis_t_event,
      event_str TYPE slis_alv_event.        "Event String.
*FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv,
       wa_field TYPE slis_fieldcat_alv.
*SORTING
DATA : it_sort TYPE slis_t_sortinfo_alv,
       wa_sort TYPE slis_sortinfo_alv.
*Layout
DATA : wa_layout TYPE slis_layout_alv.
INITIALIZATION.
  check = 'X'.
  rep_id = sy-repid.
START-OF-SELECTION.
  wa_it1_sum-mname = 'BBB'.
  wa_it1_sum-amount1 = '-500'.
  wa_it1_sum-amount2 = '-200'.
  APPEND wa_it1_sum  TO it1_sum.
  wa_it1_sum-mname = 'BBB'.
  wa_it1_sum-amount1 = 100.
  wa_it1_sum-amount2 = 200.
  APPEND wa_it1_sum  TO it1_sum.
  wa_it1_sum-mname = 'CCC'.
  wa_it1_sum-amount1 = 500.
  wa_it1_sum-amount2 = 10000.
  APPEND wa_it1_sum  TO it1_sum.
  wa_it1_sum-mname = 'CCC'.
  wa_it1_sum-amount1 = 105000.
  wa_it1_sum-amount2 = 20500.
  APPEND wa_it1_sum  TO it1_sum.
  wa_it1_sum-mname = 'AAA'.
  wa_it1_sum-amount1 = 21000.
  wa_it1_sum-amount2 = 22000.
  APPEND wa_it1_sum  TO it1_sum.
  wa_it1_sum-mname = 'BBB'.
  wa_it1_sum-amount1 = 5500.
  wa_it1_sum-amount2 = 2200.
  APPEND wa_it1_sum  TO it1_sum.
*          Heading
  wa_listheader-typ = 'H'.
  wa_listheader-info = 'ALV TEST Top-of-Page'.
  APPEND wa_listheader TO it_listheader.
*          FIELD CATALOG
  wa_field-col_pos = 1 .
  wa_field-tabname = 'IT1_SUM'.
  wa_field-fieldname = 'MNAME'.
  wa_field-seltext_m = 'Material Number'.
*ls_fcat-do_sum = 'X'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.
  wa_field-col_pos = 2 .
  wa_field-tabname = 'IT1_SUM'.
  wa_field-fieldname = 'AMOUNT1'.
  wa_field-seltext_m = 'Amount 1'.
  wa_field-do_sum = check.
  wa_field-edit = 'X'. " To add this you can edit any Colum
  wa_field-edit_mask = 'V___________'.  " Use this to place the (-) Minus Signe on the left side
*ls_fcat-do_sum = 'X'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.
  wa_field-col_pos = 3 .
  wa_field-tabname = 'IT1_SUM'.
  wa_field-fieldname = 'AMOUNT1'.
  wa_field-seltext_m = 'Amount 2'.
  wa_field-do_sum = check.
  wa_field-edit_mask = 'V___________'.
*ls_fcat-do_sum = 'X'.
  APPEND wa_field TO it_field.
  CLEAR wa_field.
*          SORT By MNAME
  wa_sort-spos = 1.
  wa_sort-fieldname = 'MNAME'.
  wa_sort-tabname = 'IT1_SUM'.
  wa_sort-up = check. " Here Use u2018downu2019 for descending Order
  wa_sort-subtot = check.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.
*          ALV Layout Setting
  wa_layout-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.
*          Calling function to raise event to display heading and icon above ALV
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
   EXPORTING
     i_list_type           = 0
   IMPORTING
     et_events             = event[]
* EXCEPTIONS
*   LIST_TYPE_WRONG       = 1
*   OTHERS                = 2
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*          Calling TOP_OF_PAGE Event
  READ TABLE event WITH KEY name = 'TOP_OF_PAGE' INTO event_str.
  IF sy-subrc = 0.
    MOVE: 'TOP_OF_PAGE' TO event_str-form.
    APPEND event_str TO event.
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = sy-cprog
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
     i_grid_title                      = 'ALV Test'
*   I_GRID_SETTINGS                   =
     is_layout                         = wa_layout
     it_fieldcat                       = it_field
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
     it_sort                           = it_sort
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
     i_default                         = 'X'
     i_save                            = 'X'
*   IS_VARIANT                        =
     it_events                         = event[]
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = it1_sum
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*&      Form  top_of_page
*       text
FORM top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_listheader[]
      i_logo                   = 'ENJOYSAP_LOGO'
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
ENDFORM.           "top_of_page
Kind Regards,
Faisal

Similar Messages

  • Restrict Which Users Can Enter Data In List Form in SharePoint Foundation 2013

    Is there a way to restrict which users can enter data in particular fields in a list item entry form?
    We are using a SharePoint Foundation 2013 list and calendar to manage vacation time. We need to restrict non-supervisor users users from entering a value in a certain field in the vacation request form.
    Here is how the system works now:
    1. Employees complete the vacation request form (which creates a list item)
    2. An email is sent to their supervisor to either approve or decline the request
    3. Approved requests are automatically entered onto the vacation calendar
    We have restricted the list so that only supervisors can edit items (the pending vacation requests). The problem is that all users can mark their own requests as approved when they fill out the request form in the first place. Is there a way to restrict
    which users can enter data in particular fields on a list item entry form?

    Thanks for the suggestion. We ended up 1) hiding the approval column and 2) creating a second list, workflow, etc. The user no longer sees the approval column when filling out the form. Requests are now submitted to list A. Workflow #1 copies the request
    to List B, then deletes the item from List A. Once the request is added to List B, Workflow #2 emails the user that the request has been received and emails the supervisor that a request needs to be approved. Only supervisors have editing permissions on List
    B. Approved requests are automatically added to the vacation calendar (the calendar view of List B).
    We found the following site to be helpful in learning how to hide the list column:
    http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2013/06/03/how-to-hide-a-sharepoint-list-column-from-a-list-form.aspx

  • How to set the maximum length that a user can enter in Msgstyledtextinput

    Hi Everyone,
    I'm currently using EBS 11.5.1 and 10.2g DB
    Is there a way that I can set the maximum length that a user can input?
    I changed the Maximum Length to lower number (from 150 to 100) but I get the following error.
    Developer Mode Exception encountered in item SaveLocation
    Error: The item SaveLocation has a maximum length (100)
             which is not equal to that of the corresponding VO attribute
           , SaveLocation length (150).
    Action: Make sure they are equal in size. There must be other way to set that value
    Thanks,
    Elmer

    You have to set the maximum length of column to 150 to avoid this error.
    You can set the same in Jdev.
    Thanks
    --Anil                                                                                                                                                                                                                                                       

  • The best technique to allow user to enter text in a smart form.

    I have created a smartform based on a sales order. Now in one section of the form, the user will have to type out a text or include an existing text based on certain parameters like plant (t001w-werks) which may vary for the sales orders. I want to know the best possible way to go about with this.
    Thanks,
    Bindu.

    Hi,
      Create 'Program lines' and write a condition based on plant and assign the required text to a vairable. Display the variable as text element.
    Program lines:
    IF ITAB-WERKS = '1001'.
          g_f_text = 'ABC'.
    ELSE.
         g_f_text = 'EFG'.
    ENDIF.
    Text element:
       G_F_TEXT.

  • Display/Print the Selection criteria entered by USER on the ALV Report o/p?

    Hi Experts,
    I hv a requirement of to print/display the Selection criteria entered by user in the selection screen.........on the top portion of the ALV report output lay out.
    There is a FM for this purpose, but, I forgot its name!!
    So, let me know the FM or FMs, so that, will choose, which is best one,
    or the piece of code, which covers all select-option entries..........appreciated.
    thanq
    Edited by: SAP ABAPer on Sep 3, 2008 6:35 PM

    Use the Function RS_REFRESH_FROM_SELECTOPTIONS get the selection details, now format the data accordingly in the TOP_OF_PAGE using the calss CL_DD_DOCUMENT.
    Check the below mention code.
    REPORT  ztest_page.
    TABLES: sflight.
    DATA : it_flight TYPE TABLE OF sflight WITH HEADER LINE.
    DATA BEGIN OF it_sel_opt OCCURS 0.
            INCLUDE STRUCTURE rsparams.
    DATA END   OF it_sel_opt.
    SELECT-OPTIONS: s_carrid FOR sflight-carrid.
    START-OF-SELECTION.
      SELECT * FROM sflight INTO TABLE it_flight
       WHERE carrid IN s_carrid.
    END-OF-SELECTION.
      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          curr_report     = sy-repid
        TABLES
          selection_table = it_sel_opt
        EXCEPTIONS
          not_found       = 01
          no_report       = 02.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = sy-repid
          i_callback_html_top_of_page = 'TOP_OF_PAGE'
          i_structure_name            = 'SFLIGHT'
        TABLES
          t_outtab                    = it_flight
        EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.
    *&      Form  top_of_page
    *       text
    *      -->DOCUMENT   text
    FORM top_of_page USING document TYPE REF TO cl_dd_document.
      DATA : dl_text(255) TYPE c.  "Text
    * Add new-line
      CALL METHOD document->new_line.
      CALL METHOD document->new_line.
      CLEAR : dl_text.
    * program ID
      dl_text = 'Program Name :'.
      CALL METHOD document->add_gap.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_heading_int.
      CLEAR dl_text.
      dl_text = sy-repid.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      CLEAR : dl_text.
      dl_text = 'Selection Criteria'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 34.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      CLEAR : dl_text.
      CONCATENATE 'SELECT Option' 'SIGN' 'OPTION' 'LOW' 'HIGH'
      INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      CALL METHOD document->add_gap
        EXPORTING
          width = 34.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      LOOP AT it_sel_opt.
        CLEAR : dl_text.
        CONCATENATE it_sel_opt-selname  it_sel_opt-sign
         it_sel_opt-option it_sel_opt-low it_sel_opt-high
        INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
        CALL METHOD document->add_gap
          EXPORTING
            width = 34.
        CALL METHOD document->add_text
          EXPORTING
            text         = dl_text
            sap_emphasis = cl_dd_area=>heading
            sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
        CALL METHOD document->new_line.
      ENDLOOP.
    ENDFORM.                    "top_of_page

  • To edit the field in the ALV report

    Hi,
        i want to edit the field of the ALV report what i need to do for that..
    Thanks & Regards
    Ashu Singh

    hi,
    check the code,
    REPORT  zalv_fcat.* Output table T006 structure declarationTYPES : BEGIN OF ty_t006.
            INCLUDE STRUCTURE t006.
    TYPES : END OF ty_t006.*Internal table and wa declaration for T006
    DATA : it_t006 TYPE STANDARD TABLE OF ty_t006,
           wa_t006 TYPE ty_t006.*declarations for ALV
    DATA: ok_code               TYPE sy-ucomm,
    fieldcatalog for T006
          it_fielcat           TYPE lvc_t_fcat,
    fieldcatalog for fieldcatalog itself:
          it_fielcatalogue           TYPE lvc_t_fcat,
          it_layout           TYPE lvc_s_layo.*declaration for toolbar function
    DATA:   it_excl_func        TYPE ui_functions.
    Controls to display it_t006 and corresponding fieldcatalog
    DATA: cont_dock TYPE REF TO cl_gui_docking_container,
          cont_alvgd     TYPE REF TO cl_gui_alv_grid.*controls to display the fieldcatalog as editable alv grid and container
    DATA: cont_cust TYPE REF TO cl_gui_custom_container,
          cont_editalvgd     TYPE REF TO cl_gui_alv_grid.*intialization event
    INITIALIZATION.*start of selection event
    START-OF-SELECTION.
    LOCAL CLASS Definition for data changed in fieldcatalog ALV
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    LOCAL CLASS implementation for data changed in fieldcatalog ALV
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION*data declaration for event receiver
    DATA: event_receiver TYPE REF TO lcl_event_receiver.*end of selection event
    END-OF-SELECTION.*setting the screen for alv output for table display and
    *changed fieldcatalalogue display
    SET SCREEN 600.
    On this statement double click  it takes you to the screen painter SE51. Enter the attributes
    *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
    *Go to SE41 and create status 'STATUS600' and create THE function code 'SUBMIT'
    *and 'EXIT' with icons and icon texts
    Also create a TitleBar 'TITLE600' and give the relevant title.&----
    *&      Module  STATUS_0600  OUTPUT
    MODULE status_0600 OUTPUT.
      SET PF-STATUS 'STATUS600'.
      SET TITLEBAR 'TITLE600'.
    CREATE ALV GRID CONTROL IF DOES NOT EXISTS INITIALLY
      IF cont_dock IS INITIAL.
        PERFORM create_alv.
      ENDIF.ENDMODULE.                             " STATUS_0600  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 as shown below
    *&      Module  USER_COMMAND_0600  INPUT
    MODULE user_command_0600 INPUT.
      CASE ok_code.
        WHEN 'SUBMIT'.
    *TO GET THE CURRENT FIELDCATALOGUE FROM THE FRONTEND
          CALL METHOD cont_alvgd->set_frontend_fieldcatalog
            EXPORTING
              it_fieldcatalog = it_fielcat.
    *refresh the alv
          CALL METHOD cont_alvgd->refresh_table_display.
    *to Send Buffered Automation Queue to Frontend
          CALL METHOD cl_gui_cfw=>flush.*Exit button clicked to leave the program
        WHEN 'EXIT'.
          LEAVE PROGRAM.  ENDCASE.ENDMODULE.                             " USER_COMMAND_0600  INPUT&----
    *&      Form  CREATE_ALV
    &----FORM create_alv.*create a docking container and dock the control at the botton
      CREATE OBJECT cont_dock
          EXPORTING
               dynnr = '600'
               extension = 100
               side = cl_gui_docking_container=>dock_at_bottom.*create the alv grid for display the table
      CREATE OBJECT cont_alvgd
          EXPORTING
               i_parent = cont_dock.*create custome container for alv
      CREATE OBJECT cont_cust
          EXPORTING
               container_name = 'CCONT'.
    *create alv editable grid
      CREATE OBJECT cont_editalvgd
          EXPORTING
               i_parent = cont_cust.* register events for the editable alv
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_data_changed FOR cont_editalvgd.  CALL METHOD cont_editalvgd->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.*building the fieldcatalogue for the initial display
      PERFORM build_fieldcat CHANGING it_fielcat it_fielcatalogue.*building the fieldcatalogue after the user has changed it
      PERFORM change_fieldcat CHANGING it_fielcatalogue.*fetch data from the table
      PERFORM fetch_data.*    Get excluding functions for the alv editable tool bar  APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort_asc TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort_dsc TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_subtot TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_graph TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_info TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_print TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_filter TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_views TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_export TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_paste TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_find TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_copy  TO it_excl_func.
    *Alv display for the T006 table at the bottom
      CALL METHOD cont_alvgd->set_table_for_first_display
        CHANGING
          it_outtab       = it_t006[]
          it_fieldcatalog = it_fielcat[].
    optimize column width of grid displaying fieldcatalog
      it_layout-cwidth_opt = 'X'.* Get fieldcatalog of table T006 - alv might have
    modified it after passing.
      CALL METHOD cont_alvgd->get_frontend_fieldcatalog
        IMPORTING
          et_fieldcatalog = it_fielcat[].to Send Buffered Automation Queue to Frontend  CALL METHOD cl_gui_cfw=>flush. Display fieldcatalog of table T006 in editable alv grid
      CALL METHOD cont_editalvgd->set_table_for_first_display
        EXPORTING
          is_layout            = it_layout
          it_toolbar_excluding = it_excl_func
        CHANGING
          it_outtab            = it_fielcat[]
          it_fieldcatalog      = it_fielcatalogue[].
    ENDFORM.                               " CREATE_alv
    *&      Form  fetch_data
    FORM fetch_data.* select data of T006
      SELECT * FROM t006 INTO TABLE it_t006 UP TO 50 ROWS.
    ENDFORM.                               " fetch_data
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat CHANGING it_fldcat TYPE lvc_t_fcat
                                       it_fcat TYPE lvc_t_fcat.
    Fieldcatalog for table T006: it_fldcat
    to generate the fields automatically  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'T006'
        CHANGING
          ct_fieldcat            = it_fldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_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.*----
    Fieldcatalog for table LVC_T_FCAT:it_fcat
    Generate fieldcatalog of fieldcatalog structure.
    This fieldcatalog is used to display fieldcatalog 'it_fldcat'
    on the top of the screen.  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'LVC_S_FCAT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_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.
    ENDFORM.                               " BUILD_FIELDCAT
    *&      Form  CHANGE_FIELDCAT
    *after the user has modified the fieldcatalogue we build another fieldcat
    *for the modified alv display
    FORM change_fieldcat CHANGING it_fcat TYPE lvc_t_fcat.  DATA ls_fcat TYPE lvc_s_fcat.  LOOP AT it_fcat INTO ls_fcat.
        ls_fcat-coltext = ls_fcat-fieldname.
        ls_fcat-edit = 'X'.    IF ls_fcat-fieldname = 'COL_POS' OR ls_fcat-fieldname = 'FIELDNAME'.
          ls_fcat-key = 'X'.
        ENDIF.    MODIFY it_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                               " CHANGE_FIELDCAT
    ref:saptechnical tutorial.
    Regards,
    Anirban

  • Running the alv report  in  background and sending it thro email

    hi,
          i have to run the  alv report in background and send the output through email

    Hi
    Many a times there is a requirement to display ALV Grid (not ALV List) in the background Job. I have checked the SDN Forum for the same and it has been mentioned that ALV Grid cannot be displayed in Background, but the list output of ALV is possible. So user won’t have the actual Grid interface but the List interface.
    There is a workaround to display ALV Grid in Background Job. The only restriction is you can’t schedule the job through SM36. You need to execute the transaction of the report program, fill in the selection screen data and hit Execute.
    The job would be executed in background. User will be able to see the Job Log and Job Status after executing the program. User doesn’t have to go to SM37 to view the job status/log. Once the Job Status is changed to “COMPLETED”, user can click on “DISPLAY SPOOL” to view the ALV Grid.
    Limitations:
    Can’t schedulea background job
    The session should be active until the background job is completed. If the session is closed, then user won’t be able to check the output in ALV Grid. User would be able to check the output through spool or SM37
    Advantages:
    If the spool width is greater than 255 characters, then the entire width could be seen in the output because the output is directed to an ALV Grid and not to spool
    Interface of ALV Grid is available instead of ALV List even though it’s a background job.
    Program won’t give the TIME OUT error
    Steps Required:
    1. Once you execute the program, the following screen would be displayed
    2. Click “Display Job Status” to check the Status of the Background Job
    3. Click on “Display the Job Log” to check the Log
    4. Click on “Display Job Status” to check the Job Status
    5. Click on “DISPLAY SPOOL” to check the spool content once the Job Status is changed to “COMPLETED”. Output is displayed in ALV Grid
    Programs:
    1.  Two different programs needs to be created
    ZPROGRAM_ONE: This is the 1st program, where the selection screen and all the data validations would be done. Error handling for invalid data should be done in this program.
    Once the data validation is done, this program would call the 2nd program ZPROGEAM_TWO. Build the logic to display ALV Grid in this program. The logic will only display ALV in foreground and it won’t be reflected in the spool.
    ZPROGRAM_TWO: This program would fetch all the data and do all the processing. If you want the spool output along with ALV Grid output, then build the logic in this program to display ALV Grid.
    *& Report  ZPROGRAM_ONE                                                *
    REPORT  zprogram_one                            .
    PRASHANT PATIL
    TABLES : mara,
             tsp01.
    type-pools:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara       TYPE STANDARD TABLE OF t_mara,
           wa_mara      TYPE t_mara,
           wa_index     TYPE indx,        " For Index details
           wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
           i_jobsteplist     TYPE STANDARD TABLE OF tbtcstep, " For spool number
           wa_params         TYPE pri_params,  " To Get Print Parameters
           wa_jobhead        TYPE tbtcjob,     " To know the status of job
           wa_jobsteplist    TYPE tbtcstep,    " To know the spool
           w_jobname         TYPE tbtco-jobname,  " Job name for bckgrnd job
           w_jobcount        TYPE tbtco-jobcount, " Unique id for bckgrd job
           w_path            TYPE string,         " Upload path
           w_lsind           TYPE sy-lsind,       " Index
           wa_seltab         TYPE rsparams,
           i_seltab          TYPE STANDARD TABLE OF rsparams,
           wa_index1         TYPE indx,        " For Index details
           wa_index_key1     TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
            CONSTANTS DECLARATION                                        *
    CONSTANTS :
             c_a(1) TYPE c VALUE 'A',
             c_m(1) TYPE c VALUE 'M',
             c_l(1) TYPE c VALUE 'L',
             c_c(1) TYPE c VALUE 'C',
             c_zfdr(4) TYPE c VALUE 'ZFDR',
             c_x(1)    TYPE c VALUE 'X',
             c_locl(4) TYPE c VALUE 'LOCL', " Destination is LOCAL
             c_f(1)    TYPE c VALUE 'F',   " Job Status - Failed
             c_s(1)    TYPE c VALUE 'S',
             c_p(1)    TYPE c VALUE 'P'.
    SELECTION SCREEN PARAMETERS
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    START-OF-SELECTION.
    Before the export, fill the data fields before CLUSTR
      wa_index-aedat = sy-datum.
      wa_index-usera = sy-uname.
      EXPORT s_matnr
           TO DATABASE indx(st) FROM wa_index ID wa_index_key.
    To Open the Job for background processing
      PERFORM open_job.
    To get the print parameters
      PERFORM get_print_parameters.
    Submit the job in background
      PERFORM job_submit.
    Close the background job
      PERFORM job_close.
    This is the output screen with the buttons ********
    Create 3 buttons DISPLAY SPOOL, STATUS, JOBLOG
      SET PF-STATUS 'ZS001'.
      WRITE: / 'The program is submitted in Background'.
      WRITE: / 'Press DISPLAY SPOOL to see the spool'.
      WRITE: / 'Press STATUS to see the status of the background'.
    AT USER-COMMAND.
    If user presses the 'BACK' button
      IF sy-ucomm = 'BAK'.
        IF  wa_jobhead-status = c_f OR
            wa_jobhead-status = c_a.
          LEAVE TO SCREEN 0.
        ENDIF.
      ENDIF.
    If the user presses the 'DISPLAY SPOOL' Button
      IF sy-ucomm = 'DISPLAY'.
        PERFORM display_spool.
      ENDIF.
    If the user presses the 'JOB STATUS' Button
      IF sy-ucomm = 'STATUS'.
        PERFORM display_status.
      ENDIF.
    If the user presses the 'JOB LOG' Button
      IF sy-ucomm = 'JOBLOG'.
        PERFORM display_job_log.
      ENDIF.
    *&      Form  open_job
          text
    -->  p1        text
    <--  p2        text
    FORM open_job .
    This is to Create a new job which is to be submitted in background to
    process sales order/delivery/invoice
    Here we would get a unique id ( Jobcount ) which identifies our job
    along with the job name which we have assigned to our job
      CONCATENATE sy-uname
                  sy-datum
                  sy-uzeit
                          INTO w_jobname .  " Assign unique jobname
      CALL FUNCTION 'JOB_OPEN'
       EXPORTING
      DELANFREP              = ' '
      JOBGROUP               = ' '
        jobname                = w_jobname
      SDLSTRTDT              = NO_DATE
      SDLSTRTTM              = NO_TIME
      JOBCLASS               =
      IMPORTING
       jobcount                = w_jobcount
    CHANGING
      RET                    =
    EXCEPTIONS
       cant_create_job        = 1
       invalid_job_data       = 2
       jobname_missing        = 3
       OTHERS                 = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " open_job
    *&      Form  get_print_parameters
          text
    -->  p1        text
    <--  p2        text
    FORM get_print_parameters .
      DATA : l_valid TYPE c.
    This is to get the Print Parameters for the job which is to be
    submitted in background to process sales order/delivery/invoice
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
       EXPORTING
      ARCHIVE_ID                   = C_CHAR_UNKNOWN
      ARCHIVE_INFO                 = C_CHAR_UNKNOWN
      ARCHIVE_MODE                 = C_CHAR_UNKNOWN
      ARCHIVE_TEXT                 = C_CHAR_UNKNOWN
      AR_OBJECT                    = C_CHAR_UNKNOWN
      ARCHIVE_REPORT               = C_CHAR_UNKNOWN
      AUTHORITY                    = C_CHAR_UNKNOWN
      COPIES                       = C_NUM3_UNKNOWN
      COVER_PAGE                   = C_CHAR_UNKNOWN
      DATA_SET                     = C_CHAR_UNKNOWN
      DEPARTMENT                   = C_CHAR_UNKNOWN
          destination                  = c_locl " LOCL
      EXPIRATION                   = C_NUM1_UNKNOWN
          immediately                  = space
      IN_ARCHIVE_PARAMETERS        = ' '
      IN_PARAMETERS                = ' '
      LAYOUT                       = C_CHAR_UNKNOWN
      LINE_COUNT                   = C_INT_UNKNOWN
      LINE_SIZE                    = C_INT_UNKNOWN
      LIST_NAME                    = C_CHAR_UNKNOWN
      LIST_TEXT                    = C_CHAR_UNKNOWN
      MODE                         = ' '
          new_list_id                  = c_x
      PROTECT_LIST                 = C_CHAR_UNKNOWN
          no_dialog                    = c_x
      RECEIVER                     = C_CHAR_UNKNOWN
      RELEASE                      = C_CHAR_UNKNOWN
      REPORT                       = C_CHAR_UNKNOWN
      SAP_COVER_PAGE               = C_CHAR_UNKNOWN
      HOST_COVER_PAGE              = C_CHAR_UNKNOWN
      PRIORITY                     = C_NUM1_UNKNOWN
      SAP_OBJECT                   = C_CHAR_UNKNOWN
      TYPE                         = C_CHAR_UNKNOWN
          user                         = sy-uname
      USE_OLD_LAYOUT               = ' '
      UC_DISPLAY_MODE              = C_CHAR_UNKNOWN
      DRAFT                        = C_CHAR_UNKNOWN
      ABAP_LIST                    = ' '
      USE_ARCHIVENAME_DEF          = ' '
      DEFAULT_SPOOL_SIZE           = C_CHAR_UNKNOWN
      PO_FAX_STORE                 = ' '
      NO_FRAMES                    = C_CHAR_UNKNOWN
       IMPORTING
      OUT_ARCHIVE_PARAMETERS       =
          out_parameters               = wa_params
       valid                        = l_valid
       EXCEPTIONS
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         OTHERS                       = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " get_print_parameters
    *&      Form  job_submit
          text
    -->  p1        text
    <--  p2        text
    FORM job_submit .
    The job which we have created & the unique id ( jobcount ) which we
    have got identifies our job. Hence those parameters are passed along
    with the name of the background program "ZPROGRAM_TWO"
    The job is submitted in background.
      CALL FUNCTION 'JOB_SUBMIT'
        EXPORTING
      ARCPARAMS                         =
        authcknam                         = sy-uname
      COMMANDNAME                       = ' '
      OPERATINGSYSTEM                   = ' '
      EXTPGM_NAME                       = ' '
      EXTPGM_PARAM                      = ' '
      EXTPGM_SET_TRACE_ON               = ' '
      EXTPGM_STDERR_IN_JOBLOG           = 'X'
      EXTPGM_STDOUT_IN_JOBLOG           = 'X'
      EXTPGM_SYSTEM                     = ' '
      EXTPGM_RFCDEST                    = ' '
      EXTPGM_WAIT_FOR_TERMINATION       = 'X'
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LANGUAGE                          = SY-LANGU
        priparams                         = wa_params
        report                            = 'ZPROGRAM_TWO'
      VARIANT                           = ' '
    IMPORTING
      STEP_NUMBER                       =
       EXCEPTIONS
         bad_priparams                     = 1
         bad_xpgflags                      = 2
         invalid_jobdata                   = 3
         jobname_missing                   = 4
         job_notex                         = 5
         job_submit_failed                 = 6
         lock_failed                       = 7
         program_missing                   = 8
         prog_abap_and_extpg_set           = 9
         OTHERS                            = 10
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_submit
    *&      Form  job_close
          text
    -->  p1        text
    <--  p2        text
    FORM job_close .
    Once the job is submitted in background then the job is closed
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LASTSTRTDT                        = NO_DATE
      LASTSTRTTM                        = NO_TIME
      PRDDAYS                           = 0
      PRDHOURS                          = 0
      PRDMINS                           = 0
      PRDMONTHS                         = 0
      PRDWEEKS                          = 0
      PREDJOB_CHECKSTAT                 = ' '
      PRED_JOBCOUNT                     = ' '
      PRED_JOBNAME                      = ' '
      SDLSTRTDT                         = NO_DATE
      SDLSTRTTM                         = NO_TIME
      STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
        strtimmed                         = c_x
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
      RECIPIENT_OBJ                     =
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
      TARGETGROUP                       = ' '
      DIRECT_START                      =
    IMPORTING
      JOB_WAS_RELEASED                  =
    CHANGING
      RET                               =
       EXCEPTIONS
         cant_start_immediate              = 1
         invalid_startdate                 = 2
         jobname_missing                   = 3
         job_close_failed                  = 4
         job_nosteps                       = 5
         job_notex                         = 6
         lock_failed                       = 7
         invalid_target                    = 8
         OTHERS                            = 9
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_close
    *&      Form  display_spool
          text
    -->  p1        text
    <--  p2        text
    FORM display_spool .
    To Read the Job to get the spool details
      DATA : l_rqident TYPE tsp01-rqident, " Spool Number
             l_spoolno TYPE tsp01_sp0r-rqid_char.
      CLEAR : l_rqident,
              w_lsind,
              wa_jobsteplist.
      REFRESH : i_jobsteplist.
      SET PF-STATUS 'ZAR02'.
    Get the Spool Number
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Read the Job Step list to get the spool number
      READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
      CHECK wa_jobsteplist-listident <> space.
    Spool Number
      l_rqident = wa_jobsteplist-listident.
      MOVE l_rqident TO l_spoolno.
    Check the spool in TSP01
      SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
      IF  sy-subrc = 0.
        LEAVE TO LIST-PROCESSING.
        CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
          EXPORTING
            spoolid       = l_spoolno
        IMPORTING
          RC            =
          STATUS        =
        PERFORM show_alv.
      ENDIF.
      w_lsind = sy-lsind.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_spool
    *&      Form  show_alv
          text
    -->  p1        text
    <--  p2        text
    FORM show_alv .
    Before the import, fill the data fields before CLUSTR.
      wa_index1-aedat = sy-datum.
      wa_index1-usera = sy-uname.
    To Import the selection screen data from Calling Program
      IMPORT i_mara
      FROM DATABASE indx(st) ID wa_index_key1 TO wa_index1.
      FREE MEMORY ID wa_index_key1.
    This prepares the field-catalog for ALV.
      PERFORM prepare_fieldcatalog.
    This displays the output in  ALV format .
      PERFORM display_alv.
    ENDFORM.                    " show_alv
    *&      Form  display_status
          text
    -->  p1        text
    <--  p2        text
    FORM display_status .
    To Display the STATUS of the JOB which is exectued in background
      CLEAR : wa_jobsteplist.
      REFRESH : i_jobsteplist.
      WRITE:/ 'DISPLAYING JOB STATUS'.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / 'Scheduled'.
        WHEN 'R'. WRITE: / 'Released'.
        WHEN 'F'. WRITE: / 'Completed'.
        WHEN 'A'. WRITE: / 'Cancelled'.
        WHEN OTHERS.
      ENDCASE.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_status
    *&      Form  display_job_log
          text
    -->  p1        text
    <--  p2        text
    FORM display_job_log .
    To display the log of the background program
      LEAVE TO LIST-PROCESSING.
      CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
        EXPORTING
          client                    = sy-mandt
          jobcount                  = w_jobcount
          joblogid                  = ' '
          jobname                   = w_jobname
        EXCEPTIONS
          error_reading_jobdata     = 1
          error_reading_joblog_data = 2
          jobcount_missing          = 3
          joblog_does_not_exist     = 4
          joblog_is_empty           = 5
          joblog_show_canceled      = 6
          jobname_missing           = 7
          job_does_not_exist        = 8
          no_joblog_there_yet       = 9
          no_show_privilege_given   = 10
          OTHERS                    = 11.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " display_job_log
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Material no.'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Creation date'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Name of Person'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = ' Last Change'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          it_fieldcat  = i_fieldcat
        tables
          t_outtab     = i_mara.
    ENDFORM.                    " display_alv
    •     ZPROGRAM_TWO: This is the 2nd program which would be called from program ZPROGRAM_ONE.
    *& Report  ZPROGRAM_TWO                                                *
    REPORT  zprogram_two                            .
    PRASHANT PATIL
    TABLES : mara.
    TYPE-POOLS:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara        TYPE STANDARD TABLE OF t_mara,
           wa_mara       TYPE t_mara,
           wa_index      TYPE indx,        " For Index details
           wa_index_key  TYPE indx-srtfd VALUE 'PRG_ONE',
           wa_index1     TYPE indx,        " For Index details
           wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    Before the import, fill the data fields before CLUSTR.
    wa_index-aedat = sy-datum.
    wa_index-usera = sy-uname.
    To Import the selection screen data from Calling Program
    IMPORT s_matnr
    FROM DATABASE indx(st) ID wa_index_key TO wa_index.
    FREE MEMORY ID wa_index_key.
    SELECT matnr
           ersda
           ernam
           laeda
           FROM mara
           INTO TABLE i_mara
           WHERE matnr IN s_matnr.
    PERFORM prepare_fieldcatalog.
    PERFORM display_alv.
    Before the export, fill the data fields before CLUSTR
    wa_index1-aedat = sy-datum.
    wa_index1-usera = sy-uname.
    EXPORT i_mara
    TO DATABASE indx(st) FROM wa_index1 ID wa_index_key1.
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = i_fieldcat
        TABLES
          t_outtab    = i_mara.
    ENDFORM.                    " display_alv
    its possible to display ALV Grid using OO ALV. Following code can be used instead of FM.
    In the PBO, add following code
    SET PF-STATUS 'ZSTAT'.
    If program is executed in background
    CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
    e_offline = off.
    IF off IS INITIAL.
    IF container1 IS INITIAL.
    CREATE OBJECT container1
    EXPORTING
    container_name = 'CC_ALV1' .
    ENDIF.
    ENDIF.
    CREATE OBJECT g_grid1
    EXPORTING
    i_parent = container1.
    CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    i_save = 'A'
    i_default = ' '
    is_layout =
    is_print =
    IT_SPECIAL_GROUPS =
    it_toolbar_excluding =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_output
    it_fieldcatalog = i_fieldcatalog
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Reward points if useful
    Regards
    Anji

  • What is the use of variant in the alv report

    hello all,
    what is the use of variant in the alv report

    Hi,
    For Variants
    follow the link:
    http://help.sap.com/search/highlightContent.jsp
    Variants allow you to save sets of input values for programs that you often start with the same selections. You can use them for any programs except subroutine pools (type S).
    Contents
    Variants: Overview
    Initial Screen
    Displaying a Variant Overview
    Creating and Maintaining Variants
    Creating Variants
    Attributes of Variants
    Changing Variants
    Deleting Variants
    Printing Variants
    Variable Values in Variants
    Creating Variables for Date Calculations
    User-specific Selection Variables
    Creating User-specific Variables
    Changing Values Interactively
    Changing Values from the Program
    Fixed Values from Table TVARV
    Creating Table Variables from TVARV
    Changing TVARV entries
    Running a Program with a Variant
    Variants: Overview
    Use
    Whenever you start a program in which selection screens are defined, the system displays a set of input fields for database-specific and program-specific selections. To select a certain set of data, you enter an appropriate range of values.
    For further information about selection screens, see Working with selection screens in the ABAP User's Guide.
    If you often run the same program with the same set of selections (for example, to create a monthly statistical report), you can save the values in a selection set called a variant.
    You can create any number of variants for any program in which selection screens are defined. Variants are assigned exclusively to the program for which they were created.
    You can also use variants to change the appearance of the selection screen by hiding selection criteria. This is particularly useful when you are working with large selection screens on which not all of the fields are relevant.
    Reports, module pools, and function groups may have several selection screens. It is therefore possible to create a variant for more than one selection screen.
    Variants are an interface between the user and the selection screen. They can be used both in dialog and in background mode, although their uses are slightly different.
    Variants in Dialog Mode
    In dialog mode, variants make things easier for the user, since they save him or her from continually having to enter identical values. They can also make the selection screen easier to read, because you can use them to hide input fields. Running an executable program with a variant containing an optimal set of values also reduces the capacity for user error. The optimized database selections speed up the runtime of the program.
    Variants in Background Mode
    Variants are the only method for passing values to a report program in a background job. Therefore, when you run a program in the background, you must use a variant (or SUBMIT... VIA JOB). To avoid you having to create a new variant each time you run the report, ABAP contains a mechanism allowing you to pass variable values to variants. See variable values in variants.
    To ensure that an executable program is always started using a variant, you can specify in the program attributes that the program may only be started in this way.
    Features
    Creation of variants
    Display, change, copy, print, and delete variants
    Use and definition of variables in variants
    Variable date calculation
    User-specific fixed values
    Fixed values in table TVARV
    You access the variant maintenance tool from the initial screen of the ABAP Editor. Enter the name of the program, select Variants in the Sub-objects group box, and then choose Display or Change.
    Functions
    The above screen allows you to:
    Create variants
    Display the variant directory
    Display and change values and attributes
    Copy, delete, and rename variants
    Before creating a new variant for a program, you should check whether you can use or adapt an existing variant instead.
    There are two ways to display variants:
    Position the cursor on the Variant field on the initial screen and press F4. The following dialog box lists all of the available variants:
    Choose Variants ® Directory on the initial screen:
    Creating Variants
    Prerequisites
    You must have defined one or more selection screens for the relevant program. The program may have any type except type S.
    Procedure
    On the initial screen of the ABAP Editor, enter the name of the program for which you want to create a variant, select Variants in the Sub-objects group box, and choose Change.
    On the variant maintenance initial screen, enter the name of the variant you want to create.
    Note the naming convention for variants (see below).
    Choose Create.
    If the program has more than one selection screen, a dialog box appears in which you can assign the variant to one or more screens. The dialog box does not appear if the program only has one selection screen. In this case, the selection screen of the program appears straight away.
    If there is more than one selection screen, select the screens for which you want to create the variant.
    Example:
    If you choose Variant for all selection screens, the variant also applies to any selection screens that you create after creating the variant.
    Otherwise, the variant only supplies values to the selection screens that you select in the list.
    Choose Continue.
    The (first) selection screen of the program appears.
    If your program has more than one selection screen, use the scroll buttons in the left-hand corner of the application toolbar to navigate between them. If you keep scrolling forwards, the Continue button appears on the last selection screen.
    Enter the required selections, including multiple and dynamic selections.
    Choose Continue.
    Result
    When you have finished, an overview screen appears (ABAP: Save Attributes of Variant), on which you can enter the attributes of your variant and save it.
    Note that when you create a new variant, you must enter both values and attributes.
    Names of variants: Names can consist of up to 14 alphanumeric characters. The "% " character is not allowed. If you want the variant to be transported automatically with its program, you must create a system variant. The name of a system variant starts "CUS&" for customers, and "SAP&" for SAP system variants. You can only use the "&" character within this prefix in the name of a system variant. It may not occur in any other context. System variants are administered by the Workbench Organizer. Although you can create and access variants from any client, they are always stored in client "000".
    Creating Variants
    Prerequisites
    You must have defined one or more selection screens for the relevant program. The program may have any type except type S.
    Procedure
    On the initial screen of the ABAP Editor, enter the name of the program for which you want to create a variant, select Variants in the Sub-objects group box, and choose Change.
    On the variant maintenance initial screen, enter the name of the variant you want to create.
    Note the naming convention for variants (see below).
    Choose Create.
    If the program has more than one selection screen, a dialog box appears in which you can assign the variant to one or more screens. The dialog box does not appear if the program only has one selection screen. In this case, the selection screen of the program appears straight away.
    If there is more than one selection screen, select the screens for which you want to create the variant.
    Example:
    If you choose Variant for all selection screens, the variant also applies to any selection screens that you create after creating the variant.
    Otherwise, the variant only supplies values to the selection screens that you select in the list.
    Choose Continue.
    The (first) selection screen of the program appears.
    If your program has more than one selection screen, use the scroll buttons in the left-hand corner of the application toolbar to navigate between them. If you keep scrolling forwards, the Continue button appears on the last selection screen.
    Enter the required selections, including multiple and dynamic selections.
    Choose Continue.
    Result
    When you have finished, an overview screen appears (ABAP: Save Attributes of Variant), on which you can enter the attributes of your variant and save it.
    Note that when you create a new variant, you must enter both values and attributes.
    Names of variants: Names can consist of up to 14 alphanumeric characters. The "% " character is not allowed. If you want the variant to be transported automatically with its program, you must create a system variant. The name of a system variant starts "CUS&" for customers, and "SAP&" for SAP system variants. You can only use the "&" character within this prefix in the name of a system variant. It may not occur in any other context. System variants are administered by the Workbench Organizer. Although you can create and access variants from any client, they are always stored in client "000".
    reward all help full answers

  • '@' not getting displayed in the ALV report

    Hello,
    I am facing  a strange issue in the ALV report display. A string starting with '@' is not getting displayed and says "default icon " on the report. and this is varying from system to system for the same user.
    can anyone please help me in resolving the issue.
    Thanks in advance.
    Thanks and Regards,
    Santhosh Guptha N.

    @ is a default value as per ALV internal process. This is used in icons .
    I think this is causing the confusion.
    Check in the fieldcat if there is any adjsutment to be made to handle this.
    Br,
    Vijay

  • Short dump when I do total or sub total in the ALV report

    Hi,
    When I do total or sub-total on the currency field in the ALV report, it'll give a short dump like
    " The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X)".
       Short text of error message:
       Technical information about the message:
       Message classe...... "0K"
       Number.............. 000
       Variable 1.......... " "
       Variable 2.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
    Trigger Location of Runtime Error
        Program                                 SAPLSLVC
        Include                                 LSLVCF36
        Row                                     2,726
        Module type                             (FORM)
        Module Name                             FILL_DATA_TABLE
    sometime when I do the page down on the ALV report, the same short dump is coming.
    Can anyone help me out.
    Thanks
    Selva

    Hi,
    I'm getting this short dump in the standard program.
    I'm getting ALV report display perfectly. the problem is, when I do total or subtotal on the currency fields.
    2704
    2705 ************************************
    2706 * Column per Fieldcat Entry
    2707 ************************************
    2708         ls_lvc_data-value = space.
    2709         clear ls_lvc_data-style.
    2710         loop at it_fcat_local assigning <ls_fcat>
    2711                 where tech ne 'X' and no_out ne 'X'.
    2712           if l_invisible eq 'X'.
    2713             clear l_invisible.
    2714             if <ls_fcat>-do_sum is initial.
    2715               continue.
    2716             else.
    2717               clear ls_lvc_data-col_pos.
    2718             endif.
    2719           endif.
    2720
    2721           add 1 to ls_lvc_data-col_pos.
    2722
    2723           assign component <ls_fcat>-fieldname
    2724                            of structure <ls_data> to <l_field_value>.
    2725           if sy-subrc ne 0.
    >>>>>             message x000(0k).
    2727           endif.
    2728
    in this standard program, I'm getting the dump. the line is mentioned above in the code.

  • Download the ALV Report output into excel sheet or notepad

    Hi,
    how to downlaod the alv report out into excel sheet or notepad in a proper manner. program contain large number records....
    Thanks in advance!!!!
    Regards,
    kranthi.

    Hi
    Download a report to excel with format (border, color cell, etc) 
    Try this program...it may help you to change the font ..etc.
    Code:
    REPORT ZSIRI NO STANDARD PAGE HEADING.
    this report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Please note that this example maybe slow at filling the excel table
    (perhaps four fields per second on a 900 MHz machine - almost 30 seconds
    for a short example).
    To get the data on properties and methods - there is a bit of smoke and mirrors
    going on here; they are EXCEL properties and methods, not sap ones - so you need
    to look at excel help to determine how a particular function is structured. then
    build the block in sap, as shown in the example.
    If you only want to transfer the data to Excel like when you transfer the data from
    ALV to Excel simply use the Function Modules:
    XXL_SIMPLE_API
    If you want more modifications when you transfer it to Excel use:
    XXL_FULL_API

  • Plz provide the alv report

    The purpose of the report is to serve as an indicator for when an existing Purchase Requisitions is updated, and requires a Purchase Order to be changed.  Standard SAP offers no real efficient way to communicate changes/updates between Purchase Requisition and Purchase Order.
    This report will be used to notify a Purchasing Agent that a change has taken place against an existing Purchase Requisition, and the Purchase Order requires to be updated accordingly. This report will be emailed via a batch job to the buyers daily, or can be run on an ad hoc basis
    plz provide the alv report which is related to this discription.
    urgent plz

    The purpose of the report is to serve as an indicator for when an existing Purchase Requisitions is updated, and requires a Purchase Order to be changed.  Standard SAP offers no real efficient way to communicate changes/updates between Purchase Requisition and Purchase Order.
    This report will be used to notify a Purchasing Agent that a change has taken place against an existing Purchase Requisition, and the Purchase Order requires to be updated accordingly. This report will be emailed via a batch job to the buyers daily, or can be run on an ad hoc basis
    plz provide the alv report which is related to this discription.
    urgent plz

  • How to create an interactive alv report in which some parameters

    hi all,
    i want to create an interactive alv report in which some parameters in selection screen
    & when fill those & press f8 then an alv list display will show & when user double click on
    any row then those contents get shown in header details of module pool program  which call by
      tcode mentioned in same alv .And same an interactive alv report used for change & display.
    please help me give me some code same as  required above.
    ketan
    abap consultant.
    Edited by: ketan pande on Feb 14, 2009 6:09 AM

    Hi Ketan,
    Please find Sample Code.
    TYPE-POOLS:slis.
    DATA:
      w_carrid TYPE scarr-carrid,
      it_fieldcat TYPE slis_t_fieldcat_alv,
      fs_fieldcat LIKE LINE OF it_fieldcat,
      it_eventcat TYPE slis_t_event,
      fs_eventcat LIKE LINE OF it_fieldcat.
    DATA:
      t_spfli LIKE STANDARD TABLE OF spfli,
      fs_spfli LIKE LINE OF t_spfli,
      t_sflight LIKE STANDARD TABLE OF sflight,
      fs_sflight LIKE LINE OF t_sflight.
    SELECT-OPTIONS:
      s_carrid FOR w_carrid.
    START-OF-SELECTION.
      SELECT * FROM spfli INTO TABLE t_spfli WHERE carrid IN s_carrid.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program      = sy-repid
          i_callback_user_command = 'PICK'
          i_structure_name        = 'SPFLI'
        TABLES
          t_outtab                = t_spfli
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  PICK
    FORM pick USING command LIKE sy-ucomm
                    selfield TYPE slis_selfield.
      READ TABLE t_spfli INTO fs_spfli INDEX selfield-tabindex.
      CASE command.
        WHEN '&IC1'.
          SELECT * FROM sflight
          INTO TABLE t_sflight
         WHERE carrid = fs_spfli-carrid
           and connid = fs_spfli-connid.
          CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
             i_program_name               = sy-repid
           I_INTERNAL_TABNAME           =
             i_structure_name             = 'SFLIGHT'
           I_CLIENT_NEVER_DISPLAY       = 'X'
           I_INCLNAME                   =
           I_BYPASSING_BUFFER           =
           I_BUFFER_ACTIVE              =
            CHANGING
              ct_fieldcat                  = it_fieldcat
           EXCEPTIONS
             inconsistent_interface       = 1
             program_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.
          CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
           I_INTERFACE_CHECK              = ' '
           I_BYPASSING_BUFFER             =
           I_BUFFER_ACTIVE                = ' '
             i_callback_program             = sy-repid
           I_CALLBACK_PF_STATUS_SET       = ' '
           I_CALLBACK_USER_COMMAND        = ' '
           I_STRUCTURE_NAME               =
           IS_LAYOUT                      =
             it_fieldcat                    = it_fieldcat
           IT_EXCLUDING                   =
           IT_SPECIAL_GROUPS              =
           IT_SORT                        =
           IT_FILTER                      =
           IS_SEL_HIDE                    =
           I_DEFAULT                      = 'X'
           I_SAVE                         = ' '
           IS_VARIANT                     =
            it_events                      = it_eventcat
           IT_EVENT_EXIT                  =
           IS_PRINT                       =
           IS_REPREP_ID                   =
           I_SCREEN_START_COLUMN          = 0
           I_SCREEN_START_LINE            = 0
           I_SCREEN_END_COLUMN            = 0
           I_SCREEN_END_LINE              = 0
           IR_SALV_LIST_ADAPTER           =
           IT_EXCEPT_QINFO                =
           I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
         IMPORTING
           E_EXIT_CAUSED_BY_CALLER        =
           ES_EXIT_CAUSED_BY_USER         =
            TABLES
              t_outtab                       = t_sflight
          EXCEPTIONS
            program_error                  = 1
            OTHERS                         = 2
          IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "pick
    Hope this will Be Helpful
    Thanks
    Kalyan

  • Clear the values in the ALV report after calculating Subtotals

    Hi All,
    In my ALV report, I am displaying subtotals by passing DO_SUM in the Field Catalog.
    Now my problem is in the display I do not want the individual values to be displayed, I want to hide the values in the column(Not the whole column) but I want to display the subtotal of these values in the Subtotal Row.
    Example:
    Item1   10   20
    Item2   20   30
    Item3   10   50
               40   100
    As per our requirements, the output should be
    Item1
    Item2
    Item3
              40   100
    How can this be done? Please suggest.

    Populate i_sort table for the fields for which u want subtotal as shown below:
    *&      Form  sub_populate_sort
          Populate ALV sort table
          No Parameter
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    Then when populating the field catalog tables use:
    wa_lfl_fcat-no_out         =  'X'.        "No output
    Then display ur data:
    This function module for displaying the ALV report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    Regards,
    Joy.

  • How to do the ALV report output in groups and caluculate the tOTALS(URGENT

    Hi
    In my ALV report output .I have to group the output based on the DAYS field
    0-10 days in one group
    10-30 days in one group
    above 30 days one group
    There is also a field by name "AMOUNT" in my output.
    I have to calculate SUBTOTALs at the end of every group and at the end of the report i should caluculate GRAND TOTAL.
    Please remember that i should not use any any BLOCKED ALVs and for Totals i should not use the SYMBOLS provided in the application toolbar of the report
    Thanks in Advance

    Please don't repost your questions...
    Check out my answer in your other post.
    How to make the ALV report in groups  and caluculate the TOTALS
    Regards,
    Naimesh Patel

Maybe you are looking for

  • Problem with sync - itunes 11.1.3.8

    I have itunes 11.1.3.8  (on win xp) and iphone 4 with ios 7.0.4 and when i connect my phone to itunes it gives an error message and won't sync.(Error syncing) please help Thanks, Sarit.

  • Problem upload too large file in a Content Area ORA-1401

    Hi All I have a customer who is trying to upload a file with a too large name in a content area. If the filename is 80 characters, it works fine. But if the filename is upper or 80 characters the following error ocurred: ORA-01401: inserted value too

  • Lost all playlists and purchased songs after 11.1.5.5

    All of my playlists, the purchased tab, suddenly disappeared after the 11.1.5.5 update.  Seems like others have had the same issue.  I'm a senior citizen, not the most technically savvy guy on the net, and need some help to fix.  Anyone out there hel

  • Buying with a credit card from another country

    Hello, I live in Greece and except from a greek billing account I also have a french billing account with a credit card because I lived in France for some years. Now, I want to buy, for different purposes, OS X Mountain Lion with my french credit car

  • Reinstalling from Snow leopard to Lion

    i want to format my computer, but my mac is snow leopard, and i want to get lion again, however, I did not have a Lion Recovery Disk. can i download from app store for free???