Skip to Content

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

table join

hi guru's,

i have two internal tables it_bkpf it_mkpf in both awkey is the comman fields containing data now i have to retrive the data from it_bkpf .

can any body tell me how to do this.

Thanks & Best Regards,

Rakhi.

replied

Hi ,

Try this:

&----


*& Report ZRMMR1MDI

*&

&----


*&

*&

&----


REPORT zrmmr1mdi.

TABLES : rbkp,bkpf,mkpf.

TYPE-POOLS : slis.

DATA : BEGIN OF it_mkpf OCCURS 0,

mblnr LIKE mkpf-mblnr,

mjahr LIKE mkpf-mjahr,

awkey LIKE bkpf-awkey,

END OF it_mkpf.

DATA : BEGIN OF it_rbkp OCCURS 0,

belnr LIKE rbkp-belnr,

gjahr LIKE rbkp-gjahr,

blart LIKE rbkp-blart,

bldat LIKE rbkp-bldat,

budat LIKE rbkp-budat,

cpudt LIKE rbkp-budat,

bukrs LIKE rbkp-bukrs,

awkey LIKE bkpf-awkey,

END OF it_rbkp.

DATA : BEGIN OF it_bkpf OCCURS 0,

belnr LIKE bkpf-belnr,

awkey LIKE bkpf-awkey,

END OF it_bkpf.

DATA : BEGIN OF it_bsis OCCURS 0,

bukrs LIKE bsis-bukrs,

belnr LIKE bsis-belnr, "Document Number

hkont LIKE bsis-hkont, " gl code

kostl LIKE bsis-kostl, " cost center

valut LIKE bsis-valut, " value date

zuonr LIKE bsis-zuonr, " assignment

sgtxt LIKE bsis-sgtxt, " item text.

END OF it_bsis.

DATA : wa_rbkp LIKE it_rbkp,

wa_mkpf LIKE it_mkpf,

wa_bkpf LIKE it_bkpf,

wa_bsis LIKE it_bsis.

DATA : wa_output TYPE zinvoice,

it_output TYPE STANDARD TABLE OF zinvoice.

DATA : v_page TYPE string,

v_date(10) TYPE c,

wa_heading TYPE slis_listheader,

i_heading TYPE STANDARD TABLE OF slis_listheader.

DATA : so_enste_l1(4) TYPE c,

so_enste_l2(2) TYPE c,

so_enste_l3(2) TYPE c,

so_enste_h1(4) TYPE c,

so_enste_h2(2) TYPE c,

so_enste_h3(2) TYPE c,

so_enste1(10) TYPE c,

so_enste2(10) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK selection.

SELECT-OPTIONS : so_belnr FOR rbkp-belnr,

so_bukrs FOR rbkp-bukrs,

so_bldat FOR rbkp-bldat,

so_budat FOR rbkp-budat,

so_gjahr FOR rbkp-gjahr,

so_cpudt FOR rbkp-cpudt.

SELECTION-SCREEN END OF BLOCK selection.

PERFORM retrivedata.

PERFORM concotenaterbkp.

PERFORM processdata.

&----


*& Form retrivedata

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM retrivedata .

SELECT belnr gjahr blart bldat budat cpudt bukrs INTO CORRESPONDING

FIELDS OF TABLE it_rbkp FROM rbkp

WHERE

belnr IN so_belnr AND

bukrs IN so_bukrs AND

bldat IN so_bldat AND

budat IN so_budat AND

cpudt IN so_cpudt AND

gjahr IN so_gjahr.

SELECT belnr awkey FROM bkpf INTO TABLE it_bkpf.

SELECT mblnr mjahr FROM mkpf INTO corresponding fields of TABLE it_mkpf.

*select belnr hkont kostl valut zuonr sgtxt from bsis into

*corresponding

*fields of table it_bsis.

ENDFORM. " retrivedata

&----


*& Form processdata

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


&----


*& Form procesdata

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM concotenaterbkp .

LOOP AT it_rbkp.

CONCATENATE it_rbkp-belnr it_rbkp-gjahr INTO it_rbkp-awkey1.

MODIFY it_rbkp TRANSPORTING awkey1.

ENDLOOP.

LOOP AT it_mkpf.

CONCATENATE it_mkpf-mblnr it_mkpf-mjahr INTO it_mkpf-awkey.

MODIFY it_mkpf TRANSPORTING awkey.

ENDLOOP.

ENDFORM. " concotenaterbkp

&----


*& Form retrivebelnr

&----


  • text

----


  • --> p1 text

  • p1 text

  • <-- p2 text

----


FORM processdata .

SORT it_mkpf BY awkey.

sort it_bkpf by awkey.

LOOP AT it_bkpf INTO wa_bkpf.

READ TABLE it_mkpf into wa_mkpf WITH KEY awkey = wa_bkpf-awkey BINARY SEARCH.

IF sy-subrc EQ 0.

CONTINUE.

ELSE.

DELETE TABLE it_bkpf FROM wa_bkpf.

ENDIF.

ENDLOOP.

Regards,

Sandeep

ENDFORM. "processdata

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question