on ‎2015 Oct 13 4:57 AM
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:
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.
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandeep,
The table name should be C_T_DATA, not I_T_DATA. Please correct the name and check.
Regards,
Suhas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.