2015 Oct 07 1:31 PM
Hello,
I do this query to get just the intrastate documents from EKBE:
select ebeln ebelp zekkn vgabe gjahr belnr buzei budat bldat wrbtr dmbtr matnr werks hswae waers menge
from ekbe into corresponding fields of table it_ekbe
for all entries in it_ekko
where ebeln = it_ekko-ebeln
and budat in cpudt
and ( vgabe = '1' or
vgabe = '2' or
vgabe = '3' ).
But i get still documents that are not telling for intrastate!
Can some one help me to correct this query?
Hello,
I do this query to get just the intrastate documents from EKBE:
select ebeln ebelp zekkn vgabe gjahr belnr buzei budat bldat wrbtr dmbtr matnr werks hswae waers menge
from ekbe into corresponding fields of table it_ekbe
for all entries in it_ekko
where ebeln = it_ekko-ebeln
and budat in cpudt
and ( vgabe = '1' or
vgabe = '2' or
vgabe = '3' ).
But i get still documents that are not telling for intrastate!
Can some one help me to correct this query?
2015 Oct 07 1:54 PM
Are you getting extra documents as line items?
then you should probably use EBELP too.
or if it is a a problem where you are getting extra documents based on transaction type, then you should pass all the VGABE values to a range and use the range with IN operator
Ranges : r_vgabe for ekebe-vgabe.
r_vgabe-sign = 'I'.
r_vgabe-option = 'BT'.
r_vgabe-low = 1.
r_vgabe-high = 3.
append r_vgabe.
2015 Oct 07 2:17 PM
do you know at all what a Intrastat document is?
EKBE has PO history, there are no Intrastat documents per se in EKBE table. There might be documents there which will be used in an Intrastat report, but the selection is based on many more parameters than available in EKBE.
SAP has a huge program with the selection logic, I doubt you can get the same logic in a select statement on EKBE
2015 Oct 07 2:21 PM
2015 Oct 07 2:32 PM
2015 Oct 07 2:35 PM
Hi Jurgen,
I'm using the principle purchasing table EKKO, to get from the intrastate documents.
Do you know which documents (type) from purchase table, are reported as Intrastate doc's?
thanks!
2015 Oct 07 2:47 PM
well i see you have already provided some insight in this INTRASTAT Italy - MM Invoices document | SCN
2015 Oct 07 2:48 PM
In general the Intrastat report is about movements crossing border between 2 European union states. For this you need to compare the country of your vendor with the country of your plant that is entered in the PO item.
If you have a goods supplier which is in a different country than your vendor, then you have to take the country from the partner entered in the partner role GS of the purchasing document.
this is just the basics to know if a business case could be relevant.
Next you would need a goods receipt. material document can be found in EKBE.
But this alone does not tell if it is relevant for the Intrastat report of month X.
Lets make X = January for an example
If the invoice is posted in January too then it is relevant for the Intrastat report of January
If the invoice is not posted then the movement is not relevant for January report.
If the invoice is posted in February, then the movement is relevant for February Intrastat report.
If the invoice is not posted in January or February, then the movement is still relevant for February Intrastat report, but has to be valuated with the PO price.
Further you have to consider the exclusion indicator, where a user can define if a PO item is relevant for Intrastat or not.
And there are some other differences and requirement based on the country for which you have to do the report.
And last but not least it is possible to run transaction MEIS as test run, so I wonder why you need an extra own report.
2015 Oct 07 2:32 PM
Well extracting intrastat without a single selection criteria related to country will be hard.
Hint: Also you could use the search tool to find previous answers from Jürgen.
Regards,
Raymond
2015 Oct 07 2:38 PM
this is the full query:
select ebeln ekorg aedat bukrs lifnr lands inco1 exnum stceg
from ekko into corresponding fields of table it_ekko
where bukrs eq p_bukrs
and aedat in cpudt.
if sy-subrc ne 0.
message s162(00) with 'No Purchase Documents For This Criteria'.
exit.
elseif sy-subrc = 0.
select ebeln ebelp zekkn vgabe gjahr belnr buzei budat bldat wrbtr dmbtr matnr werks hswae waers menge
from ekbe into corresponding fields of table it_ekbe
for all entries in it_ekko
where ebeln = it_ekko-ebeln
and budat in cpudt
and ( vgabe = '1' or
vgabe = '2' or
vgabe = '3' ).
if sy-subrc eq 0.
" get departure country for Purchase
select lifnr land1 name1 ort01 pstlz stras telf1 telfx stcd1 stceg werks from lfa1
into corresponding fields of table it_lfa1
for all entries in it_ekko
where lifnr = it_ekko-lifnr
and land1 in frm_land.
" get arrival country for Purchase
select werks land1 pstlz from t001w into corresponding fields of table itp_t001w
for all entries in it_lfa1
where werks = it_lfa1-werks
and land1 in to_land.
if sy-subrc ne 0.
select werks land1 pstlz from t001w into corresponding fields of table itp_t001w
for all entries in it_ekbe
where werks = it_ekbe-werks
and land1 in to_land.
endif.
Any idea Raymond?
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |