Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Wa_flight-seatsocc / wa_flight-seatsmax.

Pa_int1 TYPE i, pa_op(1) TYPE c, pa_int2 TYPE i. | DATA result TYPE p DECIMALS 2. | ID ’ACTVT’ FIELD ’02’. | WRITE: / ’Authority-Check Error’(001). ENDCASE. | Wa-percentage, ’%’. | Wa_sbook-loccurkey. | SELECT-OPTIONSname FORdata_object. | MESSAGE e045(bc400) WITH pa_car. ENDIF. | CALL SCREEN 100. | CLEAR wa_sbook. |


 

 

* Create list:

WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsmax, wa_flight-seatsocc,

wa_flight-percentage, ’%’.

ENDSELECT.

 

 

IF sy-subrc NE 0.

WRITE: ’No ’, pa_car, ’flights found!’. ENDIF.


 


 

 

153 Exercise 9: Data Retrieval and Buffering in an Internal Table

 

Exercise Duration: 35 Minutes

 

 

Exercise Objectives

 

After completing this exercise, you will be able to:

• Fill an internal table with data from a database table

• Sort the content of an internal table

 

 

Business Example

 

Enhance your ABAP program for outputting required flight schedules in such a way that the percentage occupancy can be output in ascending order.

 

System Data

 

System: Will be assigned Client: Will be assigned User ID: Will be assigned Password: Will be assigned

Set up instructions: No special instructions when using a standard training

system

 

Task 1:

 

Retrieve data and fill an internal table

 

1. Copy your program ZBC400_##_SELECT_SFLIGHT (solution to first exercise in this lesson) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_SELECT_SFLIGHT_ITAB.

 

2. Define an internal table (name proposal: it_flight) using a global table type that has the global structure SBC400FOCC as the row type.

 

Hint: From SBC400FOCC use the where-used list to find a suitable table type, which might exist already.

 

3. Each SFLIGHT row that is read should not be output directly but inserted into an internal table (INSERT statement).

 

Continued on next page


 

Task 2:

 

Sort and output the internal table

 

1. Sort the internal table according to occupancy (ascending).

 

2. Use a LOOP to display the contents of the internal table.


 

Solution 9: Data Retrieval and Buffering in an Internal Table

 

Task 1:

 

Retrieve data and fill an internal table

 

1. Copy your program ZBC400_##_SELECT_SFLIGHT (solution to first exercise in this lesson) or the template SAPBC400DDS_SELECT_SFLIGHT to the new name ZBC400_##_SELECT_SFLIGHT_ITAB.

 

a) Carry out this step as usual.

 

2. Define an internal table (name proposal: it_flight) using a global table type that has the global structure SBC400FOCC as the row type.

 

Hint: From SBC400FOCC use the where-used list to find a suitable table type, which might exist already.

 

a) Carry out this step as usual.

 

3. Each SFLIGHT row that is read should not be output directly but inserted into an internal table (INSERT statement).

 

a) See source code excerpt in the model solution.

 

Task 2:

 

Sort and output the internal table

 

1. Sort the internal table according to occupancy (ascending). a) See source code excerpt in the model solution.

2. Use a LOOP to display the contents of the internal table. a) See source code excerpt in the model solution.

Result

 

Source code excerpt: SAPBC400DDS_SELECT_SFLIGHT_TAB

 

REPORT sapbc400dds_select_sflight_tab. DATA: it_flight TYPE sbc400_t_sbc400focc,

wa_flight LIKE LINE OF it_flight.

 

 

Continued on next page


 

 

PARAMETERS pa_car TYPE s_carr_id.

* Select all flights belonging to PA_CAR: SELECT carrid connid fldate seatsmax seatsocc

FROM sflight

INTO CORRESPONDING FIELDS OF wa_flight

WHERE carrid = pa_car.

 

 

* Calculate occupation of flight wa_flight-percentage =

100 * wa_flight-seatsocc / wa_flight-seatsmax.

 

 

* Insert flight into internal table


Дата добавления: 2015-11-16; просмотров: 71 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
ENDLOOP. ENDIF.| INSERT wa_flight INTO TABLE it_flight.

mybiblioteka.su - 2015-2024 год. (0.006 сек.)