cancel
Showing results for 
Search instead for 
Did you mean: 

Issue Routine - Start and field routine

Former Member
0 Kudos

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.

0rderSales areaSales orgValue
1001A100900
1002B2001000
1003C3002000
1004D4003000

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.



Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Harish,

Thanks for the response. I know i can do this at field routine level, but i thought Populating the data from start routine could be of performance improvement. Can you let me know how this could be achieved from end routine as data is from source.

Thanks,

Harish

ccc_ccc
Active Contributor
0 Kudos

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

RafkeMagic
Active Contributor
0 Kudos

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?

Former Member
0 Kudos

Hi Raf,

Here with this line i am tring to read data in source_package to work area. IT_DATA is custom defined internal table in start routine which has the data of source_package and then filter the work area and populate the result.

Thanks,

Karthik

RafkeMagic
Active Contributor
0 Kudos

I know you're trying to read "a" line... but you don't specify "which" line... hence the error.

Former Member
0 Kudos

Hi Raf,

So you want me to write

READ TABLE IT_DATA INTO WA_DATA WITH KEY /BIC/ZDOC_NUM = <SOURCE_FIELDS>-/BIC/ZDOC_NUM.

Is this what you mean?

Former Member
0 Kudos

Hi Raf,

Can you correct the code and tell me where i have gone wrong pls..

Thanks,

Karthik

RafkeMagic
Active Contributor
0 Kudos

Have you read the documentation on "read table" at all?

You can get there by positioning your cursor on READ and clicking F1... it'll explain you how to use the statement and why.

To answer your question: if your key is /BIC/ZDOC_NUM, then that's exactly what I mean.

pushkar_dhale
Participant
0 Kudos

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

Former Member
0 Kudos

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