Blogs

ABAP/4 Example Code: ALV Grid Control by applying object CL_GUI_ALV_GRID

Create ZPROGRAM and create normal screen no. 100 under this program. And in screen 100, please create custom control name ’CUSTOM1’.

Example

*** ZPROGRAM CODING ***

DATA: save_ok LIKE sy-ucomm,
      ok_code LIKE sy-ucomm,
      it_spfli TYPE TABLE OF spfli WITH HEADER LINE.

DATA: G_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      GRID1  TYPE REF TO CL_GUI_ALV_GRID,
      it_cat TYPE LVC_T_FCAT,
      wa_cat TYPE LVC_S_FCAT.

START-OF-SELECTION.
  SELECT * FROM spfli
           INTO TABLE it_spfli.
  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS ’100’.
  SET TITLEBAR ’100’.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
  save_ok = ok_code.
  clear ok_code.
  CASE save_ok.
    WHEN ’BACK’.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  INITIAL_GRID  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INITIAL_GRID OUTPUT.
  PERFORM create_field_catalog.
  PERFORM create_grid_control.
ENDMODULE.                 " INITIAL_GRID  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  create_field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_field_catalog .
  IF it_cat[] is initial.
    clear wa_cat.
    wa_cat-col_pos   = 1.
    wa_cat-fieldname = ’CARRID’.
    wa_cat-datatype  = ’CHAR’.
    wa_cat-inttype   = ’C’.
    wa_cat-intlen    = 3.
    wa_cat-reptext   = ’Airline Code’.
    wa_cat-coltext   = ’Airline Code’.
    append wa_cat to it_cat.

    clear wa_cat.
    wa_cat-col_pos   = 2.
    wa_cat-fieldname = ’CONNID’.
    wa_cat-datatype  = ’NUMC’.
    wa_cat-inttype   = ’N’.
    wa_cat-intlen    = 4.
    wa_cat-reptext   = ’Flight Conn. No’.
    wa_cat-coltext   = ’Flight Conn. No’.
    append wa_cat to it_cat.

    clear wa_cat.
    wa_cat-col_pos   = 3.
    wa_cat-fieldname = ’CITYFROM’.
    wa_cat-datatype  = ’CHAR’.
    wa_cat-inttype   = ’C’.
    wa_cat-intlen    = 20.
    wa_cat-reptext   = ’Dep. city’.
    wa_cat-coltext   = ’Dep. city’.
    append wa_cat to it_cat.

    clear wa_cat.
    wa_cat-col_pos   = 4.
    wa_cat-fieldname = ’AIRPFROM’.
    wa_cat-datatype  = ’CHAR’.
    wa_cat-inttype   = ’C’.
    wa_cat-intlen    = 3.
    wa_cat-reptext   = ’Dep. airport’.
    wa_cat-coltext   = ’Dep. airport’.
    append wa_cat to it_cat.

    clear wa_cat.
    wa_cat-col_pos   = 5.
    wa_cat-fieldname = ’CITYTO’.
    wa_cat-datatype  = ’CHAR’.
    wa_cat-inttype   = ’C’.
    wa_cat-intlen    = 20.
    wa_cat-reptext   = ’Arrival city’.
    wa_cat-coltext   = ’Arrival city’.
    append wa_cat to it_cat.

    clear wa_cat.
    wa_cat-col_pos   = 6.
    wa_cat-fieldname = ’AIRPTO’.
    wa_cat-datatype  = ’CHAR’.
    wa_cat-inttype   = ’C’.
    wa_cat-intlen    = 3.
    wa_cat-reptext   = ’Dest. airport’.
    wa_cat-coltext   = ’Dest. airport’.
    append wa_cat to it_cat.
  ENDIF.
ENDFORM.                    " create_field_catalog
*&---------------------------------------------------------------------*
*&      Form  create_grid_control
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_grid_control .
  IF G_CUSTOM_CONTAINER1 is initial .
    CREATE OBJECT G_CUSTOM_CONTAINER1
           EXPORTING CONTAINER_NAME = ’CUSTOM1’.
    CREATE OBJECT GRID1
           EXPORTING I_PARENT = G_CUSTOM_CONTAINER1.

    CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
*      EXPORTING
*        I_BUFFER_ACTIVE               =
*        I_BYPASSING_BUFFER            =
*        I_CONSISTENCY_CHECK           =
*        I_STRUCTURE_NAME              =
*        IS_VARIANT                    =
*        I_SAVE                        =
*        I_DEFAULT                     = ’X’
*        IS_LAYOUT                     =
*        IS_PRINT                      =
*        IT_SPECIAL_GROUPS             =
*        IT_TOOLBAR_EXCLUDING          =
*        IT_HYPERLINK                  =
*        IT_ALV_GRAPHICS               =
*        IT_EXCEPT_QINFO               =
*        IR_SALV_ADAPTER               =
      CHANGING
        IT_OUTTAB                     = it_spfli[]
        IT_FIELDCATALOG               = it_cat[]
*        IT_SORT                       =
*        IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4
            .
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.
ENDFORM.                    " create_grid_control
*** FLOW LOGIC ON SCREEN 100 ***
PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
  MODULE INITIAL_GRID.
*
PROCESS AFTER INPUT.
  MODULE USER_COMMAND_0100.

How to insert variable in text element in SAP smartforms

After we insert text element in SAP smartforms, the inserted text element can contain variable. We will introduce step by step to insert variable in text element.

Step by Step

  • Double click text element that you want to insert variable in left tree navigator.
    img120
    In the example, i selected text element name ’TEXT1’.

How to insert text element in SAP Smartforms

You can insert text element in SAP smartforms as following:

  • Select window that you want to insert graphic object and right click. System will list object that you can create.
    img114
    In the example, I have window name ’HEADER2’ and I want to insert text element in this window.
  • On popup menu, you will select Create -> Text
    img115

    img116

พระธาตุ คือ อะไร

พระธาตุ มีสองความหมายคือ พระบรมสารีริกธาตุของพระพุทธเจ้า และสถานที่หรือพระเจดีย์ที่มีพระบรมธาตุบรรจุ โดยแต่ละแห่งจะมีตำนานที่เล่ามูลเหตุการสร้างพระบรมธาตุเจดีย์ซึ่งสัมพันธ์กับการเสด็จโปรดสัตว์ของพระพุทธเจ้าในดินแดนต่างๆ ซึ่งสถานที่ที่มีพระบรมธาตุเจดีย์เหล่านี้มักจะกลายเป็นเมืองสำคัญในเวลาต่อมา

How to insert graphics image (Bitmap) in SAP Smartforms

You can insert graphics object (Bitmap) in SAP smartforms as following:

  • Select window that you want to insert graphic object and right click. System will list object that you can create.
    img106
    In the example, I have window name ’HEADER’ and I want to insert graphic object in this window.
  • On popup menu, you will select Create -> Graphic
    img107

    img108

If you are using Drupal and you have an ’ account, you might be interested to try Google Analytics for Drupal. By using this module, you will be able to add necessary code to all pages automatically without modification to your theme.

This is a good start. Anyway, it is possible to track your website programmatically using Google Analytics. Google Analytics module should provide high-level APIs to support Drupal user. Hope budda, the author, will continue this impressive project.