REPORT z_vtest8.
*Table declaration.
TABLES: marc,
mara,
mast.
*Selection screen.
SELECT-OPTIONS : s_matnr FOR mara-matnr,
s_werks FOR marc-werks.
PARAMETERS : p_dispo TYPE marc-dispo.
*Internal table declaration - Type 2.
DATA : BEGIN OF itab_marc OCCURS 0,
matnr TYPE matnr, "In this line the first matnr is a field in Internal table.
"The second matnr is a Data Element from a Standard table.
dispo TYPE marc-dispo, "The first dispo is internal table field
"and second marc-dispo is from standard table.
END OF itab_marc.
*Select Statement (The below commented select statement is not working).
*
*SELECT *
* FROM mara
* INTO TABLE itab_mara UP TO 10 ROWS.
*Select Statement (The below commented select statement goes to dump
*because the itab_marc has only two defined fields but select statement is
*trying to fetch and insert three fields into itab_marc.
*
*SELECT matnr werks dispo
* FROM marc
* INTO TABLE itab_marc UP TO 10 ROWS.
*Select Statement
SELECT matnr meins
FROM mara
INTO TABLE itab_marc UP TO 10 ROWS.
*Write statement.
WRITE : / 'Below is the output for the program'.
LOOP at itab_marc.
WRITE : / itab_marc-matnr, itab_marc-dispo.
ENDLOOP.
* In the output you can see the meins field values from mara table has been inserted into dispo field itab_marc.
Program Output:
*Table declaration.
TABLES: marc,
mara,
mast.
*Selection screen.
SELECT-OPTIONS : s_matnr FOR mara-matnr,
s_werks FOR marc-werks.
PARAMETERS : p_dispo TYPE marc-dispo.
*Internal table declaration - Type 2.
DATA : BEGIN OF itab_marc OCCURS 0,
matnr TYPE matnr, "In this line the first matnr is a field in Internal table.
"The second matnr is a Data Element from a Standard table.
dispo TYPE marc-dispo, "The first dispo is internal table field
"and second marc-dispo is from standard table.
END OF itab_marc.
*Select Statement (The below commented select statement is not working).
*
*SELECT *
* FROM mara
* INTO TABLE itab_mara UP TO 10 ROWS.
*Select Statement (The below commented select statement goes to dump
*because the itab_marc has only two defined fields but select statement is
*trying to fetch and insert three fields into itab_marc.
*
*SELECT matnr werks dispo
* FROM marc
* INTO TABLE itab_marc UP TO 10 ROWS.
*Select Statement
SELECT matnr meins
FROM mara
INTO TABLE itab_marc UP TO 10 ROWS.
*Write statement.
WRITE : / 'Below is the output for the program'.
LOOP at itab_marc.
WRITE : / itab_marc-matnr, itab_marc-dispo.
ENDLOOP.
* In the output you can see the meins field values from mara table has been inserted into dispo field itab_marc.
Program Output:
No comments:
Post a Comment