ABAP Inline Declarations Change - Before Vs After SAP 7.40

Inline Declarations Change - Before Vs After SAP 7.40


Before 7.40, we always had to declare and define structures and internal table as shown below.


After 7.40, SP08, there is no need to define structures and internal tables, the system automatically determines the structure of the internal table, based on the defined SELECT list.




SAMPLE PROGRAM:

Before SAP 7.40

REPORT ztest_before_7_40.

TYPES: BEGIN OF gty_mara,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
         matkl TYPE mara-matkl,
       END OF gty_mara.

TYPES: BEGIN OF gty_makt,
         matnr TYPE makt-matnr,
         maktx TYPE makt-maktx,
       END OF gty_makt.

TYPES: BEGIN OF gty_final,
         matnr TYPE mara-matnr,
         maktx TYPE makt-maktx,
         mtart TYPE mara-mtart,
         matkl TYPE mara-matkl,
       END OF gty_final.

DATA: gt_mara   TYPE TABLE OF gty_mara,
      gt_makt   TYPE TABLE OF gty_makt,
      gt_final  TYPE TABLE OF gty_final,
      gwa_final TYPE gty_final.

FIELD-SYMBOLS:  <fs_mara> TYPE gty_mara,
                <fs_makt> TYPE gty_makt.

START-OF-SELECTION.

  SELECT matnr mtart matkl FROM mara
    INTO TABLE gt_mara.

  IF gt_mara IS NOT INITIAL.
    SELECT matnr maktx FROM makt
      INTO TABLE gt_makt
      FOR ALL ENTRIES IN gt_mara
      WHERE matnr = gt_mara-matnr
      AND spras = sy-langu.
  ENDIF.

  LOOP AT gt_mara ASSIGNING <fs_mara>.
    gwa_final-matnr = <fs_mara>-matnr.
    gwa_final-mtart = <fs_mara>-mtart.
    gwa_final-matkl = <fs_mara>-matkl.

    READ TABLE gt_makt ASSIGNING <fs_makt> WITH KEY matnr =  <fs_mara>-matnr BINARY SEARCH.
    IF sy-subrc EQ 0.
      gwa_final-maktx = <fs_makt>-maktx.
    ENDIF.
    APPEND gwa_final TO gt_final.
    CLEAR: gwa_final.
  ENDLOOP.

END-OF-SELECTION.

    EXPORTING
*     I_START_COLUMN       = 25
*     I_START_LINE         = 6
*     I_END_COLUMN         = 120
*     I_END_LINE           = 20
*     I_TITLE   = 'ALV'
*     I_POPUP   = ' '
*     I_PF_STATUS          = ' '
      i_program = sy-repid
    TABLES
      it_alv    = gt_final.



After SAP 7.40 (Implementing new changes for inline declarations as mentioned above)

REPORT ztest_after_7_40.

TYPES: BEGIN OF gty_final,
         matnr TYPE mara-matnr,
         maktx TYPE makt-maktx,
         mtart TYPE mara-mtart,
         matkl TYPE mara-matkl,
       END OF gty_final.

DATA: gt_final  TYPE TABLE OF gty_final,
      gwa_final TYPE gty_final.

START-OF-SELECTION.

  SELECT matnr, mtart, matkl FROM mara
    INTO TABLE @DATA(gt_mara).

  IF gt_mara IS NOT INITIAL.
    SELECT matnr, maktx FROM makt
      INTO TABLE @DATA(gt_makt)
      FOR ALL ENTRIES IN @gt_mara
      WHERE matnr = @gt_mara-matnr
      AND spras = @sy-langu.
  ENDIF.

  LOOP AT gt_mara ASSIGNING FIELD-SYMBOL(<fs_mara>).
    gwa_final-matnr = <fs_mara>-matnr.
    gwa_final-mtart = <fs_mara>-mtart.
    gwa_final-matkl = <fs_mara>-matkl.

    READ TABLE gt_makt ASSIGNING FIELD-SYMBOL(<fs_makt>) WITH KEY matnr =  <fs_mara>-matnr BINARY SEARCH.
    IF sy-subrc EQ 0.
      gwa_final-maktx = <fs_makt>-maktx.
    ENDIF.
    APPEND gwa_final TO gt_final.
    CLEAR: gwa_final.
  ENDLOOP.

END-OF-SELECTION.

    EXPORTING
*     I_START_COLUMN       = 25
*     I_START_LINE         = 6
*     I_END_COLUMN         = 120
*     I_END_LINE           = 20
*     I_TITLE   = 'ALV'
*     I_POPUP   = ' '
*     I_PF_STATUS          = ' '
      i_program = sy-repid
    TABLES
      it_alv    = gt_final.



Comments

Also Read...