Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

matching of customer number - adding of attribute values

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

replied

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question