2006 Jan 17 7:11 AM
Dear All,
I am declaring one internal table & fetching data using inner join. Following is my structure of internal table but it is not fetching data into MATNR1, the data is there in the table.
Kindly suggest why this is happening?
Regards,
Dilip Gupchup
internal table
data : begin of sales_to_purchase_link_itab occurs 10,
*******FOR P O RELATED INFORMATION
EBELN LIKE EKKN-EBELN,"DOCUMENT NO
AEDAT LIKE EKPO-AEDAT,"P O DATE
EBELP LIKE EKKN-EBELP," ITEM
MATNR LIKE EKPO-MATNR,"MATERIAL
MENGE LIKE EKKN-MENGE,"QUANTITY
SAKTO LIKE EKKN-SAKTO,"G/L Account Number
NETWR LIKE EKKN-NETWR,"Net order value in PO
*******END FOR P O RELATED INFORMATION
*******FOR SALES ORDER RELATED INFORMATION
VBELN LIKE EKKN-VBELN,"SALES DOC NO
VBELP LIKE EKKN-VBELP,"SALES DOC ITEM
MATNR1 LIKE VBAP-MATNR,"SALES MATERIAL
ERDAT LIKE VBAP-ERDAT,"SALES DOC DATE
ARKTX LIKE VBAP-ARKTX,"MATERIAL DESCRIPTION
ZMENG LIKE VBAP-ZMENG,"QUANTITY
NETPR LIKE VBAP-NETPR,"SALE VALUE
*******FOR SALES ORDER RELATED INFORMATION
end of sales_to_purchase_link_itab.
select query
select
ekkn~ebeln
EKKN~EBELP
EKKN~SAKTO
EKKO~AEDAT
ekko~bukrs
EKPO~MATNR
EKPO~MENGE
EKPO~NETWR
vbap~vbeln
ekkn~vbelp
vbap~arktx
VBAP~MATNR
into corresponding fields of table
sales_to_purchase_link_itab from ekkn
inner join ekko on ekknebeln eq ekkoebeln "UP TO 10 ROWS.
INNER JOIN EKPO ON EKKOEBELN EQ EKPOEBELN
inner join vbap on ekknvbeln eq vbapvbeln
WHERE
EKPO~AEDAT IN S_ERDAT1.
2006 Jan 17 7:25 AM
Use this select :
See the "AS" clause...
select
ekkn~ebeln
EKKN~EBELP
EKKN~SAKTO
EKKO~AEDAT
ekko~bukrs
EKPO~MATNR
EKPO~MENGE
EKPO~NETWR
vbap~vbeln
ekkn~vbelp
vbap~arktx
VBAP~MATNR AS MATNR1
into corresponding fields of table
sales_to_purchase_link_itab from ekkn
inner join ekko on ekkn~ebeln eq ekko~ebeln "UP TO 10 ROWS.
INNER JOIN EKPO ON EKKO~EBELN EQ EKPO~EBELN
inner join vbap on ekkn~vbeln eq vbap~vbeln
WHERE
EKPO~AEDAT IN S_ERDAT1.
Ps: Reward points if helpful.
2006 Jan 17 7:15 AM
Hi the problem is with the INTO CORRESPONDING FIELDS additions to the SELECT statement.VBAP~MATNR has no fields in the itab with the same name ie,MATNR.So you please change the order of the fields in your itab and use INTO TABLE addition to the SELECT Statement..
Abdul
2006 Jan 17 7:38 AM
Hi,
or change your coding like that:
DATA rep LIKE sy-repid.
TYPE-POOLS : slis.
DATA : fcat TYPE slis_t_fieldcat_alv.
DATA wa TYPE slis_fieldcat_alv.
DATA : BEGIN OF fld OCCURS 0,
name(50),
END OF fld.
rep = sy-repid.
*only possible if fields of itab are defined with LIKE !
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = rep
i_internal_tabname = 'SALES_TO_PURCHASE_LINK_ITAB'
i_client_never_display = 'X'
i_inclname = rep
CHANGING
ct_fieldcat = fcat.
LOOP AT fcat INTO wa.
CONCATENATE wa-ref_tabname '~' wa-fieldname INTO fld-name.
APPEND fld.
ENDLOOP.
SELECT (fld)
INTO TABLE sales_to_purchase_link_itab
FROM ekkn
INNER JOIN ekko ON ekkn~ebeln EQ ekko~ebeln "UP TO 10 ROWS.
INNER JOIN ekpo ON ekko~ebeln EQ ekpo~ebeln
INNER JOIN vbap ON ekkn~vbeln EQ vbap~vbeln
WHERE
ekpo~aedat IN s_erdat1.
Andreas
2006 Jan 17 7:16 AM
I also tried this before. I didnt found a solution with "INTO CORRESPONDING FIELDS". Since it is not possible to provide a FIELD list of the type (f1, f2, f3, ...) in combination with INTO...TABLE, I would only JOIN the tables EKKN and EKKO. Then looping over the internal table and select single ... from VBAP for every row separately.
Regards
Rene
2006 Jan 17 7:17 AM
Dilip,
You are using CORRESPONDING fields and you don't have MATNR1 field in your SELECT clause, that is why it is failing.
Regards,
Ravi
2006 Jan 17 7:25 AM
Use this select :
See the "AS" clause...
select
ekkn~ebeln
EKKN~EBELP
EKKN~SAKTO
EKKO~AEDAT
ekko~bukrs
EKPO~MATNR
EKPO~MENGE
EKPO~NETWR
vbap~vbeln
ekkn~vbelp
vbap~arktx
VBAP~MATNR AS MATNR1
into corresponding fields of table
sales_to_purchase_link_itab from ekkn
inner join ekko on ekkn~ebeln eq ekko~ebeln "UP TO 10 ROWS.
INNER JOIN EKPO ON EKKO~EBELN EQ EKPO~EBELN
inner join vbap on ekkn~vbeln eq vbap~vbeln
WHERE
EKPO~AEDAT IN S_ERDAT1.
Ps: Reward points if helpful.