on 05-27-2015 8:13 AM
Hi All,
I am getting this error: Error: E:Implicit key specification is no longer allowed in the OO context. You must use an INDEX, KEY, or FROM specification. must use an INDEX, KEY or FROM specification..
I am working on a routine and i got this error while doing. In source i have data like this.
0rder | Sales area | Sales org | Value |
---|---|---|---|
1001 | A | 100 | 900 |
1002 | B | 200 | 1000 |
1003 | C | 300 | 2000 |
1004 | D | 400 | 3000 |
In target i have company code which i am deriving by filtering sales are and sales org.
ex: If salesarea = A, B
AND SALESORG = 100,200 THEN COMPANY CODE = 2000 etc.
My code below.
Start routine global declarations:
TYPES: BEGIN OF TY_CC,
/BIC/ZDOC_NUM TYPE /BIC/OIZDOC_NUM,
/BIC/ZSALAREA TYPE /BIC/OIZSALAREA,
/BIC/ZSALESORG TYPE /BIC/OIZSALESORG,
/BIC/ZPRC_KA TYPE /BIC/OIZPRC_KA,
END OF TY_CC.
DATA: IT_DATA TYPE STANDARD TABLE OF TY_CC,
WA_DATA TYPE TY_CC.
Logic:
LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_FIELDS>.
WA_DATA-/BIC/ZDOC_NUM = <SOURCE_FIELDS>-/BIC/ZDOC_NUM.
WA_DATA-/BIC/ZSALAREA = <SOURCE_FIELDS>-/BIC/ZSALAREA.
WA_DATA-/BIC/ZSALAREA = <SOURCE_FIELDS>-/BIC/ZSALAREA.
WA_DATA-/BIC/ZPRC_KA = <SOURCE_FIELDS>-/BIC/ZPRC_KA.
APPEND WA_DATA TO IT_DATA.
ENDLOOP.
field routine:
In field routine i mapped order number in source to company code in target and wrote the below code.
READ TABLE IT_DATA INTO WA_DATA.
IF WA_DATA-/BIC/ZSALESORG = '101' OR '102' OR '109' OR '107'.
AND
IF WA_DATA-/BIC/ZSALAREA = 'A' OR 'C' OR 'D' OR 'E'.
RESULT = '200'.
endif.
IF WA_DATA-/BIC/ZSALAREA = 'B' OR 'F' OR 'G'.
*
IF WA_DATA-/BIC/ZSALESORG = '105' OR '106' OR '108'.
RESULT = '300'.
endif.
Hi Karthik,
You can achieve this using field level routine itself, no need for start/end routines.
1. Map sales area and sales org from the source to your company code field in the target.
2. write the field routine as below.
IF ( SOURCE_FIELDS-SALESAREA = 'A' or SOURCE_FIELDS-SALESAREA = 'B' )
AND (SOURCE_FIELDS_SALESORG = '100' OR SOURCE_FIELDS-SALESORG = '200').
RESULT = '2000'
.....
and so on.
Note:
On performance pov, populating an internal table in start routine and reading it in the field level routine is not advised.
You can read the data and derive company code in parallel directly in END routine. The coding is also very simple.
Let me know if you need the end routine code.
Br, Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik,
First thing , why you written START ROUTINE for this requirement , we can write simple filed level routine to derive COMP_CODE. No need to read statement and declaration.
Write as like below.:
IF SOURCE_PACKAGE-/bic/zsalesorg = '101' OR
SOURCE_PACKAGE-/bic/zsalesorg = '102' OR
SOURCE_PACKAGE-/bic/zsalesorg = '109' OR
SOURCE_PACKAGE-/bic/zsalesorg = '107'.
IF SOURCE_PACKAGE-/bic/zsalarea = 'A' OR
SOURCE_PACKAGE-/bic/zsalarea = 'C' OR
SOURCE_PACKAGE-/bic/zsalarea = 'D' OR
SOURCE_PACKAGE-/bic/zsalarea = 'E'.
RESULT = '200'.
ENDIF.
elseIF SOURCE_PACKAGE-/bic/zsalesorg = '105' OR
SOURCE_PACKAGE-/bic/zsalesorg = '106' OR
SOURCE_PACKAGE-/bic/zsalesorg = '108'.
IF SOURCE_PACKAGE-/bic/zsalarea = 'B' OR
SOURCE_PACKAGE-/bic/zsalarea = 'F' OR
SOURCE_PACKAGE-/bic/zsalarea = 'G'.
RESULT = '300'.
ENDIF.
ENDIF.
Thank you
Nanda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Karthik Krishna wrote:
In field routine i mapped order number in source to company code in target and wrote the below code.
READ TABLE IT_DATA INTO WA_DATA.
hint: which line are you trying to read here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik,
You try this corrected code.
READ TABLE it_data INTO wa_data WITH KEY /bic/zdoc_num = <source_fields>-/bic/zdoc_num.
IF sy-subrc = 0.
IF wa_data-/bic/zsalesorg = '101' OR
wa_data-/bic/zsalesorg = '102' OR
wa_data-/bic/zsalesorg = '109' OR
wa_data-/bic/zsalesorg = '107'.
IF wa_data-/bic/zsalarea = 'A' OR
wa_data-/bic/zsalarea = 'C' OR
wa_data-/bic/zsalarea = 'D' OR
wa_data-/bic/zsalarea = 'E'.
result = '200'.
ENDIF.
IF wa_data-/bic/zsalesorg = '105' OR
wa_data-/bic/zsalesorg = '106' OR
wa_data-/bic/zsalesorg = '108'.
IF wa_data-/bic/zsalarea = 'B' OR
wa_data-/bic/zsalarea = 'F' OR
wa_data-/bic/zsalarea = 'G'.
result = '300'.
ENDIF.
ENDIF.
Best Regards,
Pushkar Dhale
Hi Pushkar,
Thanks a lot for the answer. The code is working fine now. If you can see i created a structure with 3 fields of source and created an internal table with that structure and that structure reflected in field routine as i have given it globally. But if i create an internal table with a structure called _ty_s-sc_1 it is not recognizing in field routine. But if i have 30 fields from source, i cannot create a structure manually with 30 fields and tag it to Internal table.
Data: it_data type standard table of _ty_s_sc_1 (not recognizing in field routine)
Custome defined structure with 3 fields are recognizing. Please clear my doubt.
Thanks,
Karthik
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.