cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Source Enhancement Help - User Exit

Former Member
0 Likes
873

I need your help in trying to figure out what I'm doing wrong here when trying to write code in the user exit for a data source enhancement requirement. Its my first time writing any code so please bear with me and any help is greatly appreciated. The scenario/requirement and the code I've written is below.

Some points I want to make are:

  • I know that there is data but when I execute in rsa3 there is not data being populated in the table.
  • The structure I have defined for ZTERM is by using the data element name (DZTERM) and not the field name as I was getting errors when I used the field name.
  • I am thinking that the structure definition might be wrong but not sure (as its my first time writing any code).
  • I am not getting data for either field (ZTERM or BUKRS).

Again thank you for your help.

Enhance 0CUSTOMER_ATTR to bring in the following fields into the data source:

·        KNB1-BUKRS; KNB1-ZTERM

The code i have written is:

*Define Structure

TYPES: BEGIN OF TYP_KNB1,

         KUNNR TYPE KUNNR,

         BUKRS TYPE BUKRS,

         DZTERM TYPE DZTERM,

         END OF TYP_KNB1.

* Declare Internal Table

  DATA: GT_KNB1 TYPE STANDARD TABLE OF TYP_KNB1.

  FIELD-SYMBOLS: <fs_knb1> TYPE TYP_KNB1,

                 <fs_data1> TYPE BIW_KNA1_S.

* Select data from db table into the internal table

         IF NOT i_t_data[] is initial.

         SELECT KUNNR

                BUKRS

                ZTERM

         From KNB1

         INTO table GT_KNB1.

        IF SY-SUBRC = 0.

              SORT GT_KNB1 by KUNNR.

            ENDIF.

* Populate the enhanced fields.

         LOOP AT i_t_data ASSIGNING <fs_data1>.

         READ TABLE GT_KNB1 ASSIGNING <fs_knb1>

              WITH KEY KUNNR = <fs_data1>-kunnr

              BINARY SEARCH.

            IF SY-SUBRC = 0.

              <fs_data1>-ZBUKRS16 = <fs_knb1>-BUKRS.

              <fs_data1>-ZZTERM16 = <fs_knb1>-ZTERM.

            ENDIF.

          ENDLOOP

      ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

karthik_vasudevan
Active Contributor
0 Likes

Hi Sandeep

Please try the below code and let us know if you have any challenges.

TYPES: BEGIN OF TYP_KNB1,

         KUNNR TYPE KNB1-KUNNR,

         BUKRS TYPE KNB1-BUKRS,

         ZTERM TYPE KNB1-ZTERM,

         END OF TYP_KNB1.

DATA: GT_KNB1 TYPE STANDARD TABLE OF TYP_KNB1.

FIELD-SYMBOLS: <FS_KNB1> TYPE TYP_KNB1,

                 <FS_DATA1> TYPE BIW_KNA1_S.


CASE I_DATASOURCE.


  WHEN '0CUSTOMER_ATTR'.



SELECT KUNNR BURKS ZTERM FROM KNB1 INTO TABLE GT_KNB1.


    SORT GT_KNB1 BY KUNNR.


    LOOP AT I_T_DATA ASSIGNING <FS_DATA1>


      READ TABLE GT_KNB1 ASSIGNING <FS_KNB1>


       WITH KEY KUNNR = <FS_DATA1>-KUNNR.



      IF SY-SUBRC = 0.


        <FS_DATA1>-BURKS = <FS_KNB1>-BURKS.


        <FS_DATA1>-ZTERM = <FS_KNB1>-ZTERM.


     ENDIF.


    ENDLOOP.


Regards

Karthik

Former Member
0 Likes

Thanks Karthik. Your suggestion worked. All i had to do was change the DZTERM to ZTERM and add the table name like you had suggested in my structure and it worked perfectly fine.

Answers (2)

Answers (2)

Former Member
0 Likes

Hi Sandeep,

The table name should be C_T_DATA, not I_T_DATA. Please correct the name and check.

Regards,

Suhas

Former Member
0 Likes

Hi Suhas,

Its actually I_T_DATA in this case/instance and not C_T_DATA. I initially thought it might be C_T_DATA too but it turned out not to be.

Thanks for the reply though.

Sandeep

Former Member
0 Likes

Hi,

Have you removed the hide check box from the data soruce via RSO2 or RSA6 ?

Did you already put a break point in your code and checked in debug and see the data getting populated ?

Thanks.

Former Member
0 Likes

Hi Jugal,

I have done that already but it wasnt populating when I ran it it rsa3 (extractor checker) but it worked fine when I modified my code a bit like Karthik had suggested.

Thanks for the reply mate

Sandeep