Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

intrastat document

former_member445510
Active Participant
0 Likes
1,619

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?

9 REPLIES 9
Read only

former_member210541
Active Participant
0 Likes
1,517

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.

Read only

JL23
Active Contributor
0 Likes
1,517

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

Read only

0 Likes
1,517

Was this qs for me Jurgen?

Read only

JL23
Active Contributor
0 Likes
1,517

can be taken from both of you.

Read only

0 Likes
1,517

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!

Read only

0 Likes
1,517

well i see you have already provided some insight in this INTRASTAT Italy - MM Invoices document | SCN

Read only

JL23
Active Contributor
0 Likes
1,517

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,517

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

Regards,

Raymond

Read only

former_member445510
Active Participant
0 Likes
1,517

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(00with '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?