on 08-17-2015 8:52 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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".
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
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
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.
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
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.
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.
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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
91 | |
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.