1 / 22

ABAP Tables

ABAP Tables. Northern Arizona University College of Business. Database tables. To reference a database table inside an ABAP program the Tables identifier must be used. Tables: Sflight . Records - Revisited. Data: Begin of Flight_Record , Carrid Like Sflight-Carrid ,

zoie
Download Presentation

ABAP Tables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ABAP Tables Northern Arizona University College of Business

  2. Database tables • To reference a database table inside an ABAP program the Tables identifier must be used. Tables: Sflight .

  3. Records - Revisited Data: Begin of Flight_Record , Carrid Like Sflight-Carrid , Connid Like Sflight-Connid , End of Flight_Record .

  4. Internal Tables Data: Begin of INT_Demo Occurs 100 , Carrid Like Sflight-Carrid , Connid Like Sflight-Connid , End of INT_Demo .

  5. Internal Tables Data: Begin of INT_Demo Occurs 100 , Include Structure Sflight , End of INT_Demo .

  6. Internal Table Structure Header Header Items Items

  7. Header Record • The header record is a temporary holding area. • The header contains data before it is written to the internal table (append). • The header contains data after an item has been read.

  8. Item Records • The item records are the internal table. • All usage of the items are via the header record.

  9. Selecting from an External Table Select * from Sflight into Flight_Record. Select Carrid Connid from Sflight into Flight_Record.

  10. Moving from the record to the header of the internal table. Move: Flight_Record-Carrid to INT_Demo-Carrid , Flight_Record-Connid to INT_Demo-Connid .

  11. Appending records from the header to the items. Append INT_Demo. • The contents of the header record are added to the end of the items.

  12. Clearing the Header Clear INT_Demo. • The Clear statement clears the header only, not the items.

  13. Clearing the Items Refresh INT_Demo. • The Refresh statement purges the internal table of all data, but not the header.

  14. Sorting the Internal Table Sort INT_Demo by Carrid Ascending SeatsOcc Descending . • Up to 50 fields can be sorted .

  15. Determining the number of items Data: W_Lines type I , W_Cnt type I . Describe INT_Demo Lines W_Lines .

  16. Looping through the table While W_Cnt < W_Lines . W_Cnt = W_Cnt + 1 . Read Table INT_Demo Index W_Cnt . . . . . . . . EndWhile .

  17. Field Strings (Record) Data: Begin of INT_Key , City(10) type C , State(2) type C , End of INT_Key .

  18. Read with Key Move ‘Flagstaff’ to City . Move ‘AZ’ to State . Read Table INT_Demo with Key INT_Key . Read Table INT_Demo with Key INT_Key Binary Search .

  19. Loop At Loop At INT_Demo . whatever . EndLoop .

  20. Loop At Where Loop At INT_Demo Where condition . whatever . EndLoop .

  21. Modifying an item Loop At INT_Demo . (modify the header field(s)). Modify INT_Demo Index sy-tabix . Clear INT_Demo . EndLoop .

  22. Deleting an item Loop At INT_Demo . If whatever . Delete INT_Demo Index sy-tabix . EndIf . Clear INT_Demo. EndLoop .

More Related