ABAP Session – 3_3-Open SQL

download ABAP Session – 3_3-Open SQL

of 29

Transcript of ABAP Session – 3_3-Open SQL

  • 7/30/2019 ABAP Session 3_3-Open SQL

    1/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    2/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    3/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    4/29

    INTO Clause to specify the target variable to which the data record is to be

    copied. Left-justified, the target area must be structured like the table row or

    the specified required fields of the row

  • 7/30/2019 ABAP Session 3_3-Open SQL

    5/29

    INTO Clausethe target structure variable should be of the same structure as

    that of the field list

    -only the corresponding field types

    have to match, not the field names-the names of the target structure

    fields are not taken into account (ONLY for this syntax)

    ALTERNATE SPECIFICATION INTO (field_1, .., field_n)

  • 7/30/2019 ABAP Session 3_3-Open SQL

    6/29

    If the target list has a different structure/order of fields than the fields that are

    being retrieved from the DB, then we use this command

    Only the fields with the SAME NAME in the target structure are filled up

    The target field types should be of the same type as the fields being readfrom DB, if not, a complex type conversion happens (Like in a MOVE

    statement). This might result in the incomplete (data cut of) transport of data to

    the target fields

    Advantages of this variant

    The target structure need not be left justified in the same way as the

    field list

    This construction is easy to maintain, since extending the field list or

    target structure does not require other changes to be made to theprogram

  • 7/30/2019 ABAP Session 3_3-Open SQL

    7/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    8/29

    The INTO TABLE clause helps to copy the multiple rows of the DB into an itab

    directly instead of row-by-row

    This is not a type of LOOP Processing and hence and ENDSELECT

    statement is not required/allowedWith the Array Fetch, any existing rows in the internal table are overwritten. If

    you want to append the rows instead, then use the APPENDING TABLE

    addition

  • 7/30/2019 ABAP Session 3_3-Open SQL

    9/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    10/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    11/29

  • 7/30/2019 ABAP Session 3_3-Open SQL

    12/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    13/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    14/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    15/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    16/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    17/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    18/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    19/29 1

  • 7/30/2019 ABAP Session 3_3-Open SQL

    20/29 2

    If a join expression is used, the SELECT command circumvents SAPbuffering.

    a maximum of 24 join expressions that join 25 database tables or views witheach other can be specified afterFROM.

    INNER JOIN:

    The inner join joins the columns of every selected line on the left- handside with the columns of all lines on the right-hand side that jointly fulfilthejoin_cond condition.

    A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may beduplicated in this case.

    If none of the lines on the right-hand side fulfils the join_condcondition, no line is created in the resulting set

    LEFT OUTER JOIN:

    The outer join basically creates the same resulting set as the inner join,with the difference that at least one line is created in the resulting set forevery selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition.

    The columns on the right-hand side that do not fulfil the join_condcondition are filled with null values

  • 7/30/2019 ABAP Session 3_3-Open SQL

    21/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    22/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    23/29 2

    LDB:

    Logical databases are special ABAP programs that retrieve data and

    make it available to application programs. The most common use of

    logical databases is still to read data from database tables by linkingthem to executable ABAP programs.

    call logical databases using the function module LDB_PROCESS. This

    allows you to call several logical databases from any ABAP program,

    nested in any way.

    A logical database provides a particular view of database tables in the

    R/3 System. It is always worth using logical databases if the structure of

    the data that you want to read corresponds to a view available through

    a logical database.

    Use tcode SE36 to create LDB

    BAPI-Methods of business objects with READ function, for example

    http://help.sap.com/saphelp_46c/helpdata/EN/9f/db99b435c111d1829f0000e829fbfe/content.htmhttp://help.sap.com/saphelp_46c/helpdata/EN/9f/db99b435c111d1829f0000e829fbfe/content.htm
  • 7/30/2019 ABAP Session 3_3-Open SQL

    24/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    25/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    26/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    27/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    28/29 2

  • 7/30/2019 ABAP Session 3_3-Open SQL

    29/29