Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
Showing results for 
Search instead for 
Did you mean: 
An application which checks automatically the VAT split status of 5,000 Romanian companies.

This post is for Romania only. The post refers to "Legea 275/2017, OG 23/2017 plata defalcata TVA".

ANAF has published short instructions on how to find the VAT split status of a company here.

I have provided on Stackoverflow a complete working program code in Python for a single request here.

Maybe later I will extend the code for CSV upload and saving...

I am back with the code and instructions for querying VAT split status using a list in CSV format.

The easy way for beginners to run the Python code is to install Anaconda (next, next, finish) and run Jupyter Notebook (ipynb extension). Anaconda is an absolutely FREE open-source distribution of Python which works on Windows, macOS, and Linux. Jupyter Notebook runs directly in your preferred Chrome, Firefox, Microsoft Edge, or other browsers.

You can find VAT split status readme instructions here, tutorial here pdf and complete code here ipynb. Further, you can easily figure out that you can add other fields in which ANAF web service returns to perform also other checks.

However, If you need all fields which ANAF web service returns, run this code here ipynb.

Maybe first of all you want to get a quick idea of how a script looks like and run a quick test for a single request here ipynb or a quick tutorial here pdf.

You can also execute a quick test for a single request without installing anything using Mybinder here. Wait for the Starting repository, then from the menu open Kernel / Restart & Run All.

Running a list of 5000 to 10000 companies will take about one hour depending on the server load. Further, if you want to improve performance you may adapt the code to include in a request a maximum of 500 elements at once instead of a single element(company).

SAP central note  2538317 "VAT split payment mechanism in Romania" does not provide a report to check and generate vendors' VAT split status and VAT IBAN account. To solve this issue you can create an ABAP report which extracts data from the following tables: Vendor master data(LFA1, LFB1, LFBK, TIBAN), Vendor Open Items(BSIK), Purchasing Contracts and Purchasing Orders (EKKO, EKPO, EKET).

You may insist on the integration of the entire process of checking and updating vendor master data with the help of SAP RFC. Python supports SAP RFC and fortunately, you can start by studying the following blog here.


Update 01 March 2021.

Request data directly from SAP.  Consider security risks and access to the internet.
*& Report ZAPI_TVA_Romania
* https://stackoverflow.com/questions/24322222/sap-fm-http-post-to-send-a-message-to-push-notification...

perform start.

form start.

data: lv_status type i,
lv_error_occurred type flag,
lv_error_msg type string,
lv_response_body type string.

perform send_json using
'[{"cui": "10874881", "data": "2017-12-22"}]'

changing lv_status lv_response_body

* Show result
format color col_heading.
write: / 'Response status:', lv_status.
if lv_error_occurred = 'X'.
format color col_negative.
write: / 'Error occurred:', lv_error_msg.
format color col_normal.
write: / 'Response:', lv_response_body.

lv_json = lv_response_body.

* https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer

endform. "start

form send_json using iv_url type string
iv_json_data type string
changing cv_status type i
cv_response_body type string
cv_error_occurred type flag
cv_error_msg type string.

data: lo_client type ref to if_http_client.

clear: cv_error_msg,

if iv_url is initial.
* No URL passed
message e349(sbds) into cv_error_msg.
cv_error_occurred = 'X'.

call method cl_http_client=>create_by_url
url = iv_url
client = lo_client
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into cv_error_msg.
cv_error_occurred = 'X'.

lo_client->request->set_cdata( iv_json_data ).
lo_client->request->set_content_type( 'application/json' ).
lo_client->request->set_method( 'POST' ).
call method lo_client->send
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
if sy-subrc ne 0.
lo_client->get_last_error( importing message = cv_error_msg ).
cv_error_occurred = 'X'.

lo_client->receive( exceptions others = 1 ).
if sy-subrc ne 0.
lo_client->get_last_error( importing message = cv_error_msg ).
cv_error_occurred = 'X'.

cv_response_body = lo_client->response->get_cdata( ).
lo_client->response->get_status( importing code = cv_status ).



Expected results.


Labels in this area