Monday, September 25, 2023

Interactive ALV

 REPORT zalv_practice1.

""REQUIREMENT:
       BASED ON THE GIVEN SALES DOCUMENT NUMBERS, DISPLAY  SALES DOCUMENT NUMBER,
"DUCOMENT DATES & CUSTOMER NUMBERS BY USING ALV& ALSO DISPLAY THE SALES DOC NUMBERS WITH GREEN COLOR.
"IF THE USER CLICK ON ANY SALES DOCUMENT ONLY THEN WE DISPLAY THE SALES ORDER  DETAILS THROUGH 'VA03'TRANSACTION.
"IF THE USER CLICKS ON ANY CUSTOMER NUMBER ONLY THEN WE DISPLAY THE CUSTOMER DETAIS THROUGH 'XD03'TRANSACTION.

TYPE-POOLS slis.
TABLES vbak,vbap,kna1.
TYPES BEGIN OF ty_vbak,
          vbeln TYPE vbak-vbeln,
          audat TYPE vbak-audat,
          kunnr TYPE vbak-kunnr,
        END OF ty_vbak.
DATAit_vbak TYPE TABLE OF ty_vbak,
      wa_vbak TYPE ty_vbak.
DATAit_vbap TYPE TABLE OF vbap,
      wa_vbap TYPE vbap.
DATAit_kna1 TYPE TABLE OF kna1,
      wa_kna1 TYPE  kna1.

DATA it_fcat TYPE slis_t_fieldcat_alv,
       wa_fcat TYPE slis_fieldcat_alv.

DATA it_event TYPE slis_t_event,
       wa_event LIKE LINE OF it_event.
**
SELECT-OPTIONSs_vbeln FOR vbak-vbeln.
SELECT-OPTIONSs_kunnr FOR vbak-kunnr.
**
START-OF-SELECTION.
  SELECT vbeln audat kunnr
    FROM vbak INTO TABLE it_vbak
    WHERE vbeln IN s_vbeln.

END-OF-SELECTION.
  wa_fcat-col_pos '1'.
  wa_fcat-fieldname 'VBELN'.
  wa_fcat-seltext_l 'S.DOC.NO'.
  wa_fcat-emphasize 'C510'.
  wa_fcat-hotspot 'X'.

  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-col_pos '2'.
  wa_fcat-fieldname 'AUDAT'.
  wa_fcat-seltext_l 'DOC.DATE'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-col_pos '3'.
  wa_fcat-fieldname 'KUNNR'.
  wa_fcat-seltext_l 'CUSTOMER NUMBER'.

  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.
  wa_event-name 'USER_COMMAND'.
  wa_event-form 'UC'.
  APPEND wa_event TO it_event.
  CLEAR wa_event.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
*     I_INTERFACE_CHECK       = ' '
*     I_BYPASSING_BUFFER      =
*     I_BUFFER_ACTIVE         = ' '
      i_callback_program      sy-repid
*     I_CALLBACK_PF_STATUS_SET       = ' '
      i_callback_user_command 'UC'
*     I_STRUCTURE_NAME        =
*     IS_LAYOUT               =
      it_fieldcat             it_fcat
*     IT_EXCLUDING            =
*     IT_SPECIAL_GROUPS       =
*     IT_SORT                 =
*     IT_FILTER               =
*     IS_SEL_HIDE             =
      i_default               'X'
*     I_SAVE                  = ' '
*     IS_VARIANT              =
      it_events               it_event
*     IT_EVENT_EXIT           =
      i_suppress_empty_data   abap_false
* IMPORTING
*     E_EXIT_CAUSED_BY_CALLER =
*     ES_EXIT_CAUSED_BY_USER  =
    TABLES
      t_outtab                it_vbak
    EXCEPTIONS
      program_error           1
      OTHERS                  2.
IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM uc USING LIKE sy-ucomm
              b TYPE slis_selfield.
  IF  b-fieldname 'VBELN'.
    READ TABLE it_vbak INTO wa_vbak INDEX b-tabindex.
    SELECT FROM vbap INTO TABLE it_vbap
      WHERE vbeln EQ wa_vbak-vbeln.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
*       I_INTERFACE_CHECK       = ' '
*       I_BYPASSING_BUFFER      =
*       I_BUFFER_ACTIVE         = ' '
        i_callback_program      sy-cprog
*       I_CALLBACK_PF_STATUS_SET       = ' '
        i_callback_user_command 'SEC'
        i_structure_name        'VBAP'
*
*       I_DEFAULT               = 'X'
*       I_SUPPRESS_EMPTY_DATA   = ABAP_FALSE
* IMPORTING
*       E_EXIT_CAUSED_BY_CALLER =
*       ES_EXIT_CAUSED_BY_USER  =
      TABLES
        t_outtab                it_vbap
      EXCEPTIONS
        program_error           1
        OTHERS                  2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

  ELSEIF  b-fieldname 'KUNNR'.
    READ TABLE it_vbak INTO wa_vbak INDEX b-tabindex.
    SELECT FROM kna1 INTO TABLE it_kna1
      WHERE kunnr EQ wa_vbak-kunnr.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'     "IF REUSE_ALV_LIST_DISPLAY, THEN THE O/P WILL NOT SET IN OP SCREEN .
      EXPORTING
*
        i_callback_program sy-repid
*
        i_structure_name   'KNA1'
*
*       I_DEFAULT          = 'X'
*
*       I_SCREEN_START_COLUMN             = 0
*       I_SCREEN_START_LINE               = 0
*       I_SCREEN_END_COLUMN               = 0
*       I_SCREEN_END_LINE  = 0
*       I_HTML_HEIGHT_TOP  = 0
*       I_HTML_HEIGHT_END  = 0
*       IT_ALV_GRAPHICS    =
*       IT_HYPERLINK       =
*       IT_ADD_FIELDCAT    =
*       IT_EXCEPT_QINFO    =
*       IR_SALV_FULLSCREEN_ADAPTER        =
*     IMPORTING
*       E_EXIT_CAUSED_BY_CALLER           =
*       ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab           it_kna1
      EXCEPTIONS
        program_error      1
        OTHERS             2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
*
*
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
*       I_INTERFACE_CHECK     = ' '
*       I_BYPASSING_BUFFER    =
*       I_BUFFER_ACTIVE       = ' '
        i_callback_program    sy-repid
*       I_CALLBACK_PF_STATUS_SET       = ' '
*       I_CALLBACK_USER_COMMAND        = ' '
        i_structure_name      'KNA1'
*       IS_LAYOUT             =
*       IT_FIELDCAT           =
*       IT_EXCLUDING          =
*       IT_SPECIAL_GROUPS     =
*       IT_SORT               =
*       IT_FILTER             =
*       IS_SEL_HIDE           =
        i_default             'X'
        i_suppress_empty_data abap_false
      IMPORTING
*       E_EXIT_CAUSED_BY_CALLER        =
*       ES_EXIT_CAUSED_BY_USER         =
*        TABLES
        t_outtab              it_kna1
      EXCEPTIONS
        program_error         1
        OTHERS                2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
*      ENDIF.
  ENDIF.
ENDFORM.

output:


when we select S.doc.no:

when we select Customer Number:
 











No comments:

Post a Comment

Translation of language in Smart Forms.

  Step by Step process to Translate English language to Spanish language in smart form. 1. Go to T-Code SE63 in command bar and then enter. ...