Skip to Content
0
Former Member
Jul 24, 2007 at 06:49 AM

Subroutine

14 Views

Hi,

In this program i want to use subroutine .i want to use subroutine instead of defining each field individually.

how to do that .

TYPE-POOLS SLIS.

TYPES:

BEGIN OF TY_VBAK,

VBELN TYPE VBAK-VBELN,

AUDAT TYPE VBAK-AUDAT,

AUART TYPE VBAK-AUART,

NETWR TYPE VBAK-NETWR,

KUNNR TYPE VBAK-KUNNR,

END OF TY_VBAK.

DATA:

ST_VBAK TYPE TY_VBAK,

IT_VBAK TYPE TABLE OF TY_VBAK.

DATA:

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

ST_FIELDCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV.

SELECT-OPTIONS:

SKUNNR FOR ST_VBAK-KUNNR.

START-OF-SELECTION.

ST_FIELDCAT-COL_POS = '1'.

ST_FIELDCAT-TABNAME = 'ST_VBAK'.

ST_FIELDCAT-FIELDNAME = 'VBELN'.

ST_FIELDCAT-KEY = 'X'.

ST_FIELDCAT-HOTSPOT = 'X'.

ST_FIELDCAT-SELTEXT_L = 'SALES DOCUMENT NUMBER'.

ST_FIELDCAT-SELTEXT_M = 'SALES DOC NO'.

ST_FIELDCAT-SELTEXT_S = 'ORDER NO'.

APPEND ST_FIELDCAT TO IT_FIELDCAT.

CLEAR ST_FIELDCAT.

ST_FIELDCAT-COL_POS = '2'.

ST_FIELDCAT-TABNAME = 'ST_VBAK'.

ST_FIELDCAT-FIELDNAME = 'AUDAT'.

ST_FIELDCAT-KEY = ''.

ST_FIELDCAT-HOTSPOT = ''.

ST_FIELDCAT-SELTEXT_L = 'SALES DOCUMENT DATE'.

ST_FIELDCAT-SELTEXT_M = 'SALES DOC DT'.

ST_FIELDCAT-SELTEXT_S = 'DATE'.

APPEND ST_FIELDCAT TO IT_FIELDCAT.

CLEAR ST_FIELDCAT.

ST_FIELDCAT-COL_POS = '3'.

ST_FIELDCAT-TABNAME = 'ST_VBAK'.

ST_FIELDCAT-FIELDNAME = 'AUART'.

ST_FIELDCAT-KEY = ''.

ST_FIELDCAT-HOTSPOT = ''.

ST_FIELDCAT-SELTEXT_L = 'SALES DOCUMENT DATE'.

ST_FIELDCAT-SELTEXT_M = 'SALES DOC DT'.

ST_FIELDCAT-SELTEXT_S = 'DATE'.

APPEND ST_FIELDCAT TO IT_FIELDCAT.

CLEAR ST_FIELDCAT.

ST_FIELDCAT-COL_POS = '4'.

ST_FIELDCAT-TABNAME = 'ST_VBAK'.

ST_FIELDCAT-FIELDNAME = 'NETWR'.

ST_FIELDCAT-KEY = ''.

ST_FIELDCAT-HOTSPOT = ''.

ST_FIELDCAT-SELTEXT_L = 'NET WORTH'.

ST_FIELDCAT-SELTEXT_M = 'NET WOR'.

ST_FIELDCAT-SELTEXT_S = 'NW'.

APPEND ST_FIELDCAT TO IT_FIELDCAT.

CLEAR ST_FIELDCAT.

ST_FIELDCAT-COL_POS = '5'.

ST_FIELDCAT-TABNAME = 'ST_VBAK'.

ST_FIELDCAT-FIELDNAME = 'KUNNR'.

ST_FIELDCAT-KEY = ''.

ST_FIELDCAT-HOTSPOT = ''.

ST_FIELDCAT-SELTEXT_L = 'CUSTOMER NUMBER'.

ST_FIELDCAT-SELTEXT_M = 'CUST NUM'.

ST_FIELDCAT-SELTEXT_S = 'CUST'.

APPEND ST_FIELDCAT TO IT_FIELDCAT.

CLEAR ST_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZAC_TAB31'

IT_FIELDCAT = 'SLIS_T_FIELDCAT_ALV'

TABLES

T_OUTTAB = IT_VBAK

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.

SELECT VBELN AUDAT AUART NETWR KUNNR

FROM VBAK INTO TABLE IT_VBAK

WHERE KUNNR IN SKUNNR.