cancel
Showing results for 
Search instead for 
Did you mean: 

How do I access start routine internal table from Field Routine ?

c_s3
Participant
0 Kudos

I am trying to lookup  DSO_1  when Loading from Datasource to  DSO_2 to derice a Key_Figure_1 (NETPR_VKM),  there are 4 common  fields that will uniquely identify a record within these two DSO's

I have the following code in my Start Routine

DATA: it_zdso_1 TYPE STANDARD TABLE OF  /BIC/AZDSO_1.

DATA: wa_zdso_1 TYPE /BIC/AZDSO_1.

SELECT  DOC_NUMBER S_ORD_ITEM GI_DATE MATERIAL SCHED_LINE NETPR_VKM

       INTO CORRESPONDING FIELDS OF TABLE it_zdso_1

       FROM /BIC/AZDSO_1

       FOR ALL ENTRIES IN SOURCE_PACKAGE

       WHERE doc_number  = SOURCE_PACKAGE-VBELN

       AND   s_ord_item  = SOURCE_PACKAGE-POSNR

       AND   gi_date     = SOURCE_PACKAGE-WADAT

       AND   material    = SOURCE_PACKAGE-MATNR

       AND   sched_line  = SOURCE_PACKAGE-ETENR.

I mapped all the four fields to NETPR_VKM in my transformations and chose routine, what do I do now ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

Make sure that the data declaration is done in the global area:

DATA: it_zdso_1 TYPE STANDARD TABLE OF  /BIC/AZDSO_1.

DATA: wa_zdso_1 TYPE /BIC/AZDSO_1.


Then the field routine should look like this:


read table it_zdso_1 into wa_zdso_1

     with table key doc_number  = SOURCE_FIELDS-VBELN

                    s_ord_item  = SOURCE_FIELDS-POSNR

                    gi_date     = SOURCE_FIELDS-WADAT

                    material    = SOURCE_FIELDS-MATNR

                    sched_line  = SOURCE_FIELDS-ETENR.

if sy-subrc = 0.

  result = wa_zdso_1-NETPR_VKM.

endif.


Best regards,

Sander

c_s3
Participant
0 Kudos

i do have the data declaration in the global area

*$*$ begin of 2nd part global - insert your code only below this line  *

... "insert your code here

DATA: it_zdso_1 TYPE STANDARD TABLE OF  /BIC/AZDSO_1.

DATA: wa_zdso_1 TYPE /BIC/AZDSO_1.

*$*$ end of 2nd part global - insert your code only before this line   *

*$*$ begin of routine - insert your code only below this line        *-*

... "insert your code here

*--  fill table "MONITOR" with values of structure "MONITOR_REC"

*-   to make monitor entries

... "to cancel the update process

*    raise exception type CX_RSROUT_ABORT.

... "to skip a record"

*    raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

*    raise exception type CX_RSROUT_SKIP_VAL.

read table it_zdso_1 into wa_zdso_1

      with table key doc_number  = SOURCE_FIELDS-VBELN

                     s_ord_item  = SOURCE_FIELDS-POSNR

                     gi_date     = SOURCE_FIELDS-WADAT

                     material    = SOURCE_FIELDS-MATNR

                     sched_line  = SOURCE_FIELDS-ETENR.

if sy-subrc = 0.

   result = wa_zdso_1-NETPR_VKM.

endif.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "compute_0NETPR_VKM

I receive this error message

E:The field "SOURCE_FIELDS" is unknown, but there is a field with the similar name "SOURCE_FIELDS_RULE". "SOURCE_FIELDS_RULE".

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

No, the data declaration should be a bit up. You have to insert the coding into the global declaration area:

*$*$ begin of global - insert your declaration only below this line  *-*

    ... "insert your code here

*$*$ end of global - insert your declaration only before this line   *-*

The coding for Key Figure NETPR_VKM should be done in the respective field routine.

Best regards,

Sander

former_member586947
Contributor
0 Kudos

Hi,

   Yes, the declarations should be as mentioned above and all these decelerations should be in the start routine.

Rest of the code should be in filed routine. And SOURCE_FILEDS should be in angular brackets. i.e <SOURCE_FILEDS>.

Regards,

Satya.

c_s3
Participant
0 Kudos

when I give the brackets

E:The field "<SOURCE_FILEDS>" is unknown, but there is a field with the

similar name "SOURCE_FIELDS_RULE". "SOURCE_FIELDS_RULE".

c_s3
Participant
0 Kudos

okay, I changed it, but still the same.

*$*$ begin of global - insert your declaration only below this line  *-*

... "insert your code here

DATA: it_zdso_1 TYPE STANDARD TABLE OF  /BIC/AZDSO_1.

DATA: wa_zdso_1 TYPE /BIC/AZDSO_1.

*$*$ end of global - insert your declaration only before this line   *-*




*$*$ begin of routine - insert your code only below this line        *-*

... "insert your code here


read table it_zdso_1 into wa_zdso_1

      with table key doc_number  = SOURCE_FIELDS-VBELN

                     s_ord_item  = SOURCE_FIELDS-POSNR

                     gi_date     = SOURCE_FIELDS-WADAT

                     material    = SOURCE_FIELDS-MATNR

                     sched_line  = SOURCE_FIELDS-ETENR.

if sy-subrc = 0.

   result = wa_zdso_1-NETPR_VKM.

endif.


*--  fill table "MONITOR" with values of structure "MONITOR_REC"

*-   to make monitor entries

... "to cancel the update process

*    raise exception type CX_RSROUT_ABORT.

... "to skip a record"

*    raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

*    raise exception type CX_RSROUT_SKIP_VAL.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "compute_0NETPR_VKM

former_member586947
Contributor
0 Kudos

Hi,

   Have you done the deceleration of internal tables in the start routine. Is your start routine is fine? Remove angular brackets and try. I mean SOURCE_FIELDS, don't put any angular brackets in the field routine.

If still there is an issue then please paste your start routine code and filed routine code here. So, will analyze and suggest you the reason.

Regards,

Satya.

c_s3
Participant
0 Kudos

This is in my start routine and this does not give me Syntax errors

*$*$ begin of global - insert your declaration only below this line  *-*

... "insert your code here

DATA: it_zdso_1 TYPE STANDARD TABLE OF  /BIC/AZDSO_1.

DATA: wa_zdso_1 TYPE /BIC/AZDSO_1.

*$*$ end of global - insert your declaration only before this line   *-*


SELECT  DOC_NUMBER S_ORD_ITEM GI_DATE MATERIAL SCHED_LINE NETPR_VKM

       INTO CORRESPONDING FIELDS OF TABLE it_zdso_1

       FROM /BIC/AZDSO_1

       FOR ALL ENTRIES IN SOURCE_PACKAGE

       WHERE doc_number  = SOURCE_PACKAGE-VBELN

       AND   s_ord_item  = SOURCE_PACKAGE-POSNR

       AND   gi_date     = SOURCE_PACKAGE-WADAT

       AND   material    = SOURCE_PACKAGE-MATNR

       AND   sched_line  = SOURCE_PACKAGE-ETENR.


This is in my start routine



*$*$ begin of routine - insert your code only below this line        *-*

... "insert your code here


read table it_zdso_1 into wa_zdso_1

      with table key doc_number  = SOURCE_FIELDS-VBELN

                     s_ord_item  = SOURCE_FIELDS-POSNR

                     gi_date     = SOURCE_FIELDS-WADAT

                     material    = SOURCE_FIELDS-MATNR

                     sched_line  = SOURCE_FIELDS-ETENR.

if sy-subrc = 0.

   result = wa_zdso_1-NETPR_VKM.

endif.


*--  fill table "MONITOR" with values of structure "MONITOR_REC"

*-   to make monitor entries

... "to cancel the update process

*    raise exception type CX_RSROUT_ABORT.

... "to skip a record"

*    raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

*    raise exception type CX_RSROUT_SKIP_VAL.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "compute_0NETPR_VKM

former_member586947
Contributor
0 Kudos

Hi,

   In the filed routine copy the below code and try.

read table it_zdso_1 into wa_zdso_1

      with key doc_number  = SOURCE_FIELDS-VBELN

                     s_ord_item  = SOURCE_FIELDS-POSNR

                     gi_date     = SOURCE_FIELDS-WADAT

                     material    = SOURCE_FIELDS-MATNR

                     sched_line  = SOURCE_FIELDS-ETENR.

if sy-subrc = 0.

   result = wa_zdso_1-NETPR_VKM.

endif.


Regards,

Satya.

c_s3
Participant
0 Kudos

I still get the same error, do I need to declare anything else in Field Routine other than the code you provided  ?

Scope \CLASS lcl_transform\METHOD compute_0NETPR_VKM

E:The field "SOURCE_FIELDS" is unknown, but there is a field with the

similar name "SOURCE_FIELDS_RULE". "SOURCE_FIELDS_RULE".

I see Below code was automatically placed

METHOD compute_0NETPR_VKM.

*   IMPORTING

*     request     type rsrequest

*     datapackid  type rsdatapid

*     SOURCE_FIELDS_RULE-VBELN TYPE /BI0/OIDOC_NUMBER

*     SOURCE_FIELDS_RULE-WADAT TYPE /BI0/OIGI_DATE

*     SOURCE_FIELDS_RULE-MATNR TYPE /BI0/OIMATERIAL

*     SOURCE_FIELDS_RULE-ETENR TYPE /BI0/OISCHED_LINE

*     SOURCE_FIELDS_RULE-POSNR TYPE /BI0/OIS_ORD_ITEM

*    EXPORTING

*      RESULT type _ty_s_TG_1-NETPR_VKM

     DATA:

       MONITOR_REC    TYPE rsmonitor.

former_member586947
Contributor
0 Kudos

Hi,

   In filed routine where you are inserting the above code. It should be below the line

"*$*$ begin of routine - insert your code only below this line        *-*".

Please share your transformation mapping for the lookup field.

Regards,

Satya.

c_s3
Participant
0 Kudos
Former Member
0 Kudos

HI CS

based on your source fields. if you writing in field routine below code should work

read table it_zdso_1 into wa_zdso_1

      with key doc_number  = SOURCE_FIELDS_RULE-VBELN

                     s_ord_item  = SOURCE_FIELDS_RULE-POSNR

                     gi_date     = SOURCE_FIELDS_RULE-WADAT

                     material    = SOURCE_FIELDS_RULE-MATNR

                     sched_line  = SOURCE_FIELDS_RULE-ETENR.

if sy-subrc = 0.

   result = wa_zdso_1-NETPR_VKM.

endif.

c_s3
Participant
0 Kudos

This does not give me Sytanx errors, but when I test the rule or load data I do not get a value, I know there are values in the Lookup DSO, where else  can I  check ? Also why did we have to use SOURCE_FIELDS_RULE ? Instead of SOURCE_FIELDS ?

former_member586947
Contributor
0 Kudos

Hi,

   Debug the routine. You will come to know the issue.

Regards,

Satya.

c_s3
Participant
0 Kudos

Thanks for the reply, Sai for your reference here is how it finally ended.  I decided to move the routine from Datasource > DSO and place it during DSO > Cube Load, in doing so when I mapped,  it had 0DOC_CURRENCY and NETPR_VKM,because it was already mapped with these two fields I removed NETPR_VKM but was forced to keep 0DOC_CURRENCY as it is needed for Currency key figures. The test rule does not work , but who cares, now it loads correct values

former_member206066
Participant
0 Kudos

Hello Sander,

I have used your code but it is saying source_package is unknown

Please help.

Thanks,

Ipsita

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi CS

you need to read the internal table you have populated as below.  also define it_zdso_1 with type having only 5 fields you need since the DSO may have many fields which are not required here.

loop at source_package assigning <source_fields>.

read  table it_zdso_1 into wa_zdso_1

with table key

     doc_number  = <source_fields>-VBELN

          s_ord_item  = <source_fields>-POSNR

         gi_date     = <source_fields>-WADAT

          material    = <source_fields>-MATNR

         sched_line  = <source_fields>-ETENR.

if sy-subrc = 0.

<source_fields>-NETPR_VKM = wa_zdso_1--NETPR_VKM.

endif.

endloop.

c_s3
Participant
0 Kudos

I get the following error.

E:Field "SOURCE_PACKAGE" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement.

also

should <source_fields>-NETPR_VKM = wa_zdso_1--NETPR_VKM.

be  RESULT = wa_zdso_1-NETPR_VKM.  ?

former_member586947
Contributor
0 Kudos

Hi,

   Your start routine is perfect. And also, you said all the four fields mapped in the transformation for the filed NETPR_VKM. Now write the filed routine for this field.

Here in the filed routine, you need reed the data from the internal table declared in start routine(it_zdso_1) and update the RESULT field.

data: wa_zdso_1 TYPE it_zdso_1.

READ TABLE it_zdso_1 INTO  wa_zdso_1 WITH TABLE KEY

       

          doc_number  = <source_fields>-VBELN

          s_ord_item  = <source_fields>-POSNR

         gi_date     = <source_fields>-WADAT

          material    = <source_fields>-MATNR

         sched_line  = <source_fields>-ETENR.


IF sy-subrc = 0.

        RESULT = wa_zdso_1-NETPR_VKM.


ENDIF.

Try this and let me know.

Regards,

Satya.

c_s3
Participant
0 Kudos

i get


E:The field "SOURCE_FIELDS" is unknown, but there is a field with the similar name "SOURCE_FIELDS_RULE". "SOURCE_FIELDS_RULE".