Posts

ABAP : Dynamic ITAB for Ranges

Example of ABAP Code Dynamic Internal Table - Ranges
*---------------------------------------------------------------------*
*      Form  f_ranges_str
*      By Oka Wirasatha
*---------------------------------------------------------------------*

form F_RANGES_STR
  using FV_FIELD
        FV_SIGN FV_OPTION FV_LOW FV_HIGH.
  type-pools:
    ABAP.

  data:
    GR_STRUCTDESCR    type ref to CL_ABAP_STRUCTDESCR,
    GR_TABLEDESCR     type ref to CL_ABAP_TABLEDESCR,
    GR_DATADESCR      type ref to CL_ABAP_DATADESCR,
    GR_TYPEDESCR      type ref to CL_ABAP_TYPEDESCR,
    GT_COMPONENTS     type ABAP_COMPONENT_TAB,
    GW_COMPONENT      type line of ABAP_COMPONENT_TAB,
    GR_WA             type ref to DATA,
    GR_TAB            type ref to DATA,
    LV_TEXT(20).

  field-symbols: <fs_wa> type any,
                 <fs_val> type any,
                 <fs_tab> type TABLE.
* determine components of structure -> GT_COMPONENTS
  move 'SIGN' to GW_COMPONENT-NAME.
  GW_C…

ABAP Dialog Programming : Set Filter data of Table Control

Example ABAP code for Filter data of table control

*---------------------------------------------------------------------*
*      Form  F_filter_data
*---------------------------------------------------------------------*
*  By Oka Wirasatha
*---------------------------------------------------------------------*
form F_FILTER_DATA .
  field-symbols :
    <selected_col> type CXTAB_COLUMN.
  data : LW_COLS like TC_ITEM-COLS.
  data : GT_FIELDCAT type LVC_T_FCAT.
  data LAYO type LVC_S_LAYO.
  data : GT_FILTER_INDEX type LVC_T_FIDX,
         LT_SELCOL type table of LVC_S_COL with header line.
  data : LT_FILT type LVC_T_FILT,
         LW_FILT type LVC_S_FILT,
         LT_LAYOUT type LVC_S_LAYO.

* find out if a column is selected.
  loop at TC_ITEM-COLS assigning <selected_col>.
    if <selected_col>-SELECTED = 'X'.
      LT_SELCOL-FIELDNAME = <selected_col>-SCREEN-NAME+7(10).
      append LT_SELCOL.
    endif.
  endloop.

  call function 'LVC_FIELDCATA…

ABAP Dialog Programming : Sorting selected column in Table Control

This is example of abap code for sorting selected table control.

*---------------------------------------------------------------------*
*      Form  F_SORT_TABLE
*---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      By Oka Wirasatha
*----------------------------------------------------------------------*
form F_SORT_TABLE using FV_CODE.
  field-symbols :
    <lfs1>,
    <selected_col> type CXTAB_COLUMN.
  data : LW_COLS like TC_ITEM-COLS.
  data : LV_TXT1(20),
         LV_INDEX(2) type N.
  data : begin of W_SORT,
          SORT01(20),
          SORT02(20),
          SORT03(20),
          SORT04(20),
          SORT05(20),
          SORT06(20),
          SORT07(20),
    end of W_SORT.

* find out if a column is selected.
  LV_INDEX = 0.
  clear W_SORT.
  loop at TC_ITEM-COLS assigning <selected_col>.
    if <selected_col>-SELECTED = 'X'.
      …

Problem SAP-SCRIPT line command too long

Sometimes your sap scripts command too long, how to covered this ? Easy way is press shift+F8.

Dynamic Selection Screen Base on TCODE

SELECTION-SCREEN BEGIN OF BLOCK SO WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,"Sales order number                   S_VBELND FOR LIKP-VBELN,"Delivery number                     S_VBELNI FOR VBRK-VBELN,"Invoice number                      S_VBELNP FOR VBKD-BSTKD."PO number            SELECTION-SCREEN END OF BLOCK SO.                            
*--- EVENT AT SCREEN OUTPUT ------------------------------- AT SELECTION-SCREEN OUTPUT.                                          CASE SY-TCODE.                                                       WHEN 'ZEDI6'.                                                        LOOP AT SCREEN.                                                      CASE SCREEN-GROUP4.                                                  WHEN '001'.                  "Sales order select                     SCREEN-ACTIVE = '1'.       "1=Active, 0=Don't display              MODIFY SCREEN.�����������������…

Dynamic selection screens based on user input parameters

Dynamic selection screens based on user input parameters with dropdowns and execute button disabled.
The selection screen  push button does the functionality of the disabled execute button
REPORT  zsscr.

*TYPE POOLS DECLARATIONS FOR VALUE REQUEST MANAGER AND ICONS

TYPE-POOLS : vrm,
             icon.

*SELECTION SCREEN FIELDS
TABLES : sscrfields.

*GLOBAL DECLARATIONS

DATA : flag TYPE c,
      tablename(10),
      mmtable LIKE dd02l-tabname,
      sdtable LIKE dd02l-tabname,
      hrtable LIKE dd02l-tabname.

*DECLARATIONS FOR SELECTION SCREEN STATUS

DATA it_ucomm TYPE TABLE OF sy-ucomm.

**********SELECTION-SCREENS*********************

Dynamic Table Selection

REPORT zdany_dynamic_select.

* We use some parameters to dynamically control the select, this is not very
* clever but this is just a test program !!
PARAMETER : p_tabnam TYPE tabname DEFAULT 'SFLIGHT',
            p_selfl1 TYPE edpline DEFAULT 'CARRID',
            p_selfl2 TYPE edpline DEFAULT 'CONNID',
            p_selfl3 TYPE edpline DEFAULT 'FLDATE',
            p_selfl4 TYPE edpline DEFAULT 'PRICE',
            p_selfl5 TYPE edpline DEFAULT 'CURRENCY',
            p_where1 TYPE edpline DEFAULT 'PRICE > 300',
            p_where2 TYPE edpline DEFAULT 'AND CURRENCY = ''EUR'''.

FIELD-SYMBOLS :  TYPE ANY TABLE,
                 TYPE ANY,
                 TYPE ANY.

DATA: lt_where    TYPE TABLE OF edpline,
      lt_sel_list TYPE TABLE OF edpline,
      lt_group    TYPE TABLE OF edpline,
      l_having    TYPE string,
      l_wa_name   TYPE string,
      l_sel_list  TYPE edpline,
      dref        TYPE…