- We can use one of two methods to pass an internal table to a subroutine:
- Pass with header line.
- Pass body only
- Summarizes the effect of each of these methods on internal tables with and without header lines.
Steps
- Go to Transaction Code SE38.
Source Code
REPORT ZPASS_INTER_TAB_SUB.
DATA : IT_MAKT TYPE TABLE OF MAKT WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR IT_MAKT-MATNR.
PERFORM FETCH_DATA USING S_MATNR[] CHANGING IT_MAKT[].
PERFORM DISPLAY TABLES IT_MAKT.
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
Internal Table passed without header Line
*----------------------------------------------------------------------*
* -->P_S_MATNR text
* <--P_IT_MAKT text
*----------------------------------------------------------------------*
form FETCH_DATA using p_s_matnr LIKE s_matnr[]
changing p_it_makt LIKE it_makt[].
SELECT * FROM MAKT INTO TABLE p_it_makt[] WHERE MATNR IN p_s_matnr.
endform. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
Internal Table passed with header Line
*----------------------------------------------------------------------*
* -->P_IT_MAKT text
*----------------------------------------------------------------------*
form DISPLAY tables p_it_makt structure MAKT.
"Insert correct name for <...>.
LOOP AT p_it_makt.
WRITE : / p_it_makt-MATNR , p_it_makt-SPRAS , p_it_makt-MAKTX.
ENDLOOP.
endform. " DISPLAY
DATA : IT_MAKT TYPE TABLE OF MAKT WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR IT_MAKT-MATNR.
PERFORM FETCH_DATA USING S_MATNR[] CHANGING IT_MAKT[].
PERFORM DISPLAY TABLES IT_MAKT.
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
Internal Table passed without header Line
*----------------------------------------------------------------------*
* -->P_S_MATNR text
* <--P_IT_MAKT text
*----------------------------------------------------------------------*
form FETCH_DATA using p_s_matnr LIKE s_matnr[]
changing p_it_makt LIKE it_makt[].
SELECT * FROM MAKT INTO TABLE p_it_makt[] WHERE MATNR IN p_s_matnr.
endform. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
Internal Table passed with header Line
* -->P_IT_MAKT text
*----------------------------------------------------------------------*
form DISPLAY tables p_it_makt structure MAKT.
"Insert correct name for <...>.
LOOP AT p_it_makt.
WRITE : / p_it_makt-MATNR , p_it_makt-SPRAS , p_it_makt-MAKTX.
ENDLOOP.
endform. " DISPLAY
No comments:
Post a Comment