terça-feira, 18 de julho de 2023

Calling method from another class from another program

PROGRAM 1

 REPORT y_test_prog1.

DATA lv_cc TYPE bkpf-bukrs.

CLASS lcl_local_class DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS :
      cc_code IMPORTING lv_cc TYPE bkpf-bukrs.
ENDCLASS.

CLASS lcl_local_class IMPLEMENTATION.
  METHOD cc_code.
    IF lv_cc = ‘1000’.
      WRITE  lv_cc.
    ELSE.
      WRITE : ‘Worked’ , lv_cc.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  lv_cc = ‘1000’.
  CALL METHOD lcl_local_class=>cc_code
    EXPORTING
      lv_cc = lv_cc.

PROGRAM 2

REPORT y_test_prog2.

PARAMETER  lv_cc TYPE bkpf-bukrs.

DATA : go_test         TYPE REF TO object,
       ge_abs_typename TYPE string
          VALUE ‘\PROGRAM=Y_TEST_PROG1\CLASS=LCL_LOCAL_CLASS’.

START-OF-SELECTION.
  CREATE OBJECT go_test TYPE (ge_abs_typename).
BREAK-POINT.
  CALL METHOD go_test->(‘CC_CODE’)
    EXPORTING
      lv_cc = lv_cc.

Nenhum comentário:

Postar um comentário