Monday, September 25, 2023

Interactive with ALV for run TCODE 'VA03' and 'XD03'.

 *&---------------------------------------------------------------------*

*& Report ZALV_PRACTICE1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zalv_practice1.
""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 uc USING LIKE sy-ucomm
              b TYPE slis_selfield.
  IF  b-fieldname 'VBELN'.
    SET PARAMETER ID 'DUC' FIELD b-value.
    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
  ELSE.
    IF  b-fieldname 'KUNNR'.
      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDIF.
ENDFORM.

output:

next screen:
when select s.doc.no:

when 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. ...