Hi,

 Im trying to implement a BADI which takes Customer Number(KUNNR)  and gets the Customer Name.But im getting a error at INTERFACE when i define.

alt text

and when i execute my BAdI in se38,i get a short dump saying..

alt text

My Method Code:

    method YIN_GET_KNA1NAME~GET_NAME.

     IF KUNNR IS NOT INITIAL.

      TYPES:

          BEGIN OF TY_KNA1,

            KUNNR TYPE KNA1-KUNNR,

            NAME1 TYPE KNA1-NAME1,

          END OF TY_KNA1.

      DATA:

            WA_KNA1 TYPE TY_KNA1,

            IT_KNA1 TYPE STANDARD TABLE OF TY_KNA1.

      SELECT KUNNR NAME1 INTO TABLE IT_KNA1 FROM KNA1 WHERE KUNNR = KUNNR.

      IF SY-SUBRC NE 0.

        READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = KUNNR.

        NAME1 = WA_KNA1-NAME1.

      ENDIF.

    ENDIF.

  endmethod.

SE38 Program Code:

REPORT  Y_BADI_1.

  CLASS CL_EXITHANDLER DEFINITION LOAD.

  DATA:

        Y_BADI_INSTANCE TYPE REF TO YIN_GET_KNA1NAME.

    DATA:

        YNAME1 TYPE KNA1-NAME1.

    PARAMETERS:

        P_KUNNR TYPE KNA1-KUNNR.

      START-OF-SELECTION.

        CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

        EXPORTING

          EXIT_NAME                     = 'YBADI_GET_KNA1NAME'

          NULL_INSTANCE_ACCEPTED        = 'X'

*        IMPORTING

*          ACT_IMP_EXISTING              =

        CHANGING

          INSTANCE                      = Y_BADI_INSTANCE

*        EXCEPTIONS

*          NO_REFERENCE                  = 1

*          NO_INTERFACE_REFERENCE        = 2

*          NO_EXIT_INTERFACE             = 3

*          CLASS_NOT_IMPLEMENT_INTERFACE = 4

*          SINGLE_EXIT_MULTIPLY_ACTIVE   = 5

*          CAST_ERROR                    = 6

*          EXIT_NOT_EXISTING             = 7

*          DATA_INCONS_IN_EXIT_MANAGEM   = 8

*          others                        = 9

              .

      IF SY-SUBRC <> 0.

*       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

          CALL METHOD Y_BADI_INSTANCE->GET_NAME

        EXPORTING

          KUNNR  = P_KUNNR

        IMPORTING

          NAME1  = YNAME1

          .

      WRITE: YNAME1.

asked 23 Mar '12, 07:58

bobby's gravatar image

bobby
1464513
accept rate: 0%

edited 23 Mar '12, 08:45

pedrolima's gravatar image

pedrolima ♦♦
1.1k232840


If you change the interface method to use changing for the name1 instead of export it should not give the error in the interface.

And for running new BADIs the test program must be different. Se an example below. Also remember to set the "Implementation is active" in the implementation.

data:
  y_badi_instance type ref to ybadi_3_kna1,
  yname1 type name1.

parameters:
  p_kunnr type kna1-kunnr.

    start-of-selection.
      get badi y_badi_instance.

      call badi y_badi_instance->get_name
        exporting
          kunnr = p_kunnr
        changing
          name1 = yname1.

      write: yname1.
permanent link

answered 23 Mar '12, 08:44

pedrolima's gravatar image

pedrolima ♦♦
1.1k232840
accept rate: 32%

edited 26 Mar '12, 06:28

hhey thank you.

(23 Mar '12, 13:01) bobby

hi,i tried changing name1 to use changing but it didnt work.Still same error.Please help.Thanks..!!

(24 Mar '12, 09:33) bobby
1

I did a test with your code and noticed that you are using new badis so your test code should be different. I've updated above.

(26 Mar '12, 06:14) pedrolima ♦♦

Thank you very much for your effort.

(27 Mar '12, 13:20) bobby
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×5

question asked: 23 Mar '12, 07:58

question was seen: 13,851 times

last updated: 27 Mar '12, 13:20