Checkbox in alv report

hi all,
i am facing one problem regarding checkbox in alv.
i have to buttons on alv report as 'select all' (to select all) and 'send mail'(as i have to send mail to selected record)
wat i have done till now is:
1. when i run the report and cleck on checkboxes the action is reflected in internal table..n i can capture the data.
2.when i click on select all button all the records get selected and i can capture the data again.
now the problem :
when i clcik on "select all" and all the record get selected ..but when i deselect any of those record..the changes in internal table lost i.e. the checkbox field because empty for all the record.....
PLZ GIVE SOLUTION FOR FUNCTION "REUSE_ALV_GRID_DISPLAY" ONLY...
now the code:
************LAYOUT**************
DATA: gd_layout TYPE SLIS_LAYOUT_ALV.
  gd_layout-colwidth_optimize = 'X'.
gd_layout-zebra      = 'X'.
  gd_layout-box_fieldname  = 'CHECKBOX'.
  gd_layout-box_tabname  = 'IT_CONF'.
****alv display*************
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_grid_title             = 'Detailed List'
        it_fieldcat              = fieldcat
        i_callback_program       = sy-repid
        i_callback_user_command  = 'USER_CMD'
        i_callback_pf_status_set = 'EMAILS'
        IS_LAYOUT                = gd_layout
      TABLES
        t_outtab                 = it_conf
      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.
  endif.
endform.                    "alv_display
*&      Form  sush1
      text
     -->RT_EXTAB   text
FORM emails USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'EMAILS'.
ENDFORM.                    "emails
*&      Form  user_cmd
      text
     -->P_UCOMM    text
     -->LS_SELFIELDtext
FORM user_cmd USING p_ucomm LIKE sy-ucomm ls_selfield type slis_selfield.
IF REF_GRID IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        E_GRID = REF_GRID.
  ENDIF.
IF NOT REF_GRID IS INITIAL.
    CALL METHOD REF_GRID->CHECK_CHANGED_DATA.
  ENDIF.
  IF p_ucomm = 'EMAIL'.
    loop at it_conf  where checkbox = 'X'.
**[[[[[[[U MAY NOT SEE THIS THIS IS FOR MAIL PUPOSE]]]]]]]]]]]]*********
      select single  sachn  telnr  into (tc_name , tc_num ) from t526
      where SACHX = it_conf-zztc
      and werks = it_conf-werks .
  ******find the emil of employee.
       clear : p_0105,p_0105[].
        CALL FUNCTION 'HR_READ_INFOTYPE'
          EXPORTING
            pernr           = it_conf-pernr
            infty           = '0105'
            BEGDA           = pn-begda
            ENDDA           = pn-endda
          TABLES
            infty_tab       = p_0105
          EXCEPTIONS
            infty_not_found = 1
            OTHERS          = 2.
       if sy-subrc = 0.
        read table p_0105 with key subty = 10.
        move p_0105-USRID_LONG to email.
    endif.
find immediate superior by Z FM.
      clear pernr_s.
      CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
        EXPORTING
          pernr     = it_conf-pernr
          begda     = '18000101'
          endda     = '99991231'
        IMPORTING
          v_pernr   = pernr_s
        EXCEPTIONS
          not_found = 1
          OTHERS    = 2.
      if sy-subrc = 0.
find the email of the immed. superiors personal number..
        clear : p_0105,p_0105[].
        CALL FUNCTION 'HR_READ_INFOTYPE'
          EXPORTING
            pernr           = pernr_s
            infty           = '0105'
            BEGDA           = pn-begda
            ENDDA           = pn-endda
          TABLES
            infty_tab       = p_0105
          EXCEPTIONS
            infty_not_found = 1
            OTHERS          = 2.
        read table p_0105 with key subty = 10.
        move p_0105-USRID_LONG to email_s.
          endif.
        if email <> ' '.
        perform send_mail using it_conf-ename email email_s tc_name tc_num.
        endif.
        if email_s <> ' '.
        perform send_mail using it_conf-ename email email_s tc_name tc_num.
        endif.
****MAIL PART IS OVER*******************************************
    endloop.
endif.
*****FOR  "SELECT ALL " BUTTON**************
   IF p_ucomm = 'SELECT'.
   flag = 1.
    loop at it_conf.
      move 'X' to it_conf-checkbox.
      MODIFY IT_CONF.
    endloop.
    ls_selfield-refresh = 'X'.
    endif.

" Please  see the code  of  myin  in the    'SELECT' & 'DESELECT'.
case save_ok.
    when 'EXIT'.
      perform exit_program.
    when 'SELECT'.
      perform select_all_entries changing gt_outtab[].
    when 'DESELECT'.
      perform deselect_all_entries changing gt_outtab[].
    when 'RESET'.
      perform reset_selected_entries changing gt_outtab[].
    when 'SWITCH'.
      perform switch_activation changing gt_outtab[].
  endcase.
form select_all_entries changing pt_outtab type standard table.
  data: ls_outtab type gs_outtab.
  data: l_valid type c,
        l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
*       you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
  call method g_grid->check_changed_data
              importing
                 e_valid = l_valid.
  if l_valid eq 'X'.
    loop at pt_outtab into ls_outtab.
      perform check_lock using    ls_outtab
                         changing l_locked.
      if l_locked is initial
         and not ls_outtab-checkbox eq '-'.
        ls_outtab-checkbox = 'X'.
      endif.
      modify pt_outtab from ls_outtab.
    endloop.
    call method g_grid->refresh_table_display.
  endif.
endform.   
form check_lock using    ps_outtab type gs_outtab
                changing p_locked.
  data ls_celltab type lvc_s_styl.
  loop at ps_outtab-celltab into ls_celltab.
    if ls_celltab-fieldname = 'CHECKBOX'.
      if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
        p_locked = 'X'.
      else.
        p_locked = space.
      endif.
    endif.
  endloop.
endform.       
form deselect_all_entries changing pt_outtab type standard table.
  data: ls_outtab type gs_outtab.
  data: l_valid type c,
        l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
*       you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
  call method g_grid->check_changed_data
              importing
                 e_valid = l_valid.
  if l_valid eq 'X'.
    loop at pt_outtab into ls_outtab.
      perform check_lock using    ls_outtab
                       changing l_locked.
      if l_locked is initial
         and not ls_outtab-checkbox eq '-'.
        ls_outtab-checkbox = ' '.
      endif.
      modify pt_outtab from ls_outtab.
    endloop.
    call method g_grid->refresh_table_display.
  endif.
reward  points if it is usefull ......
Girish

Similar Messages

  • Checkbox in alv report-doubt

    hi all
        can anybody tell me the coding lines for
    1)when checking a check box 'test run' in selection-screen,
    a particular output field(for eg.,itab_final-WBS1) has to be updated in standard table(e.g,CATSDB-WBS)  ,if not checked,it should not be updated,just the user has to view the report
    thanks in advance
    Moderator Message: Please do your on work. If you get stuck after putting some effort from your side, then ask a specific question here.
    Edited by: kishan P on Apr 7, 2011 10:30 AM

    Hi,
    1.SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
    The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
    The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
    Sample code:
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = variant save condition ( A=all, U = user-specific )
           CHANGING
                cs_variant = internal table containing the program name (and the default variant---optional )
           EXCEPTIONS
                not_found  = 2.
    2.A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
    Output list description structure.
         The parameters are described under the following heads:
    •     Display options
    •     Exceptions
    •     Totals
    •     Interaction
    •     Detail screen
    •     Display variants (only for hierarchical-sequential lists)
    •     Color
    •     Other
    The layout table is of type slis_layout_alv_spec and has the following fields:
    Reward,if useful.
    Thanks,
    Chandu

  • ACTIONS ON ALV REPORT FOR CHECKBOX?

    hi All,
    i have to display ALVreport with one of the columns has checkbox.whenever user presses any checkbox,in repected row values have to be validated and updated in DataBase.
    My First Doubt is,How can i get the column of checkBoxes in ALV Report.?
    2.How can i add action for that checkBox?
    Regards,
    Ravi.

    Hi Ravi,
    Your requirement can be achieved by creating a custom function in your ALV.
    We create a button in the ALV toolbar with text 'Confirm'. When user clicks on this, a popup screen is called for confirmation. Based on the input we set the flag.
    To accomplish this, When defining the configuration model of the ALV, do the following
    Assume that we get the model of the ALV into lo_list
    lo_list = lo_ref_interfacecontroller->get_model( ).
    DATA:
    * Generate an object for self defined functions
        lo_self_functions          TYPE REF TO if_salv_wd_function_settings,
    * Generate an object for button 'Confirm'
        lo_button_conf          TYPE REF TO cl_salv_wd_fe_button,
    * Set Self-defined functions
    * 'Confirm' Button
      lo_self_functions ?= lo_list.
      lo_self_function = lo_self_functions->create_function( 'CONFIRM' ).
      CREATE OBJECT lo_button_conf.
      CLEAR l_text.
      l_text = 'Confirm'
      lo_button_sel_all->set_text( l_text ).
      lo_button_sel_all->set_image_source( '< Any icon name >' ).
      lo_button_sel_all->set_image_first( 'X' ).
      lo_self_function->set_editor( lo_button_conf ).
    In the methods tab, Create a event handler for ON_FUNCTION event of the ALV.
    ONFUNTION     Event Handler     ON_FUNCTION     ON_FUNCTION     INTERFACECONTROLLER     alv_name
    In the ONFUNCTION method, Do the following.
      DATA:
        l_window                  TYPE REF TO if_wd_window,
        l_componentcontroller_api TYPE REF TO if_wd_component,
        l_window_manager          TYPE REF TO if_wd_window_manager,
        l_api                     TYPE REF TO if_wd_view_controller,
        lt_text                   TYPE string_table,
        l_text_line               TYPE string.
    * Based on the function selected, set the selection
      CASE  r_param->id.
        WHEN 'CONFIRM'.
    * Call the confirmation for popup
      l_api = wd_this->wd_get_api( ).
      l_componentcontroller_api = wd_comp_controller->wd_get_api( ).
      l_window_manager = l_componentcontroller_api->get_window_manager( ).
      CALL METHOD l_window_manager->create_popup_to_confirm
        EXPORTING
          text            = lt_text
          button_kind     = if_wd_window=>co_buttons_yesno
          message_type    = if_wd_window=>co_msg_type_question
          window_position = if_wd_window=>co_center
        RECEIVING
          result          = l_window.
      CALL METHOD l_window->subscribe_to_button_event
        EXPORTING
          button            = if_wd_window=>co_button_yes
          action_name       = 'YES'
          action_view       = l_api
          is_default_button = abap_false.
      CALL METHOD l_window->subscribe_to_button_event
         EXPORTING
           button            = if_wd_window=>co_button_no
           action_name       = 'NO'
           action_view       = l_api
           is_default_button = abap_false.
      l_window->open( ).
      ENDCASE.
    Create 2 actions with names YES and NO ( As mentioned in the subscription.
    In these actions, bases on the inputs, set the flag to a context attribute and update the same in the table you wanted.
    Hope this is what you want.
    Regards,
    Sravan Varagani.

  • RE: Use of checkbox in ALV

    Hi All,
    Please provide a solution. how to use checkboxes in ALV report.
    •     “Include Blocked A ” checkbox – default is unchecked –
    THEN the report data should include all A flagged for Block (as well as all active A )
    •     “Include Deleted A ” checkbox – default is unchecked –
    Then the report data should include all  A flagged for deletion (as well as all active A )
    •     “Include Deactivated A ” checkbox – default is unchecked –
    Then the report data should include all A  flagged for deactivated on
    •     “Include Disposed/Retired A” checkbox – default is unchecked –
    When checked
    •      “Include A without values” checkbox – default is unchecked
    When checked
    Then also include A Master Records without an A Value Date.

    Check below code for Dynamic selection screen as per radio buttons
    TABLES: ekpo, resb, ltak.
    PARAMETER : p_res RADIOBUTTON GROUP rb1 DEFAULT 'X'  USER-COMMAND ucom,
                p_sto    RADIOBUTTON GROUP rb1.
    SELECT-OPTIONS :
               s_rwerks FOR ekpo-werks NO INTERVALS NO-EXTENSION MODIF ID s,
               s_wempf  FOR resb-wempf NO INTERVALS NO-EXTENSION MODIF ID r,
               s_deldt  FOR resb-bdter NO-EXTENSION DEFAULT sy-datum,
               s_tanum  FOR ltak-tanum NO-EXTENSION MODIF ID s,
               s_bdatu  FOR ltak-bdatu NO-EXTENSION MODIF ID r.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF p_sto = 'X'.
          IF screen-group1 = 'R'.
            screen-input  = 0.
            MODIFY SCREEN.
            CONTINUE.
          ENDIF.
        ENDIF.
        IF p_res = 'X'.
          IF screen-group1 = 'S'.
            screen-input  = 0.
            MODIFY SCREEN.
            CONTINUE.
          ENDIF.
        ENDIF.
      ENDLOOP.
    I think this will solve your problem....
    Rewards if helpful...
    Regards,
    Minal

  • Functionality of Checkbox in ALV Grid Report

    Hi Experts,
    I created a ALV grid report with the checkbox as my first coloum and other fields as shown below. Initially, my ALV report displays as below. It is working fine till here.
    checkbox       customer     material      quantity       UOM         Sales Order    Delivery
                           C1                  M1           1                  KG
                           C1                   M2           2                  KG
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    I have created a push button on application toolbar for creating sales order and delivery using bapi's. When I click on my pushbutton, as of now it creates the SO and delivery for the first customer C1 and updates my Internal table with the sales order number and delivery number. If I need to create sales order for the second customer I need to run my ALV report again and so on for 3rd, 4th and 5th customers. It is also working fine till here.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
                           C1                  M1           1                  KG          SO1               DEL1
                           C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
                           C3                   M1          1                   KG
                           C3                   M2          2                   KG
                           C3                   M3           3                 KG
                            C4                  M1           1                  KG
                           C5                   M5           1                  KG
    Need help on this:
    When I select the check boxes as shown below and when I click the push button to create SO and Delivery then my program should create sales order and delivery for all the checked ones as shown below. What is the condition do I need to put here for selecting the checkbox.
    checkbox       customer     material      quantity       UOM     Sales Order     Delivery
    X                      C1                  M1           1                  KG         SO1               DEL1
    X                     C1                   M2           2                  KG         SO1               DEL1
                            C2                   M1          1                   KG
                            C2                  M2           2                   KG
    X                     C3                   M1          1                   KG        SO3             DEL3
    X                     C3                   M2          2                   KG        SO3             DEL3
    X                     C3                   M3           3                 KG          SO3            DEL3
                            C4                  M1           1                  KG
    X                     C5                   M5           1                  KG          SO5            DEL5
    I would really appreciate if somebody could help me / guide me on this. I will also post my code if someone needs to understand what I am doing exactly.
    Thanks.

    You need to use OO ABAP
    Use Class the class  1)  CL_GUI_ALV_GRID, 2) CL_GUI_CUSTOM_CONTAINER
    Create Sceen and container on same screen.
    Check following COde it used for printing purpose.
    Using AFTER_USER_COMMAND  Event you will find Check box selected entries.
    Capture those in another internal Table and use it for SO Creation
    DATA:  O_GRID TYPE REF TO CL_GUI_ALV_GRID,
           O_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           T_FCAT TYPE LVC_T_FCAT,
           CONTAINER(15) TYPE C VALUE 'ET_CONTAINER'.
          CLASS EVENT_CLASS DEFINITION
    CLASS EVENT_CLASS DEFINITION.
      PUBLIC SECTION.
        METHODS: BEFORE_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
                 DOUBLE_CLICK_N  FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN,
                 TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT.
    ENDCLASS.                    "EVENT_CLASS DEFINITION
          CLASS EVENT_CLASS IMPLEMENTATION
    CLASS EVENT_CLASS IMPLEMENTATION.
      METHOD BEFORE_COMMAND.
        IF E_UCOMM = 'PRINT'.
          CLEAR : W_FLAG.
          T_FINAL2 = T_FINAL.
          SORT T_FINAL2 BY COL_CHK .
          DELETE   T_FINAL2 WHERE COL_CHK = ' '.
          IF NOT T_FINAL2 IS INITIAL.
            LOOP AT T_FINAL2 INTO WA_FINAL.
              IF W_FLAG IS INITIAL.
      Does some of modification/s in control parameters
                W_CONTROL_PARAM-NO_OPEN   = 'X'.
                W_CONTROL_PARAM-NO_CLOSE  = 'X'.
                W_CONTROL_PARAM-PREVIEW   = 'X'.
                W_CONTROL_PARAM-NO_DIALOG = SPACE.
                W_OUTPUT_OPTIONS-TDNEWID = 'X'.
                W_OUTPUT_OPTIONS-TDIMMED = SPACE.
      Opens the smartform print-job
                CALL FUNCTION 'SSF_OPEN'
                  EXPORTING
                    OUTPUT_OPTIONS     = W_OUTPUT_OPTIONS
                    CONTROL_PARAMETERS = W_CONTROL_PARAM
                  EXCEPTIONS
                    FORMATTING_ERROR   = 1
                    INTERNAL_ERROR     = 2
                    SEND_ERROR         = 3
                    USER_CANCELED      = 4
                    OTHERS             = 5.
                IF SY-SUBRC EQ 0.
                  W_FLAG = 'X'.
                ELSE.
                 LEAVE LIST-PROCESSING.
                ENDIF.
              ENDIF.
              IF W_FLAG = 'X'.
                CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
                  EXPORTING
                    FORMNAME           = 'ZFORM_BIW_PRINT'
                  IMPORTING
                    FM_NAME            = LF_FM_NAME
                  EXCEPTIONS
                    NO_FORM            = 1
                    NO_FUNCTION_MODULE = 2
                    OTHERS             = 3.
                IF SY-SUBRC <> 0.
                ENDIF.
                IF SY-SUBRC = 0.
                  CALL FUNCTION LF_FM_NAME
                    EXPORTING
                      CONTROL_PARAMETERS = W_CONTROL_PARAM
                     V_VBELN            = WA_FINAL-VBELN
                      WA_FINAL           = WA_FINAL.
                   TABLES
                     T_FINAL            = T_FINAL.
                ELSE.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                ENDIF.
              ENDIF.
            ENDLOOP.
           * Close the smartform print job
            IF W_FLAG EQ 'X'.
              CALL FUNCTION 'SSF_CLOSE'
                EXCEPTIONS
                  FORMATTING_ERROR = 1
                  INTERNAL_ERROR   = 2
                  SEND_ERROR       = 3
                  OTHERS           = 4.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "BEFORE_COMMAND

  • ALV Report Output Checkbox

    Hi,
    I'm developing an ALV Report. The output of the report contains a checkbox for each row. There are 2 buttons in the Application bar namely 'Select-ALL' and 'DeSelect-ALL'. The requirement is when I click either of the button it should select or deselect all the checkbox. The problem is when i click either the button first time its not working but when i click for second time its working. Basically It needs 2 clicks for the operation. Can anybody suggest a solution how to make work of the program at the first clck itself.
    Thanks,
    Kaarthick

    Since your program is working in debugging mode, It might be some problem pertaining to some time delay or lag, or a refresh problem.
    So save your code once again activate it and shut down your saplogon and after couple of minutes log in again.
    I faced a similar problem, it was working in debugging and not when executed directly, it was some lag problem only.

  • How to make checkbox field inactive in the output of ALV report.

    Dear All,
    I am having one ALV report in whose output there are checkboxes against each record. Example: the output columns of my ALV report are:
    Checkbox, Sales Document No, Billing Document No.
    Now, my requirement is that if for the Sales Document No there exists any Billing Document No in the output then the Checkbox should be inactive but if the Billing document coloumn is empty for a particular Sales Document No then only the Checkbox field should become active.
    Kindly guide me on how to make this checkbox field inactive.
    Waiting for your reply.
    Warm Regards,
    N.Jain

    Hello,
    Follow the below steps:
    1.Define as--> GS_STATUS TYPE SLIS_STATUS,
    2.check layout check box fieldname is not initial.
          then set the status according to your logical conditions
          GS_STATUS-FLG_CHECKBOXES_ACTIVE = 'X'
    Hope this would help you.
    Let me know your feedback.
    Regards,
    Raju

  • Urgent: about the checkbox in OOP ALV report

    Hi Experts,
    I had use OOP method to display my ALV report. In the report I have a checkbox for each line. I had set this check box use below statements:
        gt_fieldcat_record-tabname = 'GT_ISSUE_INT'.
        gt_fieldcat_record-fieldname = 'CHECKBOX'.
        gt_fieldcat_record-checkbox = 'X'.
        gt_fieldcat_record-edit = 'X'.
        APPEND gt_fieldcat_record.
    When I press the save button, then I will save the lines to my Z-table which its GT_ISSUE_INT-CHECKBOX = 'X'.
    Now I click the checkbox to select several lines in my ALV report and then press save, but it do not work. Then I check the internal table GT_ISSUE_INT in debugger, I found the GT_ISSUE_INT-CHECKBOX = ' '. Above statements is not correct for the checkbox?? Or I need additional statements to move 'X' to GT_ISSUE_INT-CHECKBOX?? Please help!!!Thanks.

    Hi,
    If u want to read check box status from list, need to call function module explicitly.
    see the sample code:
    case sy-ucomm.
    when 'SAVE'.
    Data ref1 type ref to cl_gui_alv_grid.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
               E_GRID = ref1.
           call method ref1->check_changed_data.
    loop at GT_ISSUE_INT to workarea.
    ____ continue writing ur code.
    function module read the data from list . and save the changes that made on list.
    when u debug, u can see the check box status as 'X' after exucut\ing this fm and method.
    reward if helpful.
    regards,
    swapna

  • Open Field in ALV Report

    Hi all,
    i have to develop a ALV report.
    In that report i have to put a open quantity column , so that the user can enter values in that, and that value should get updated in the database.
    So please suggest me how to develop such report with open field.
    Thanks in advance,
    Regards,
    Pawan

    Hi,
    Try executing the below code
    REPORT YMS_EDITBLOCKALV.
    TABLES : rmmg1,MCHB, mkpf.
    DATA: BEGIN OF t_mseg OCCURS 0,
    zeile LIKE mseg-zeile,
    menge LIKE mseg-menge,
    meins LIKE mseg-meins,
    matnr LIKE mseg-matnr,
    werks LIKE mseg-werks,
    charg LIKE mseg-charg,
    bwart LIKE mseg-bwart,
    END OF t_mseg.
    DATA:BEGIN OF t_mchb OCCURS 0.
    INCLUDE STRUCTURE mchb.
    data flag type c.
    matnr LIKE mchb-matnr,
    charg LIKE mchb-charg,
    werks LIKE mchb-werks,
    clabs LIKE mchb-clabs,
    DATA END OF t_mchb.
    TYPE-POOLS slis.
    data: progname like sy-repid,
    fieldcattab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    data tabindex type i.
    data wa_matnr LIKE mchb-matnr.
    progname = sy-repid.
    SELECTION-SCREEN BEGIN OF BLOCK b_b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS s_docno FOR mkpf-mblnr. " OBLIGATORY.
    PARAMETERS p_docyr LIKE mkpf-mjahr. " OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b_b1.
    START-OF-SELECTION.
    SELECT zeile
    menge
    meins
    matnr
    werks
    charg
    bwart
    FROM mseg
    INTO TABLE t_mseg
    WHERE mblnr IN s_docno AND mjahr = p_docyr.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 1.
    fieldcattab-fieldname = 'ZEILE'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-fix_column = 'X'.
    fieldcattab-seltext_l = 'Item'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 2.
    fieldcattab-fieldname = 'MENGE'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Quantity'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 3.
    fieldcattab-fieldname = 'MEINS'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Unit'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 4.
    fieldcattab-fieldname = 'MATNR'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Material'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 5.
    fieldcattab-fieldname = 'WERKS'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Plant'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 6.
    fieldcattab-fieldname = 'CHARG'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Batch No'.
    APPEND fieldcattab.
    CLEAR fieldcattab.
    fieldcattab-col_pos = 7.
    fieldcattab-fieldname = 'BWART'.
    fieldcattab-tabname = 'T_MSEG'.
    fieldcattab-seltext_l = 'Inventory'.
    fieldcattab-hotspot = 'X'.
    APPEND fieldcattab.
    end-of-selection.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = PROGNAME
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'USERCOMMAND1'
    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 =
    I_GRID_SETTINGS =
    IS_LAYOUT =
    IT_FIELDCAT = fieldcattab[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    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
    IT_ALV_GRAPHICS =
    IT_ADD_FIELDCAT = fieldcattab
    IT_HYPERLINK =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = t_mseg
    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 usercommand1 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
    slis_selfield.
    CASE r_ucomm.
    WHEN '&IC1'.
    tabindex = rs_selfield-tabindex.
    read table t_mseg INDEX tabindex.
    select * from mchb into table t_mchb where matnr = t_mseg-matnr.
    clear fieldcattab.
    CLEAR fieldcattab[].
    fieldcattab-col_pos = 1.
    fieldcattab-fieldname = 'FLAG'.
    fieldcattab-tabname = 'T_MCHB'.
    fieldcattab-fix_column = 'X'.
    fieldcattab-seltext_l = 'Check Box'.
    fieldcattab-input = 'X'.
    fieldcattab-edit = 'X'.
    fieldcattab-checkbox = 'X'.
    APPEND fieldcattab.
    clear fieldcattab.
    fieldcattab-col_pos = 2.
    fieldcattab-fieldname = 'MATNR'.
    fieldcattab-tabname = 'T_MCHB'.
    fieldcattab-fix_column = 'X'.
    fieldcattab-seltext_l = 'Material'.
    fieldcattab-emphasize = 'C1'.
    fieldcattab-input = 'X'.
    fieldcattab-edit = 'X'.
    fieldcattab-checkbox = 'X'.
    APPEND fieldcattab.
    clear fieldcattab.
    fieldcattab-col_pos = 3.
    fieldcattab-fieldname = 'CHARG'.
    fieldcattab-tabname = 'T_MCHB'.
    fieldcattab-seltext_l = 'Batch No'.
    fieldcattab-emphasize = 'C2'.
    fieldcattab-input = 'X'.
    fieldcattab-edit = 'X'.
    APPEND fieldcattab.
    clear fieldcattab.
    fieldcattab-col_pos = 4.
    fieldcattab-fieldname = 'WERKS'.
    fieldcattab-tabname = 'T_MCHB'.
    fieldcattab-seltext_l = 'Plant'.
    fieldcattab-emphasize = 'C30'.
    fieldcattab-input = 'X'.
    fieldcattab-edit = 'X'.
    APPEND fieldcattab.
    clear fieldcattab.
    fieldcattab-col_pos = 5.
    fieldcattab-fieldname = 'CLABS'.
    fieldcattab-tabname = 'T_MCHB'.
    fieldcattab-seltext_l = 'Stock'.
    fieldcattab-emphasize = 'C601'.
    fieldcattab-input = 'X'.
    fieldcattab-edit = 'X'.
    APPEND fieldcattab.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = PROGNAME
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'USERCOMMAND2'
    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 =
    I_GRID_SETTINGS =
    IS_LAYOUT =
    IT_FIELDCAT = FIELDCATTAB[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    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
    IT_ALV_GRAPHICS =
    IT_ADD_FIELDCAT =
    IT_HYPERLINK =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = t_mchb
    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.
    FORM usercommand2 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
    slis_selfield.
    CASE r_ucomm.
    WHEN '&IC1'.
    IF rs_selfield-sel_tab_field = 'T_MCHB-MATNR'.
    CALL FUNCTION 'ZALV2'
    EXPORTING
    CTU = 'X'
    MODE = 'E'
    UPDATE = 'A'
    GROUP =
    USER =
    KEEP =
    HOLDDATE =
    NODATA = '/'
    MATNR_001 = '200-200'
    KZSEL_01_002 = 'X'
    IMPORTING
    SUBRC =
    TABLES
    MESSTAB =
    SET PARAMETER ID 'RID' FIELD RMMG1-MATNR.
    CALL TRANSACTION 'MM03' and skip first screen.
    ENDIF.
    ENDCASE.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = progname
    i_callback_user_command = 'USERCOMMAND3'
    it_fieldcat = fieldcattab[]
    TABLES
    t_outtab = t_mchb
    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.
    Regards,
    chandru

  • End of Page event not triggering in ALV report

    Hello,
    I am developing an ALV report using REUSE_ALV_LIST_DISPLAY. Whatever I write in top_of_page, it will be displayed in the header portion of the output.
    But I want to display some footer text at the end of the page. The problem I am facing is, the WRITE statements within end_of_page are not displayed when the report is run.
    I have populated the i_events as follows :
    FORM f_events CHANGING p_i_events TYPE slis_t_event.
    CONSTANTS : l_c_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
                l_c_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
    DATA : l_wa_event TYPE slis_alv_event.
    Returns table of possible events
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = p_i_events.
    To append internal table holding event names with event 'TOP OF PAGE'
      READ TABLE  p_i_events INTO l_wa_event
      WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc = 0.
          MOVE   l_c_top_of_page TO l_wa_event-form.
          APPEND l_wa_event      TO p_i_events.
      ENDIF.
    To append internal table holding event names with event 'END OF PAGE'
      READ TABLE  p_i_events INTO l_wa_event
      WITH KEY name = slis_ev_end_of_page.
      IF sy-subrc = 0.
          MOVE   l_c_end_of_page TO l_wa_event-form.
          APPEND l_wa_event      TO p_i_events.
      ENDIF.
    ENDFORM.                               "f_events
    Regds
    Rajesh

    Hi have a look at the following code, and change ur code for end of page accordingly. this will resolve ur problem.
    This is a basic ALV with the followings:-
    - Page Heading
    - Page No
    - Sub-Total
    - Grand Total
    REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_PRINT
    IS_REPREP_ID =
    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.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    *END OF ZALV PROGRAM
    Satish

  • Issue in ALV Report

    Hi,
    I have a issue in ALV Report for displaying one field's data into output.
    I am getting data into all other fields in ALV Report except for this field.
    This field & related fields are declared as below: in final internal table.
    sta_no     TYPE z3status,
    status(10) TYPE c,
    Here z3status is of type Char(1).
    In Report
    I have put a condition :
    IF i_tab-sta_no EQ 1.
       i_tab-status = 'Created'.
    ELSE.
       i_tab-status = 'Closed'.
    ENDIF.
    and to field catalog also i am passing right information as for every other field in ALV Report.
    Till the point use of REUSE_ALV_LIST_DISPLAY F.M also final internal table is having status field filled.
    But in output nothing gets displayed for Status field.
    Can anybody tell me what can be the issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    I have no problem in data fetching into final internal table.
    Everything is coming well to REUSE_ALV_DISPLAY F.M.
    But still Status field data is not getting displayed.
    I have posted some code for reference:
            LOOP AT t_z3manboxid INTO wa_z3manboxid.
              wa_result-manifest_no     = wa_z3manboxid-zmanno.
              wa_result-item_no         = wa_z3manboxid-item_no.
              IF l_item_no NE wa_z3manboxid-item_no.
                wa_result-piece_quantity  = wa_z3manboxid-vemng.
                wa_result-unit            = wa_z3manboxid-vemeh.
                wa_result-manifester      = wa_z3manboxid-usnam.
                wa_result-manifest_sta_no = wa_z3manboxid-z3status.
                IF wa_result-manifest_sta_no EQ 1.
                  wa_result-manifest_status = c_created.
                ELSEIF wa_result-manifest_sta_no EQ 2.
                  wa_result-manifest_status = c_in_transit.
                ELSEIF wa_result-manifest_sta_no EQ 3.
                  wa_result-manifest_status = c_arrived.
                ELSEIF wa_result-manifest_sta_no EQ 4.
                  wa_result-manifest_status = c_closed.
                ENDIF.
              ENDIF.
              l_item_no  = wa_z3manboxid-item_no.
              APPEND wa_result TO t_result.
              CLEAR: wa_result, wa_z3manboxid.
            ENDLOOP.
    Building field catalog following code is added:
    For status call is as below:
      PERFORM f_build_fieldcat  USING c_tab
                                      c_manifest_status
                                      c_space
                                      c_space
                                      c_mannf_status
                                      c_space1
                                      15.
    FORM f_build_fieldcat USING p_tabname p_fldname
                                p_rtabname p_rfldname
                                p_fldhdg p_check
                                p_length.
      CLEAR t_fieldcat_ln1.
      ADD 1 TO g_col_pos.
      t_fieldcat_ln1-tabname       = p_tabname.
      t_fieldcat_ln1-fieldname     = p_fldname.
      t_fieldcat_ln1-ref_tabname   = p_rtabname.
      t_fieldcat_ln1-ref_fieldname = p_rfldname.
      t_fieldcat_ln1-ddictxt       = c_l.
      t_fieldcat_ln1-seltext_l     = p_fldhdg.
      t_fieldcat_ln1-no_zero       = space.
      t_fieldcat_ln1-do_sum        = space.
      t_fieldcat_ln1-col_pos       = g_col_pos.
      t_fieldcat_ln1-no_out        = space.
      t_fieldcat_ln1-just          = c_c.
      t_fieldcat_ln1-qfieldname    = space.
      t_fieldcat_ln1-checkbox      = p_check.
      t_fieldcat_ln1-input         = p_check.
      t_fieldcat_ln1-reptext_ddic  = p_fldhdg.
      IF p_fldname EQ c_manno.
        t_fieldcat_ln1-key     = c_x.
        t_fieldcat_ln1-hotspot = c_x.
      ELSE.
        t_fieldcat_ln1-key     = space.
        t_fieldcat_ln1-hotspot = p_check.
      ENDIF.
      t_fieldcat_ln1-outputlen      = p_length.
      t_fieldcat_ln1-intlen         = p_length.
      t_fieldcat_ln1-ddic_outputlen = p_length.
      APPEND t_fieldcat_ln1 TO t_fieldcat1.
    ENDFORM.                    " f_build_fieldcat
    FORM f_build_sortcat USING p_fldname.
      CLEAR t_sortcat_ln1.
      ADD 1 TO g_col_pos.
      t_sortcat_ln1-spos      = g_col_pos.
      t_sortcat_ln1-fieldname = p_fldname.
      t_sortcat_ln1-up        = c_x.
      t_sortcat_ln1-down      = space.
      t_sortcat_ln1-subtot    = c_x.
      APPEND t_sortcat_ln1 TO t_sortcat1.
    ENDFORM.                    " f_build_sortcat
    FORM f_build_layout.
      t_layout1-zebra           = c_x.
      t_layout1-no_vline        = c_space1.
      t_layout1-reprep          = c_x.
      t_layout1-detail_popup    = c_x.
      t_layout1-window_titlebar = text-005.
      t_layout1-no_scrolling    = c_space1.
      t_layout1-detail_titlebar = text-005.
      t_layout1-numc_sum        = c_x.
      t_layout1-get_selinfos    = c_x.
      t_layout1-min_linesize    = 132.
    ENDFORM.                    " f_build_layout
      DATA: l_pgm TYPE syrepid,
            l_exit(1) TYPE c.
      CLEAR: l_pgm,
             l_exit.
      l_pgm = sy-repid.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program      = l_pgm
                i_callback_user_command = c_user_command
                is_layout               = t_layout1
                it_fieldcat             = t_fieldcat1
                i_save                  = c_a
                it_events               = t_eventcat1
           IMPORTING
                e_exit_caused_by_caller = l_exit
           TABLES
                t_outtab                = t_result
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc NE 0.
        l_exit = l_exit.
      ENDIF.
    To ALV F.M t_result table is updated with correct data.
    But it is not getting displayed.
    What can be the reason!
    Can anybody give the solution!
    Thanks for your replies.
    Thanks,
    Deep.

  • ALV Report for Purchasing Each Vendor

    Hi Anybody,
    I am developing Purchasing Report. But I want display records in ALV Report based Vendor ID and Name.
    Like Standard Report ME2M.
    Ex: 
      Vendor ID : A0002                Name : UMS SEMICONDUCTOR PTE LTD.,
        sNO     po no        item    Price        Qty
         1.       10001          10    12.30           10
         2.       10002          20    30.30           50
         3.       10003          30    40.30           150
      Vendor ID : X0012                Name : ALPHA PTE LTD.,
          sNO     po no        item    Price        Qty
         1.       10004          10    1.30           10
         2.       10005          20    50.30          50
         3.       10006          30    620.30        150
    How to I will do?.  Anybody please tell me.
    Tks
    S.Muthu.
    IT Dept.

    hi..follow this code..
    ===================================================================
    ===================================================================
    report  .
    ========================== Global definitions  ====================
    Data Types
    type-pools: slis.
    types: begin of tp_data,
    lifnr like ekko-lifnr,
           end of tp_data,
           tp_tbl_data type standard table of tp_data.
    Constants
    Data objects (variable declarations and definitions)
    Report data to be shown.
    data: it_data type standard table of tp_data.
    Heading of the report.
    data: t_heading type slis_t_listheader.
    ======================= Selection Screen ==========================
    selection-screen: begin of block b1 with frame title text-t01.
    DATA: w_aux_lifnr like ekko-lifnr.
    SELECT-OPTIONS s_lifnr for w_aux_lifnr
    DEFAULT LIFNR .
    selection-screen: end of block b1.
    ======================== Event Blocks =============================
    at selection-screen.
    start-of-selection.
      perform get_data using it_data.
    end-of-selection.
      perform build_alv using it_data t_heading.
    ======================== Subroutines ==============================
    *&      Form  get_data
          Gets the information to be shown in the report.
    form get_data using t_data type tp_tbl_data.
    SELECT ekko~lifnr
    INTO CORRESPONDING FIELDS OF TABLE t_data
    FROM ekko as ekko
    WHERE ekko~lifnr in s_lifnr
    endform.                    " get_data
    *&      Form  build_alv
          Builds and display the ALV Grid.
    form build_alv using t_data type tp_tbl_data
                         t_heading  type slis_t_listheader.
    ALV required data objects.
    data: w_title   type lvc_title,
          w_repid   type syrepid,
          w_comm    type slis_formname,
          w_status  type slis_formname,
          x_layout  type slis_layout_alv,
          t_event    type slis_t_event,
          t_fieldcat type slis_t_fieldcat_alv,
          t_sort     type slis_t_sortinfo_alv.
    refresh t_fieldcat.
    refresh t_event.
    refresh t_sort.
    clear x_layout.
    clear w_title.
    Field Catalog
      perform set_fieldcat2 using:
    1 'LIFNR' 'LIFNR' 'EKKO' space space  space  space  space  space space space space space space space t_fieldcat .
    Layout
    x_layout-zebra = 'X'. 
    Top of page heading
      perform set_top_page_heading using t_heading t_event.
    Events
      perform set_events using t_event.
    GUI Status
      w_status = ''.
      w_repid = sy-repid.
    Title
    w_title = <<If you want to set a title for
                the ALV, please, uncomment and edit this line>>.
    User commands
      w_comm   = 'USER_COMMAND'.
    Order
    Example
    PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
    Displays the ALV grid
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = w_repid
          it_fieldcat              = t_fieldcat
          is_layout                = x_layout
          it_sort                  = t_sort
          i_callback_pf_status_set = w_status
          i_callback_user_command  = w_comm
          i_save                   = 'X'
          it_events                = t_event
          i_grid_title             = w_title
        tables
          t_outtab                 = t_data
        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.
    endform.                    " build_alv.
    *&      Form  set_top_page_heading
          Creates the report headings.
    form set_top_page_heading using t_heading type slis_t_listheader
                                    t_events  type slis_t_event.
    data: x_heading type slis_listheader,
          x_event   type line of slis_t_event.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = ''(001).
      append x_heading to t_heading.
    Program name
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Program: '.
      x_heading-info = sy-repid.
      append x_heading to t_heading.
    User who is running the report
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'User: '.
      x_heading-info = sy-uname.
      append x_heading to t_heading.
    Date of execution
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Date: '.
      write sy-datum to x_heading-info.
      append x_heading to t_heading.
    Time of execution 
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Time: '.
      write sy-uzeit to x_heading-info.
      append x_heading to t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      append x_event to t_events.
    endform.
    *&      Form  set_events
          Sets the events for ALV.
          The TOP_OF_PAGE event is alredy being registered in
          the set_top_page_heading subroutine.
    form set_events using t_events type slis_t_event.
    data: x_event   type line of slis_t_event.
    Example
    clear x_event.
    x_event-name = .
    x_event-form = .
    append x_event to t_event.
    endform.
    *&      Form  set_order
          Adds an entry to the order table.
    FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
                         t_sort TYPE slis_t_sortinfo_alv.
      DATA: x_sort TYPE slis_sortinfo_alv.
      CLEAR x_sort.
      x_sort-fieldname = p_fieldname.
      x_sort-tabname   = p_tabname.
      x_sort-up = p_up.
      x_sort-down = p_down.
      x_sort-subtot = p_subtot.
      APPEND x_sort TO t_sort.
    ENDFORM.                    "set_order
    *&      Form  set_fieldcat2
          Adds an entry to the field catalog.
       p_colpos: Column position.
       p_fieldname: Field of internal table which is being described by
    *            this record of the field catalog.
       p_ref_fieldname: (Optional) Table field / data element which
    *                describes the properties of the field.
    *                If this field is not given, it is copied from
    *                the fieldname.
       p_ref_tabname: (Optional) Table which holds the field referenced
    *              by <<p_ref_fieldname>>.
                      If this is not given, the parameter
                      <<p_ref_fieldname>> references a data element.
       p_outputlen: (Optional) Column width.
       p_noout: (Optional) If set to 'X', states that the field is not
    *           showed initially. If so, the field has to be
                included in the report at runtime using the display
                options.
       p_seltext_m: (Optional) Medium label to be used as column header.
       p_seltext_l: (Optional) Long label to be used as column header.
       p_seltext_s: (Optional) Small label to be used as column header.
       p_reptext_ddic: (Optional) Extra small (heading) label to be
    *                used as column header.
       p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
                  whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
                  or REPTEXT_DDIC as text for column header.
       p_hotspot: (Optional) If set to 'X', this field will be used
    *             as a hotspot area for cursor, alolowing the user
    *          to click on the field.
       p_showasicon: (Optional) If set to 'X', this field will be shown
                     as an icon and the contents of the field will set
    *             which icon to show.
       p_checkbox: (Optional) If set to 'X', this field will be shown
                   as a checkbox.
       p_edit: (Optional) If set to 'X', this field will be editable.
       p_dosum: (Optional) If set to 'X', this field will be summed
                (aggregation function) according to the grouping set
                by the order functions.
       t_fieldcat: Table which contains the whole fieldcat.
    FORM set_fieldcat2 USING
          p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
          t_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-hotspot = p_hotspot.
      wa_fieldcat-checkbox = p_checkbox.
      wa_fieldcat-icon = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    Set reference fieldname, tablenam and rollname.
    If p_ref_tabname is not given, the ref_fieldname given
       is a data element.
    If p_ref_tabname is given, the ref_fieldname given is a
       field of a table.
    In case ref_fieldname is not given,
       it is copied from the fieldname.
      IF p_ref_tabname IS INITIAL.
        wa_fieldcat-rollname =   p_ref_fieldname.
      ELSE.
        wa_fieldcat-ref_tabname = p_ref_tabname.
        IF p_ref_fieldname EQ space.
          wa_fieldcat-ref_fieldname =   wa_fieldcat-fieldname.
        ELSE.
          wa_fieldcat-ref_fieldname =   p_ref_fieldname.
        ENDIF.
      ENDIF.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
      IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
      ENDIF.
      IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
      ENDIF.
      IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
      ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
      IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
      ENDIF.
    Set as editable or not.
      IF NOT p_edit IS INITIAL.
        wa_fieldcat-input     = 'X'.
        wa_fieldcat-edit     = 'X'.
      ENDIF.
      APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    ======================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
        i_logo             = <<If you want to set a logo, please,
                             uncomment and edit this line>>
          it_list_commentary = t_heading.
    endform.                    " alv_top_of_page
    *&      Form  user_command
          Called on user_command ALV event.
          Executes custom commands.
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
    Example Code
    Executes a command considering the sy-ucomm.
    CASE r_ucomm.
       WHEN '&IC1'.
         Set your "double click action" response here.
         Example code: Create and display a status message.
         DATA: w_msg TYPE string,
               w_row(4) TYPE n.
         w_row = rs_selfield-tabindex.
         CONCATENATE 'You have clicked row' w_row
                     'field' rs_selfield-fieldname
                     'with value' rs_selfield-value
                     INTO w_msg SEPARATED BY space.
         MESSAGE w_msg TYPE 'S'.
    ENDCASE.
    End of example code.
    endform.                    "user_command

  • F4 Help needed in ALV report

    Hi Gurus,
    I have create one report which should monitor the batch jobs.
    I some small requirements in that report. Can one can help in updating my code.
    Reuirements:
    Last run date and time should allow only one entry and these should be placed in one line as shown in the requirements.
    ·         F4 on Job status should show the description also.
    ·         F4 on user name should give user details. It should be similar to the f4 in transaction SU01D
    ·         Donu2019t show the entire log on the report. Show only 1 line per job with similar to what is shown in the SM37 report. Job Name, Start Date, Start Time, Job Created By, Sppol, Status, Duration. User can double click on it to see job log or spool list.
    below is the report. Please help me out
    REPORT ZJOB_MONITORING.
    T A B L E S
    TABLES: tbtco.
    T Y P E - S P O O L S
    TYPE-POOLS: slis.
    T Y P E  D E C L A R A T I O N S
    *TYPES: BEGIN OF type_tbtco,
           include TYPE tbtco,
          END OF type_tbtco.
    TYPES: BEGIN OF type_output,
           STRTTIME TYPE tbtco-STRTTIME,
           strtdate TYPE tbtco-strtdate,
           jobname  TYPE tbtco-jobname,
           line     TYPE string,
           END OF type_output.
    S T R U C T U R E S
    DATA: s_tbtco  TYPE tbtco,
          s_joblog TYPE zsbb_uc4_joblog,
          s_output TYPE type_output.
    I N T E R N A L  T A B L E S
    DATA: i_tbtco  TYPE STANDARD TABLE OF tbtco,
          i_joblog TYPE STANDARD TABLE OF zsbb_uc4_joblog,
          i_output TYPE STANDARD TABLE OF type_output.
    DATA: Begin of itab_jobname OCCURS 0,
          jobname type tbtco-jobname,
          end of itab_jobname.
    DATA: Begin of itab_user OCCURS 0,
          jobname type tbtco-sdluname,
          end of itab_user.
    DATA: Begin of itab_stat OCCURS 0,
          jobname type tbtco-status,
          end of itab_stat.
    DATA: Begin of itab_uzeit occurs 0,
          uzeit type sy-uzeit,
          end of itab_uzeit.
    Heading of the report.
    DATA: t_heading TYPE slis_t_listheader.
    DATA : t_fieldcat TYPE slis_t_fieldcat_alv.
    S E L E C T I O N  S C R E E N
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_strtda FOR sy-datum,
                    s_lstrun FOR sy-uzeit OBLIGATORY,
                    s_jobnam FOR tbtco-jobname,
                    s_user   FOR tbtco-sdluname,
                    s_status FOR tbtco-status.
    PARAMETERS: p_email AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK bl1.
    "                         AT SELECTION-SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_JOBNAM-LOW.
      PERFORM f4_JOBNAM-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_JOBNAM-HIGH.
      PERFORM f4_JOBNAM-HIGH.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_user-low.
      PERFORM f4_USER-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_user-high.
      PERFORM f4_USER-HIGH.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_status-low.
      PERFORM f4_STATUS-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_status-high.
      PERFORM f4_STATUS-HIGH.
    S T A R T  O F  S E L E C T I O N
    START-OF-SELECTION.
      PERFORM select_data.
    If email is checked.
    Send the output table as an email attachment to the distribution list.
    Get the email list from the config table. " ask from where to get it
      IF p_email = 'X'.
    Call FM 'SO_OBJECT_SEND'.
    Fill the fields which are not commented accordingly.
    CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
         OBJECT_HD_CHANGE = OBJECT_HD_CHANGE
         OBJECT_TYPE      = 'RAW'
         OWNER            = SY-UNAME
       TABLES
         OBJCONT          = TEXT
         OBJPARA          = OBJPARA
         RECEIVERS        = RECEIVERS
       EXCEPTIONS
         OTHERS           = 01.
    IF SY-SUBRC NE 0.
       RAISE ERROR.
    ENDIF.
    ENDIF.
    Prepare the ALV Report.
    PERFORM alv_grid_display.
    *&      Form  alv_grid_display
          text
    FORM alv_grid_display .
    alv required data objects.
      DATA: w_repid    TYPE syrepid,
            x_layout   TYPE slis_layout_alv,
            t_event    TYPE slis_t_event,
           t_fieldcat TYPE slis_t_fieldcat_alv,
            w_title    TYPE lvc_title,
            w_print    TYPE slis_print_alv,
            w_comm    TYPE slis_formname,
            flag       TYPE c VALUE 'N'.
      REFRESH t_fieldcat.
      REFRESH t_event.
      CLEAR   x_layout.
      CLEAR   w_title.
    Field Catalog
    PERFORM set_fieldcat2 USING:
       1 'strttime'   'BTCXTIME'   space           t_fieldcat ,
       2 'jobname'    'BTCJOB'     space           t_fieldcat ,
       3 'line'        space       'Job Log'       t_fieldcat .
    *PERFORM set_fieldcat2 USING:
       1 'strttime'   'BTCXTIME'   space     'I_OUTPUT'      t_fieldcat ,
       2 'jobname'    'BTCJOB'     space     'I_OUTPUT'      t_fieldcat ,
       3 'line'        space       'Job Log' 'I_OUTPUT'      t_fieldcat .
      PERFORM set_fieldcat.
    Layout
      x_layout-zebra = 'X'.
      x_layout-colwidth_optimize = 'X'.
    GUI Status
      w_repid = sy-repid .
    Top of page heading
    PERFORM set_top_page_heading USING t_heading t_event flag.
    call the FM 'REUSE_ALV_GRID_DISPLAY'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = w_repid
         is_layout                         = x_layout
         it_fieldcat                       = t_fieldcat
        IT_SORT                           =
         i_save                            = 'X'
         it_events                         = t_event
       TABLES
          t_outtab                         = i_output
       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.
    ENDFORM.                    " alv_grid_display
    *&      Form  set_top_page_heading
          text
    FORM set_top_page_heading  USING
                               t_heading TYPE slis_t_listheader
                               t_events  TYPE slis_t_event
                               flag      TYPE c.
      DATA: x_heading TYPE slis_listheader,
            x_event   TYPE LINE OF slis_t_event.
    Report title
      CLEAR t_heading[].
      CLEAR x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'Job Details'(002).
      APPEND x_heading TO t_heading.
    Name of the report program
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Report ID:'.
      x_heading-info = sy-repid.
      APPEND x_heading TO t_heading.
    User who is running the report
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'User: '.
      x_heading-info = sy-uname.
      APPEND x_heading TO t_heading.
    Date of execution
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Date: '.
      WRITE sy-datum TO x_heading-info.
      APPEND x_heading TO t_heading.
    Time of execution
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Time: '.
      WRITE sy-uzeit TO x_heading-info.
      APPEND x_heading TO t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      APPEND x_event TO t_events.
    ENDFORM.                    " set_top_page_heading
    *&      Form  set_fieldcat2
          text
    FORM set_fieldcat2  USING
                        p_colpos p_fieldname p_ref_fieldname
                        p_seltext_m
                        p_tabname
                        t_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
    the ref_fieldname given is a data element.
      IF NOT p_ref_fieldname IS INITIAL.
        wa_fieldcat-rollname =   p_ref_fieldname.
      ENDIF.
    Set text headers.
      IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
      ENDIF.
      wa_fieldcat-tabname = 'I_OUTPUT'.
      APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                    " set_fieldcat2
    *&      Form  F4_JOBNAM-LOW
          text
    -->  p1        text
    <--  p2        text
    FORM F4_JOBNAM-LOW .
      SELECT jobname FROM tbtco
                  INTO TABLE itab_jobname.
      DELETE ADJACENT DUPLICATES FROM itab_jobname.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield             = 'jobname'
      PVALKEY                = ' '
         DYNPPROG               = 'sy-repid'
         DYNPNR                 = '1000'
         DYNPROFIELD            = 's_jobnam-low'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG               = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab            = itab_jobname
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_JOBNAM-LOW
    *&      Form  F4_JOBNAM-HIGH
          text
    -->  p1        text
    <--  p2        text
    FORM F4_JOBNAM-HIGH .
      SELECT jobname FROM tbtco
                    INTO TABLE itab_jobname.
      DELETE ADJACENT DUPLICATES FROM itab_jobname.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield             = 'jobname'
      PVALKEY                = ' '
         DYNPPROG              = 'sy-repid'
         DYNPNR                = '1000'
         DYNPROFIELD           = 's_jobnam-high'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG               = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab            = itab_jobname
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_JOBNAM-HIGH
    *&      Form  F4_USER-LOW
          text
    -->  p1        text
    <--  p2        text
    FORM F4_USER-LOW .
      SELECT sdluname  FROM tbtco
                    INTO TABLE itab_user.
      DELETE ADJACENT DUPLICATES FROM itab_user.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield               = 'user'
      PVALKEY                = ' '
         DYNPPROG               = 'sy-repid'
         DYNPNR                 = '1000'
         DYNPROFIELD            = 's_user-low'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG              = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab            = itab_user
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_USER-LOW
    *&      Form  F4_USER-HIGH
          text
    -->  p1        text
    <--  p2        text
    FORM F4_USER-HIGH .
      SELECT sdluname  FROM tbtco
                    INTO TABLE itab_user.
      DELETE ADJACENT DUPLICATES FROM itab_user.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield               = 'user'
      PVALKEY                = ' '
         DYNPPROG               = 'sy-repid'
         DYNPNR                 = '1000'
         DYNPROFIELD            = 's_user-high'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG              = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab            = itab_user
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_USER-HIGH
    *&      Form  F4_STATUS-LOW
          text
    -->  p1        text
    <--  p2        text
    FORM F4_STATUS-LOW .
      SELECT status  FROM tbtco
                    INTO TABLE itab_stat.
      DELETE ADJACENT DUPLICATES FROM itab_stat.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield               = 'status'
      PVALKEY                = ' '
         DYNPPROG               = 'sy-repid'
         DYNPNR                 = '1000'
         DYNPROFIELD            = 's_status-low'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG              = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab            = itab_stat
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_STATUS-LOW
    *&      Form  F4_STATUS-HIGH
          text
    -->  p1        text
    <--  p2        text
    FORM F4_STATUS-HIGH .
      SELECT status  FROM tbtco
                    INTO TABLE itab_stat.
      DELETE ADJACENT DUPLICATES FROM itab_stat.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
      DDIC_STRUCTURE         = ' '
          retfield               = 'status'
      PVALKEY                = ' '
         DYNPPROG               = 'sy-repid'
         DYNPNR                 = '1000'
         DYNPROFIELD            = 's_status-high'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
      VALUE_ORG              = 'C'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = ' '
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
        tables
          value_tab              = itab_stat
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
      PARAMETER_ERROR        = 1
      NO_VALUES_FOUND        = 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.                    " F4_STATUS-HIGH
    *&      Form  SELECT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM SELECT_DATA .
    select the entries from the table TBTCO
    as per the selection screen
      SELECT * FROM tbtco
               INTO TABLE i_tbtco
               WHERE STRTTIME IN s_lstrun AND
                     strtdate IN s_strtda AND
                     jobname  IN s_jobnam AND
                     sdluname IN s_user   AND
                     status   IN s_status.
    Get the job details for the above jobs.
      LOOP AT i_tbtco INTO s_tbtco.
        CALL FUNCTION 'ZSBB_UC4_JOB_READ_LOG'
          EXPORTING
            client                = sy-mandt
            jobcount              = s_tbtco-jobcount
            joblog                = s_tbtco-joblog
            jobname               = s_tbtco-jobname
          TABLES
            joblog_tab            = i_joblog
          EXCEPTIONS
            cant_read_joblog      = 1
            jobcount_missing      = 2
            joblog_does_not_exist = 3
            joblog_is_empty       = 4
            joblog_name_missing   = 5
            jobname_missing       = 6
            job_does_not_exist    = 7
            OTHERS                = 8.
    Write the Error handling as needed.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
    Append entries to main table.
          s_output-STRTTIME = s_tbtco-STRTTIME.
          s_output-jobname  = s_tbtco-jobname.
          LOOP AT  i_joblog INTO s_joblog.
            s_output-line = s_joblog-text.
            APPEND s_output TO i_output.
            CLEAR s_output.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " SELECT_DATA
    *&      Form  SET_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    form SET_FIELDCAT .
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      wa_fieldcat-col_pos = 1.
      wa_fieldcat-fieldname = 'STRTTIME'.
      wa_fieldcat-seltext_m = 'Start Time'.
      wa_fieldcat-tabname = 'I_OUTPUT'.
    wa_fieldcat-reptext = p_reptext.
      APPEND wa_fieldcat to t_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'JOBNAME'.
      wa_fieldcat-seltext_m = 'Job Name'.
      wa_fieldcat-tabname = 'I_OUTPUT'.
    wa_fieldcat-reptext = p_reptext.
      APPEND wa_fieldcat to t_fieldcat.
      wa_fieldcat-col_pos = 3.
      wa_fieldcat-fieldname = 'LINE'.
      wa_fieldcat-seltext_m = 'Job Log'.
      wa_fieldcat-tabname = 'I_OUTPUT'.
      APPEND wa_fieldcat to t_fieldcat.
    endform.                    " SET_FIELDCAT

    solved

  • Header prob. in ALV report

    Hi All,
    Hope you all are doing fine!!!
    In the below program am trying to print the top-of-page/header in alv report,,but am unable to do it..
    Am working on 4.6c version,,,,,its working fine in ECC 6.0 but i really dont understand why its not working in 4.6c...AM JUST PASTING THE ALV PART...!!!
    Pls. do the needful
    REPORT yjack  LINE-SIZE 132
                    LINE-COUNT 65
                    NO STANDARD PAGE HEADING.
    DATA: /sie/swe_ag0_rdo TYPE /sie/swe_ag0_rdo,
          wa_tvko TYPE tvko,
          /sie/swe_ag0_raa TYPE /sie/swe_ag0_raa,
          wa_kna1 TYPE kna1,
          wa_t001 TYPE t001,
          wa_tvkot TYPE tvkot,
          /sie/swe_ag0_con TYPE /sie/swe_ag0_con,
          /sie/swe_ag0_r02 TYPE /sie/swe_ag0_r02.
    TYPES: BEGIN OF ty_itab,
             bukrs TYPE /sie/swe_ag0_rdo-bukrs,
             vkorg TYPE /sie/swe_ag0_rdo-vkorg,
             zclpr TYPE /sie/swe_ag0_rdo-zclpr,
             zcdaz TYPE /sie/swe_ag0_rdo-zcdaz,
             vbeln TYPE /sie/swe_ag0_rdo-vbeln,
             posnr TYPE /sie/swe_ag0_rdo-posnr,
             vbtyp TYPE /sie/swe_ag0_rdo-vbtyp,
             zidag TYPE /sie/swe_ag0_rdo-zidag,
             zimpp TYPE /sie/swe_ag0_rdo-zimpp,
             zimco TYPE /sie/swe_ag0_rdo-zimco,
             zimmg TYPE /sie/swe_ag0_rdo-zimmg,
             fkdat TYPE /sie/swe_ag0_rdo-fkdat,
             zstre TYPE /sie/swe_ag0_rdo-zstre,
             vtweg TYPE /sie/swe_ag0_rdo-vtweg,
             kunrg TYPE /sie/swe_ag0_rdo-kunrg,
          END OF ty_itab.
    TYPES: BEGIN OF ty_itab2,
             bukrs TYPE /sie/swe_ag0_rdo-bukrs,
             vkorg TYPE /sie/swe_ag0_rdo-vkorg,
             zcdaz TYPE /sie/swe_ag0_rdo-zcdaz,
             fkdat TYPE /sie/swe_ag0_rdo-fkdat,
             vbeln TYPE /sie/swe_ag0_rdo-vbeln,
             zimpp TYPE /sie/swe_ag0_rdo-zimpp,
             zimco(5) TYPE p DECIMALS 2,
             zimmg(5) TYPE p DECIMALS 2,
             resid(6) TYPE p DECIMALS 2,
             kunrg TYPE /sie/swe_ag0_rdo-kunrg,
             name1 TYPE kna1-name1,
          END OF ty_itab2.
    type-pools: slis.
    types: begin of ty_final,
           bukrs type char29,
           vkorg type char24,
           mese  type char17,
           gjahr type gjahr,
           agent type char45,
           vbeln type vbeln,
           fkdat type fkdat,
           zimpp type /SIE/SWE_AG0_ZIMPP,
           zimco type /SIE/SWE_AG0_ZIMCO,
           zimmg type /SIE/SWE_AG0_ZIMMG,
           resid(5) TYPE p DECIMALS 2,
           kunrg type kunrg,
           name1 type NAME1_GP,
           end of ty_final.
    data: it_final type table of ty_final,
          wa_final type ty_final,
          g_bukrs(29) type c,
          g_vkorg(24) type c.
    data: it_fieldcat type slis_t_fieldcat_alv,
          it_layout type slis_layout_alv,
          it_list_top_of_page type slis_t_listheader,
          it_events type slis_t_event,
          wa_events type slis_alv_event,
          it_headings type slis_t_listheader,
          wa_headings type slis_listheader.
    constants: c_h type c value 'H',
               c_s type c value 'S'.
    field-symbols: <fs_final> type ty_final.
    DATA: it_itab TYPE TABLE OF ty_itab,
          it_itab2 TYPE TABLE OF ty_itab2,
          wa_itab TYPE ty_itab,
          wa_itab2 TYPE ty_itab2.
    DATA: wa_app TYPE ty_itab.
    DATA: w_var TYPE c VALUE '1',
          w_com_mese(9) TYPE c,
          w_flag_st TYPE c.
    $$ Selection-screen
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK parametri WITH FRAME TITLE text-001.
    BEG MOD ESX00596 IMS:100276414 TR:SWIK9A04W7 11.04.2007
    *PARAMETERS: p_bukrs LIKE /sie/swe_ag0_rdo-bukrs OBLIGATORY.
    *PARAMETERS: p_vkorg LIKE /sie/swe_ag0_rdo-vkorg OBLIGATORY.
    PARAMETERS: p_bukrs TYPE /sie/swe_ag0_rdo-bukrs OBLIGATORY.
    PARAMETERS: p_vkorg TYPE /sie/swe_ag0_rdo-vkorg OBLIGATORY.
    SELECT-OPTIONS: s_zcdaz FOR /sie/swe_ag0_rdo-zcdaz OBLIGATORY
                            MATCHCODE OBJECT /sie/swe_ag0_zaa.
    PARAMETERS: mese(2) TYPE n OBLIGATORY,
                anno TYPE /sie/swe_ag0_rdo-gjahr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK parametri.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: c1 AS CHECKBOX.
    SELECTION-SCREEN COMMENT 8(31) text-006 FOR FIELD c1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN: END OF BLOCK b1.
    DATA: w_cd_a   TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_gen TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_di  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_re  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_te  TYPE /sie/swe_ag0_rdo-vtweg,
          w_cd_ca  TYPE /sie/swe_ag0_rdo-vtweg.
    INITIALIZATION.
      PERFORM selezione_hard_coding.
    $$ At selection-screen
    AT SELECTION-SCREEN.
      PERFORM controlli.
    $$ Top-of-page
    TOP-OF-PAGE.
      PERFORM top_of_page.
    $$ Start-of-selection
    START-OF-SELECTION.
      perform build_events.
      PERFORM carica_itab.
      PERFORM carica_itab2.
      PERFORM stampa.
    END-OF-SELECTION.
    IF C1 EQ 'X'.
    perform fill-fieldcatalog.
    perform display_alv.
    ENDIF.
    *&      Form  fill-fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    form fill-fieldcatalog.
    data: l_fieldcat TYPE slis_fieldcat_alv.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'BUKRS'.
          l_fieldcat-col_pos       = 1.
          l_fieldcat-seltext_l     = 'Company'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'VKORG'.
          l_fieldcat-col_pos       = 2.
          l_fieldcat-seltext_l     = 'Comm. Organization'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'MESE'.
          l_fieldcat-col_pos       = 3.
          l_fieldcat-seltext_l     = 'Month'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'GJAHR'.
          l_fieldcat-col_pos       = 4.
          l_fieldcat-seltext_l     = 'Year'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'AGENT'.
          l_fieldcat-col_pos       = 5.
          l_fieldcat-seltext_l     = 'AGENT'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'VBELN'.
          l_fieldcat-col_pos       = 6.
          l_fieldcat-seltext_l     = 'Invoice'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'FKDAT'.
          l_fieldcat-col_pos       = 7.
          l_fieldcat-seltext_l     = 'Date'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMPP'.
          l_fieldcat-col_pos       = 8.
          l_fieldcat-seltext_l     = 'Taxable'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMCO'.
          l_fieldcat-col_pos       = 9.
          l_fieldcat-seltext_l     = 'Tot.Comm.'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'ZIMMG'.
          l_fieldcat-col_pos       = 10.
          l_fieldcat-seltext_l     = 'Settle'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'RESID'.
          l_fieldcat-col_pos       = 11.
          l_fieldcat-seltext_l     = 'Accruing'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'KUNRG'.
          l_fieldcat-col_pos       = 12.
          l_fieldcat-seltext_l     = 'Cust.Code'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
          l_fieldcat-tabname       = 'IT_FINAL'.
          l_fieldcat-fieldname     = 'NAME1'.
          l_fieldcat-col_pos       = 13.
          l_fieldcat-seltext_l     = 'Company Name'.
          APPEND l_fieldcat TO it_fieldcat.
          clear l_fieldcat.
    endform.                    " fill-fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       I_CALLBACK_TOP_OF_PAGE            = 'PRINT_HEADING'
       IS_LAYOUT                         = it_layout
       IT_FIELDCAT                       = it_fieldcat
       IT_EVENTS                         = it_events
      TABLES
        t_outtab                          = it_final
    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_alv
    *&      Form  build_events
          text
         -->P_IT_EVENTS[]  text
    form build_events.
    clear wa_events.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = it_events.
    read table it_events into wa_events with key name = 'TOP_OF_PAGE'.
    if sy-subrc eq 0.
    wa_events-form = 'PRINT_HEADING'.
    modify it_events from wa_events transporting form
        where name = 'TOP_OF_PAGE'.
    endif.
    endform.                    " build_events
    form PRINT_HEADING.
    clear wa_headings.
    wa_headings-typ = 'H'.
    wa_headings-info = 'DEMO FOR ALV!!!'.
    append wa_headings to it_headings.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary       = it_headings.
    endform.
    Thanks n Regards
    Jack

    Hi friend,
    I think u have to remove below lines in your program because FM 'REUSE_ALV_GRID_DISPLAY' will call directly Form 'PRINT_HEADING'   for TOP-OF-PAGE event through table 'it_events' :
    Remove lines:
        TOP-OF-PAGE.
        PERFORM top_of_page.
    Also remove the parameter
    I_CALLBACK_TOP_OF_PAGE = 'PRINT_HEADING' in  FM 'REUSE_ALV_GRID_DISPLAY'
    Also put a breakpoint in your program in the line,
    START-OF-SELECTION.
    perform build_events.
    See whether 'form' 'name' gets populated in table 'it_events'  or not.
    See sample report and compare.
    REPORT zawi_assign3 NO STANDARD PAGE HEADING.
    TYPE-POOLS: slis.
    DATA: BEGIN OF gt_outtab OCCURS 0.
            INCLUDE STRUCTURE ekpo.
    DATA: END OF gt_outtab,
          gs_layout TYPE slis_layout_alv,
          g_exit_caused_by_caller,
          gs_exit_caused_by_user TYPE slis_exit_by_user,
          g_repid LIKE sy-repid.
    DATA:
        gt_events      TYPE slis_t_event,
        gt_list_top_of_page TYPE slis_t_listheader,
        g_status_set   TYPE slis_formname VALUE 'PF_STATUS_SET',
        g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
        g_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE',
        g_top_of_list  TYPE slis_formname VALUE 'TOP_OF_LIST',
        g_end_of_list  TYPE slis_formname VALUE 'END_OF_LIST'.
    DATA: gs_variant LIKE disvariant,
          g_save.
    INITIALIZATION.
      g_repid = sy-repid.
      PERFORM layout_init USING gs_layout.
      PERFORM eventtab_build USING gt_events[].
      gs_variant-report = g_repid.
      g_save           = 'X'.
    START-OF-SELECTION.
      PERFORM select_data TABLES gt_outtab.
    END-OF-SELECTION.
      PERFORM comment_build USING gt_list_top_of_page[].
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
             i_background_id    = 'ALV_BACKGROUND'
             i_buffer_active    = 'X'
             i_callback_program = g_repid
             i_structure_name   = 'ekpo'
             is_layout          = gs_layout
             i_save             = g_save
             is_variant         = gs_variant
             it_events          = gt_events[]
        IMPORTING
             e_exit_caused_by_caller = g_exit_caused_by_caller
             es_exit_caused_by_user  = gs_exit_caused_by_user
        TABLES
             t_outtab = gt_outtab
        EXCEPTIONS
             program_error = 1
             OTHERS        = 2.
      IF sy-subrc = 0.
        IF g_exit_caused_by_caller = 'X'.
        ELSE.
          IF gs_exit_caused_by_user-back = 'X'.
          ELSE.
            IF gs_exit_caused_by_user-exit = 'X'.
            ELSE.
              IF gs_exit_caused_by_user-cancel = 'X'.
              ELSE.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
      ENDIF.
    FORM select_data TABLES rt_outtab LIKE gt_outtab[].
      SELECT * FROM ekpo INTO CORRESPONDING FIELDS
                       OF TABLE rt_outtab
                       UP TO 00030 ROWS.
    ENDFORM.                    "SELECT_DATA
    FORM layout_init USING rs_layout TYPE slis_layout_alv.
      rs_layout-detail_popup      = 'X'.
      rs_layout-edit = 'X'.
    ENDFORM.                    "LAYOUT_INIT
    FORM eventtab_build USING rt_events TYPE slis_t_event.
    *"Registration of events to happen during list display
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = rt_events.
      READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE g_top_of_page TO ls_event-form.
        APPEND ls_event TO rt_events.
      ENDIF.
    ENDFORM.                    "EVENTTAB_BUILD
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = gt_list_top_of_page.
    ENDFORM.                    "TOP_OF_PAGE
    FORM comment_build USING lt_top_of_page TYPE
                                            slis_t_listheader.
      DATA: ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = text-100.
      APPEND ls_line TO lt_top_of_page.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Program'.
      ls_line-info = sy-repid.
      APPEND ls_line TO lt_top_of_page.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'User'.
      ls_line-info = sy-uname.
      APPEND ls_line TO lt_top_of_page.
    ENDFORM.                    "COMMENT_BUILD
    Might solve your problem.
    Thanks.
    Edited by: Sap Fan on Feb 20, 2009 9:50 AM
    Edited by: Sap Fan on Feb 20, 2009 9:52 AM
    Edited by: Sap Fan on Feb 20, 2009 9:54 AM

  • How to read the check box value in alv report

    hi experts,
    i m working on one alv report where i m using the check box for field selection in alv display.
    but i don't know how to read the only selected fields.
    wa_fieldcat-fieldname = 'BOX'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Box'.
      wa_fieldcat-checkbox = 'X'.
      wa_fieldcat-input = 'X'.
      wa_fieldcat-edit = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'AUFNR'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Sales Doc'.
      wa_fieldcat-hotspot = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = v_repid
         I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         it_fieldcat                       = i_fieldcat[]
         i_save                            = 'A'
         it_events                         = v_events
        TABLES
          t_outtab                          = it_header
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
    when '&RELEAS'.
    endcase
    endform.
    i gone through some already posted que for same problem i tried options like
    loop at it_header.
    endloop.
    but i m getting box field empty.
    is there i missed something? plz sugeest.. if u have any other solution plz post...

    Have this code in your user command fm:
    * For capturing changed data
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = w_grid.
      CALL METHOD w_grid->check_changed_data
        IMPORTING
          e_valid = w_valid.
      IF w_valid = 'X'.
    loop at itab where mark = 'X'.
    endloop.
    ENDIF.
    Regards,
    Ravi

Maybe you are looking for