Code: Alles auswählen.
TYPES: BEGIN OF ty_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
xblnr TYPE bkpf-xblnr,
blart TYPE bkpf-blart,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
gjahr TYPE bkpf-gjahr,
awkey TYPE bkpf-awkey,
awtyp TYPE bkpf-awtyp,
cpudt TYPE bkpf-cpudt,
refsc TYPE c LENGTH 50, "Referenzschlüssel umsortiert.
END OF ty_bkpf,
BEGIN OF ty_toa02,
sap_object TYPE toa02-sap_object,
object_id TYPE toa02-object_id,
archiv_id TYPE toa02-archiv_id,
arc_doc_id TYPE toa02-arc_doc_id,
ar_object TYPE toa02-ar_object,
ar_date TYPE toa02-ar_date,
END OF ty_toa02,
BEGIN OF ty_toa01,
mandt TYPE toa01-mandt,
sap_object TYPE toa01-sap_object,
object_id TYPE toa01-object_id,
archiv_id TYPE toa01-archiv_id,
arc_doc_id TYPE toa01-arc_doc_id,
ar_object TYPE toa01-ar_object,
ar_date TYPE toa01-ar_date,
del_date TYPE toa01-del_date,
reserve TYPE toa01-reserve,
END OF ty_toa01.
TYPES: tty_toa01 TYPE TABLE OF ty_toa01,
tty_toa02 TYPE TABLE OF ty_toa02.
DATA: gt_bkpf TYPE STANDARD TABLE OF ty_bkpf.
form f_verknuepfung
changing p_toa02 TYPE tty_toa02
p_toa01 TYPE tty_toa01.
Loop at p_toa02 ASSIGNING FIELD-SYMBOL(<p_toa02>).
Loop at gt_bkpf ASSIGNING FIELD-SYMBOL(<gt_bkpf>)
where xblnr = <p_toa02>-object_id(10).
IF <gt_bkpf>-awtyp = 'IBKPF'.
loop at p_toa01 ASSIGNING <p_toa01>
where arc_doc_id = <p_toa02>-arc_doc_id.
<p_toa01>-sap_object = 'BKPF'.
<p_toa01>-ar_object = 'ZFIZZZZFI'.
<p_toa01>-object_id = <gt_bkpf>-refsc.
modify p_toa01 from <p_toa01>.
endloop.
elseif <gt_bkpf>-awtyp = 'RMRP'.
Loop at p_toa01 ASSIGNING <p_toa01>
where arc_doc_id = <p_toa02>-arc_doc_id.
<p_toa01>-sap_object = 'ZZZZ'.
<p_toa01>-ar_object = 'ZFIZZZZMM'.
<p_toa01>-object_id = <gt_bkpf>-awkey.
modify p_toa01 from <p_toa01>.
endloop.
endif.
ENDLOOP.
ENDLOOP.
endform.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZTEST6
*&---------------------------------------------------------------------*
REPORT ZTEST6.
TYPES: BEGIN OF ty_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
xblnr TYPE bkpf-xblnr,
blart TYPE bkpf-blart,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
gjahr TYPE bkpf-gjahr,
awkey TYPE bkpf-awkey,
awtyp TYPE bkpf-awtyp,
cpudt TYPE bkpf-cpudt,
refsc TYPE c LENGTH 50, "Referenzschlüssel umsortiert.
END OF ty_bkpf,
BEGIN OF ty_toa02,
sap_object TYPE toa02-sap_object,
object_id TYPE toa02-object_id,
archiv_id TYPE toa02-archiv_id,
arc_doc_id TYPE toa02-arc_doc_id,
ar_object TYPE toa02-ar_object,
ar_date TYPE toa02-ar_date,
END OF ty_toa02,
BEGIN OF ty_toa01,
mandt TYPE toa01-mandt,
sap_object TYPE toa01-sap_object,
object_id TYPE toa01-object_id,
archiv_id TYPE toa01-archiv_id,
arc_doc_id TYPE toa01-arc_doc_id,
ar_object TYPE toa01-ar_object,
ar_date TYPE toa01-ar_date,
del_date TYPE toa01-del_date,
reserve TYPE toa01-reserve,
END OF ty_toa01.
TYPES: tty_toa01 TYPE TABLE OF ty_toa01,
tty_toa02 TYPE TABLE OF ty_toa02.
DATA: gt_bkpf TYPE STANDARD TABLE OF ty_bkpf.
form f_verknuepfung
changing p_toa02 TYPE tty_toa02
p_toa01 TYPE tty_toa01.
Loop at p_toa02 ASSIGNING FIELD-SYMBOL(<p_toa02>).
ASSIGN gt_bkpf[ xblnr = <p_toa02>-object_id(10) ] TO FIELD-SYMBOL(<gt_bkpf>).
CHECK SY-SUBRC = 0. " Wenn der ASSIGN auf die Nase gefallen ist, weil es die Zeile gar nicht gibt, mit dem LOOP AT p_toa02 weitermachen
CASE <gt_bkpf>-awtyp.
WHEN 'IBKPF'.
ASSIGN p_toa01[ arc_doc_id = <p_toa02>-arc_doc_id ] TO <p_toa01>.
CHECK SY-SUBRC = 0. " Wenn der ASSIGN auf die Nase gefallen ist, weil es die Zeile gar nicht gibt, mit dem LOOP AT p_toa02 weitermachen
<p_toa01>-sap_object = 'BKPF'.
<p_toa01>-ar_object = 'ZFIZZZZFI'.
<p_toa01>-object_id = <gt_bkpf>-refsc.
WHEN 'RMRP'.
ASSIGN p_toa01[ arc_doc_id = <p_toa02>-arc_doc_id ] TO <p_toa01>.
<p_toa01>-sap_object = 'ZZZZ'.
<p_toa01>-ar_object = 'ZFIZZZZMM'.
<p_toa01>-object_id = <gt_bkpf>-awkey.
ENDCASE.
Endloop.
endform.
Code: Alles auswählen.
DATA gt_bkpf TYPE HASHED TABLE OF ty_bkpf WITH UNIQUE KEY xblnr.
Code: Alles auswählen.
DATA gt_bkpf TYPE SORTED TABLE OF ty_bkpf WITH NON-UNIQUE KEY xblnr.
Folgende Benutzer bedankten sich beim Autor DeathAndPain für den Beitrag:
Sonne1234