cancel
Showing results for 
Search instead for 
Did you mean: 

Lookup from table, which has 1:N relation with Data package

Former Member
0 Kudos

Hi,

I have to look up for Sales Office, Sales district from 0Cust_Sales Masterdata, while loading data to 0FIAR_C03 (from 0FI_AR_4).

0FI_AR_4 has fields -

0Customer

10000

While 0CUST_SALES has

Customer Division DistrCh. SalesOff SalesDistr

10000 10 20 1000 120

10000 20 20 1500 121

Whenever I am looking up for Sales Office, Sales Distr, Division,Distr chn. It is loading ONLY FIRST RECORD.

I want to load both the records. I have written following code-

************************************************************************

SELECT DIVISION

DISTR_CHAN

SALESORG

CUST_SALES

OBJVERS

SALES_DIST

SALES_OFF

INTO TABLE GT_REC_SET

FROM /BI0/MCUST_SALES

FOR ALL ENTRIES IN DATA_PACKAGE

WHERE CUST_SALES = DATA_PACKAGE-DEBITOR AND

OBJVERS = 'A'.

IF SY-SUBRC = 0.

SORT GT_REC_SET BY CUST_SALES.

ENDIF.

************************************************************************************

READ TABLE GT_REC_SET

WITH KEY CUST_SALES = COMM_STRUCTURE-DEBITOR

INTO GW_REC_SET

BINARY SEARCH.

IF SY-SUBRC = 0.

  • result value of the routine

RESULT = GW_REC_SET-DISTR_CHAN.

ENDIF.

Any solution will be a great help....

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

" Read table with key" will return only first record.

You may have to "loop at ... where" .

And, even if you find two values, how are you going to set it? You have only one field RESULT, so the second will overwrite the first one.

To make one row into two in this case, this logic will have to be applied in the start routine.