You are on page 1of 15

Pseudo code of the report program.

Get Country from User.


Select Required records from table: SCUSTOM into internal table:
ITABSCUSTOM Where country = country code.
Case Country.
When 'DE'.
Country Name = 'Germany'.
When 'GB'.
Country Name = 'Great Britain'.
When 'US'.
Country Name = 'USA'.
When 'CA'.
Country Name = 'Canada'.
When 'FR'.
Country Name = 'France'.
When 'AU'.
Country Name = 'Australia'.
When 'NZ'.
Country Name = 'New Zealand'.
When Others.
Print: Error Message.
End Case.
Print country, page and number.
Print system information date, time, and user.

Loop of internal table itabscustom for Business Customer.


Count For number of Business customer.
Select records from Sbook where Customer id of internal table and
table are same.
Print records from internal table for business customer.
End Loop.
IF no records for business customer
Print message
Loop of internal table itabscustom for Business Customer.
Count For number of Private customer.
Select records from Sbook where Customer id of internal table and
table are same.
Print records from internal table for Private customers.
End Loop.
if no records for Private customer.
Print message
Print total number of business customers.
Print total number of private customers.
Print hidden id and name of customer selected
Select Required records from table: SBOOK into internal table:
itab_sbook
Where id = hidden id
Loop of internal table itab_sbook.
Select Agent Name from table: Stravelag to internal table: itab_sbook
where Agency number is same.
Modify the internal table for the Record.
End Loop.
Sort internal table: itab_sbook by name in ascending order
Print Required records from internal table: itab_sbook.

Print Class
If itab_sbook class F
Class name = 'FRST'
Else if class C.
Class name = 'BSNS'
Else if class Y
Class name= 'ECON'
End if.
IF No Bookings for the customer
Print message
Print: Total Bookings for the Customer

Hard Code of the Program:


*&---------------------------------------------------*
*&
*&---------------------------------------------------*
*& Customer Booking Report
*&
*&---------------------------------------------------*
REPORT

YA4004A2.

*----------------------------------------------------*
* Tables.
*
*----------------------------------------------------*
TABLES: SCUSTOM,
SBOOK,
STRAVELAG.

" Customer Detail Table.


" Booking Detail Table.
" Travel Agency Detail Table.

*-----------------------------------------------------*
* Variables.
*
*-----------------------------------------------------*
DATA: BOOKING TYPE I,
CUSTOMER_NO_B(3) TYPE P,
CUSTOMER_NO_P(3) TYPE P,
CUSTOMER_BOOK_NO TYPE I,
COUNTRY_NAME TYPE STRING,
AGENT_NAME TYPE STRING,
AGENCY_NUMBER TYPE I,
CLASS_NAME TYPE STRING.

"
"
"
"
"
"
"
"

Number Of Bookings.
Total No of Business Customers.
Total No of Private Customers.
Total Customers Booking Numbers.
Country Name.
Agent Name.
Agency Number.
Class Name For Ticket Class.

*-----------------------------------------------------*
* Internal Table of Scustom Table.
*-----------------------------------------------------*
DATA: BEGIN OF ITABSCUSTOM OCCURS 0,
ID LIKE SCUSTOM-ID,
NAME LIKE SCUSTOM-NAME,
POSTBOX LIKE SCUSTOM-POSTBOX,
POSTCODE LIKE SCUSTOM-POSTCODE,
CITY LIKE SCUSTOM-CITY,
DISCOUNT LIKE SCUSTOM-DISCOUNT,
CUSTTYPE LIKE SCUSTOM-CUSTTYPE,

END OF ITABSCUSTOM.
*-----------------------------------------------------*
* Internal Table of Sbook and Stravelag Tables.
*-----------------------------------------------------*
DATA: BEGIN OF ITAB_SBOOK OCCURS 0,
FLIGHT_DATE LIKE SBOOK-FLDATE,
BOOK_ID LIKE SBOOK-BOOKID,
CARR_ID LIKE SBOOK-CARRID,
CONN_ID LIKE SBOOK-CONNID,
CLASS LIKE SBOOK-CLASS,
AGENCY_NUMBER LIKE STRAVELAG-AGENCYNUM,
AGENT_NAME LIKE STRAVELAG-NAME,
END OF ITAB_SBOOK.
*-----------------------------------------------------*
* User Will Input Company Code Manually.
*-----------------------------------------------------*
PARAMETERS: Country LIKE SCUSTOM-COUNTRY.
*-----------------------------------------------------*
* Fatch the Required Data From Scustom Table to
* ItabScustom Internal Table.
*-----------------------------------------------------*
*-----------------------------------------------------*
SELECT ID NAME POSTBOX POSTCODE CITY DISCOUNT CUSTTYPE
FROM SCUSTOM INTO TABLE ITABSCUSTOM
WHERE COUNTRY = Country.
*-----------------------------------------------------*
*-----------------------------------------------------*
* Using Case, Country Names Deternined From
* Country Code and If the Country Code is Other Than
* Given Seven Contries, Display Appropriate Message.
*-----------------------------------------------------*

CASE Country.

WHEN 'DE'.
COUNTRY_NAME = 'Germany'.
WHEN 'GB'.
COUNTRY_NAME = 'Great Britain'.
WHEN 'US'.
COUNTRY_NAME = 'USA'.
WHEN 'CA'.
COUNTRY_NAME = 'Canada'.
WHEN 'FR'.
COUNTRY_NAME = 'France'.
WHEN 'AU'.
COUNTRY_NAME = 'Australia'.
WHEN 'NZ'.
COUNTRY_NAME = 'New Zealand'.
WHEN OTHERS.
SKIP 1.
ULINE AT /1(175).
WRITE: /1 SY-VLINE NO-GAP,'No' AS ICON,
'You cannot Search other than 7 countries.' color 6,
175 SY-VLINE NO-GAP.
ULINE AT /1(175).
EXIT.
ENDCASE.
*-----------------------------------------------------*
* Print the Report Heading With System Variables.
*-----------------------------------------------------*
TOP-OF-PAGE.
ULINE AT /1(175).
FORMAT COLOR COL_HEADING.
WRITE: / SY-VLINE NO-GAP,25 'Customer Booking Report for',

COUNTRY_NAME,110 'Page :', SY-PAGNO,


175 SY-VLINE NO-GAP.
ULINE AT /1(175).
WRITE: / SY-VLINE NO-GAP,'Run Date',
20 SY-DATUM,55 'At :',60 SY-UZEIT,
90 'By :',SY-UNAME,175 SY-VLINE NO-GAP.
ULINE AT /1(175).
WRITE: / SY-VLINE NO-GAP,'Customer ID',25 'Name',
55 'Post Box',69 'Post Code',90 'City',
119 'Discount',133 'Number of Bookings',
175 SY-VLINE NO-GAP.
FORMAT RESET.
ULINE AT /1(175).
*-----------------------------------------------------*
* Start of Selection starts from Here and Also
* Prints Some Messages With System Variables.
*-----------------------------------------------------*
START-OF-SELECTION.
WRITE: /175 SY-VLINE NO-GAP.
WRITE: 1 SY-VLINE NO-GAP,'Bussiness Customers' COLOR 7,
175 SY-VLINE NO-GAP.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
*-----------------------------------------------------*
* Loop Of Internal Table Itabscustom with
* Business Customers.
*-----------------------------------------------------*
LOOP AT ITABSCUSTOM WHERE CUSTTYPE = 'B'.
CUSTOMER_NO_B = CUSTOMER_NO_B + 1.

" Counter For Total Number Of


" Customers with Type Business.

SELECT * FROM SBOOK


" Check the Common ID's
WHERE CUSTOMID = ITABSCUSTOM-ID. " Between the Itabscustom
ENDSELECT.
" and Table Sbook and Select Data.
BOOKING = SY-DBCNT.
*-----------------------------------------------------*

* Print the Report Lines.


*-----------------------------------------------------*
WRITE: / SY-VLINE NO-GAP,ITABSCUSTOM-ID,
25 ITABSCUSTOM-NAME,55 ITABSCUSTOM-POSTBOX,
70 ITABSCUSTOM-POSTCODE,90 ITABSCUSTOM-CITY,
120 ITABSCUSTOM-DISCOUNT,'%',130 BOOKING,
175 SY-VLINE NO-GAP.

*-----------------------------------------------------*
* Hidden fields Require For the Secondry List's
* Common fields.
*-----------------------------------------------------*
HIDE:ITABSCUSTOM-ID, ITABSCUSTOM-NAME.

" Hidden fields Customer-ID


" and Customer-Name.

ENDLOOP.
SORT ITABSCUSTOM BY ID ASCENDING.

" Sort By Customer ID


" in Ascending Order.

*-----------------------------------------------------*
* IF the Record not found with Bussines Customer,
* it will return Message.
*-----------------------------------------------------*
IF SY-SUBRC <> 0.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
FORMAT COLOR 6.
WRITE: /1 SY-VLINE NO-GAP,
5 'No Business Customers Records from',
COUNTRY_NAME,175 SY-VLINE NO-GAP.
FORMAT RESET.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
ENDIF.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
WRITE: 1 SY-VLINE NO-GAP,
'Private Customers' COLOR 7,175 SY-VLINE NO-GAP.

WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.


*-----------------------------------------------------*
* Loop Of Internal Table Itabscustom with
* Private Customers.
*-----------------------------------------------------*
LOOP AT ITABSCUSTOM WHERE CUSTTYPE = 'P'.
CUSTOMER_NO_P = CUSTOMER_NO_P + 1.

" Counter For Total Number Of


" Customers with Type Private.

SELECT * FROM SBOOK


" Check the Common ID's
WHERE CUSTOMID = ITABSCUSTOM-ID. " Between the Itabscustom
ENDSELECT.
"and Table Sbook and Select Data.
BOOKING = SY-DBCNT.
*-----------------------------------------------------*
* Print the Report Lines.
*-----------------------------------------------------*
WRITE: /1 SY-VLINE NO-GAP,ITABSCUSTOM-ID,
25 ITABSCUSTOM-NAME,55 ITABSCUSTOM-POSTBOX,
70 ITABSCUSTOM-POSTCODE,90 ITABSCUSTOM-CITY,
120 ITABSCUSTOM-DISCOUNT,'%',130 BOOKING,
175 SY-VLINE NO-GAP.
*-----------------------------------------------------*
* Hidden fields Require For the
* Secondry List's Common fields.
*-----------------------------------------------------*
HIDE:ITABSCUSTOM-ID, ITABSCUSTOM-NAME.

" Hidden fields Customer-ID


" and Customer-Name.

ENDLOOP.
SORT ITABSCUSTOM BY ID ASCENDING.

" Sort By Customer ID


" in Ascending Order.

*-----------------------------------------------------*
* IF the Record not found with Private Customer,
* it will return Message.
*-----------------------------------------------------*
IF SY-SUBRC <> 0.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.

FORMAT COLOR 6.
WRITE: /1 SY-VLINE NO-GAP,
5 'No Private Customers Records from',
COUNTRY_NAME,175 SY-VLINE NO-GAP.
FORMAT RESET.
WRITE: /1 SY-VLINE NO-GAP,175 SY-VLINE NO-GAP.
ENDIF.
ULINE AT /1(175).
*-----------------------------------------------------*
* Prints Total Number Of Business Customers.
*-----------------------------------------------------*
FORMAT COLOR 3.
WRITE: /1 SY-VLINE NO-GAP,
'Total Business Customers:',
27 CUSTOMER_NO_B,175 SY-VLINE NO-GAP.
*-----------------------------------------------------*
* Prints Total Number Of Private Customers.
*-----------------------------------------------------*
WRITE: /1 SY-VLINE NO-GAP,'Total Private Customers:',
27 CUSTOMER_NO_P,175 SY-VLINE NO-GAP.
FORMAT RESET.
ULINE AT /1(175).
*-----------------------------------------------------*
* Prints Message At the Top Of the Page
* with Some System Varibles.
*-----------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
FORMAT COLOR COL_HEADING.
ULINE AT /1(175).
WRITE: /1 SY-VLINE NO-GAP,25 'Customer Flight Booking.',
110 'Page :', SY-PAGNO,175 SY-VLINE NO-GAP.
ULINE AT /1(175).
WRITE: /1 SY-VLINE NO-GAP,25 'Flight Booking for Customer',
ITABSCUSTOM-ID,':',ITABSCUSTOM-NAME,175 SY-VLINE NO-GAP.
ULINE AT /1(175).
WRITE: /1 SY-VLINE NO-GAP,'Travel Agent',

45 'Flight Date',67 'Booking ID',


85 'Carrier ID',105 'Flight Number',
127 'Ticket Class',175 SY-VLINE NO-GAP.
ULINE AT /1(175).
FORMAT RESET.
*-----------------------------------------------------*
* At Line Selection Part for the Drill Down
* from First List to Secondry List.
*-----------------------------------------------------*
AT LINE-SELECTION.

" For Drill Down To Secondry List.

CHECK NOT ITABSCUSTOM-ID IS INITIAL. "Check the Initial Value Of the


"ID.
*-----------------------------------------------------*
* Fatch the Required Data From Sbook Table
* to ITAB_SBOOK Internal Table whose Customer ID's are Same.
*-----------------------------------------------------*

*-----------------------------------------------------*
SELECT FLDATE BOOKID CARRID CONNID CLASS AGENCYNUM FROM SBOOK
INTO TABLE ITAB_SBOOK
WHERE CUSTOMID = ITABSCUSTOM-ID.
*-----------------------------------------------------*
*-----------------------------------------------------*
* Loop Of Internal Table ITAB_SBOOK.
*-----------------------------------------------------*
LOOP AT ITAB_SBOOK.
CUSTOMER_BOOK_NO = SY-TABIX.

" Gives the Total Number Of the


" Customer's Bookings.

SELECT SINGLE * FROM STRAVELAG


WHERE AGENCYNUM = ITAB_SBOOK-AGENCY_NUMBER.
ITAB_SBOOK-AGENT_NAME = STRAVELAG-NAME.
MODIFY ITAB_SBOOK INDEX SY-TABIX.
ENDLOOP.

SORT ITAB_SBOOK BY AGENT_NAME ASCENDING. "Sort Name in Ascending


"Order.
*-----------------------------------------------------*
* Loop Of Internal Table ITAB_SBOOK
* for Print the Records.
*-----------------------------------------------------*
LOOP AT ITAB_SBOOK.
*-----------------------------------------------------*
* Print the Report Lines.
*-----------------------------------------------------*
WRITE: /1 SY-VLINE NO-GAP,ITAB_SBOOK-AGENT_NAME,
40 SY-VLINE NO-GAP,45 ITAB_SBOOK-FLIGHT_DATE,
60 SY-VLINE NO-GAP,67 ITAB_SBOOK-BOOK_ID,
80 SY-VLINE NO-GAP,88 ITAB_SBOOK-CARR_ID,
100 SY-VLINE NO-GAP,110 ITAB_SBOOK-CONN_ID.
*-----------------------------------------------------*
* Using If Condition it Will Determine the class name
* from Characters and Print it.
*-----------------------------------------------------*
IF ( ITAB_SBOOK-CLASS = 'F' ).
CLASS_NAME = 'FRCT'.
WRITE: 120 SY-VLINE NO-GAP,130 CLASS_NAME.
ELSEIF ( ITAB_SBOOK-CLASS = 'C' ).
CLASS_NAME = 'BSNS'.
WRITE: 120 SY-VLINE NO-GAP,130 CLASS_NAME.
ELSEIF ( ITAB_SBOOK-CLASS = 'Y' ).
CLASS_NAME = 'ECON'.
WRITE: 120 SY-VLINE NO-GAP,130 CLASS_NAME.
ENDIF.
WRITE: 175 SY-VLINE NO-GAP.
ENDLOOP.

*-----------------------------------------------------*

* If No Record Found For the Select Customer


* It will Return the Message.
*-----------------------------------------------------*
IF SY-SUBRC <> 0.
FORMAT COLOR 6.
WRITE: /1 SY-VLINE NO-GAP,'No Record found of',
ITABSCUSTOM-NAME,175 SY-VLINE NO-GAP.
ULINE AT /1(175).
EXIT.
ENDIF.
ULINE AT /1(175).
*-----------------------------------------------------*
* Prints the Total Number Of Customer Bookings.
*-----------------------------------------------------*
FORMAT COLOR 3.
WRITE: /1 SY-VLINE NO-GAP,
'Total Bookings for the Customer :',
CUSTOMER_BOOK_NO,175 SY-VLINE NO-GAP.
ULINE AT /1(175).
FORMAT RESET.
CLEAR ITABSCUSTOM.

" Clear the Itabscustom table


" before end of selection.

*-----------------------------------------------------*
* End Of the Selection.
*-----------------------------------------------------*
END-OF-SELECTION.
CLEAR ITABSCUSTOM.

" Clear the Itabscustom table


" After end of selection.

*-----------------------------------------------------*
*
End OF The Report Program.
*-----------------------------------------------------*

Example:
The example of the output report of this program is given below.

Report Program output:

Output of the Customers (B and P).

Output of the Customers Bookings.

You might also like