Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

What is the wrong in this code

Former Member
0 Likes
989

*&---------------------------------------------------------------------*
*& 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 ).
1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
945

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

10 REPLIES 10
Read only

Former Member
0 Likes
945

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 ).

Read only

Former Member
0 Likes
945

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

Greetings,

Blag.

Read only

Former Member
0 Likes
945

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.

Read only

0 Likes
945

Sorry Shankar,

This is not the error. Just comment the method X then you will not find the error.

Regards,

Lisa.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
945

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

Read only

0 Likes
945

Hi `Rich,

I understood what you mean to ask me but my question is diffrent. On the sysntax check i am getting an error. When i comment the method in the local class then the syntax error will not exist.

Could you please explain me what is the reason for it.

Regards,

Lisa.

Read only

0 Likes
945

What is the error?

Regards,

RIch Heilman

Read only

Former Member
0 Likes
946

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

Read only

0 Likes
945

Hi,

May i know why do i need toput this start of selection?

Regards,

Lisa.

Read only

0 Likes
945

Hi Lisa,

This events lets the system know from where the execution of code will start.

Ashven