0% found this document useful (0 votes)
402 views

Inner Join

The document declares data types and internal tables to store sales order and item data from the VBAK and VBAP tables. It selects order and item data into the internal tables based on selection screen criteria. The data from the two tables is then mapped and written to a final internal table for output.

Uploaded by

Pinku Mondal
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
402 views

Inner Join

The document declares data types and internal tables to store sales order and item data from the VBAK and VBAP tables. It selects order and item data into the internal tables based on selection screen criteria. The data from the two tables is then mapped and written to a final internal table for output.

Uploaded by

Pinku Mondal
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

REPORT ZNILU_01.

****Types Declarartion
data:x1 type vbak-vbeln.
SELECTION-SCREEN:begin of block b1 with FRAME title text001.
select-OPTIONS:s_vbeln for x1.
PARAMETERS:s_date type vbak-erdat.
SELECTION-SCREEN:end of block b1.
INITIALIZATION.
move 'My Report' To text001.
*TYPES:x2 type vbak-vbeln.
*data: BEGIN OF Y_VBAK OCCURS 0,
* VBELN TYPE VBAK-VBELN,
* ERDAT TYPE VBAK-ERDAT,
* END OF Y_VBAK.
TYPES:BEGIN OF Y_VBAK ,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
END OF Y_VBAK.
types: BEGIN OF y_final,
VBELN TYPE VBAk-VBELN,
ERDAT TYPE VBAK-ERDAT,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
END OF y_final.
types: BEGIN OF y_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
END OF y_VBAP.
**Internal Table declaration using refrence from structure
DATA:V_VBAK TYPE STANDARD TABLE OF Y_VBAK INITIAL SIZE 0 WITH HEADER LINE ,
v_vbap type STANDARD TABLE OF y_vbap INITIAL SIZE 0,
w_vbap TYPE y_vbap,
v_final type STANDARD TABLE OF y_final INITIAL SIZE 0 WITH HEADER LINE.
* W_VBAK TYPE Y_VBAK.

***Start of selection event


START-OF-SELECTION.

****selectin data as per value at selection screen one by one using header line
and appending to body
* SELECT VBELN
* ERDAT
* FROM VBAK INTO V_VBAK WHERE VBELN IN s_VBELN.
*append v_vbak.
* ENDSELECT.
****selectin data as per value at selection screen using into table directlky ap
pendinmg mass data ino internal table body
SELECT VBELN
ERDAT
FROM VBAK INTO TABLE V_VBAK WHERE VBELN IN s_VBELN.
***using for all entries
if v_vbak[] is NOT INITIAL."Checking vbak is no empty
SELECT VBELN
POSNR
MATNR
NETWR
from vbap into TABLE v_vbap FOR ALL ENTRIES IN v_vbak
where vbeln = v_vbak-vbeln.
endif.
***innner join
*SELECT a~vbeln
* a~erdat
* b~posnr
* b~matnr
* b~netwr
*INTO TABLE v_final
* from vbak as a INNER JOIN vbap as b
* on a~vbeln = b~vbeln where a~vbeln in s_vbeln.
***inserting one tables date to anotherREPORT ZNILU_01.
****Types Declarartion
data:x1 type vbak-vbeln.
SELECTION-SCREEN:begin of block b1 with FRAME title text001.
select-OPTIONS:s_vbeln for x1.
PARAMETERS:s_date type vbak-erdat.
SELECTION-SCREEN:end of block b1.
INITIALIZATION.
move 'My Report' To text001.
*TYPES:x2 type vbak-vbeln.
*data: BEGIN OF Y_VBAK OCCURS 0,
* VBELN TYPE VBAK-VBELN,
* ERDAT TYPE VBAK-ERDAT,
* END OF Y_VBAK.
TYPES:BEGIN OF Y_VBAK ,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
END OF Y_VBAK.
types: BEGIN OF y_final,
VBELN TYPE VBAk-VBELN,
ERDAT TYPE VBAK-ERDAT,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
END OF y_final.
types: BEGIN OF y_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
END OF y_VBAP.
**Internal Table declaration using refrence from structure
DATA:V_VBAK TYPE STANDARD TABLE OF Y_VBAK INITIAL SIZE 0 WITH HEADER LINE ,
v_vbap type STANDARD TABLE OF y_vbap INITIAL SIZE 0,
w_vbap TYPE y_vbap,
v_final type STANDARD TABLE OF y_final INITIAL SIZE 0 WITH HEADER LINE.
* W_VBAK TYPE Y_VBAK.

***Start of selection event


START-OF-SELECTION.

****selectin data as per value at selection screen one by one using header line
and appending to body
* SELECT VBELN
* ERDAT
* FROM VBAK INTO V_VBAK WHERE VBELN IN s_VBELN.
*append v_vbak.
* ENDSELECT.
****selectin data as per value at selection screen using into table directlky ap
pendinmg mass data ino internal table body
SELECT VBELN
ERDAT
FROM VBAK INTO TABLE V_VBAK WHERE VBELN IN s_VBELN.
***using for all entries
if v_vbak[] is NOT INITIAL."Checking vbak is no empty
SELECT VBELN
POSNR
MATNR
NETWR
from vbap into TABLE v_vbap FOR ALL ENTRIES IN v_vbak
where vbeln = v_vbak-vbeln.
endif.
***innner join
*SELECT a~vbeln
* a~erdat
* b~posnr
* b~matnr
* b~netwr
*INTO TABLE v_final
* from vbak as a INNER JOIN vbap as b
* on a~vbeln = b~vbeln where a~vbeln in s_vbeln.
***inserting one tables date to another emty internal table
loop at v_vbap INTO w_vbap.
v_final-vbeln = w_vbap-vbeln .
v_final-matnr = w_vbap-matnr .
v_final-netwr = w_vbap-netwr.
append v_final.
endloop.
***mapping two table data and updating final table
loop at v_final.
READ TABLE v_vbak with key vbeln = v_final-vbeln.
if sy-subrc = 0.
v_final-erdat = v_vbak-erdat.
modify v_final TRANSPORTING erdat.
endif.
endloop.

* LOOP AT V_VBAK.
*
* WRITE:/ v_VBAK-VBELN , v_VBAK-ERDAT.
* ENDLOOP.
**write statement.
loop at v_final.
write:/ v_final-vbeln , v_final-erdat , v_final-matnr.
ENDLOOP. emty internal table
loop at v_vbap INTO w_vbap.
v_final-vbeln = w_vbap-vbeln .
v_final-matnr = w_vbap-matnr .
v_final-netwr = w_vbap-netwr.
append v_final.
endloop.
***mapping two table data and updating final table
loop at v_final.
READ TABLE v_vbak with key vbeln = v_final-vbeln.
if sy-subrc = 0.
v_final-erdat = v_vbak-erdat.
modify v_final TRANSPORTING erdat.
endif.
endloop.

* LOOP AT V_VBAK.
*
* WRITE:/ v_VBAK-VBELN , v_VBAK-ERDAT.
* ENDLOOP.
**write statement.
loop at v_final.
write:/ v_final-vbeln , v_final-erdat , v_final-matnr.
ENDLOOP.

You might also like