Monday, 18 May 2020

SPLITTING CUSTOM CONTAINER BY SPLITTER CONTAINER AND DISPLAYING INTERACTIVE ALV


SPLITTING CUSTOM CONTAINER BY SPLITTER CONTAINER AND DISPLAYING INTERACTIVE ALV

CLASS HANDLE_EVENT DEFINITION.
  PUBLIC SECTION.
 CLASS-METHODS : HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK
                  OF CL_GUI_ALV_GRID IMPORTING E_ROW.

ENDCLASS.

DATA : IT_MARA TYPE TABLE OF MARA,
       WA_MARA TYPE MARA,
       IT_MAKT TYPE TABLE OF MAKT,
       WA_MAKT TYPE MAKT,
       O_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
       O_SPLI TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
       O_REF1 TYPE REF TO CL_GUI_CONTAINER,
       O_REF2 TYPE REF TO CL_GUI_CONTAINER,
       O_ALV1 TYPE REF TO CL_GUI_ALV_GRID,
       O_ALV2 TYPE REF TO CL_GUI_ALV_GRID,
       OK_CODE TYPE SY-UCOMM.

SELECT-OPTIONS : S_MATNR FOR WA_MARA-MATNR.

CLASS HANDLE_EVENT IMPLEMENTATION.

  METHOD HANDLE_DOUBLE_CLICK.
    CLEAR WA_MARA.
    READ TABLE IT_MARA INTO WA_MARA INDEX E_ROW.
    select * from makt into table it_makt
       where matnr = wa_mara-matnr.
    IF SY-SUBRC = 0.
      IF O_ALV2 IS NOT BOUND.

        create object O_ALV2
          exporting

            I_PARENT          =  O_REF2

          exceptions
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5
            .
        if SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.

call method O_ALV2->SET_TABLE_FOR_FIRST_DISPLAY
         exporting

           I_STRUCTURE_NAME              = 'MAKT'
*            
          changing
            IT_OUTTAB                     = IT_MAKT

          exceptions
            INVALID_PARAMETER_COMBINATION = 1
            PROGRAM_ERROR                 = 2
            TOO_MANY_LINES                = 3
            OTHERS                        = 4
                .
        if SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.


      ENDIF.

    ENDIF.

call method O_ALV2->REFRESH_TABLE_DISPLAY
*   exporting
*     IS_STABLE      =
*     I_SOFT_REFRESH =
   exceptions
     FINISHED       = 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.


  ENDMETHOD.

ENDCLASS.


START-OF-SELECTION.

PERFORM FETCH_DATA.
 END-OF-SELECTION.

  CALL SCREEN 100.

FORM FETCH_DATA.

SELECT * FROM MARA INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR.


ENDFORM.

MODULE SPLIT_CONTAINER OUTPUT.

  IF O_CUST IS NOT BOUND.
    create object O_CUST
      exporting
*        PARENT                      =
        CONTAINER_NAME              = 'CUST'

      exceptions
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6
        .
    if SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.


                   .
 create object O_SPLI
  exporting
*     LINK_DYNNR        =
*     LINK_REPID        =
*     SHELLSTYLE        =
*     LEFT              =
*     TOP               =
*     WIDTH             =
*     HEIGHT            =
*     METRIC            = CNTL_METRIC_DYNPRO
*     ALIGN             = 15
     PARENT            = O_CUST
     ROWS              = 2
    COLUMNS           = 1
*     NO_AUTODEF_PROGID_DYNNR =
*     NAME              =
   exceptions
     CNTL_ERROR        = 1
     CNTL_SYSTEM_ERROR = 2
     OTHERS            = 3
     .
 if SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 endif.

call method O_SPLI->GET_CONTAINER
                 exporting
                   ROW       = 1
                   COLUMN    = 1
                 receiving
                   CONTAINER =  O_REF1 .


call method O_SPLI->GET_CONTAINER
                 exporting
                   ROW       = 2
                   COLUMN    = 1
                 receiving
                   CONTAINER =  O_REF2 .


  ENDIF.


ENDMODULE.

MODULE MARA_DISPLAY OUTPUT.

  IF O_ALV1 IS NOT BOUND.

    create object O_ALV1
      exporting

        I_PARENT          = O_REF1
*        I_APPL_EVENTS     = SPACE

      exceptions
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        OTHERS            = 5
        .
    if SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.


SET HANDLER HANDLE_EVENT=>HANDLE_DOUBLE_CLICK FOR O_ALV1.

   call method O_ALV1->SET_TABLE_FOR_FIRST_DISPLAY
    exporting

*       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              = 'MARA'

     changing
       IT_OUTTAB                     = IT_MARA
*       IT_FIELDCATALOG               =
*       IT_SORT                       =
*       IT_FILTER                     =
     exceptions
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       OTHERS                        = 4
           .
   if SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   endif.


  ENDIF.

ENDMODULE.                 " MARA_DISPLAY  OUTPUT








No comments:

Post a Comment