68
ABAP Reports

Abap reports

  • Upload
    mkpatil

  • View
    4.212

  • Download
    10

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Abap reports

ABAP Reports

Page 2: Abap reports

Report Components

• Report Input Fields (Values)• Report Selection Screens (Visuals)• Report Selection Screen Events

Page 3: Abap reports

Report Input Fields (Values)

• PARAMETERS– TEXT Field– CHECKBOX– RADIOBUTTON

• SELECT-OPTIONS– Enables us to create value range and

complex selections for an input field instead of just one single input value an input field .

Page 4: Abap reports

Report Input Fields (Values)

DATA wa_flight TYPE dv_flights.PARAMETERS country LIKE wa_flight-countryfr.SELECT-OPTIONS so_car FOR wa_flight-carrid.

Parameter: one value only

Select-Options: range and complex selection (example: value = CO or between AA and BA …)

Page 5: Abap reports

Report Input Fields (Values)To change the Labels use Goto > Text elements > Selection Texts

Page 6: Abap reports

PARAMETERSDATA wa_flight TYPE dv_flights.PARAMETERS pa_carr LIKE wa_flight-carrid.PARAMETERS: pa_name AS CHECKBOX DEFAULT 'X',

pa_curr AS CHECKBOX DEFAULT 'X'.PARAMETERS: pa_lim_1 RADIOBUTTON GROUP lim,

pa_lim_2 RADIOBUTTON GROUP lim DEFAULT 'X' ,pa_lim_3 RADIOBUTTON GROUP lim.

2 checkboxes, each can be checked or unchecked independently

1 set of radiobuttons, only one can be selected at a time from the GROUP

1 input field

Reference: See T-Code: BIBSfor more examples

Page 7: Abap reports

PARAMETERS* Check if any checkbox has been selectedCONSTANTS mark VALUE ‘X’.IF pa_name EQ mark…ENDIF.* Check which RADIOBUTTON has been selectedCASE mark.WHEN pa_lim_1. …WHEN pa_lim_2. …WHEN pa_lim_3. …ENDCASE.

Page 8: Abap reports

SELECT-OPTIONSSELECT-OPTIONS so_car FOR wa_flight-carrid

DEFAULT ‘AA’.This creates an internal table (with a header)

having the name so_car. The internal table has 4 columns SIGN, OPTION, LOW and HIGH.

SIGN I (Include), E (Exclude)OPTION EQ (Equal), NE (Not equal), LE (Less

than or equal), LT (Less than), GE (Greater than or equal), GT (Greater than), BT (Between), NB (Not between), CP (Contains pattern), NP (Contains pattern not)

LOW or both LOW & HIGH contain values depending on OPTION value

Page 9: Abap reports

SELECT-OPTIONS

The selection is union of all Includes minus the union of all Excludes.= Union of (Value = ‘CO’, Value between ‘AA’ and ‘BA’)MinusUnion of (Value = ‘AB’, Value between ‘AF’ and ‘AZ’)= (‘AA’, ‘AB’, ‘AC’, ‘AF’, ‘AZ’, ‘BA’, ‘CO’) Minus (‘AB’, ‘AF’, ‘AZ’)= (‘AA’, ’AC’, ’BA’, ’CO’)

Will select-options make query’s ‘where’ clause complicated for programmer? No – it is easy to use in any ‘where’ clause as shown below –SAP takes care of the logic.SELECT * FROM dv_flights INTO wa_flight WHERE carrid IN so_car.

AZAFBTE

ABEQE

BAAABTI

COEQI

HIGHLOWOPTIONSIGN

Page 10: Abap reports

SELECT-OPTIONSOPTIONS (during definition of select-options)DEFAULT ‘AA’ [defaults the low value]DEFAULT ‘AA’ TO ‘BA’ [defaults the low & high values]MEMORY ID <pid> [saves selection screen input field value to memory

for later retrieval of the value to screen]LOWER CASE [suppresses the conversion of input to upper case]OBLIGATORY [makes the field a required field]NO-EXTENSION [suppresses the possibility of multiple selections]NO INTERVELS [suppresses the interval limit – high]MODIF ID <mod> [The name of modification group <mod> is a three-

character variable name without quotation marks. Parameters assigned to a modification group can be processed as an entire group with the LOOP AT SCREEN and MODIFY SCREEN statements – Used for dynamic modifications to selection screen at run time]

Page 11: Abap reports

Report Selection Screens (Visuals)

• SELECTION-SCREEN BEGIN OF BLOCK (block can be set of parameter fields, select-option fields, radio buttons or any other combination)

• SELECTION-SCREEN BEGIN OF LINE• SELECTION-SCREEN BEGIN OF SCREEN (defines

another screen that may be called later)• SELECTION-SCREEN BEGIN OF SCREEN <name> AS

SUBSCREEN (defines sub screens that may be used on Tab pages)

• SELECTION-SCREEN BEGIN OF TABBED BLOCK <name>

• SELECTION-SCREEN PUSHBUTTON …

Page 12: Abap reports

Report Selection Screens (Visuals)DATA wa_flight TYPE dv_flights.

SELECTION-SCREEN BEGIN OF BLOCK b_oneWITH FRAME TITLE text-tld.

PARAMETERS country LIKE wa_flight-countryfr.SELECT-OPTIONS so_car FOR wa_flight-carrid DEFAULT 'AA' TO 'BA'.

SELECTION-SCREEN END OF BLOCK b_one.

Selection-screen block(the colored/highlighted box)Title

Page 13: Abap reports

Report Selection Screens (Visuals)

To change the Labels use Goto > Text elements > Text Symbols

SELECTION-SCREEN BEGIN OF BLOCK b_oneWITH FRAME TITLE text-tld.

Page 14: Abap reports

SELECTION-SCREEN PUSHBUTTON

* Structure for pushbutton commandTABLES: sscrfields. SELECTION-SCREEN PUSHBUTTON pos_low(20) push_det

USER-COMMAND details.

INITIALIZATION.* Text for pushbuttonspush_det = 'Hide details'(p02).

AT SELECTION-SCREEN.* Evaluate pushbutton command

CASE sscrfields-ucomm.WHEN 'DETAILS'.

CHECK sy-dynnr = 1100.IF switch = '1'.switch = '0'.

ELSE.switch = '1'.

ENDIF.ENDCASE.

Page 15: Abap reports

("AT" screen selection ... -remember "AT" as an event)

Report Selection Screen Events• LOAD-OF-PROGRAM (when program is loaded in memory)• INITIALIZATION (after the program load, but before the display of

selection screen – values may be defaulted here)• AT SELECTION-SCREEN OUTPUT (executed immediately before

the selection screen is displayed – PBO – Process Before “Output”)• AT SELECTION-SCREEN (executed immediately after the selection

screen is displayed – PAI – Process After “Input” (after “Input” from user)– AT SELECTION-SCREEN – AT SELECTION-SCREEN ON <field> – AT SELECTION-SCREEN ON <select-table>– AT SELECTION-SCREEN ON RADIOBUTTON GROUP <group>– AT SELECTION-SCREEN ON BLOCK <block>– AT SELECTION-SCREEN ON HELP-REQUEST (F1)– AT SELECTION-SCREEN ON VALUE-REQUEST (F4)

• START-OF-SELECTION (report logic to run the actual program after inputs are validated)

Page 16: Abap reports

Report Selection Screen Events (continued)

LOAD-OF-PROGRAM.This event keyword defines an event block whose event is triggered

by the ABAP-runtime environment when an executable program, a module pool, a function group or a sub-routine pool is loaded in the internal session. When a program is called using SUBMIT or usinga transaction code, then – at every call – a new internal session is opened and the event block is executed once at every call. You can initialize global data objects of the program here. The event block must be executed completely; otherwise, a runtime error will occur. Therefore, no statements are allowed to be executed that leave the event block without returning. At the first call of an external Procedure (sub-program or function module), the framework program of the called procedure is loaded into the internal session of the caller, thus triggering the event LOAD-OF-PROGRAM. The event block is executed before the called procedure. At any further call of a procedure of the same framework program by a caller ofthe same internal session, the event LOAD-OF-PROGRAM is triggered no longer.

Page 17: Abap reports

Report Selection Screen Events (continued)

INITIALIZATION.This event keyword defines an event block whose

event is triggered by the ABAP runtime environment during the flow of an executable program, directly after LOAD-OF-PROGRAM and before the selection screen processing of any existing standard selection screen. This gives you the one-time opportunity to initialize the input fields of the selection screen, including those defined in the logical database linked with the program.

Page 18: Abap reports

Report Selection Screen Events (continued)

START-OF-SELECTION.This event keyword defines an event block for which the event

is triggered by the ABAP runtime environment during the flow of an executable program and before any selection screens are processed. In an executable program, all statements that are not declarations and that are listed before the first explicit processing block, or if the program does not contain any explicit processing blocks, then all functional statements of the program, are assigned to an implicit event block START-OF-SELECTION, which is inserted before any START-OF-SELECTION event blocks. If the program is linked to a logical database, preparatory tasks can be performed at START-OF-SELECTION before the logical database imports the data. If the program is not linked to a logical database, this event block becomes a type of “main program” from which procedures or screens are called.

Page 19: Abap reports

Report Selection Screen Events (continued)

END-OF-SELECTION.This statement defines an event block, whose event

is raised by the ABAP-runtime environment during the calling of an executable program , if the logical database, with which the program is linked, has completely finished its work.

Page 20: Abap reports

Report Selection Screen Events (continued)

AT LINE-SELECTION.This statement defines an event block whose event

is triggered by the ABAP runtime environment during the display of a screen list – provided the screen cursor is on a list line and you select a function using the function code PICK. Through the definition of this event block, the standard list status is automatically enhanced in such a way that the function code F2 and, with it, the double-click mouse function is linked up to the function code PICK.

Page 21: Abap reports

Report Selection Screen Events (continued)

END-OF-PAGE.This statement defines an event block that is raised

by the ABAP-runtime during creation of a basic list, if there is a line reservation in the addition LINE-COUNT of the initiating statement for a page footer, which was reached while writing to this page. A list output that takes place in the event block, is placed in this area. Output statements that exceed the reserved area will be ignored.

Page 22: Abap reports

Report Selection Screen Events (continued)

TOP-OF-PAGE [DURING LINE-SELECTION].

This statement using the option DURING LINE-SELECTION defines an event block whose event is triggered by the ABAP runtime environment during the creation of a list. This occurs when a new page is started – that is, immediately before the first line in a new page is to be output. All list outputs that take place in the event block are placed below the standard page header of the list. You cannot output more lines than are available in the page within the event block. The NEW-PAGE statement is ignored within this event block. The entire output written to the list in the event block belongs to the page header of the current list page. The top page header cannot be moved when you scroll vertically in a list displayed on the screen. For each TOP-OF-PAGE event, the placeholders “&1″ – “&9″ are replaced with the contents of system fields sy-tvar0 – sy-tvar9 in the standard heading and the column headings of the standard page header during creation of a basic list. You can assign values to these system fields in the program.

If you do not use an addition, an event block is triggered for event TOP-OF-PAGE during the creation of a basic list. If you use the addition DURING LINE-SELECTION, an event block is triggered for the corresponding events during the creation of details lists. You have to use system fields like sy-lsind to distinguish between the individual details lists.

Page 23: Abap reports

Report Selection Screen Events (continued)

AT USER-COMMAND.This statement defines an event block whose

event is triggered by the ABAP runtime environment if, during the display of a screen list, a function with a self-defined function code was chosen.

Page 24: Abap reports

Report Selection Screen Events (continued)

AT PF##.This statement defines an event block whose

event is triggered by the ABAP runtime environment during list display – provided the screen cursor is on a list line and a function is selected using the function code PF##. Here ## stands for a number between 01 and 24. In the= standard list status, these function codes are assigned to the function keys of the input device.

Page 25: Abap reports

Report Selection Screen Events (continued)

– AT SELECTION-SCREEN• If an error message or warning message is displayed during this

event, the system makes “all” selection screen fields ready for input– AT SELECTION-SCREEN ON <field>

• If an error message or warning message is displayed during this event, the system makes “only” the above screen fields ready for input

– AT SELECTION-SCREEN ON <block>• This is available to check entry combinations of a logical group. All

fields in this “block” are made ready for input when an error message is issued

– AT SELECTION-SCREEN ON END OF <sel>• For selections where you can enter any number of single values

and ranges, a different screen is displayed where multiple selections (values and ranges) can be entered, the AT SELECTION-SCREEN ON END OF <sel> is executed when this screen is processed. See next page for visual

Note: AT SELECTION-SCREEN is Executed last, if below specific one like AT SELECTION-SCREEN ON <field> exists. Both are executed unless the first message is of type error

Page 26: Abap reports

Report Selection Screen Events (continued)

AT SELECTION-SCREEN ON END OF so_car.CHECK <condition>.MESSAGE e003(bc405).

Page 27: Abap reports

Report Selection Screen Events (continued)

– AT SELECTION-SCREEN ON HELP-REQUEST (F1)• When the user presses F1 on the relevant field, the subsequent processing

block is executed. You can thus implement a self-programmed help for the input/output fields of the selection screen

AT SELECTION-SCREEN ON HELP-REQUEST FOR so_car.CALL SCREEN 100 STARTING AT 30 03 ENDING AT 70 10.

– AT SELECTION-SCREEN ON VALUE-REQUEST (F4)• When the user selects this pushbutton or presses F4 for the field, the event

is executed. You can thus implement a self-programmed possible entries routine for the input/output fields of the selection screen. If the program contains such an event and the user presses F4 , the system processes this rather than displaying the check table or the fixed values of the Dictionary field

Note: It is recommended that instead of creating these events for F1 and F4, it is better to use the system F1 and F4 help that retrieves the values from Dictionary. This way F1 and F4 provides uniform look and feel application wide.

Page 28: Abap reports

Event Blocks for Selection Screens

Page 29: Abap reports

Event Blocks for Lists

Page 30: Abap reports

Event Blocks for Executable Programs (Reports)

Page 31: Abap reports

ABAP Statements for Screen Display

WRITE– A very important keyword in the reporting area is the

WRITE statement. You use WRITE to output literals or fields on the screen or printer. Subsequent WRITE statements appear on the same output line, unless a line feed occurs. If a line is full, the system continues the output in the next line.

– The simplest form of the WRITE statement outputs a literal. Remember always to include literals in quotation marks. A simple WRITE statement may be:

– WRITE 'My first program'.

Page 32: Abap reports

ABAP Statements for Screen Display

• NEW-PAGE– Use the NEW-PAGE statement to create a page

break in your list. Page breaks improve the clarity of the page layout of your list

• SKIP– Use the SKIP statement to create a line feed. To

create several line feeds, specify the desired number behind SKIP. SKIP 5 (This line creates five line feeds)

• ULINE– Use the ULINE statement to create a line feed first

and then draw a horizontal line. This statement also helps to make lists easier to read

Page 33: Abap reports

Terminal (user), External and Internal Sessions• When you logon using the SAP Logon icon on desktop you

create a brand new terminal session. • Generally each GUI window is one external session• You create new external sessions by choosing System >

Create session or entering /o in the command field• Each time a new window opens a new external session is

created, unless you use the SAP Logon icon to create a session which will create a new terminal (or user session)

• You can have up to six external sessions opened simultaneously in one terminal session

• External sessions are subdivided into internal sessions

Create NewTerminal or UserSession CALL TRANSACTION <t-code>.

Create new External Session

Create new Internal Session

Page 34: Abap reports

Terminal (user), External and Internal Sessions (continued)

• Each program occupies its own internal session• Each time a new program is called its data must be stored

somewhere in memory depending on the requirements• Generally each of the called program consists of one internal

session each. You can go back to the calling programs internal session after the called program completes (or overlay and neverreturn)

• We do not observe internal sessions in any visual way because they are “internal sessions”- all we see is one external session generally represented by one GUI window

• Each external session can contain up to nine internal sessions• When a different user logs on a new terminal session is created.

The new terminal session starts a new (or first) external session. When the first program is run new (or first) internal session isstarted for that user

Page 35: Abap reports

Terminal (user), External and Internal Sessions (continued)

To create new Terminal or User Sessions (or new Logon) use SAP Logon icon on same or different workstation. SAP licensingmay not allow one user to have multiple Terminal Sessions (i.e., multiple logons)

Terminal Session 1

Terminal Session 2

Different SAP Memory

Page 36: Abap reports

Terminal (user), External and Internal Sessions (continued)

Here the author is trying to create multiple logons ( or terminal sessions or user sessions). SAP MEMORY [GET/SET Parameters] area is NOT common across multiple logons

Page 37: Abap reports

ABAP and SAP MemoryABAP memory• ABAP memory is a memory area that all ABAP programs

within the same internal session can access using the EXPORT and IMPORT statements

• Data within this ABAP memory remains intact during a whole sequence of program calls

• To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made

• The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory

• If control is then returned to the program which made the initial call, the same process operates in reverse

Page 38: Abap reports

ABAP MemoryREPORT Z_EXPORT_ABAP_MEM.PARAMETERS: myparam TYPE c LENGTH 4.DATA: mydata(4) TYPE C.

START-OF-SELECTION.mydata = myparam.export mydata to memory id 'MYABAP_MEMORY'.

WRITE 'Value exported'.WRITE mydata.

*SUBMIT Z_IMPORT_ABAP_MEM.

Page 39: Abap reports

ABAP MemoryREPORT Z_IMPORT_ABAP_MEM.*PARAMETERS: myparam TYPE c LENGTH 4.DATA: mydata(4) TYPE C.

START-OF-SELECTION.import mydata from memory id 'MYABAP_MEMORY'.

WRITE 'mydata = '.

WRITE mydata.

Page 40: Abap reports

ABAP MemoryNotes:After the export program is run, if the import program is run 1) In the same window – ABAP memory values are read2) Import program is called from the export program (SUBMIT) –

ABAP memory values are read3) Called from a new session (external) created using the ‘Creates

New Session’ button on the top menu - ABAP memory values are NOT read

4) Called from a new user logon (SAPgui) from the same or different PC for the same user - ABAP memory values are NOT read

5) Called from a new user logon (SAPgui) from the same or different PC for a different user - ABAP memory values are NOT read

Page 41: Abap reports

ABAP and SAP Memory (continued)

SAP Memory • SAP memory is a memory area to which all main

sessions within a SAPgui (login or user session) have access

• Use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another.

• Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters)

Page 42: Abap reports

GET/SET parameters• These are also called SPA/GPA parameters• The most frequent use of GET/SET parameters

is to fill input fields on screens• These parameters are reset when you logoff the

sessions (exit)• These parameters can be set either for a

particular user or for a particular program using the SET PARAMETER statement

• Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement

Page 43: Abap reports

GET/SET parametersREPORT Z_SET_PARAMETER.PARAMETERS: myparam1 TYPE c LENGTH 4 MEMORY ID ZMYID1.PARAMETERS: myparam2 TYPE c LENGTH 4.

* INITIALIZATION.* note: since there is no GET parameter here no values will be initialized (read)* for myparam2 (myparam1 is fine as it is defined with MEMORY ID option).

START-OF-SELECTION.* note: myparam2 but not myparam1 needs SET parameter cmd* because myparam1 is defined with MEMORY ID option.* SET PARAMETER ID 'ZMYID1' FIELD myparam1.SET PARAMETER ID 'ZMYID2' FIELD myparam2.

WRITE 'Parameter [myparam1/myparam2]: '.WRITE: myparam1, '/', myparam2.

*SUBMIT Z_GET_PARAMETER VIA SELECTION-SCREEN AND RETURN.

Page 44: Abap reports

GET/SET parametersREPORT Z_GET_PARAMETER.PARAMETERS: myparam1 TYPE c LENGTH 4 MEMORY ID ZMYID1.PARAMETERS: myparam2 TYPE c LENGTH 4.

INITIALIZATION.* note: only myparam2 (but not myparam1) needs GET parameter* command because myparam1 is defined with MEMORY ID option.* GET PARAMETER ID 'ZMYID1' FIELD myparam1.GET PARAMETER ID 'ZMYID2' FIELD myparam2.

* note: since there is no SET parameter here* no values will be set for myparam2 (myparam1 is fine).START-OF-SELECTION.WRITE 'Parameter [myparam1/myparam2]: '.WRITE: myparam1, '/', myparam2.

Page 45: Abap reports

GET/SET parametersNotes:After the Set program is run, if the Get program is run 1) In the same window – SAP memory values are read2) Get program is called from the Set program (SUBMIT) – SAP

memory values are read3) Get program called from a new session (external) created using the

‘Creates New Session’ button on the top menu - SAP memory values are read

4) Called from a new user logon (SAPgui) from the same or different PC for the same user - SAP memory values are NOT read

5) Called from a new user logon (SAPgui) from the same or different PC for a different user - SAP memory values are NOT read

Page 46: Abap reports

GET/SET DEMO with Line Selection Event

REPORT Z_CALLINGPGM.

DATA: carrier TYPE spfli-carrid,connection TYPE spfli-connid.

START-OF-SELECTION.SELECT carrid connid

FROM spfliINTO (carrier, connection).

WRITE: / carrier HOTSPOT, connection HOTSPOT.HIDE: carrier, connection.

ENDSELECT.

AT LINE-SELECTION.SET PARAMETER ID: 'CAR' FIELD carrier,

'CON' FIELD connection.SUBMIT Z_CALLEDPGM AND RETURN.*SUBMIT Z_CALLEDPGM2 VIA SELECTION-SCREEN AND RETURN.

Page 47: Abap reports

GET/SET DEMO with Line Selection Event (continued)

REPORT Z_CALLEDPGM.DATA: carrier TYPE spfli-carrid,

connection TYPE spfli-connid.

INITIALIZATION.*GET PARAMETER ID: 'CAR' FIELD carrier, 'CON' FIELD connection.

START-OF-SELECTION.GET PARAMETER ID: 'CAR' FIELD carrier,

'CON' FIELD connection.IF sy-subrc <> 0.

MESSAGE 'Parameter not found' TYPE 'I'.ELSE.

write: / 'Details of carrier/connection are: '.write: / carrier, '/', connection.

ENDIF.END-OF-SELECTION.

Page 48: Abap reports

GET/SET DEMO with Line Selection Event (continued)

REPORT Z_CALLEDPGM2.

PARAMETER: p_carr TYPE spfli-carrid,p_conn TYPE spfli-connid.

INITIALIZATION.GET PARAMETER ID: 'CAR' FIELD p_carr, 'CON' FIELD

p_conn.

START-OF-SELECTION.write: / 'Details of carrier/connection are: '.write: / p_carr, '/', p_conn.

END-OF-SELECTION.

Page 49: Abap reports

Variants

• Variants allow you to reuse values entered once on the selection screens. These are helpful when: – The program is started frequently with same

values– The program is run in the background

Page 50: Abap reports

Variants (continued)

• A variant consists of two parts:The values entered on the selection screen (example: Value “AA” for airlines)The attributes and display attributes of the parameters and select-options (example: Making some fields read-only or some not visible, etc)

Note: If you use the INITIALIZATION event to initialize any variables in the program, the variant will not have any effect on them (will get overwritten by the initialization)

Page 51: Abap reports

Variable Values in Variants• Variable date calculations – D option (this option is used when a

date is in a variant - today's date, first day of month, or the last day of the previous month)

• User-specific values – B option (this option is used to enter user-specific values in a selection field)

• Values defined in table TVARVC – T option (To fill selection fields for a specific task using a variant you can save fixed values in table TVARVC. To avoid having to create new variants for each minor change in the selection values, you can assign a value in table TVARVC to a selection and then just change this value. This is particularly important if the corresponding value on the selection screen is write-protected)

* TVARV (client dependent table) TVARVC (client independent)

Page 52: Abap reports

Variable Values in VariantsVariable date calculations

Page 53: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• *&------------------------------------------------*&------------------------------------------------*& Event INITIALIZATION*&------------------------------------------------INITIALIZATION.* Initialize select-options for CARRID" OPTIONAL

MOVE: 'AA' TO so_car-low,'QF' TO so_car-high,'BT' TO so_car-option,'I' TO so_car-sign.

APPEND so_car.CLEAR so_car.

MOVE: 'AZ' TO so_car-low,'EQ' TO so_car-option,'E' TO so_car-sign.

APPEND so_car.

* Set texts for tabstrip pushbuttonstab1 = 'Connections'(tl1).tab2 = 'Date'(tl2).tab3 = 'Type of flight'(tl3).

* Set second tab page as initial tabairlines-activetab = 'DATE'.airlines-dynnr = '1200'.

* Text for pushbuttonspush_det = 'Hide details'(p02).

Page 54: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• *&------------------------------------------------*& Event START-OF-SELECTION*&------------------------------------------------START-OF-SELECTION.

* Checking the output parametersCASE mark.

WHEN all.* Radiobutton ALL is marked

SELECT * FROM dv_flights INTO wa_flightWHERE carrid IN so_car

AND connid IN so_conAND fldate IN so_fdtAND cityfrom IN so_startAND cityto IN so_dest.

WRITE: / wa_flight-carrid,wa_flight-connid,wa_flight-fldate,wa_flight-countryfr,wa_flight-cityfrom,wa_flight-airpfrom,wa_flight-countryto,wa_flight-cityto,wa_flight-airpto,wa_flight-seatsmax,wa_flight-seatsocc.

ENDSELECT.

Page 55: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• WHEN national.* Radiobutton NATIONAL is marked

SELECT * FROM dv_flights INTO wa_flightWHERE carrid IN so_carAND connid IN so_conAND fldate IN so_fdtAND cityfrom IN so_startAND cityto IN so_destAND countryto = dv_flights~countryfrAND countryto = country.

WRITE: / wa_flight-carrid,wa_flight-connid,wa_flight-fldate,wa_flight-countryfr,wa_flight-cityfrom,wa_flight-airpfrom,wa_flight-countryto,wa_flight-cityto,wa_flight-airpto,wa_flight-seatsmax,wa_flight-seatsocc.

ENDSELECT.

Page 56: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• WHEN internat.* Radiobutton INTERNAT is marked

SELECT * FROM dv_flights INTO wa_flightWHERE carrid IN so_carAND connid IN so_conAND fldate IN so_fdtAND cityfrom IN so_startAND cityto IN so_destAND countryto <> dv_flights~countryfr.

WRITE: / wa_flight-carrid,wa_flight-connid,wa_flight-fldate,wa_flight-countryfr,wa_flight-cityfrom,wa_flight-airpfrom,wa_flight-countryto,wa_flight-cityto,wa_flight-airpto,wa_flight-seatsmax,wa_flight-seatsocc.

ENDSELECT.ENDCASE.

Page 57: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• *&------------------------------------------------*& Event AT SELECTION-SCREEN ON BLOCK PARAM*&------------------------------------------------AT SELECTION-SCREEN ON BLOCK param. " OPTIONAL* check country for national flights is not emptyCHECK national = 'X' AND country = space.MESSAGE e003(bc405).

*&------------------------------------------------*& Event at selection-screen output*&------------------------------------------------AT SELECTION-SCREEN OUTPUT.

CASE sy-dynnr.

WHEN 1100.LOOP AT SCREEN.IF screen-group1 = 'DET'.screen-active = switch.MODIFY SCREEN.

ENDIF.ENDLOOP.

IF switch = '1'.push_det = text-p02.

ELSE.push_det = text-p01.

* clear additional select-options to avoid unwanted* influence at selection from database

REFRESH: so_start,so_dest.

ENDIF.ENDCASE.

Page 58: Abap reports

Example: ZBC405_C027393_SSCS_3E01

• *&------------------------------------------------*& Event at selection-screen*&------------------------------------------------AT SELECTION-SCREEN.* Evaluate pushbutton commandCASE sscrfields-ucomm.WHEN 'DETAILS'.CHECK sy-dynnr = 1100.IF switch = '1'.switch = '0'.

ELSE.switch = '1'.

ENDIF.ENDCASE.

Page 59: Abap reports

Example: BC405_SSCS_3TOP• *&------------------------------------------------

*& Include BC405_SSCS_3TOP*&*&------------------------------------------------

REPORT bc405_sscs_3.

* Workarea for data fetchDATA: wa_flight TYPE dv_flights.

* Constant for CASE statementCONSTANTS mark VALUE 'X'.

* Structure for pushbutton commandTABLES: sscrfields.* flag to control hiding / showing* of detail select-optionsDATA: switch TYPE n VALUE '1'.

* Selections for connectionsSELECTION-SCREEN BEGIN OF SCREEN 1100 AS SUBSCREEN.SELECT-OPTIONS: so_car FOR wa_flight-carrid,

so_con FOR wa_flight-connid.SELECTION-SCREEN SKIP 2.SELECTION-SCREEN PUSHBUTTON pos_low(20) push_det

USER-COMMAND details.SELECTION-SCREEN SKIP.SELECTION-SCREEN BEGIN OF BLOCK bl_det

WITH FRAME TITLE text-tld.SELECT-OPTIONS:

so_start FOR wa_flight-cityfrom MODIF ID det,so_dest FOR wa_flight-cityto MODIF ID det.

SELECTION-SCREEN END OF BLOCK bl_det.SELECTION-SCREEN END OF SCREEN 1100.

Page 60: Abap reports

Example: BC405_SSCS_3TOP

•* Selections for flightsSELECTION-SCREEN BEGIN OF SCREEN 1200 AS SUBSCREEN.SELECT-OPTIONS so_fdt FOR wa_flight-fldate NO-EXTENSION.SELECTION-SCREEN END OF SCREEN 1200.

* Output parameterSELECTION-SCREEN BEGIN OF SCREEN 1300 AS SUBSCREEN.SELECTION-SCREEN BEGIN OF BLOCK param WITH FRAME

TITLE text-tl3.SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME.PARAMETERS:

all RADIOBUTTON GROUP rbg1,national RADIOBUTTON GROUP rbg1,internat RADIOBUTTON GROUP rbg1 DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK radio.PARAMETERS: country LIKE wa_flight-countryfr.SELECTION-SCREEN END OF BLOCK param.SELECTION-SCREEN END OF SCREEN 1300.

SELECTION-SCREEN BEGIN OF TABBED BLOCK airlinesFOR 10 LINES.

SELECTION-SCREEN TAB (20) tab1 USER-COMMAND connDEFAULT SCREEN 1100.

SELECTION-SCREEN TAB (20) tab2 USER-COMMAND dateDEFAULT SCREEN 1200.

SELECTION-SCREEN TAB (20) tab3 USER-COMMAND typeDEFAULT SCREEN 1300.

SELECTION-SCREEN END OF BLOCK airlines .

Page 61: Abap reports

Calling programs using Transaction Code

Method 1LEAVE TO TRANSACTION <t-code>. • The system terminates the current program and starts the program with

transaction code . The statement is the equivalent of entering /n in the command field followed by the transaction code. After the called program the user returns to the application menu and NOT to the calling program (When using LEAVE TO TRANSACTION, the current call sequence is exited completely. Upon completion of the called transaction, the runtime environment returns to the position where the first program in the call sequence was called)

LEAVE TO CURRENT TRANSACTION.• The system terminates the current program and restarts the same program

(This transaction code is contained in the system field sy-tcode)LEAVE TO TRANSACTION <t-code> AND SKIP FIRST SCREEN.• If you use the …AND SKIP FIRST SCREEN addition, the system does not

display the screen contents of the first screen in the transaction. However, it does process the flow logic

Page 62: Abap reports

Calling programs using Transaction Code (continued)

Method 2CALL TRANSACTION <t-code>.• The system calls the ABAP program with a transaction code and

when the called program completes or encounters a LEAVE PROGRAM statement, the system resumes processing at the next statement after the call in the calling program

CALL TRANSACTION <t-code> AND SKIP FIRST SCREEN.• If you use the …AND SKIP FIRST SCREEN addition, the system

does not display the screen contents of the first screen in the transaction. However, it does process the flow logic

• If you started a transaction using CALL TRANSACTION that uses update techniques, you can use the UPDATE… addition to specify the update technique (asynchronous (default), synchronous, or local) that the program should use (See data transfer method)

Page 63: Abap reports

Calling programs using Transaction Code (continued)

LEAVE TO TRANSACTION 'ZBC405_1'.CALL TRANSACTION 'ZBC405_1' [AND SKIP FIRST SCREEN .]

Provide selection values in Variant. If values are different each time, use Variable date calculations - D option Or Values defined in table TVARVC - T option, etc. Update table TVARVC with new values before calling the transaction

Page 64: Abap reports

Calling programs using Program/Report Name

SUBMIT <programname>.After the called program the user returns to the application menu and

NOT to the calling program. Here users do not see the selection screen, therefore selection values will have to be populated using WITH options shown in the next few slides

SUBMIT <programname> AND RETURN.After the called program is completed the user returns to the calling

program. Here too users do not see the selection screen, therefore selection values will have to be populated using WITH options shown in the next few slides

SUBMIT <programname> VIA SELECTION-SCREEN.Shows the selection screen (first screen) of the called program, where

user may enter the selection values. If selection values are populated using the WITH options, the users will see these values and can modify them if required or just execute the report

Page 65: Abap reports

Calling programs using Program/Report Name (continued)

SUBMIT <programname> WITH <p_param1> = 'value1‘ WITH <p_param2> = 'value2'.

Use the above syntax to pass/populate parameters from the calling program to the called program.

Example:SUBMIT ZBC405_C027393_SSCS_2

WITH COUNTRY = 'ZZZ'

WITH COUNTRY2 = 'YYY' VIA SELECTION-SCREEN.

Page 66: Abap reports

Calling programs using Program/Report Name (continued)

SUBMIT <programname> WITH SELECTION-TABLE rspar [VIA SELECTION-SCREEN].

If you specify this addition, parameters and selection criteria on the selection screen are supplied from an internal table rspar. The row type for this internal table is RSPARAMS. The structured data type RSPARAMS is defined in the ABAP Dictionary and has the following components, all of which are data type CHAR:

– SELNAME length 8 – must contain the name of a parameter or selection criterion [select-options] for the selection screen in block capitals

– KIND length 1 – must contain the type of selection screen component (P for parameters, S for selection criteria)

– SIGN length 1 – specifies whether the result of the row condition needs to be included for each row (I – Inclusive, E – Exclusive)

– OPTION length 2 – specifies the comparison operators EQ (equal), NE (not equal), GT (greater than), BT (between) and NB (not between)

– LOW length 45 – this is the lower limit of the range (in the case of parameters, the value must be specified in LOW and all other components are ignored)

– HIGH length 45 – this is the lower limit of the range

Page 67: Abap reports

Calling programs using Program/Report Name (continued)

Example showing “WITH SELECTION-TABLE”

DATA: MY_RSPAR LIKE STANDARD TABLE OF RSPARAMSWITH HEADER LINE.

MOVE: 'SO_CAR' TO MY_RSPAR-SELNAME,'S' TO MY_RSPAR-KIND,'I' TO MY_RSPAR-SIGN,'BT' TO MY_RSPAR-OPTION,'CO' TO MY_RSPAR-LOW,'DL' TO MY_RSPAR-HIGH.

APPEND MY_RSPAR.CLEAR MY_RSPAR.MOVE: 'SO_CAR' TO MY_RSPAR-SELNAME,

'S' TO MY_RSPAR-KIND,'I' TO MY_RSPAR-SIGN,'EQ' TO MY_RSPAR-OPTION,'LH' TO MY_RSPAR-LOW,' ' TO MY_RSPAR-HIGH.

APPEND MY_RSPAR. CLEAR MY_RSPAR.

MOVE: 'COUNTRY' TO MY_RSPAR-SELNAME,'P' TO MY_RSPAR-KIND,‘I' TO MY_RSPAR-SIGN,'EQ' TO MY_RSPAR-OPTION,'FR' TO MY_RSPAR-LOW.

APPEND MY_RSPAR. SUBMIT ZBC405_C027393_SSCS_2 WITH SELECTION-

TABLE MY_RSPAR VIA SELECTION-SCREEN.

You can pass parametersand/or select-options by specifying correct value in the KIND field (P for parameters, S for select-options)

Page 68: Abap reports

Calling programs using Program/Report Name (continued)

SUBMIT <programname> USING SELECTION-SET 'VARIANT1‘

If you specify this option, the parameters and selection criteria for the selection screen are supplied with values from a variant. Provide the name of the variant in single quotes. If the variant does not exist, the system sends an error message. If the variant belongs to a different selection screen, it is ignored.