Skip to Content
0
Former Member
Nov 03, 2012 at 08:22 PM

End Routine Lookup to get multiple lines of KFs in Planned Order DSO

363 Views

Hello Gurus,

I am trying to get KBREAREST from KBED table passing PLNUM & BERID into the PLAF table. I dont do anything in ECC. I bring them in 2 seperate DSOs in BW.

So in BW there is a DSO one for Planned Orders (PLAF) and one for CapReq (KBED).

There is one record of Planned Order in the Planned Order DSO. There can be multiple Remaing Cap Req in the Cap Req DSO.

I added the ZKBEAREST to Planned Order DSO .

I try to do a lookup in the CapReq DSO while loading into the PlannedOrder DSO.

So lets say:

Planned Order Source | Cap Req Source

Planned Order| Cap red ID |QTY | | Planned Order | Cap Req ID| ZKBEAREST

123 | 789 |1200 | | 123 | 789 | 1

| 123 | 789 | 0

| 123 | 789 | 7

Planned Order DSO outcome after the lookup

Planned Order| Cap red ID |QTY | ZKBEAREST

123 |789 |1200| 0

I wrote a code in the End Routien to add some lines just for ZKBEAREST and make it additive in DSO leaving other Keyfigs as overwrite. I had also set the field routine to ZKBEAREST to constant.

Please see my code and let me know where I need to change it please.

TYPES: BEGIN OF TY_ZPKBEAREST,
ZPLNUM TYPE /BIC/AEPP00D1100-/bic/ZPLNUM,
ZCAPREQID TYPE /BIC/AEPP00D1100-/BIC/ZCAPREQID,
ZPKBEAREST TYPE /BIC/AEPP00D1100-/bic/ZPKBEAREST,
ZKBEAREST TYPE /BIC/AEPP00D1100-/bic/ZKBEAREST,
END OF TY_ZPKBEAREST.
DATA: IT_ZPKBEAREST TYPE STANDARD TABLE OF TY_ZPKBEAREST,

W_ZPKBEAREST TYPE TY_ZPKBEAREST.

data: result_fields_new type _ty_s_TG_1.DATA: S_TAB1 TYPE _ty_s_TG_1.DATA: T_TAB1 TYPE STANDARD TABLE OF _ty_s_TG_1
WITH NON-UNIQUE DEFAULT KEY.REFRESH: T_TAB1.REFRESH IT_ZPKBEAREST.
if RESULT_PACKAGE[] is not initial.SELECT /BIC/ZPLNUM /BIC/ZCAPREQID /BIC/ZPKBEAREST /BIC/ZKBEAREST
INTO TABLE IT_ZPKBEAREST
FROM /BIC/AEPP00D1100
FOR ALL ENTRIES IN RESULT_PACKAGE
WHERE /BIC/ZPLNUM = RESULT_PACKAGE-/BIC/ZPLNUM AND
/BIC/ZCAPREQID = RESULT_PACKAGE-/BIC/ZCAPREQID.ENDIF.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
LOOP AT IT_ZPKBEAREST INTO W_ZPKBEAREST
WHERE ZPLNUM = <RESULT_FIELDS>-/BIC/ZPLNUM AND
ZCAPREQID = <RESULT_FIELDS>-/BIC/ZCAPREQID.

result_fields_new = <result_fields>.
result_fields_new-/bic/ZPLNUM = W_ZPKBEAREST-ZPLNUM.

CALL METHOD me->new_record__end_routine
EXPORTING
source_segid = 1
source_record = 0
IMPORTING
record_new = result_fields_new-record.
append result_fields_new to T_TAB1.
endloop.
endloop.
LOOP AT T_TAB1 INTO S_TAB1.
APPEND S_TAB1 TO RESULT_PACKAGE.
ENDLOOP.

-*-

Please help me fix my code.

Thanks in advance for your help.