Skip to Content
author's profile photo Former Member
Former Member

What is the wrong in this code

*&---------------------------------------------------------------------*
*& Report  ZTESTTEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztesttest LINE-SIZE 256.
TYPE-POOLS: slis.

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE ,
               <dyn_wa>,
               <dyn_field>.
FIELD-SYMBOLS: <dyn_table1> TYPE STANDARD TABLE ,
               <dyn_wa1>,
               <dyn_field1>.

DATA: alv_fldcat TYPE slis_t_fieldcat_alv,
      it_fldcat TYPE lvc_t_fcat.

TYPE-POOLS : abap.

DATA : it_details TYPE abap_compdescr_tab,
       wa_details TYPE abap_compdescr.
DATA :itab TYPE abap_component_tab.
*----------------------------------------------------------------------*
*       CLASS cl_my_structure  DEFENITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_my_structure DEFINITION.
  PUBLIC  SECTION.
    METHODS: x.
  PROTECTED SECTION.

  PRIVATE SECTION.



ENDCLASS.                    "cl_my_structure  DEFENITION
*----------------------------------------------------------------------*
*       CLASS cl_my_structure IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_my_structure IMPLEMENTATION.
  METHOD x.
    WRITE 'HI'.
  ENDMETHOD.                    "x
ENDCLASS.                    "cl_my_structure IMPLEMENTATION


DATA : ref_descr TYPE REF TO cl_abap_structdescr.

DATA: new_table TYPE REF TO data,
      new_line  TYPE REF TO data,
      wa_it_fldcat TYPE lvc_s_fcat.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text .
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.

* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 03:07 PM

    I'm not sure what you are exactly trying to achieve, but at a glance the code is missing the event heading start-of-selection making the last statement inaccessable.

    Also you aren't invoking any of the methods in your local class.

    You'd need something like this after the selection screen definition.

    -


    start-of-selection.

    data: lv_my_obj type ref to cl_my_structure.

    create object lv_my_obj.

    lv_my_obj->x( ).

    • Get the structure of the table.

    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).

    -


    Regards

    Darren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 03:03 PM

    <b>abap_component_tab</b> does not exist...At least not on my system....Comment that and works fine....

    Greetings,

    Blag.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2007 at 03:04 PM

    That depends on what you want it to do. Do you want it to write "Hi"? If so...

    
    report  ztesttest line-size 256.
    *type-pools: slis.
    *
    *field-symbols: <dyn_table> type standard table ,
    *               <dyn_wa>,
    *               <dyn_field>.
    *field-symbols: <dyn_table1> type standard table ,
    *               <dyn_wa1>,
    *               <dyn_field1>.
    *
    *data: alv_fldcat type slis_t_fieldcat_alv,
    *      it_fldcat type lvc_t_fcat.
    *
    *type-pools : abap.
    *
    *data : it_details type abap_compdescr_tab,
    *       wa_details type abap_compdescr.
    *data :itab type abap_component_tab.
    *----------------------------------------------------------------------*
    *       CLASS cl_my_structure  DEFENITION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    class cl_my_structure definition.
      public  section.
        methods: x.
      protected section.
    
      private section.
    
    
    
    endclass.                    "cl_my_structure  DEFENITION
    *----------------------------------------------------------------------*
    *       CLASS cl_my_structure IMPLEMENTATION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    class cl_my_structure implementation.
      method x.
        write 'HI'.
      endmethod.                    "x
    endclass.                    "cl_my_structure IMPLEMENTATION
    
    
    *data : ref_descr type ref to cl_abap_structdescr.
    *
    *data: new_table type ref to data,
    *      new_line  type ref to data,
    *      wa_it_fldcat type lvc_s_fcat.
    
    data: o_ref type ref to cl_my_structure.
    
    selection-screen begin of block b1 with frame title text .
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    
    start-of-selection.    "<--  YES, YOU NEED THIS.
    
    create object o_ref .
    call method o_ref->x.
    
    * Get the structure of the table.
    *ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    
    

    Regards,

    RIch Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 03:02 PM

    use start-of-selection.

    <b>START-OF-SELECTION.</b>

    • Get the structure of the table.

    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 03:03 PM

    Hi,

    In the type pool there is no component called abap_component_tab.

    DATA :itab TYPE abap_component_tab.

    The above line is error in the code.

    And also last line is also wrong

    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table )

    Reward if helpful.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.