Publishing soon
Saturday, March 26, 2022
Saturday, March 19, 2022
Wednesday, March 9, 2022
Monday, March 7, 2022
Friday, March 4, 2022
Tuesday, March 1, 2022
4.Internal Table
Internal Tables
- Internal tables are collection of records.
- Internal tables are temporary tables. ie.. The data in the internal table will not save any where in the SAP.
- Internal table are dynamic in memory allocation. so no need to provide size for internal table during declaration.
- The scope of the internal table is only within the program.
- Storing or retrieving of data from internal table are always record by record.
Syntax for internal table declaration.
SYNTAX :- data: <internal_table_name> like table of <workarea_name>.
DATA: it_emp LIKE TABLE OF wa_emp.
Note:
Database -> Internal Table -> Workarea.
ITAB vs DB.Tables.
- Internal table are temporary memory location.
- Internal table are specific to program. ie we cannot access it outside the program.
- Internal table are dynamic in memory allocation.
--------------
- Database table are permanent memory location.
- Database tables are accessed any from in the SAP.
- Size of the db tables are must be specified during declaration.
Note:
Syntax of accessing the fields from work_area.
Syntax of accessing the fields from work_area.
<work_area - field name>
Ex: wa_emp-ename.
Note:
Append is the keyword used to transfer the data from workarea to internal table .
Syntax: Append <work_area> to <internal_table>.
Object 1.
Fill internal table manually.
*&--------------------------------------
*& Report ZITAB_OBJ1*&--------------------------------------
REPORT zitab_obj1.
"declaration
DATA: BEGIN OF emp,
eid(10) TYPE c,
ename(25) TYPE c,
eadd(35) TYPE c,
END OF emp.
DATA employee LIKE TABLE OF emp.
"Filling data.
emp-eid = '1'.
emp-ename = 'raju'.
emp-eadd = 'pune'.
APPEND emp TO employee.
emp-eid = '2'.
emp-ename = 'ramu'.
emp-eadd = 'hyadrabad'.
APPEND emp TO employee.
emp-eid = '3'.
emp-ename = 'ravi'.
emp-eadd = 'bangalore'.
APPEND emp TO employee.
"diaplay data
LOOP AT employee INTO emp.
WRITE:/ emp-eid, emp-ename, emp-eadd.
ENDLOOP.
Note:
Syntax for select query:
SELECT <field1>, <field2>, <field3>.....
FROM <db_table>
INTO TABLE <itab>
WHERE <cond>.
Object 2:
To display the company code, company names and city.
*&------------------------------------
*& Report ZITAB_OBJ2
*&------------------------------------
REPORT zitab_obj2.
"Declaration
DATA: BEGIN OF wa,
bukrs(4) TYPE c,
butxt(25) TYPE c,
ort01(25) TYPE c,
END OF wa.
DATA itab LIKE TABLE OF wa.
"Filling itab using select query
SELECT bukrs, butxt, ort01
FROM t001
INTO TABLE @itab.
"Display output
LOOP AT itab INTO wa.
WRITE:/ wa-bukrs, wa-butxt, wa-ort01.
ENDLOOP.
*& Report ZITAB_OBJ2
*&------------------------------------
REPORT zitab_obj2.
"Declaration
DATA: BEGIN OF wa,
bukrs(4) TYPE c,
butxt(25) TYPE c,
ort01(25) TYPE c,
END OF wa.
DATA itab LIKE TABLE OF wa.
"Filling itab using select query
SELECT bukrs, butxt, ort01
FROM t001
INTO TABLE @itab.
"Display output
LOOP AT itab INTO wa.
WRITE:/ wa-bukrs, wa-butxt, wa-ort01.
ENDLOOP.
Object 3:
To display the customer numbers, Customer names, Cities and Countries.
*&------------------------------------
*& Report ZITAB_OBJ3
*&------------------------------------
REPORT zitab_obj3.
*& Report ZITAB_OBJ3
*&------------------------------------
REPORT zitab_obj3.
"Declaration
DATA: BEGIN OF wa,
kunner(10) TYPE c,
name1(35) TYPE c,
ort01(35) TYPE c,
land1(3) TYPE c,
END OF wa.
DATA itab LIKE TABLE OF wa.
"Logic
SELECT kunnr, name1, ort01, land1
FROM kna1
INTO TABLE @itab.
"Display output
LOOP AT itab INTO wa.
WRITE:/ wa-kunner, wa-name1, wa-ort01, wa-land1.
ENDLOOP.
DATA: BEGIN OF wa,
kunner(10) TYPE c,
name1(35) TYPE c,
ort01(35) TYPE c,
land1(3) TYPE c,
END OF wa.
DATA itab LIKE TABLE OF wa.
"Logic
SELECT kunnr, name1, ort01, land1
FROM kna1
INTO TABLE @itab.
"Display output
LOOP AT itab INTO wa.
WRITE:/ wa-kunner, wa-name1, wa-ort01, wa-land1.
ENDLOOP.
Note:
- Domain is the collection of data type and length.
- Data Element is the collection of domain with short description.
Note:
- Syntax for declaring the field
- DATA <field_name>(length) TYPE <data_type>.
- DATA <field_name> TYPE <data_element>.
- DATA <field_name>(length) TYPE <data_type>-<field_name>
- DATA bukrs(4) TYPE c.
- DATA bukrs TYPE bukrs.
- DATA bukrs TYPE T001-bukrs.
Object 4:
To display the company codes, company names, cities.
*&------------------------------------
*& Report ZITAB_OBJ4
*&------------------------------------
REPORT zitab_obj4.
*& Report ZITAB_OBJ4
*&------------------------------------
REPORT zitab_obj4.
Select-Option
- Select-Option is the keyword used to accept different type of inputs like
- single value
- multiple single value
- single range
- multiple range inputs.
- Syntax for select option.
- SELECT-OPTION <name of the select option> for <variable>.
- DATA var TYPE T001-bukrs.
- SELECT-OPTION so_bukrs FOR var.
- Syntax for select option in select query.
SELECT <field1>, <field2>, <field3>...
FROM <db_table>
INTO TABLE <itab>
WHERE <field> IN <select_option>.
Object 5:
based on the given company codes display the company codes, company name, cities.
*&------------------------------------
*& Report ZITAB_OBJ5
*&------------------------------------
REPORT zitab_obj5.
*& Report ZITAB_OBJ5
*&------------------------------------
REPORT zitab_obj5.
Note:
The order of the fields in the workarea as well as the order of the fields in the select query must be same otherwise sometimes it leads to dump.
Object 6:
Based on the given customer no display the customer number, customer names, cities.
*&------------------------------------
*& Report ZITAB_OBJ6
*&------------------------------------
REPORT zitab_obj6.
*& Report ZITAB_OBJ6
*&------------------------------------
REPORT zitab_obj6.
Parameter:
- Parameter is the keyword which accepts single value as input at run time.
- Syntax
- PARAMETER <name> TYPE <data_type> p_bukrs T001-bukrs.
- PARAMETER p_bukrs TYPE T001-bukrs.
- Syntax for parameter in select query.
FROM <db_table>
INTO TABLE <itab>
WHERE <field_name> = <parameter>.
Difference between parameter and select option.
- Parameter is the keyword which accepts the single value at runtime.
- Variable declared as parameter wont fetch any data from database, if executed without input.
- Parameter stores values in internal tables.
- There is no selection table concept in parameter.
- = operator is used in select query where condition.
- Radio button, Check box are created using parameter.
------------------
- Select option is the keyword which accept the single value, multiple single value, single range, multiple range.
- Variable declared as select option fetch entire data from database, if executed without input.
- Select option stores values in internal table.
- It create selection table with 4 column. SIGN, OPTION, LOW, HIGH.
- IN operator is used in select query where condition.
- Dropbox can be created using select option.
Types of internal tables.
There are 3 types of internal tables are there
- Standard internal table
- Sorted internal table
- Hashed internal table
Subscribe to:
Posts (Atom)
-
What is Enhancement in SAP? Enhancement in SAP refers to the process of customizing or extending the standard SAP software without modifyin...
-
DDIC 1.Introduction Tcode for DDIC is SE11. Data dictionary is the central source of the data base management system. It is used to create a...