+ All Categories
Home > Documents > abapreports-111108223616-phpapp01

abapreports-111108223616-phpapp01

Date post: 02-Jun-2018
Category:
Upload: rhsabbir007
View: 217 times
Download: 0 times
Share this document with a friend

of 68

Transcript
  • 8/10/2019 abapreports-111108223616-phpapp01

    1/68

    ABAP Reports

  • 8/10/2019 abapreports-111108223616-phpapp01

    2/68

    Report Components

    Report Input Fields (Values)

    Report Selection Screens (Visuals)

    Report Selection Screen Events

  • 8/10/2019 abapreports-111108223616-phpapp01

    3/68

    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 ofjust one single input value an input field .

  • 8/10/2019 abapreports-111108223616-phpapp01

    4/68

    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 )

  • 8/10/2019 abapreports-111108223616-phpapp01

    5/68

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

  • 8/10/2019 abapreports-111108223616-phpapp01

    6/68

    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: BIBS

    for more examples

  • 8/10/2019 abapreports-111108223616-phpapp01

    7/68

    PARAMETERS* Check if any checkbox has been selected

    CONSTANTS mark VALUE X.IF pa_name EQ mark

    ENDIF.

    * Check which RADIOBUTTON has been selected

    CASE mark.

    WHEN pa_lim_1.

    WHEN pa_lim_2. WHEN pa_lim_3.

    ENDCASE.

  • 8/10/2019 abapreports-111108223616-phpapp01

    8/68

    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 4columns 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 thanor 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

  • 8/10/2019 abapreports-111108223616-phpapp01

    9/68

    SELECT-OPTIONS

    The selection is union of all Includes minus the union of all Excludes.

    = Union of (Value = CO, Value between AA and BA)Minus

    Union 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 querys 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

  • 8/10/2019 abapreports-111108223616-phpapp01

    10/68

    SELECT-OPTIONSOPTIONS (during definition of select-options)

    DEFAULT AA [defaults the low value]

    DEFAULT AA TO BA [defaults the low & high values]MEMORY ID [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 [The name of modification group is a three-character variable name without quotation marks. Parameters

    assigned to a modification group can be processed as an entiregroup with the LOOP AT SCREEN and MODIFY SCREENstatements Used for dynamic modifications to selection screen atrun time]

  • 8/10/2019 abapreports-111108223616-phpapp01

    11/68

    Report Selection Screens (Visuals)

    SELECTION-SCREEN BEGIN OF BLOCK (block can be

    set of parameter fields, select-option fields, radio buttonsor 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 AS

    SUBSCREEN (defines sub screens that may be used onTab pages)

    SELECTION-SCREEN BEGIN OF TABBED BLOCK

    SELECTION-SCREEN PUSHBUTTON

  • 8/10/2019 abapreports-111108223616-phpapp01

    12/68

    Report Selection Screens (Visuals)DATA wa_flight TYPE dv_flights.

    SELECTION-SCREEN BEGIN OF BLOCK b_one

    WITH 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

  • 8/10/2019 abapreports-111108223616-phpapp01

    13/68

    Report Selection Screens (Visuals)

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

    SELECTION-SCREEN BEGIN OF BLOCK b_one

    WITH FRAME TITLE text-tld.

  • 8/10/2019 abapreports-111108223616-phpapp01

    14/68

    SELECTION-

    SCREEN PUSHBUTTON* Structure for pushbutton command

    TABLES: 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 commandCASE sscrfields-ucomm.WHEN 'DETAILS'.

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

    ELSE.switch = '1'.ENDIF.

    ENDCASE.

  • 8/10/2019 abapreports-111108223616-phpapp01

    15/68

    ("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 beforethe selection screen is displayed PBO Process Before Output)

    AT SELECTION-SCREEN (executed immediately after the selectionscreen is displayed PAI Process After Input(after Input fromuser)

    AT SELECTION-SCREEN AT SELECTION-SCREEN ON

    AT SELECTION-SCREEN ON

    AT SELECTION-SCREEN ON RADIOBUTTON GROUP

    AT SELECTION-SCREEN ON 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 afterinputs are validated)

  • 8/10/2019 abapreports-111108223616-phpapp01

    16/68

    Report Selection Screen Events

    (continued)LOAD-OF-PROGRAM.

    This event keyword defines an event block whose event is triggeredby the ABAP-runtime environment when an executable program, amodule pool, a function group or a sub-routine pool is loaded in theinternal session. When a program is called using SUBMIT or usinga transaction code, then at every call a new internal session isopened and the event block is executed once at every call. You caninitialize 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 theevent block without returning. At the first call of an externalProcedure (sub-program or function module), the frameworkprogram of the called procedure is loaded into the internal sessionof the caller, thus triggering the event LOAD-OF-PROGRAM. Theevent block is executed before the called procedure. At any furthercall of a procedure of the same framework program by a caller ofthe same internal session, the event LOAD-OF-PROGRAM istriggered no longer.

  • 8/10/2019 abapreports-111108223616-phpapp01

    17/68

    Report Selection Screen Events

    (continued)INITIALIZATION.

    This event keyword defines an event block whoseevent 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 anyexisting 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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    18/68

    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 flowof an executable program and before any selection screensare processed. In an executable program, all statements thatare not declarations and that are listed before the first explicitprocessing block, or if the program does not contain any

    explicit processing blocks, then all functional statements ofthe 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 alogical database, preparatory tasks can be performed at

    START-OF-SELECTION before the logical database importsthe data. If the program is not linked to a logical database,this event block becomes a type of main program fromwhich procedures or screens are called.

  • 8/10/2019 abapreports-111108223616-phpapp01

    19/68

    Report Selection Screen Events

    (continued)END-OF-SELECTION.

    This statement defines an event block, whose eventis 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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    20/68

    Report Selection Screen Events

    (continued)AT LINE-SELECTION.

    This statement defines an event block whose eventis 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 thedefinition 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 functioncode PICK.

  • 8/10/2019 abapreports-111108223616-phpapp01

    21/68

    Report Selection Screen Events

    (continued)END-OF-PAGE.

    This statement defines an event block that is raisedby 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 thispage. 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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    22/68

    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 ofa list. This occurs when a new page is started that is, immediately before thefirst line in a new page is to be output. All list outputs that take place in the eventblock are placed below the standard page header of the list. You cannot outputmore lines than are available in the page within the event block. The NEW-PAGEstatement is ignored within this event block. The entire output written to the list inthe 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 thescreen. For each TOP-OF-PAGE event, the placeholders &1 &9 arereplaced with the contents of system fields sy-tvar0 sy-tvar9 in the standardheading and the column headings of the standard page header during creation ofa 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-PAGEduring the creation of a basic list. If you use the addition DURING LINE-

    SELECTION, an event block is triggered for the corresponding events during thecreation of details lists. You have to use system fields like sy-lsind to distinguishbetween the individual details lists.

  • 8/10/2019 abapreports-111108223616-phpapp01

    23/68

    Report Selection Screen Events

    (continued)AT USER-COMMAND.

    This statement defines an event block whoseevent is triggered by the ABAP runtime

    environment if, during the display of a screen

    list, a function with a self-defined functioncode was chosen.

  • 8/10/2019 abapreports-111108223616-phpapp01

    24/68

    Report Selection Screen Events

    (continued)AT PF##.

    This statement defines an event block whoseevent is triggered by the ABAP runtime

    environment during list display provided the

    screen cursor is on a list line and a function isselected 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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    25/68

    Report Selection Screen Events

    (continued) AT SELECTION-SCREEN

    If an error message or warning message is displayed during thisevent, the system makes all selection screen fields ready for input

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

    event, the system makes only the above screen fields ready forinput

    AT SELECTION-SCREEN ON

    This is available to check entry combinations of a logical group. Allfields in this block are made ready for input when an errormessage is issued

    AT SELECTION-SCREEN ON END OF For selections where you can enter any number of single values

    and ranges, a different screen is displayed where multipleselections (values and ranges) can be entered, the ATSELECTION-SCREEN ON END OF is executed when thisscreen is processed. See next page for visual

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

  • 8/10/2019 abapreports-111108223616-phpapp01

    26/68

    Report Selection Screen Events

    (continued)

    AT SELECTION-SCREEN ON END OF so_car.

    CHECK .

    MESSAGE e003(bc405).

  • 8/10/2019 abapreports-111108223616-phpapp01

    27/68

    Report Selection Screen Events

    (continued) AT SELECTION-SCREEN ON HELP-REQUEST (F1)

    When the user presses F1 on the relevant field, the subsequent processingblock 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 entriesroutine for the input/output fields of the selection screen. If the programcontains such an event and the user presses F4 , the system processes thisrather than displaying the check table or the fixed values of the Dictionaryfield

    Note: It is recommended that instead of creating these events for F1 and F4, itis better to use the system F1 and F4 help that retrieves the values fromDictionary. This way F1 and F4 provides uniform look and feel applicationwide.

  • 8/10/2019 abapreports-111108223616-phpapp01

    28/68

    Event Blocks for Selection Screens

  • 8/10/2019 abapreports-111108223616-phpapp01

    29/68

    Event Blocks for Lists

  • 8/10/2019 abapreports-111108223616-phpapp01

    30/68

    Event Blocks for Executable Programs (Reports)

  • 8/10/2019 abapreports-111108223616-phpapp01

    31/68

    ABAP Statements for Screen

    Display

    WRITE

    A very important keyword in the reporting area is theWRITE 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 continuesthe output in the next line.

    The simplest form of the WRITE statement outputs a

    literal. Remember always to include literals inquotation marks. A simple WRITE statement may be:

    WRITE 'My first program'.

  • 8/10/2019 abapreports-111108223616-phpapp01

    32/68

    ABAP Statements for Screen

    Display NEW-PAGE

    Use the NEW-PAGE statement to create a pagebreak in your list. Page breaks improve the clarity ofthe page layout of your list

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

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

    ULINE

    Use the ULINE statement to create a line feed firstand then draw a horizontal line. This statement alsohelps to make lists easier to read

  • 8/10/2019 abapreports-111108223616-phpapp01

    33/68

    Terminal (user), External and Internal Sessions

    When you logon using the SAP Logon icon on desktop youcreate 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 asession 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 New

    Terminal orUser

    Session CALL TRANSACTION .

    Create new External Session

    Create new Internal Session

  • 8/10/2019 abapreports-111108223616-phpapp01

    34/68

    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 internalsession after the called program completes (or overlay and neverreturn)

    We do not observe internal sessions in any visual way becausethey are internal sessions- all we see is one external sessiongenerally 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

  • 8/10/2019 abapreports-111108223616-phpapp01

    35/68

    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

  • 8/10/2019 abapreports-111108223616-phpapp01

    36/68

    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

  • 8/10/2019 abapreports-111108223616-phpapp01

    37/68

    ABAP and SAP MemoryABAP memory

    ABAP memory is a memory area that all ABAP programs

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

    Data within this ABAP memory remains intact during awhole sequence of program calls

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

    The internal session of the called program then replaces

    that of the calling program. The program called can thenread from the ABAP memory

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

  • 8/10/2019 abapreports-111108223616-phpapp01

    38/68

    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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    39/68

    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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    40/68

    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 read

    3) Called from a new session (external) created using the Creates

    New Session button on the top menu - ABAP memory values areNOT read

    4) Called from a new user logon (SAPgui) from the same or differentPC 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

  • 8/10/2019 abapreports-111108223616-phpapp01

    41/68

    ABAP and SAP Memory

    (continued)SAP Memory

    SAP memory is a memory area to which all mainsessions within a SAPgui (login or user session)have access

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

    Application programs that use SAP memory

    must do so using SPA/GPA parameters (alsoknown as SET/GET parameters)

  • 8/10/2019 abapreports-111108223616-phpapp01

    42/68

    GET/SET parameters These are also called SPA/GPA parameters

    The most frequent use of GET/SET parametersis to fill input fields on screens

    These parameters are reset when you logoff thesessions (exit)

    These parameters can be set either for aparticular user or for a particular program usingthe SET PARAMETER statement

    Other ABAP programs can then retrieve the setparameters using the GET PARAMETERstatement

  • 8/10/2019 abapreports-111108223616-phpapp01

    43/68

    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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    44/68

    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.

  • 8/10/2019 abapreports-111108223616-phpapp01

    45/68

    GET/SET parametersNotes:

    After the Set program is run, if the Get program is run

    1) In the same window SAP memory values are read

    2) Get program is called from the Set program (SUBMIT) SAP

    memory values are read

    3) Get program called from a new session (external) created using the

    Creates New Session button on the top menu - SAP memoryvalues 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 differentPC for a different user - SAP memory values are NOT read

  • 8/10/2019 abapreports-111108223616-phpapp01

    46/68

    GET/SET DEMO ith Li

  • 8/10/2019 abapreports-111108223616-phpapp01

    47/68

    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.

    GET/SET DEMO ith Li

  • 8/10/2019 abapreports-111108223616-phpapp01

    48/68

    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' FIELDp_conn.

    START-OF-SELECTION.

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

    END-OF-SELECTION.

  • 8/10/2019 abapreports-111108223616-phpapp01

    49/68

    Variants Variants allow you to reuse values entered

    once on the selection screens. These arehelpful when:

    The program is started frequently with same

    values

    The program is run in the background

  • 8/10/2019 abapreports-111108223616-phpapp01

    50/68

    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 haveany effect on them (will get overwritten by the

    initialization)

  • 8/10/2019 abapreports-111108223616-phpapp01

    51/68

    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 dayof 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 fieldsfor a specific task using a variant you can save fixed values in tableTVARVC. To avoid having to create new variants for each minorchange in the selection values, you can assign a value in tableTVARVC to a selection and then just change this value. This isparticularly important if the corresponding value on the selection

    screen is write-protected)* TVARV (client dependent table) TVARVC (client independent)

  • 8/10/2019 abapreports-111108223616-phpapp01

    52/68

    Variable Values in VariantsVariable date calculations

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    53/68

    Example:

    ZBC405_C027393_SSCS_3E01 *&------------------------------------------------

    *&------------------------------------------------*& Event INITIALIZATION*&------------------------------------------------INITIALIZATION.

    * Initialize select-options for CARRID" OPTIONALMOVE: '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).

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    54/68

    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_carAND connid IN so_conAND fldate IN so_fdtAND cityfrom IN so_start

    AND 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.

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    55/68

    Example:

    ZBC405_C027393_SSCS_3E01 WHEN national.

    * Radiobutton NATIONAL is markedSELECT * 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_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.

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    56/68

    Example:

    ZBC405_C027393_SSCS_3E01 WHEN internat.

    * Radiobutton INTERNAT is markedSELECT * 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_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.

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    57/68

    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 databaseREFRESH: so_start,so_dest.

    ENDIF.ENDCASE.

    Example:

  • 8/10/2019 abapreports-111108223616-phpapp01

    58/68

    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.

    Example: BC405 SSCS 3TOP

  • 8/10/2019 abapreports-111108223616-phpapp01

    59/68

    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_detUSER-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.

    Example: BC405 SSCS 3TOP

  • 8/10/2019 abapreports-111108223616-phpapp01

    60/68

    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 FRAMETITLE 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 .

    Calling programs using Transaction

  • 8/10/2019 abapreports-111108223616-phpapp01

    61/68

    Calling programs using Transaction

    CodeMethod 1

    LEAVE TO TRANSACTION .

    The system terminates the current program and starts the program with

    transaction code . The statement is the equivalent of entering /n in thecommand field followed by the transaction code. After the called programthe user returns to the application menu and NOT to the calling program(When using LEAVE TO TRANSACTION, the current call sequence isexited completely. Upon completion of the called transaction, the runtimeenvironment 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 AND SKIP FIRST SCREEN.

    If you use the AND SKIP FIRST SCREEN addition, the system does notdisplay the screen contents of the first screen in the transaction. However, itdoes process the flow logic

  • 8/10/2019 abapreports-111108223616-phpapp01

    62/68

    Calling programs using Transaction

  • 8/10/2019 abapreports-111108223616-phpapp01

    63/68

    g p g g

    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

    Calling programs using

  • 8/10/2019 abapreports-111108223616-phpapp01

    64/68

    g p g g

    Program/Report NameSUBMIT .

    After the called program the user returns to the application menu andNOT to the calling program. Here users do not see the selectionscreen, therefore selection values will have to be populated usingWITH options shown in the next few slides

    SUBMIT AND RETURN.

    After the called program is completed the user returns to the callingprogram. Here too users do not see the selection screen, therefore

    selection values will have to be populated using WITH optionsshown in the next few slides

    SUBMIT VIA SELECTION-SCREEN.

    Shows the selection screen (first screen) of the called program, whereuser may enter the selection values. If selection values are

    populated using the WITH options, the users will see these valuesand can modify them if required or just execute the report

    Calling programs using

  • 8/10/2019 abapreports-111108223616-phpapp01

    65/68

    g p g g

    Program/Report Name (continued)SUBMIT WITH =

    'value1 WITH = '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.

    Calling programs using

  • 8/10/2019 abapreports-111108223616-phpapp01

    66/68

    g p g g

    Program/Report Name (continued)SUBMIT WITH

    SELECTION-TABLErspar [VIASELECTION-SCREEN].

    If you specify this addition, parameters and selection criteria on the selection screen aresupplied from an internal table rspar. The row type for this internal table isRSPARAMS. The structured data type RSPARAMS is defined in the ABAP Dictionaryand 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, Sfor selection criteria)

    SIGN length 1 specifies whether the result of the row condition needs to be included foreach 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 valuemust be specified in LOW and all other components are ignored)

    HIGH length 45 this is the lower limit of the range

    Calling programs using

  • 8/10/2019 abapreports-111108223616-phpapp01

    67/68

    g p g g

    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 parameters

    and/or select-options by

    specifying correct value in the

    KIND field (P for parameters,

    S for select-options)

    Calling programs using

  • 8/10/2019 abapreports-111108223616-phpapp01

    68/68

    Program/Report Name (continued)SUBMIT USING SELECTION-

    SET 'VARIANT1

    If you specify this option, the parameters andselection criteria for the selection screen are

    supplied with values from a variant. Provide thename of the variant in single quotes. If thevariant does not exist, the system sends an error

    message. If the variant belongs to a differentselection screen, it is ignored.


Recommended