Application Development 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: 

Excluding abstract classes

omar_saber
Explorer
0 Kudos
1,183

Hello everyone,

I have one interface which is used for 3 classes and I have one class from this classes is Abstract class I need a way to to exclude this class when I call the program, please find my code here:

1 ACCEPTED SOLUTION

xiaosanyu
Participant
1,089
LOOP AT lt_classes ASSIGNING FIELD-SYMBOL(<print_cl>).


    DATA: get TYPE REF TO zmar_if_handson .


    CREATE OBJECT get TYPE (<print_cl>-clsname).


    SELECT SINGLE @abap_true INTO @DATA(lv_exists) FROM seoclassdf WHERE clsname= @<print_cl>-clsname AND clsabstrct = @abap_true.
    IF sy-subrc = 0 AND lv_exists = abap_true.
      ls_output-daemon_name = get->naming( ).
      ls_output-priority = get->priority( ).
      ls_output-damon_config = get->get_daemon_start_config( ).
      APPEND ls_output TO lt_output.
    ENDIF.
  ENDLOOP.


You need to review the basic grammar of ABAP.

17 REPLIES 17

xiaosanyu
Participant
1,089

TABLE: "SEOCLASSDF"
FIELD: "CLSABSTRCT" = 'X'

SELECT SINGLE @ABAP_TRUE INTO @DATA(LV_EXISTS) FROM SEOCLASSDF WHERE CLSNAME= @<print_cl>-clsname AND CLSABSTRCT = @ABAP_TRUE.
IF SY-SUBRC = 0 AND LV_EXISTS = ABAP_TRUE.
" ABSTRCT CLASS
ELSE.
ENDIF.

0 Kudos
1,089

Thank you for your answer, but can you please explain more?

1,089

SE16N, paste your classname into the SEOCLASSDF-CLSNAME, observe the value of CLSABSTRCT and you will understand.

0 Kudos
1,089

I Understand now but when i pass my class name into CLSNAME = @myclass_name I get an error says that this field is uknown IDK why, do you have why is this happening?

0 Kudos
1,089

Please provide a screenshot of the error & paste your code.

0 Kudos
1,089
    SELECT SINGLE @ABAP_TRUE INTO @DATA(LV_EXISTS) FROM SEOCLASSDF WHERE CLSNAME =  @ZMAR_HANDSON2 AND CLSABSTRCT = @ABAP_TRUE.
IF sy-subrc = 0 and lv_exists = ABAP_TRUE.
ELSE.
ENDIF.

And this is my error:

0 Kudos
1,089

What's 'ZMAR_HANDSON2' mean? Class name or Variable name?

0 Kudos
1,089

It's a class name

0 Kudos
1,089
 CLSNAME = 'ZMAR_HANDSON2'

0 Kudos
1,089

Yes the error is gone thank you, but it didn't select the class from the 3 classes which using the same interface, I use this line in this loop

'' lt_classes'' is a table which conssest the 3 classes which using the same interface and this is the error:

0 Kudos
1,089

omar.saber Better post code as text rather than image (impossible to copy/paste)

matt
Active Contributor
0 Kudos
1,089

Please use the CODE button when pasting code. It makes it easier to read and you're more likely to get an answer.

omar_saber
Explorer
0 Kudos
1,089

I added, thank you for letting me know 🙂

xiaosanyu
Participant
1,090
LOOP AT lt_classes ASSIGNING FIELD-SYMBOL(<print_cl>).


    DATA: get TYPE REF TO zmar_if_handson .


    CREATE OBJECT get TYPE (<print_cl>-clsname).


    SELECT SINGLE @abap_true INTO @DATA(lv_exists) FROM seoclassdf WHERE clsname= @<print_cl>-clsname AND clsabstrct = @abap_true.
    IF sy-subrc = 0 AND lv_exists = abap_true.
      ls_output-daemon_name = get->naming( ).
      ls_output-priority = get->priority( ).
      ls_output-damon_config = get->get_daemon_start_config( ).
      APPEND ls_output TO lt_output.
    ENDIF.
  ENDLOOP.


You need to review the basic grammar of ABAP.

0 Kudos
1,089

I am a beginner to ABAP programming and have only been started 3 weeks ago so I still learning, But thank you very much for your help, I am really appreciate it 🙂

0 Kudos
1,089

Cheer. 💪

Sandra_Rossi
Active Contributor
0 Kudos
1,089

It's worse, you have removed the code!