F ALV program using Subroutine in SAP ABAP | CodeTheta

ALV program using Subroutine in SAP ABAP


Code :
REPORT ZVP_ALV_EKPO_DETAILS.

TYPE-POOLSSLIS.

TYPESBEGIN OF ST_EKPO,
         EBELN TYPE EBELN,
         MATNR TYPE MATNR,
         EMATN TYPE EMATN,
         BUKRS TYPE BUKRS,
       END OF ST_EKPO.


DATAIT_EKPO   TYPE STANDARD TABLE OF ST_EKPO,
      WA_EKPO   TYPE ST_EKPO,

      IT_FCAT   TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT   TYPE SLIS_FIELDCAT_ALV,
      WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

      LV_EBELN  TYPE EKPO-EBELN.

SELECT-OPTIONSS_EBELN FOR LV_EBELN.

SELECT EBELN
       MATNR
       BUKRS
  FROM EKPO INTO TABLE IT_EKPO UP TO 50 ROWS
  WHERE EBELN IN S_EBELN.

PERFORM GETDETAILS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    IS_LAYOUT   WA_LAYOUT
    IT_FIELDCAT IT_FCAT
  TABLES
    T_OUTTAB    IT_EKPO.


FORM GETDETAILS.
  WA_FCAT-COL_POS '1'.
  WA_FCAT-FIELDNAME 'EBELN'.
  WA_FCAT-SELTEXT_M 'Purchasing Document Number'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_FCAT-COL_POS '2'.
  WA_FCAT-FIELDNAME 'MATNR'.
  WA_FCAT-SELTEXT_M 'Material Number'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_FCAT-COL_POS '3'.
  WA_FCAT-FIELDNAME 'BURKS'.
  WA_FCAT-SELTEXT_M 'Company Code'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_LAYOUT-COLWIDTH_OPTIMIZE 'X'.
ENDFORM.


Output :


IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment