cancel
Showing results for 
Search instead for 
Did you mean: 

matching of customer number - adding of attribute values

Former Member
0 Kudos

Hello,

My aim is to fill the master data table of info object 0CUST_SALES with data for records already existing in table via update from earlier transaction data load.

So, I want the system to check if a certain customer that exist from the start in the master data table (before master data load) also exists in the source master data table in R/3 (table KNVV). If the customer exists, then I want to update certain attributes (customer group and price group) for the matching records.

Can we do this by adding the following code (quasi) in the start routine of the info package for the 0CUST_SALES_ATTR master data load?

1 BEGIN LOOP KNVV

2 IF 0CUST_SALES-customer number = KNVV-customer number

3 IF 0CUST_SALES-customer group is empty

4 Add value in 0CUST_SALES-customer group

3 IF 0CUST_SALES-price group is empty

4 Add value in 0CUST_SALES-price group

2 ELSE ignore record

1 END LOOP

Could this be the solution to enter the required attributes in the existing records of the master data table? Please note that I do not want to add new records. I only want to add values in attribute fields of existing records (based on the matching of customer number)

If anyone could help me with the code for this I'd be eternally greatful

Best regards,

Fredrik

Message was edited by: Fredrik Carlsson

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi dear,

maybe I'm missing some point...but why do you need to perform this check ?

Is not 0CUST_SALES_ATTR data already coming from KNVV table?

And what do you need to update the old master data or the new one ?

Former Member
0 Kudos

Hello Roberto and thanks for showing interest and helping out!

I need to update the masterdata which is based on the transaction data load...

The reason for my proposed solution is that in KNVV there is only data with distribution channel and division 01 (this data is furthermore manipulated manually + via customer exit on SD-order level in order to separate on distr.channel + division level).

However, the transaction data (that fills the customer number, distr.channel and division fields in masterdata table for 0CUST_SALES) looks different. This data shows different values in distr.channel and division fields.

This means I will not get the master data and transaction data matched if I just load 0CUST_SALES the standard way (since I will not be able to see the customer group for records other than distr.channel and division 01 – I need to see the customer group for the actual trans.data).

I don’t want to add any new records in the table. Instead I want to add, for example, the customer group value in the correct record (that is, where I have a match on customer number between KNVV and 0CUST_SALES.

I think this logic is ok, or? My problem is I’m not the best at ABAP. Could you help me out with the code?

I appreciate your help!

Best regards,

Fredrik

Message was edited by: Fredrik Carlsson

Former Member
0 Kudos

Hi fredrik,

this will not work, as in BW system you have no table KNVV, you have only the table with the 0CUST_SALES_ATTR already loaded from sourcesystem table KNVV

/manfred

Former Member
0 Kudos

Hello Manfred,

Yes, you are right. Perhaps I then have to first upload KNVV into a z-table and use this for the comparison..?

Best regards,

Fredrik

Former Member
0 Kudos

Updated quasi code:

BEGIN LOOP ZKNVV

IF 0CUST_SALES-customer number = ZKNVV-customer number

IF 0CUST_SALES-customer group is empty

Add value in 0CUST_SALES-customer group

IF 0CUST_SALES-price group is empty

Add value in 0CUST_SALES-price group

ELSE ignore record

END LOOP

*ZKNVV is uploaded from R/3 table KNVV

Former Member
0 Kudos

Hi Fredrik,

for me it makes no sense, as 0CUST_SALES_ATTR is the extract from R/3 table KNVV. why loading it again in a separate table ?

/manfred

Former Member
0 Kudos

Hello there,

The reason for my proposed solution is that in KNVV there is only data with distribution channel and division 01 (this data is furthermore manipulated manually + via customer exit on SD-order level in order to separate on distr.channel + division level).

However, the transaction data load in BW (that fills the customer number, distr.channel and division fields in masterdata table for 0CUST_SALES) looks different. This data shows different values in distr.channel and division fields (01, 02, 03,04 etc.)

This means I will not get the master data and transaction data matched if I just load 0CUST_SALES_ATTR the standard way (I will not be able to see the customer group for records other than distr.channel and division 01 – I need to see the customer group for the actual trans.data).

I don’t want to add any new records in the table. Instead I want to add, for example, the customer group value in the correct record (that is, where I have a match on customer number between ZKNVV and 0CUST_SALES.

Do you see how I mean?

Best regards,

Fredrik

Former Member
0 Kudos

Hi Fredrik,

I don't understand it realy exact, as I know KNVV in R/3 has keyfields DIVISION, SALESORG and DISTR_CHAN, what is your SD-orders customer exit doing ? As I understand if one of thie keyfields is manipulated than the keyfieldcombination must exist in KNVV, otherwise delivery + invoicing would fail.

/manfred

Former Member
0 Kudos

Hi dear,

the problem here is not your ABAP knowledge, but our understanding of your requirements!

If you go to your R/3 and in SE16 transaction ask to see the content, you have to see the same record that std datasource upload in your BW (if you don't use any filter..)

How is it possible that BW upload more data compared to what you are seeing in KNVV (that is the source of that datasource) ?!?!

Former Member
0 Kudos

Hello the two of you!

I appreciate your concern and help in this matter and I am sorry I'm not the very best at explaining my thoughts..

Yes, the master data load comes from KNVV via 0CUST_SALES_ATTR. But the transaction data load come from a COPA data source (I don't remember the name).

Here is an example:

Transaction data load; COPA DS; include customer 0001, division 04, distribution channel 01 (this adds this record in 0CUST_SALES. Unfortunately the customer group and the price group are missing. I need these in the final report together with this exact combination of key values)

Master data load; 0CUST_SALES (based on KNVV); include customer 0001, division 01, distribution channel 01, customer group 10, price group 20

I want to fetch the customer group and the price group from KNVV for customer 0001 (both the customer group and price group are unique for a certain customer in KNVV so when fetching I do not need to take into account the division and distribution channel. There is only one record per customer number in KNVV (always with division 01 and distribution channel 01)). The price group for customer 0001 in KNVV should be added to the price group attribute in 0CUST_SALES.

I agree that it is weird, but the basis for this mess is the misuse of the division and distribution channel terminology...

Do you see how I mean?

Regards,

Fredrik

Former Member
0 Kudos

Ok, now it's better !!!

Just a little doubt.

When you say "Transaction data load; COPA DS; include customer 0001, division 04, distribution channel 01 <b>this adds this record in 0CUST_SALES</b>" this means that in your COPA infosource you are using 0CUST_SALES as infoobject and you are loading without master data validation (in other words, since this datasource uploads a customersales combination that doesn't exist on your "original" master data, a record with only key fields - customer, distr chan and division - is added on it).

Ok, now you don't need to take missed data from KNVV because you already have this info (every customer always with division 01 and distribution channel 01) in your 0CUST_SALES_ATTR master data records !

So, you can create a little ABAP pgm that, in a process chain, once you loaded your COPA transactional records, fill in these blank fields what you need (you can extract from master data table only records with distr_chan and division different than '1' and force what you need on the basis of the same record but with distr_chan and division = '1')!

Hope it helps!

Bye,

Roberto

Former Member
0 Kudos

Thank you Roberto!

If I understand you correctly, I should:

1) Load COPA trans data (this adds records in 0CUST_SALES (different divisions, different distribution channels))

2) Load KNVV master data (this adds additional records in 0CUST_SALES (division is always 01 and distribution channel is always 01)

So now all needed data exist in 0CUST_SALES

3) Add price group and customer group to a certain customer number (x) by matching this "transaction customer" with the price group and customer group available on the corresponding "master data customer".

How could this ABAP look?

Thanks!!!

Best regards,

Fredrik

Former Member
0 Kudos

Hi dear,

I can give you some sample code, but I don't have any system to test it and you have to check the syntax...

Anyway...


TABLE /BI0/PCUST_SALES.
DATA: TB_CUST_SALES  LIKE /BI0/PCUST_SALES OCCURS 0 WITH HEADER LINE,
      TB_CUST_KNVV LIKE /BI0/PCUST_SALES OCCURS 0 WITH HEADER LINE,
      TB_CUST_COPA LIKE /BI0/PCUST_SALES OCCURS 0 WITH HEADER LINE.

SELECT * FROM /BI0/PCUST_SALES
         INTO TB_CUST_SALES
         WHERE OBJVERS = 'A'.

LOOP AT TB_CUST_SALES.
IF TB_CUST_SALES-DISTR_CHAN = '01' AND
   TB_CUST_SALES-DIVISION   = '01'.
TB_CUST_KNVV = TB_CUST_SALES.
APPEND TB_CUST_KNVV.
ELSE.
TB_CUST_COPA = TB_CUST_SALES.
APPEND TB_CUST_COPA.
ENDIF.
ENDLOOP.

LOOP AT TB_CUST_COPA
WHERE PRICE_GROUP = ' ' AND
CUST_GROUP = ' '.
LOOP AT TB_CUST_KNVV 
WHERE CUSTOMER = TB_CUST_COPA-CUSTOMER.
TB_CUST_COPA-PRICE_GROUP = TB_CUST_KNVV-PRICE_GROUP.
TB_CUST_COPA-CUST_GROUP = TB_CUST_KNVV-CUST_GROUP.
MODIFY TB_CUST_COPA.
ENDLOOP.
ENDLOOP.

LOOP AT TB_CUST_COPA.
SELECT PRICE_GROUP CUST_GROUP FROM /BI0/PCUST_SALES UP TO 1 ROWS
WHERE CUSTOMER   = TB_CUST_COPA-CUSTOMER AND
      DISTR_CHAN = TB_CUST_COPA-DISTR_CHAN AND
      DIVISION   = TB_CUST_COPA-DIVISION AND
      OBJVERS    = 'A'.
/BI0/PCUST_SALES-PRICE_GROUP = TB_CUST_COPA-PRICE_GROUP.
/BI0/PCUST_SALES-CUST_GROUP  = TB_CUST_COPA-CUST_GROUP.
MODIFY /BI0/PCUST_SALES.
COMMIT WORK.
ENDLOOP.

Former Member
0 Kudos

Thank you Roberto!

I really appreciate all your efforts to help me!

Best regards,

Ferdrik

Answers (0)