Sunday, December 19, 2010
Steps to follow.
  • Export I_SAVE = 'X' or 'A' through REUSE_ALV_GEID_DISPLAY.
  • Define one parameter to select variant on selection-screen itself instead of selecting on Output.
    parameters :p_layout like disvariant-variant.
    
  • F4 help to get variants set for the report
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
      PERFORM get_variant.
    
      "subroutine code and define w_variant structure type disvariant.
    *&---------------------------------------------------------------------*
    *&      Form  get_variant
    *&---------------------------------------------------------------------*
    FORM get_variant.
    
      DATA: lw_variant TYPE disvariant,
      l_exit     TYPE char1.
    
      lw_variant-report = sy-repid.
    
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = lw_variant
          i_save     = 'A'
        IMPORTING
          e_exit     = l_exit
          es_variant = lw_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF l_exit EQ space.
          p_layout = lw_variant-variant.
    
          IF NOT p_layout IS INITIAL.
            PERFORM get_w_variant.
          ENDIF.
        ENDIF.
      ENDIF.
    
    ENDFORM.                    " get_variant
    *&---------------------------------------------------------------------*
    *&      Form  get_w_variant
    *&---------------------------------------------------------------------*
    FORM get_w_variant.
    
      w_variant-report      = sy-repid.
      w_variant-handle      = space.
      w_variant-log_group   = space.
      w_variant-username    = space.
      w_variant-variant     = p_layout.
      w_variant-text        = space.
      w_variant-dependvars  = space.
    
    ENDFORM.                    " get_w_variant
    
  • Pass w_variant structure through REUSE_ALV_GRID_DISPLAY FM
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program      = 'ZTEST_NOTEPAD' "Program name
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat             = i_field
        it_sort                 = i_sort
        i_save                  = 'X'
        is_variant              = w_variant "If you pass variant selected on selection-screen
      TABLES
        t_outtab                                         "on F4 help,corresponding output is displayed
    
      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.
    
  • If you select variant and pass through FM it will be remained when u come back from secondary ALV.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.