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

Excluding abstract classes

omar_saber
Explorer
0 Likes
5,517

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
Read only

xiaosanyu
Participant
5,423
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
Read only

xiaosanyu
Participant
5,423

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.
Read only

0 Likes
5,423

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

Read only

5,423

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

Read only

0 Likes
5,423

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?

Read only

0 Likes
5,423

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

Read only

0 Likes
5,423
    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:

Read only

0 Likes
5,423

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

Read only

0 Likes
5,423

It's a class name

Read only

0 Likes
5,423
 CLSNAME = 'ZMAR_HANDSON2'
Read only

0 Likes
5,423

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:

Read only

0 Likes
5,423

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

Read only

matt
Active Contributor
0 Likes
5,423

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

Read only

omar_saber
Explorer
0 Likes
5,423

I added, thank you for letting me know 🙂

Read only

xiaosanyu
Participant
5,424
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.

Read only

0 Likes
5,423

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 🙂

Read only

0 Likes
5,423

Cheer. 💪

Read only

Sandra_Rossi
Active Contributor
0 Likes
5,423

It's worse, you have removed the code!