Friday, July 31, 2015

Select with Appending

We can directly append records into an internal table with select statement by using APPENDING clause. Syntax is as follows.
SELECT db_field1, db_field2,…
  FROM db_table APPENDING TABLE internal_table
  WHERE db_field = condition.

Where is optional. By using APPENDING clause we can re-select and fetch another sort of records into the same internal table. Here the system appends the records to the last position of the internal table. After appending these records when we write the data then it will come one by one (not in the same row).

In below example at first we have selected PO number. So the system will append the PO numbers only. After that in the second select the system will select the materials and append those to the last position of the internal table and so on.

REPORT  zabap_gui.

TABLES: ekpo.

* Creating a custom structure of Item Table
TYPES:
      BEGIN OF ty_ekpo,
        ebeln TYPE ekpo-ebeln,
        ebelp TYPE ekpo-ebelp,
        matnr TYPE ekpo-matnr,
        werks TYPE ekpo-werks,
        lgort TYPE ekpo-lgort,
      END OF ty_ekpo.

* Creating a line type of predefined structure
DATA:
      wa_ekpo TYPE ty_ekpo,
      it_ekpo TYPE STANDARD TABLE OF ty_ekpo.

REFRESH it_ekpo.

SELECT ebeln
  FROM ekpo APPENDING TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT matnr
  FROM ekpo APPENDING TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT werks
  FROM ekpo APPENDING TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT lgort
  FROM ekpo APPENDING TABLE it_ekpo
  WHERE ebeln = '3000000232'.

LOOP AT it_ekpo INTO wa_ekpo.
  WRITE:/    wa_ekpo-ebeln,
             wa_ekpo-matnr,
             wa_ekpo-werks,
             wa_ekpo-lgort.
ENDLOOP.

The output is like this. One by one record will come for same row information.





















We can use CORRESPONDING FIELDS OF statement also.
SELECT db_field1, db_field2,…
  FROM db_table
  APPENDING CORRESPONDING FIELDS OF TABLE internal_table
  WHERE db_field = condition.

In this case the output will come with the corresponding fields. The system will put the respective data on the respective fields of the output screen. But the records will come one by one (different rows) rather the same row.

REPORT  zabap_gui.

TABLES: ekpo.

* Creating a custom structure of Item Table
TYPES:
      BEGIN OF ty_ekpo,
        ebeln TYPE ekpo-ebeln,
        ebelp TYPE ekpo-ebelp,
        matnr TYPE ekpo-matnr,
        werks TYPE ekpo-werks,
        lgort TYPE ekpo-lgort,
      END OF ty_ekpo.

* Creating a line type of predefined structure
DATA:
      wa_ekpo TYPE ty_ekpo,
      it_ekpo TYPE STANDARD TABLE OF ty_ekpo.

REFRESH it_ekpo.

SELECT ebeln
  FROM ekpo APPENDING CORRESPONDING FIELDS OF TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT matnr
  FROM ekpo APPENDING CORRESPONDING FIELDS OF TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT werks
  FROM ekpo APPENDING CORRESPONDING FIELDS OF TABLE it_ekpo
  WHERE ebeln = '3000000232'.

SELECT lgort
  FROM ekpo APPENDING CORRESPONDING FIELDS OF TABLE it_ekpo
  WHERE ebeln = '3000000232'.

LOOP AT it_ekpo INTO wa_ekpo.
  WRITE:/    wa_ekpo-ebeln,
             wa_ekpo-matnr,
             wa_ekpo-werks,
             wa_ekpo-lgort.
ENDLOOP.


The output is like this.


13 comments:

Rahul said...

It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

Bhavya Kumar said...

Best blog.Got to learn new things.Thanks for this Blog SAP Success Factors Training in Chennai

Paritosh Sabat said...

What is the use of the Append with Select statement, we can anyways achieve it without Append also. Can you plz explain ?

Shalini said...


Hi, This is shalini from Chennai learned SAP Training in Chennai from mr.karthick. The training really was good and i got selected in leading mnc company as SAP Consultant.

You can contact 8122241286 for Best SAP Training in Chennai or reach www.thecreatingexperts.com

sushma said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Shruti Ramalingam said...


From My search…Creating Experts provides Best SAP Training with real time projects assistance.

Most of the modules are equipped with advance level topics which the student can learn from the basics to the advance level stage.

They also provide placement assistance in leading MNC companies across the globe according to the current requirements.

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

And these are the Best SAP training institute which provides Real Time Hands on Training…

codedion Technologies-9003085882

creating Experts-8122241286

http://thecreatingexperts.com/sap-mm-training-in-chennai/

Shalini said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

kavi kalyan said...

Best SAP Success Factor Training in Chennai

http://thecreatingexperts.com/sap-training-in-chennai/
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
http://thecreatingexperts.com/sap-mm-training-in-chennai/
http://thecreatingexperts.com/sap-fico-training-in-chennai/

suganya said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...


Best SAP MM Material Managemnt Real time hands on Training in chennai

http://thecreatingexperts.com/sap-mm-training-in-chennai/

sushma said...

Informative Blog...For a long time I was craving for a career growth in programming and then I came to know that THE CREATING EXPERTS is the one who provide training with hands on training and real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact 8122241286

ragu varan said...

Best SAP HANA Training in Chennai by leading HANA Consultant.
Reach at 9003085882
http://thecreatingexperts.com/category/sap-hana-training-in-chennai/

gilledashivani said...

Great information. the information provided is of great use as i got to learn new things. If you are looking for real time training in SAP ABAP, kindly contact sieve software
Sieve software offers real time training by industry experts with live projects and placement support.
SAP ABAP TRAINING IN HYDERABAD