Field catalog in abap objects

hi friends,
               i am using factory method to display my alv. now some of the fields in my internal table i have declared them as char fields, i want certain type of headings for these fields,so where can i give heading to these fields.
               where exactly do we create a field catalog for factory method.
pls advice me on this

hi
good
go throgh this code
*& Report  Z_ALV_OOPS
REPORT  Z_ALV_OOPS.
*Event class Definition                             "Event handler class
class event_handle definition.
  public section.
    methods: handle_user
      for event user_command of cl_gui_alv_grid
      importing e_ucomm.
endclass.
*Event class Implementation
class event_handle implementation.
  method handle_user.
    write:/ ''.
  endmethod.
endclass.
Data: t_alv       type ref to cl_gui_alv_grid,           "ALV control
      t_cont      type ref to cl_gui_custom_container,   "Cust Container
      t_alv2      type ref to cl_gui_alv_grid,           "ALV control
      t_cont2     type ref to cl_gui_custom_container,   "Cust Container
      t_fieldcat  type lvc_t_fcat with header line,      "Field Cat
      t_fieldcat2 type lvc_t_fcat with header line,      "Field Cat
      t_layout    type lvc_s_layo,                       "Layout
      t_event     type ref to event_handle,              "Event handler
      t_sort      type LVC_T_SORT with header line,      "Sort
      t_toolbar   type ui_functions with header line.    "Toolbar xclude
Types: begin of g_vbak,                                 "Header Table
         vbeln like vbak-vbeln,
         auart like vbak-auart,
         vkorg like vbak-vkorg,
         vtweg like vbak-vtweg,
         spart like vbak-spart,
         kunnr like vbak-kunnr,
         bstnk like vbak-bstnk,
         seltab,
       end of g_vbak.
Types: begin of g_vbap,                                  "Item Table
         vbeln like vbap-vbeln,
         posnr(6) type c,
        posrn like vbap-posnr,
         matnr like vbap-matnr,
         netwr like vbap-netwr,
         waerk like vbap-waerk,
       end of g_vbap.
Data: t_vbak type g_vbak occurs 0,
      t_vbap type g_vbap occurs 0.
Start-Of-Selection.
*Fetch data from DB Table
select vbeln auart vkorg vtweg spart kunnr bstnk
    from vbak into table t_vbak up to 20 rows.
End-Of-Selection.
*Call ALV screen
call screen 100.
*&      Module  STATUS_0100  OUTPUT
      text
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'ALV'.
  SET TITLEBAR 'VBAK'.
if t_cont is initial.
  create object t_cont
    exporting
      container_name = 'ALV'.
  create object t_alv
    exporting
      i_parent = t_cont.
*Create event handlers
  create object t_event.
  set handler t_event->handle_user for t_alv.
  perform build_fieldcatlog.
  perform build_layout.
  perform xclude_toolbar.
  CALL METHOD t_alv->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                     = t_layout
     IS_PRINT                      =
     IT_SPECIAL_GROUPS             =
      IT_TOOLBAR_EXCLUDING          = t_toolbar[]
     IT_HYPERLINK                  =
     IT_ALV_GRAPHICS               =
     IT_EXCEPT_QINFO               =
    CHANGING
      IT_OUTTAB                     = t_vbak[]
      IT_FIELDCATALOG               = t_fieldcat[]
     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.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
      text
MODULE USER_COMMAND_0100 INPUT.
Data: lt_rows type lvc_t_row,
      wa_rows type line of lvc_t_row,
      wa_vbak type g_vbak,
      l_lines type i.
refresh: t_vbap.
case sy-ucomm.
  when 'DET'.                                  "Item details
  Get selected rows from ALV
    call method t_alv->get_selected_rows
        importing
            et_index_rows = lt_rows.
  Fetch corresponding Item details from VBAP
    loop at lt_rows into wa_rows.
      read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                vbeln.
      select vbeln posnr matnr netwr waerk from vbap
          appending corresponding fields of table t_vbap
          where vbeln = wa_vbak-vbeln.
    endloop.
  Prepare fieldcatlog
  Display Item details in ALV
    call screen 200 starting at 8 5.
  when 'SHOW'.                                  "Display order
    call method t_alv->get_selected_rows
        importing
            et_index_rows = lt_rows.
    Describe table lt_rows lines l_lines.
    if l_lines > 1.
      message e999(z_error).
    else.
      read table lt_rows into wa_rows index 1.
      read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                vbeln.
      set parameter id 'AUN' field wa_vbak-vbeln.
      call transaction 'VA03' and skip first screen.
    endif.
endcase.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  build_fieldcatlog
      text
form build_fieldcatlog .
  clear t_fieldcat.
  t_fieldcat-col_pos = '1'.
  t_fieldcat-fieldname = 'VBELN'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'VBELN'.
  append t_fieldcat.
  t_fieldcat-col_pos = '2'.
  t_fieldcat-fieldname = 'AUART'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'AUART'.
  append t_fieldcat.
  t_fieldcat-col_pos = '3'.
  t_fieldcat-fieldname = 'VKORG'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'VKORG'.
  append t_fieldcat.
  t_fieldcat-col_pos = '4'.
  t_fieldcat-fieldname = 'VTWEG'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'VTWEG'.
  append t_fieldcat.
  t_fieldcat-col_pos = '5'.
  t_fieldcat-fieldname = 'SPART'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'SPART'.
  append t_fieldcat.
  t_fieldcat-col_pos = '6'.
  t_fieldcat-fieldname = 'KUNNR'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'KUNNR'.
  append t_fieldcat.
  t_fieldcat-col_pos = '7'.
  t_fieldcat-fieldname = 'BSTNK'.
  t_fieldcat-ref_table = 'VBAK'.
  t_fieldcat-ref_field = 'BSTNK'.
  append t_fieldcat.
endform.                    " build_fieldcatlog
*&      Module  LEAVE  INPUT
      text
module LEAVE input.
case sy-ucomm.
  when 'BACK' or 'EXIT' or 'CANCEL'.
    leave program.
endcase.
endmodule.                 " LEAVE  INPUT
*&      Form  build_layout
      text
-->  p1        text
<--  p2        text
form build_layout .
t_layout-zebra = 'X'.
t_layout-sel_mode = 'A'.
t_layout-grid_title = 'Header Details'.
endform.                    " build_layout
*&      Form  build_fcat_vbap
      text
form build_fcat_vbap .
  clear t_fieldcat2.
  t_fieldcat2-scrtext_m = 'Sales Doc'.
  t_fieldcat2-col_pos = 1.
  t_fieldcat2-fieldname = 'VBELN'.
  t_fieldcat2-tabname = 'T_VBAP'.
  t_fieldcat2-no_zero = 'X'.
  t_fieldcat2-ref_table = 'VBAP'.
  t_fieldcat2-ref_field = 'VBELN'.
  append t_fieldcat2.
  clear t_fieldcat2.
  t_fieldcat2-col_pos = 2.
  t_fieldcat2-scrtext_m = 'Item'.
  t_fieldcat2-fieldname = 'POSNR'.
  t_fieldcat2-tabname = 'T_VBAP'.
  t_fieldcat2-intlen = '6'.
  t_fieldcat2-inttype = 'C'.
  t_fieldcat2-no_zero = 'X'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'POSNR'.
  append t_fieldcat2.
  clear t_fieldcat2.
  t_fieldcat2-col_pos = 3.
  t_fieldcat2-fieldname = 'MATNR'.
  t_fieldcat2-ref_table = 'VBAP'.
  t_fieldcat2-ref_field = 'MATNR'.
  append t_fieldcat2.
  clear t_fieldcat2.
  t_fieldcat2-col_pos = 4.
  t_fieldcat2-fieldname = 'NETWR'.
  t_fieldcat2-ref_table = 'VBAP'.
  t_fieldcat2-ref_field = 'NETWR'.
  t_fieldcat2-do_sum = 'X'.
  append t_fieldcat2.
  clear t_fieldcat2.
  t_fieldcat2-col_pos = 5.
  t_fieldcat2-fieldname = 'WAERK'.
  t_fieldcat2-ref_table = 'VBAP'.
  t_fieldcat2-ref_field = 'WAERK'.
  append t_fieldcat2.
endform.                    " build_fcat_vbap
*&      Module  STATUS_0200  OUTPUT
      text
module STATUS_0200 output.
  SET PF-STATUS 'ITEM1'.
  SET TITLEBAR 'VBAP'.
  perform build_fcat_vbap.
  perform sort_alv2.
if t_cont2 is initial.
  create object t_cont2
    exporting
      container_name = 'ITEM'.
  create object t_alv2
    exporting
      i_parent = t_cont2.
  t_layout-grid_title = 'Item Details'.
  CALL METHOD t_alv2->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                     = t_layout
     IS_PRINT                      =
     IT_SPECIAL_GROUPS             =
      IT_TOOLBAR_EXCLUDING          = t_toolbar[]
     IT_HYPERLINK                  =
     IT_ALV_GRAPHICS               =
     IT_EXCEPT_QINFO               =
     IR_SALV_ADAPTER               =
    CHANGING
      it_outtab                     = t_vbap[]
      IT_FIELDCATALOG               = t_fieldcat2[]
      IT_SORT                       = t_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.
else.
  CALL METHOD t_alv2->refresh_table_display
   EXPORTING
     IS_STABLE      =
     I_SOFT_REFRESH =
   EXCEPTIONS
     FINISHED       = 1
     others         = 2
  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.
endmodule.                 " STATUS_0200  OUTPUT
*&      Module  USER_COMMAND_0200  INPUT
      text
module USER_COMMAND_0200 input.
case sy-ucomm.
  when 'GOBACK'.
    leave to screen 0.
endcase.
endmodule.                 " USER_COMMAND_0200  INPUT
*&      Form  sort_alv2
      text
-->  p1        text
<--  p2        text
form sort_alv2 .
clear t_sort.
t_sort-spos = '1'.
t_sort-fieldname = 'VBELN'.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
append t_sort.
endform.                    " sort_alv2
*&      Form  xclude_toolbar
      text
-->  p1        text
<--  p2        text
form xclude_toolbar .
t_toolbar = '&DETAIL'.
append t_toolbar.
t_toolbar = '&&SEP00'.
append t_toolbar.
t_toolbar = '&&SEP01'.
append t_toolbar.
t_toolbar = '&&SEP02'.
append t_toolbar.
t_toolbar = '&SORT_ASC'.
append t_toolbar.
t_toolbar = '&SORT_DSC'.
append t_toolbar.
t_toolbar = '&FIND'.
append t_toolbar.
t_toolbar = '&MB_FILTER'.
append t_toolbar.
t_toolbar = '&&SEP04'.
append t_toolbar.
t_toolbar = '&MB_SUM'.
append t_toolbar.
t_toolbar = '&MB_SUB_TOTAL'.
append t_toolbar.
t_toolbar = '&PRINT_BACK'.
append t_toolbar.
t_toolbar = '&MB_VIEW'.
append t_toolbar.
t_toolbar = '&MB_EXPORT'.
append t_toolbar.
t_toolbar = '&GRAPH'.
append t_toolbar.
t_toolbar = '&COLO'.
append t_toolbar.
t_toolbar = '&&SEP06'.
append t_toolbar.
t_toolbar = '&&SEP07'.
append t_toolbar.
t_toolbar = '&INFO'.
append t_toolbar.
t_toolbar = '&&SEP03'.
append t_toolbar.
endform.                    " xclude_toolbar
reward point if helpful.
thanks
mrutyun^

Similar Messages

  • Using instruction for creating field catalog to archive object "MM_MATNR"

    Hi all,
    I need a using instruction for creating a new field catalog to archive object "MM_MATNR". I'd like to create a field catalog using some fields of tables mara, makt, mvke and marc.
    Thanks for your help!

    Hi,
    Go to following link;
    [Material Master Archiving|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90f75a80-867f-2d10-7aa6-ac164e43e89f?quicklink=index&overridelayout=true]

  • Field Catalog from data object..

    Hi all,
    data:
    g_head_ref      TYPE REF TO data,
           g_item_ref      TYPE REF TO data.
        CALL BADI handle->set_header_item_data
          EXPORTING
            i_document_type    = g_document_type
            i_head_item        = g_head_item
            i_ab_document_type = doc_typ
            i_header_table     = g_header_table
            i_item_table       = g_item_table
            i_map_fields       = g_map_fields
          IMPORTING
            e_subrc            = l_subrc
            e_head_ref         = g_head_ref
            e_item_ref         = g_item_ref.
    here i get the g_data_ref and g_item_ref filled with the values..
    now i assigned these object to field symbols to display the same in the ALV.....
    Issues is follwoing-->
    I dont know the table structure or table name with which these ref object or the field symbols is type of now....
    (in this case it can be a local prog type defined structure..)..
    how can i create a fieldcatlog out of it..??
    I have already tried
    FM 'REUSE_ALV_FIELDCATALOG_MERGE' --> need an internal table with defined type...
    cl_abap_structdescr=>describe_by_data --> need a DDIC structure (in this case it can be a local prog type defined structure..)..
    if the class cl_abap_structdescr is the correct way to do it...please let me know exact flow of methods...if there is some other solution do let me know.
    Regards,
    Yadesh

    Hi
    i don't know what the variable g_map_fields, perhaps has it the definition of the table? if it's so you can use it to fill catalog table for ALV, else you can use CL_ABAP_STRUCTDESCR
    data: g_head_ref TYPE REF TO data.
    data: g_item_ref TYPE REF TO data.
    field-symbols: <fs_head> type table.
    field-symbols: <fs_wa> type any.
    data: l_comp type flag.
    DATA: MY_STRUCT TYPE REF TO CL_ABAP_STRUCTDESCR.
    ASSIGN g_head_ref->* TO <fs_head>.
    LOOP AT <fs_head> ASSIGNING <fs_wa>.
        MY_STRUCT ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <fs_wa> ).
        EXIT.
    ENDLOOP.
    Now in MY_STRUCT->COMPONENTS you have the definition of the table and u can use it in order to fill the catalog table for ALV
    Max

  • ABAP Objects v/s Field Symbols

    Hi,
    My query is:
    In ABAP Objects, reference variables can be assigned to each other.
    We can also assign the reference variable to a field symbol.
    Does that mean, that we can achieve the same functionality(like accessing a method of the class) using the field-symbols?
    If so, why not use field-symbols instead of objects? What are the other differences?
    Please provide your opinions.
    Regards
    s.a.k

    Hi,
    We can have any number of Field Symbols refering to One Variable or Object, but all these Field symbols refer to same memory location they donto have individual memory locations.
    Where are in Object, if diffrent objected are created refreing to one object all the objects have diffrent memory locations.
    Read the documentation of Field symbols and ABAP Objects you will get the clear diffrene.
    Regards,
    Kumar M.

  • Problem with Field catalog

    Hi,
    I am trying to create a condition table for inventory management. I require it at material group / movement type level. I added the fields ZZMATKL (type MATKL) and ZZBWART (type BWART) in the structure KOMPBZ2 (which is present in in the include of structure KOMPBME).
    I also added the two above custom fields in table V_T161F. But when I try to create a condition table I dont find the above two fields in the field catalog.
    Please help.
    Am I using an incorrect structure?
    Thanks!!
    Aroop

    Hi Friend,
      Looking at your code, I found that you have not the fieldcatalog at all.
    You need to fill the fieldcatalog with all the fields you want to display in the alv.
    Check the following links regarding field catalog:
    http://abap-gallery.blogspot.com/2007/07/field-catalog-in-alv.html
    Check this link for sample program:
    http://www.****************/Tutorials/ALV/SampleALVGridProgram.htm
    Hope this helps you.
    Any queries, get back to me.
    Regards,
    Chandra Sekhar

  • Build field catalog for dynamic data objects

    Hi
    Could you please tell me how to build a field catalog (ooops alv)  for an internal table which is a dynamic data object.
      TYPES: BEGIN OF t_addsubty,
             subty TYPE subty,
             pernr TYPE persno,
             END OF t_addsubty.
      TYPES: ty_addsubty type t_addsubty occurs 1.
    i have data object using these
            CREATE DATA dref3 TYPE (g_type1).
            ASSIGN dref3->* TO <fs_dp>.
    where g_type1 refers a data type which i defined in the program. g_type1 = ty_addsubty. 
    now <fs_dp> refers to an internal table.
    now i want to build a field catalog for this internal table.
    In my program <fs_dp> structure is not always the same. i.e now it is ty_addsubty but for some other conditions the structure is different.
    please help me out.
    regards
    badri

    Here some piece of code, which shows how it works:
    <SNIP>
    type-pools:
         abap.
    DATA:
      lr_tabledescr          TYPE REF TO cl_abap_tabledescr,
      lr_structdescr     TYPE REF TO cl_abap_structdescr.
    field-symbols:
      <lw_component>     type abap_compdescr_tab.
    TYPES:
         BEGIN OF t_addsubty,
              subty TYPE subty,
              pernr TYPE persno,
         END OF t_addsubty.
    TYPES:
         ty_addsubty type t_addsubty occurs 1.
    CREATE DATA dref3 TYPE (g_type1).
    ASSIGN dref3->* TO <fs_dp>.
    lr_tabledescr ?= cl_abap_tabledescr=>describe_by_data( <fs_dp> ).
    assert condition lr_tabledescr is bound.
    lr_structdescr ?= lr_tabledescr->get_table_line_type( ).
    loop at lr_structdescr->components assigning <lw_component>.
    *     do whatever you want with the information about
    *     the components of the structure
    endloop.
    </SNIP>
    Do not forget to reward points...

  • External field catalog & Info object catalogs - Role - in Flexible upload

    1) What is the role of Info Object catalogs maintained in the Data Basis & the Source Data Basis?
    Please be kind enough to mention a scenario u2013 underlining their utility in the consolidation process.
    Like u2026.
    Are they used for loading master data from source system to the BCS system?
    Can they be used in the flexible upload u2013 data collection function?
    Are they used for as a source of AFD data?
    I came across the below documentation on flexible upload - in an SAP material.
    *When uploading from a field catalog, you also have the option of using mapping. In this case, the file structure no longer has to correspond with the structure of the data basis.*
    Understood the above 2 points.
    *Rather, you can assign a BW InfoObjectCatalog that acts as the data structure description for the file here. You specify this InfoObjectCatalog in Customizing for the data basis.*
    2)Does the above statement implies that we need not do any setting in the field catalog tab of the flexible upload? If yes, what do we do?
    In the flexible upload u2013 field catalog tab u2013 we define the data structure for the file we upload (correct me if Iu2019m wrong).
    If you use an external field catalog, you have to specify how you want to map the data structure for the file to the structure for the data basis.
    3)Pls give an example of an external field catalog.
    4)Can we use an external field catalog in the upload of RFD?
    Many Thanks
    Kind Regards,
    Kumar

    There are two possibilities of using Infoobject catalog in SEM-BCS (it is true for both catalogs, characteristics and key figures):
    u2022     In a data basis. The system adds these chars and KFs that are sitting in the defined in the Data Basis catalogs to u201CAdditional Fieldsu201D of each data stream (the tab strip u201CData Stream Fieldsu201D in data basis. If you check some of these fields and generate data basis, these additional infoobjects will be placed into appropriate ODS/DSO objects and you will be able to use them for uploading of some extra information.
    Without indicating the Infoobject Catalog for Chars youu2019ll not be able to configure a new functionality of "assets/liabilities" at all.
    u2022     In a source data basis.
    After including source data basis to your data basis youu2019ll be able to use external infoobjects catalog in a method of the category Flexible Upload. Tick the flag of using the external catalog and choose the SDB. In the mapping tab youu2019ll have a possibility to choose from those chars and KFs that are located in the catalogs.
    This might be used for upload of ANY data, RFD, AFD or master data.
    The scenarios, I guess, are rather obvious.
    Hope this helps.

  • F4 help for field in ALV grid control (using ABAP objects)

    Hi All,
        I have created a z table ZTAB which is a master table( with single column X). field X should be a input field in ALV Grid through F4 key. I have created searchelp and assigned it to data element of X feild, and in domain level I have assigned ZTAB as value table.
        And in ALV field catalog wrote ls_fcat-ref_tab = 'ZTAB'. But still I'm not getting list of values when I press F4.
    Can anyone help me to understand what is missing here? How to call standardard F4 help?
    This is very urgent..
    Regards
    Jaker.

    u can refer to this standard program :BCALV_EDIT_08
    also u wont get the list of values automatically..
    declare a class :
    CLASS LCL_EVENT_HANDLER DEFINITION.
      PUBLIC SECTION.
        METHODS :
        handle_on_f4 for event onf4 of cl_gui_alv_grid
        importing e_fieldname es_row_no er_event_data,
    ENDCLASS.               "LCL_EVENT_HANDLER
    implementation of class
    here u pass ur internal table what u want to display as pop up for f4 help.
    *&       Class (Implementation)  LCL_EVENT_HANDLER
           Text
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Method to handle F4 click.
      Method handle_on_f4.
    Function to create a popup and passing the values of internal table in it.
          CALL FUNCTION 'POPUP_WITH_TABLE'
            EXPORTING
              ENDPOS_COL   = 60
              ENDPOS_ROW   = 60
              STARTPOS_COL = 5
              STARTPOS_ROW = 5
              TITLETEXT    = 'pop up'
            IMPORTING
              CHOICE       = wa_grid-zfield
            TABLES
              VALUETAB     = ITAB
            EXCEPTIONS
              BREAK_OFF    = 1
              OTHERS       = 2.
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            RETURN.
          ENDIF.
      endmethod.                    "handle_on_f4
    ENDCLASS.               "LCL_EVENT_HANDLER
    hope this gives u some idea.

  • Reg: Dynamic Field catalog in ALV

    Hi ,
    Can any one guide me to build a dynamic field catalog in ALV report?
    Below is the format which i expect..........
    Material    |     Plant1    |    Plant2    |    Plant3    | ....................|    Plant 20      |
    Qty
    Val
    Qty
    Val
    Qty
    Val
    Qty
    Val
    The plant 1 to 20 has to be brought dynamically as headings from T001W table. (Horizontally populate)
    Below each plant i need sub-headings "QTY" and "VAL".                                  (Horizontally populate)
    List of Materials should be brought vertically from MARA table.                          (Vertically populate)
    Can anyone suggest how to bring out this format for populating data accordingly into the o/p format?
    Ur help will be appreciated.
    Thanks,
    K.S.Kannan

    your part of the code is present in routine
    perform dynamic_table.
    *& Report ZCS_NAC_MAT_CHARACTERISTICS
    2/ Description ...: Business requirement is to get all materials
    without any characteristic values maintained in SAP
    which are given in the selection screen.
    REPORT znac_material_char.
    TYPE-POOLS : abap,
    slis.
    TABLES : kssk,
    klah,
    mara,
    makt,
    cabn,
    t134,
    t023.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv ,
    wa_fieldcat TYPE slis_fieldcat_alv.
    DATA : w_layout TYPE slis_layout_alv.
    DATA : st_layout TYPE slis_layout_alv.
    DATA : t_header TYPE slis_t_listheader,
    w_header TYPE slis_listheader.
    TYPES : BEGIN OF ty_cabn,
    atinn TYPE cabn-atinn,
    atnam TYPE cabn-atnam,
    END OF ty_cabn.
    DATA : i_cabn TYPE STANDARD TABLE OF ty_cabn WITH HEADER LINE.
    DATA : w_cabn LIKE i_cabn.
    TYPES : BEGIN OF ty_ausp,
    objek TYPE ausp-objek,
    atinn TYPE ausp-atinn,
    klart TYPE ausp-klart,
    END OF ty_ausp.
    DATA : i_ausp TYPE STANDARD TABLE OF ty_ausp WITH HEADER LINE.
    DATA : w_ausp LIKE i_ausp.
    TYPES : BEGIN OF ty_mara,
    matnr TYPE mara-matnr,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_mara.
    DATA : i_mara TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara LIKE i_mara.
    DATA : i_mara_temp TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara_temp LIKE i_mara_temp.
    TYPES :BEGIN OF ty_data,
    atnam TYPE cabn-atnam,
    atinn TYPE cabn-atinn,
    objek TYPE ausp-objek,
    klart TYPE ausp-klart,
    matnr TYPE mara-matnr,
    maktx TYPE makt-maktx,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_data.
    DATA : i_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
    DATA : w_data LIKE i_data.
    DATA : i_class TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class LIKE i_class.
    DATA : i_class_temp TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class_temp LIKE i_class_temp.
    DATA : i_objdata TYPE STANDARD TABLE OF clobjdat WITH HEADER LINE.
    DATA : w_objdata LIKE i_objdata.
    TYPES : BEGIN OF ty_objdata_temp.
    TYPES: matnr TYPE mara-matnr.
    TYPES: maktx TYPE makt-maktx.
    INCLUDE STRUCTURE clobjdat.
    TYPES : prdha TYPE mara-prdha.
    TYPES : mstde TYPE mara-mstde.
    TYPES : END OF ty_objdata_temp.
    DATA : i_objdata_temp TYPE STANDARD TABLE OF ty_objdata_temp WITH HEADER LINE.
    DATA : w_objdata_temp LIKE i_objdata_temp.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
    <fs_dyntable>,
    <fs_fldval> TYPE ANY.
    DATA: t_newtable TYPE REF TO data,
    t_newline TYPE REF TO data,
    fs_fldcat TYPE slis_t_fieldcat_alv,
    t_fldcat1 TYPE lvc_t_fcat,
    wa_it_fldcat TYPE lvc_s_fcat,
    wa_colno(2) TYPE n,
    wa_flname(30) TYPE c.
    DATA: fieldname(20) TYPE c.
    DATA: fieldvalue(40) TYPE c.
    DATA: index(3) TYPE c,
    v_time(60) TYPE c.
    DATA: wa_cat LIKE LINE OF fs_fldcat.
    CONSTANTS : c_nac TYPE klah-class VALUE 'NAC',
    c_klart TYPE ausp-klart VALUE '001',
    c_check TYPE c VALUE 'X' .
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (28) text-001 .
    SELECT-OPTIONS: s_atnam FOR cabn-atnam NO INTERVALS OBLIGATORY. " Characteristic name
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_matnr FOR mara-matnr. " material Number
    SELECT-OPTIONS: s_mtart FOR mara-mtart. " material type
    SELECT-OPTIONS: s_matkl FOR mara-matkl. " material type
    SELECT-OPTIONS: s_mstae FOR mara-mstae. " X-Plant material status
    PARAMETERS : s_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum . " date
    SELECTION-SCREEN END OF BLOCK b2 .
    AT SELECTION-SCREEN ON s_atnam.
    SELECT SINGLE * FROM cabn WHERE atnam IN s_atnam.
    IF sy-subrc 0.
    MESSAGE text-003 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matnr.
    SELECT SINGLE * FROM mara WHERE matnr IN s_matnr.
    IF sy-subrc 0.
    MESSAGE text-004 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_mtart.
    SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.
    IF sy-subrc 0.
    MESSAGE text-005 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matkl.
    SELECT SINGLE * FROM t023 WHERE matkl IN s_matkl.
    IF sy-subrc 0.
    MESSAGE text-006 TYPE 'E'.
    ENDIF.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM get_data_keydate.
    PERFORM material_all_charname.
    PERFORM get_classification.
    PERFORM dynamic_table.
    *& Form dynamic_table
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table.
    PERFORM fieldcatalog.
    PERFORM dynamic_table_create.
    PERFORM final_data.
    PERFORM final_fieldcatalog.
    PERFORM layout_build.
    PERFORM grid_display.
    ENDFORM. " fieldcat
    *& Form layout_build
    text
    FORM layout_build .
    st_layout-zebra = c_check.
    st_layout-no_vline = ''.
    st_layout-colwidth_optimize = c_check.
    st_layout-detail_popup = c_check.
    st_layout-detail_initial_lines = c_check.
    st_layout-detail_titlebar = text-021.
    ENDFORM. " layout_build
    *& Form alv_top_of_page
    text
    FORM alv_top_of_page.
    REFRESH t_header.
    CLEAR t_header.
    w_header-typ = 'H'. "H=Header, S=Selection, A=Action
    w_header-key = ' '.
    w_header-info = text-019.
    APPEND w_header TO t_header.
    CONCATENATE sy-datum4(2) '-' sy-datum6(2) '-' sy-datum0(4) ' / ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit4(2) INTO v_time.
    w_header-typ = 'S'. "H=Header, S=Selection, A=Action
    w_header-key = text-020.
    w_header-info = v_time.
    APPEND w_header TO t_header.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = t_header.
    ENDFORM. "alv_top_of_page
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    FORM grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
    it_fieldcat = fs_fldcat
    is_layout = st_layout
    i_default = c_check
    i_save = 'A'
    it_events = v_events[]
    TABLES
    t_outtab = <t_dyntable>.
    ENDFORM. " grid_display
    *& Form FINAL_FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM final_fieldcatalog .
    wa_cat-fieldname = text-009.
    wa_cat-seltext_m = text-015.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-011.
    wa_cat-seltext_m = text-016.
    wa_cat-outputlen = 40.
    APPEND wa_cat TO fs_fldcat.
    LOOP AT s_atnam.
    CLEAR wa_cat.
    wa_cat-fieldname = s_atnam-low.
    wa_cat-seltext_m = s_atnam-low.
    wa_cat-outputlen = '15'.
    APPEND wa_cat TO fs_fldcat.
    ENDLOOP.
    wa_cat-fieldname = text-012.
    wa_cat-seltext_m = text-017.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-013.
    wa_cat-seltext_m = text-018.
    wa_cat-outputlen = 8.
    APPEND wa_cat TO fs_fldcat.
    ENDFORM. " FINAL_FIELDCATALOG
    *& Form FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM fieldcatalog .
    wa_it_fldcat-fieldname = text-009.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-011.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 40.
    APPEND wa_it_fldcat TO t_fldcat1.
    LOOP AT s_atnam.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = s_atnam-low.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 30.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDLOOP.
    wa_it_fldcat-fieldname = text-012.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-013.
    wa_it_fldcat-datatype = text-014.
    wa_it_fldcat-intlen = 8.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDFORM. " FIELDCATALOG
    *& Form DYNAMIC_TABLE_CREATE
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table_create .
    Create dynamic internal table and assign to FS
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fldcat1
    IMPORTING
    ep_table = t_newtable.
    ASSIGN t_newtable->* TO <t_dyntable>.
    Create dynamic work area and assign to FS
    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
    ASSIGN t_newline->* TO <fs_dyntable>.
    ENDFORM. " DYNAMIC_TABLE_CREATE
    *& Form FINAL_DATA
    text
    --> p1 text
    <-- p2 text
    FORM final_data .
    LOOP AT i_objdata_temp INTO w_objdata_temp.
    *assign w_objdata_temp-matnr to <fs_dyntable>.
    AT NEW matnr.
    wa_flname = text-009.
    fieldvalue = w_objdata_temp-matnr.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    ENDAT.
    wa_flname = text-011.
    fieldvalue = w_objdata_temp-maktx.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = w_objdata_temp-atnam.
    fieldvalue = w_objdata_temp-ausp1.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-012.
    fieldvalue = w_objdata_temp-prdha.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-013.
    fieldvalue = w_objdata_temp-mstde.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    AT END OF matnr.
    APPEND <fs_dyntable> TO <t_dyntable>.
    ENDAT.
    ENDLOOP.
    ENDFORM. " FINAL_DATA
    *& Form GET_CLASSIFICATION
    text
    --> p1 text
    <-- p2 text
    FORM get_classification .
    LOOP AT i_data INTO w_data.
    SELECT SINGLE * FROM klah WHERE class = c_nac.
    IF sy-subrc = 0.
    IF w_data-mstde >= klah-vondt.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
    EXPORTING
    class = c_nac
    classtext = c_check
    classtype = c_klart
    clint = 0
    features = c_check
    language = sy-langu
    object = w_data-objek
    TABLES
    t_class = i_class
    t_objectdata = i_objdata
    EXCEPTIONS
    no_classification = 1
    no_classtypes = 2
    invalid_class_type = 3
    OTHERS = 4.
    LOOP AT i_class INTO w_class.
    MOVE w_class TO w_class_temp.
    APPEND w_class_temp TO i_class_temp.
    ENDLOOP .
    LOOP AT s_atnam.
    READ TABLE i_objdata INTO w_objdata WITH KEY atnam = s_atnam-low.
    IF sy-subrc = 0.
    MOVE w_data-matnr TO w_objdata_temp-matnr.
    MOVE w_data-maktx TO w_objdata_temp-maktx.
    MOVE-CORRESPONDING w_objdata TO w_objdata_temp.
    MOVE w_data-prdha TO w_objdata_temp-prdha.
    MOVE w_data-mstde TO w_objdata_temp-mstde.
    APPEND w_objdata_temp TO i_objdata_temp.
    ENDIF.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_CLASSIFICATION

  • Field catalog in OOP

    I have an internal table that needs to be displayed in ALV using abap objects. I have tried to use the sflight templates but I get error in i_structure and it_outtab , when I directly pass my internal table to them
    What is the solutions to this problem.
    If I am building a field catalog , then how to pass it to the screen
    Thankyou

    Hi
    refer this program you will find all the things
    reward if usefull
    *& Report  Z_ALV_OOPS
    REPORT  Z_ALV_OOPS.
    *Event class Definition                             "Event handler class
    class event_handle definition.
      public section.
        methods: handle_user
          for event user_command of cl_gui_alv_grid
          importing e_ucomm.
    endclass.
    *Event class Implementation
    class event_handle implementation.
      method handle_user.
        write:/ ''.
      endmethod.
    endclass.
    Data: t_alv       type ref to cl_gui_alv_grid,           "ALV control
          t_cont      type ref to cl_gui_custom_container,   "Cust Container
          t_alv2      type ref to cl_gui_alv_grid,           "ALV control
          t_cont2     type ref to cl_gui_custom_container,   "Cust Container
          t_fieldcat  type lvc_t_fcat with header line,      "Field Cat
          t_fieldcat2 type lvc_t_fcat with header line,      "Field Cat
          t_layout    type lvc_s_layo,                       "Layout
          t_event     type ref to event_handle,              "Event handler
          t_sort      type LVC_T_SORT with header line,      "Sort
          t_toolbar   type ui_functions with header line.    "Toolbar xclude
    Types: begin of g_vbak,                                 "Header Table
             vbeln like vbak-vbeln,
             auart like vbak-auart,
             vkorg like vbak-vkorg,
             vtweg like vbak-vtweg,
             spart like vbak-spart,
             kunnr like vbak-kunnr,
             bstnk like vbak-bstnk,
             seltab,
           end of g_vbak.
    Types: begin of g_vbap,                                  "Item Table
             vbeln like vbap-vbeln,
             posnr(6) type c,
    *         posrn like vbap-posnr,
             matnr like vbap-matnr,
             netwr like vbap-netwr,
             waerk like vbap-waerk,
           end of g_vbap.
    Data: t_vbak type g_vbak occurs 0,
          t_vbap type g_vbap occurs 0.
    Start-Of-Selection.
    *Fetch data from DB Table
    select vbeln auart vkorg vtweg spart kunnr bstnk
        from vbak into table t_vbak up to 20 rows.
    End-Of-Selection.
    *Call ALV screen
    call screen 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ALV'.
      SET TITLEBAR 'VBAK'.
    if t_cont is initial.
      create object t_cont
        exporting
          container_name = 'ALV'.
      create object t_alv
        exporting
          i_parent = t_cont.
    *Create event handlers
      create object t_event.
      set handler t_event->handle_user for t_alv.
      perform build_fieldcatlog.
      perform build_layout.
      perform xclude_toolbar.
      CALL METHOD t_alv->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                     = t_layout
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          = t_toolbar[]
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          IT_OUTTAB                     = t_vbak[]
          IT_FIELDCATALOG               = t_fieldcat[]
    *      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.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
    Data: lt_rows type lvc_t_row,
          wa_rows type line of lvc_t_row,
          wa_vbak type g_vbak,
          l_lines type i.
    refresh: t_vbap.
    case sy-ucomm.
      when 'DET'.                                  "Item details
    *   Get selected rows from ALV
        call method t_alv->get_selected_rows
            importing
                et_index_rows = lt_rows.
    *   Fetch corresponding Item details from VBAP
        loop at lt_rows into wa_rows.
          read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                    vbeln.
          select vbeln posnr matnr netwr waerk from vbap
              appending corresponding fields of table t_vbap
              where vbeln = wa_vbak-vbeln.
        endloop.
    *   Prepare fieldcatlog
    *   Display Item details in ALV
        call screen 200 starting at 8 5.
      when 'SHOW'.                                  "Display order
        call method t_alv->get_selected_rows
            importing
                et_index_rows = lt_rows.
        Describe table lt_rows lines l_lines.
        if l_lines > 1.
          message e999(z_error).
        else.
          read table lt_rows into wa_rows index 1.
          read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                    vbeln.
          set parameter id 'AUN' field wa_vbak-vbeln.
          call transaction 'VA03' and skip first screen.
        endif.
    endcase.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  build_fieldcatlog
    *       text
    form build_fieldcatlog .
      clear t_fieldcat.
      t_fieldcat-col_pos = '1'.
      t_fieldcat-fieldname = 'VBELN'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VBELN'.
      append t_fieldcat.
      t_fieldcat-col_pos = '2'.
      t_fieldcat-fieldname = 'AUART'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'AUART'.
      append t_fieldcat.
      t_fieldcat-col_pos = '3'.
      t_fieldcat-fieldname = 'VKORG'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VKORG'.
      append t_fieldcat.
      t_fieldcat-col_pos = '4'.
      t_fieldcat-fieldname = 'VTWEG'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VTWEG'.
      append t_fieldcat.
      t_fieldcat-col_pos = '5'.
      t_fieldcat-fieldname = 'SPART'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'SPART'.
      append t_fieldcat.
      t_fieldcat-col_pos = '6'.
      t_fieldcat-fieldname = 'KUNNR'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'KUNNR'.
      append t_fieldcat.
      t_fieldcat-col_pos = '7'.
      t_fieldcat-fieldname = 'BSTNK'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'BSTNK'.
      append t_fieldcat.
    endform.                    " build_fieldcatlog
    *&      Module  LEAVE  INPUT
    *       text
    module LEAVE input.
    case sy-ucomm.
      when 'BACK' or 'EXIT' or 'CANCEL'.
        leave program.
    endcase.
    endmodule.                 " LEAVE  INPUT
    *&      Form  build_layout
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form build_layout .
    t_layout-zebra = 'X'.
    t_layout-sel_mode = 'A'.
    t_layout-grid_title = 'Header Details'.
    endform.                    " build_layout
    *&      Form  build_fcat_vbap
    *       text
    form build_fcat_vbap .
      clear t_fieldcat2.
      t_fieldcat2-scrtext_m = 'Sales Doc'.
      t_fieldcat2-col_pos = 1.
      t_fieldcat2-fieldname = 'VBELN'.
      t_fieldcat2-tabname = 'T_VBAP'.
      t_fieldcat2-no_zero = 'X'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'VBELN'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 2.
      t_fieldcat2-scrtext_m = 'Item'.
      t_fieldcat2-fieldname = 'POSNR'.
      t_fieldcat2-tabname = 'T_VBAP'.
      t_fieldcat2-intlen = '6'.
      t_fieldcat2-inttype = 'C'.
      t_fieldcat2-no_zero = 'X'.
    *  t_fieldcat2-ref_table = 'VBAP'.
    *  t_fieldcat2-ref_field = 'POSNR'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 3.
      t_fieldcat2-fieldname = 'MATNR'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'MATNR'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 4.
      t_fieldcat2-fieldname = 'NETWR'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'NETWR'.
      t_fieldcat2-do_sum = 'X'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 5.
      t_fieldcat2-fieldname = 'WAERK'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'WAERK'.
      append t_fieldcat2.
    endform.                    " build_fcat_vbap
    *&      Module  STATUS_0200  OUTPUT
    *       text
    module STATUS_0200 output.
      SET PF-STATUS 'ITEM1'.
      SET TITLEBAR 'VBAP'.
      perform build_fcat_vbap.
      perform sort_alv2.
    if t_cont2 is initial.
      create object t_cont2
        exporting
          container_name = 'ITEM'.
      create object t_alv2
        exporting
          i_parent = t_cont2.
      t_layout-grid_title = 'Item Details'.
      CALL METHOD t_alv2->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                     = t_layout
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          = t_toolbar[]
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
    *      IR_SALV_ADAPTER               =
        CHANGING
          it_outtab                     = t_vbap[]
          IT_FIELDCATALOG               = t_fieldcat2[]
          IT_SORT                       = t_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.
    else.
      CALL METHOD t_alv2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
    *    EXCEPTIONS
    *      FINISHED       = 1
    *      others         = 2
      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.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
    *       text
    module USER_COMMAND_0200 input.
    case sy-ucomm.
      when 'GOBACK'.
        leave to screen 0.
    endcase.
    endmodule.                 " USER_COMMAND_0200  INPUT
    *&      Form  sort_alv2
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form sort_alv2 .
    clear t_sort.
    t_sort-spos = '1'.
    t_sort-fieldname = 'VBELN'.
    t_sort-up = 'X'.
    t_sort-subtot = 'X'.
    append t_sort.
    endform.                    " sort_alv2
    *&      Form  xclude_toolbar
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form xclude_toolbar .
    t_toolbar = '&DETAIL'.
    append t_toolbar.
    t_toolbar = '&&SEP00'.
    append t_toolbar.
    t_toolbar = '&&SEP01'.
    append t_toolbar.
    t_toolbar = '&&SEP02'.
    append t_toolbar.
    t_toolbar = '&SORT_ASC'.
    append t_toolbar.
    t_toolbar = '&SORT_DSC'.
    append t_toolbar.
    t_toolbar = '&FIND'.
    append t_toolbar.
    t_toolbar = '&MB_FILTER'.
    append t_toolbar.
    t_toolbar = '&&SEP04'.
    append t_toolbar.
    t_toolbar = '&MB_SUM'.
    append t_toolbar.
    t_toolbar = '&MB_SUB_TOTAL'.
    append t_toolbar.
    t_toolbar = '&PRINT_BACK'.
    append t_toolbar.
    t_toolbar = '&MB_VIEW'.
    append t_toolbar.
    t_toolbar = '&MB_EXPORT'.
    append t_toolbar.
    t_toolbar = '&GRAPH'.
    append t_toolbar.
    t_toolbar = '&COLO'.
    append t_toolbar.
    t_toolbar = '&&SEP06'.
    append t_toolbar.
    t_toolbar = '&&SEP07'.
    append t_toolbar.
    t_toolbar = '&INFO'.
    append t_toolbar.
    t_toolbar = '&&SEP03'.
    append t_toolbar.
    endform.                    " xclude_toolbar

  • Upload an excel file input into an itab,display in ALV using ABAP objects

    Requirement:
    Create a selection screen which takes an excel file as input with parameters emp id, emp name, salary, mnth, ph no.
    Create a database table with the same fields.
    The program needs to have two modes. Display mode and update mode.
    Display mode only displays the file data in alv grid and update mode updates database table with similar parameters as above and also shows alv grid output.
    task is to do using Object oriented approach. This should also have the facility to modify the cell values in ALV grid and once saved then it needs to update the database accordingly.
    I have done the same functionality in a report program without using ABAP objects but finding difficulty in using object oriented approach.Please help me as i am new to abap-objects.
    Thanks in advance.......

    Hi,
    The selection screen design and all remains the same.
    Get all the detials which you need in your final internal table.
    This internal table will be used to display in the ALV grid.
    The approach remains the same as the normal programing.
    Prepare a field catalog table and then use it along with the internal table to display in the grid.
    The only change is that instead of FM you will have to make us of classes and their methods.
    Firstly you will have to create a screen.
    On this screen create a custom control object and give it some name. say for eg. CC_CONTAINER.
    This will be a container on which the ALV grid object will be placed.
    2 objects are needed to display the grid
    CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID.
    In the PBO of the screen first create an instance of object CL_GUI_CUSTOM_CONTAINER
    CREATE OBJECT y_lobj_cont
          EXPORTING
             container_name              = 'CC_CONTAINER'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Then create a instance of the GRID
    IF y_lobj_grid IS INITIAL.
          CREATE OBJECT y_lobj_grid
            EXPORTING
              i_parent          = y_lobj_cont
             EXCEPTIONS
               error_cntl_create = 1
               error_cntl_init   = 2
               error_cntl_link   = 3
               error_dp_create   = 4
               OTHERS            = 5 .
          IF sy-subrc NE 0.
            MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
                       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ENDIF.
    Then call the method SET_TABLE_FOR_FIRST_DISPLAY to display the grid.
    CALL METHOD y_lobj_grid->set_table_for_first_display
          EXPORTING
            it_toolbar_excluding          = y_v_lt_exclude
          CHANGING
            it_outtab                     = y_li_tbl
            it_fieldcatalog               = y_li_fcat
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Check the example program BCALV_GRID_EDIT for better understanding.
    Regards,
    Ankur Parab

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        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."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        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."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->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               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      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.
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_error = 1
            OTHERS     = 2.
        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."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 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.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        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."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->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               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      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.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_error = 1
            OTHERS     = 2.
        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."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 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.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        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."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->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               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      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.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 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.
    ENDFORM.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 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.
    ENDFORM.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Adding leading zeros in abap objects.

    Can anyone explain me
    1. How to add leading zeros to a field in abap objects.
    For eg:
    data: dmb(6) type c value '123456',
    actually the output value of c should have leading zeros added to it for length 16.
    i.e '0000000000123456' . If the length of dmb is less than 16 then leading zeros should be added to that value to make it 16 as length.
    Please tell me how to do it in ABAP Objects.

    Hi Camila
    Try to use the statement
    DATA: ALPHABET(15) VALUE '     ABCDEFGHIJ',
          M1(4)        VALUE 'ABCD',
          M2(6)        VALUE 'BJJCA '.
    SHIFT ALPHABET LEFT DELETING LEADING M1.
    The field
    ALPHABET
    remains unchanged.
    SHIFT ALPHABET LEFT DELETING LEADING SPACE.
    The field ALPHABET now has the following contents:
    'ABCDEFGHIJ     '.
    SHIFT ALPHABET RIGHT DELETING TRAILING M2.
    <b>ALPHABET</b> now has the following contents:
    '      ABCDEFGHI'.
    <u><b>IN CHARACTER MODE</b></u>
    <b>Effect</b>
    This is the default setting (see above), and the addition is therefore optional.
    <b>Note
    Performance:</b>
    For performance reasons, you should avoid using SHIFT in WHILE loops.
    The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ...
    LEFT DELETING LEADING
    ... variant is around 3.5 msn, for ...
    RIGHT DELETING TRAILING
    ... around 4.5 msn.
    Reward all helpfull answers
    Regards
    Pavan

  • Dynamic documents in ABAP Objects (weblog)

    Hi SDNers,
    Do you want to implement the following features in ABAP Screens?
    1. Large font sizes and more colour options than traditional ABAP/4 (There are some limitations also)
    2. ICONS and pictures in different sizes
    3. Texts
    4. Links
    5. Pushbuttons
    6. Input fields
    7. Dropdown list boxes
    8. Tables with row span and with column span
    9. Tables with frames and without frames
    10. Tables with buttons, icons, pictures, input elements and texts in it.
    Then please read the below weblog to incorporate these features...
    <a href="/people/venkata.ramisetti/blog/2005/12/20/dynamic-documents-in-abap-objects">Dynamic Documents in ABAP Objects</a>
    Thanks,
    Ramakrishna

    one limitation which comes to my mind immediately is that you cannot create spool output of the dynamic document.
    Regards
    Raja

  • Single click in abap objects

    hi,
        can any1 pls explain me the single click event LINK_CLICK in abap object.
    does this single click event mean that if i click anywhere on my alv report it will trigger the event.
       pls explain me about this LINK_CLICK event in details pls

    answered the similar question last week. You can see here Event
    Link_click or ALV_Object Model HYPERLINK.
    This example demonstrates how to use a Hiperlink field in ALV. These example was based on 'SALV_DEMO_TABLE_COLUMNS' that contains Hiperlink, icon, Hotspot...
    The Code is:
    REPORT zsalv_mar NO STANDARD PAGE HEADING.
          CLASS lcl_handle_events DEFINITION
    CLASS lcl_handle_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          on_link_click FOR EVENT link_click OF cl_salv_events_table
            IMPORTING row column.
    ENDCLASS.                    "lcl_handle_events DEFINITION
          CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD on_link_click.
        DATA: l_row_string TYPE string,
              l_col_string TYPE string,
              l_row        TYPE char128.
        WRITE row TO l_row LEFT-JUSTIFIED.
        CONCATENATE text-i02 l_row INTO l_row_string SEPARATED BY space.
        CONCATENATE text-i03 column INTO l_col_string SEPARATED BY space.
        MESSAGE i000(0k) WITH 'Single Click' l_row_string l_col_string.
      ENDMETHOD.                    "on_single_click
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION
    DATA: gr_events TYPE REF TO lcl_handle_events.
    TYPES: BEGIN OF g_type_s_outtab.
    INCLUDE TYPE alv_tab.
    TYPES:   t_hyperlink TYPE salv_t_int4_column,
           END   OF g_type_s_outtab.
    DATA: gt_outtab TYPE STANDARD TABLE OF g_type_s_outtab.
    DATA: gr_table   TYPE REF TO cl_salv_table.
    TYPES: BEGIN OF g_type_s_hyperlink,
             handle    TYPE salv_de_hyperlink_handle,
             hyperlink TYPE service_rl,
             carrid    TYPE s_carrid,
           END   OF g_type_s_hyperlink.
    DATA: gt_hyperlink TYPE STANDARD TABLE OF g_type_s_hyperlink.
    SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.
    PARAMETERS: p_amount TYPE i DEFAULT 30.
    SELECTION-SCREEN END OF BLOCK gen.
    START-OF-SELECTION.
      PERFORM select_data.
      PERFORM display.
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    FORM select_data .
      DATA: line_outtab  TYPE g_type_s_outtab,
            ls_hype      TYPE g_type_s_hyperlink,
            lt_hyperlink TYPE salv_t_int4_column,
            ls_hyperlink TYPE salv_s_int4_column,
            v_tabix      TYPE sytabix.
      SELECT *
        FROM alv_tab
        INTO CORRESPONDING FIELDS OF TABLE gt_outtab
            UP TO p_amount ROWS.
      LOOP AT gt_outtab INTO line_outtab.
        v_tabix = sy-tabix.
        ls_hype-handle    = sy-tabix.
        ls_hype-hyperlink = line_outtab-url.
        ls_hype-carrid    = line_outtab-carrid.
        INSERT ls_hype INTO TABLE gt_hyperlink.
        ls_hyperlink-columnname = 'URL'.
        ls_hyperlink-value      = sy-tabix.
        APPEND ls_hyperlink TO lt_hyperlink.
        line_outtab-t_hyperlink = lt_hyperlink.
        MODIFY gt_outtab FROM line_outtab INDEX v_tabix.
        CLEAR line_outtab.
        CLEAR lt_hyperlink.
        CLEAR ls_hyperlink.
      ENDLOOP.
    ENDFORM.                    " select_data
    *&      Form  display
          text
    -->  p1        text
    <--  p2        text
    FORM display .
      TRY.
          cl_salv_table=>factory(
            IMPORTING
              r_salv_table = gr_table
            CHANGING
              t_table      = gt_outtab ).
        CATCH cx_salv_msg.                                  "#EC NO_HANDLER
      ENDTRY.
      DATA: lr_functions TYPE REF TO cl_salv_functions_list.
      lr_functions = gr_table->get_functions( ).
      lr_functions->set_default( abap_true ).
    *... set the columns technical
      DATA: lr_columns TYPE REF TO cl_salv_columns_table,
            lr_column  TYPE REF TO cl_salv_column_table.
      lr_columns = gr_table->get_columns( ).
      lr_columns->set_optimize( abap_true ).
    *... §4.7 set hyperlink column
      DATA: lr_hyperlinks TYPE REF TO cl_salv_hyperlinks,
            ls_hyperlink  TYPE g_type_s_hyperlink.
      DATA: lr_functional_settings TYPE REF TO cl_salv_functional_settings.
      TRY.
          lr_columns->set_hyperlink_entry_column( 'T_HYPERLINK' ).
        CATCH cx_salv_data_error.                           "#EC NO_HANDLER
      ENDTRY.
      TRY.
          lr_column ?= lr_columns->get_column( 'URL' ).
          lr_column->set_cell_type( if_salv_c_cell_type=>link ).
          lr_column->set_long_text( 'URL' ).
        CATCH cx_salv_not_found.                            "#EC NO_HANDLER
      ENDTRY.
      lr_functional_settings = gr_table->get_functional_settings( ).
      lr_hyperlinks = lr_functional_settings->get_hyperlinks( ).
      LOOP AT gt_hyperlink INTO ls_hyperlink.
        TRY.
            lr_hyperlinks->add_hyperlink(
              handle    = ls_hyperlink-handle
              hyperlink = ls_hyperlink-hyperlink ).
          CATCH cx_salv_existing.                           "#EC NO_HANDLER
        ENDTRY.
      ENDLOOP.
      DATA: lr_events TYPE REF TO cl_salv_events_table.
      lr_events = gr_table->get_event( ).
      CREATE OBJECT gr_events.
      SET HANDLER gr_events->on_link_click FOR lr_events.
      gr_table->display( ).
    ENDFORM.                    " display

Maybe you are looking for