Permalink
Browse files

update usage documentation part

  • Loading branch information...
1 parent 7fcccd4 commit 5a8c8dbbf742e9265b04c6042141f17071354372 @agrausem agrausem committed Jul 24, 2012
Showing with 48 additions and 13 deletions.
  1. +27 −0 README.rst
  2. +21 −13 docs/usage.rst
View
@@ -29,4 +29,31 @@ You need to add this lines to the settings file of your django project ::
USER = '' # Username
PASSWF = '' # Password
+If you want to use the SAP models filter application, you must activate the
+administration interface in the settings file of your project and add the sifac
+application in your INSTALLED_APPS setting ::
+ INSTALLED_APPS = (
+ ...,
+ django.contrib.admin,
+ ...,
+ sifac
+ )
+
+To create tables needed by the sifac application, syncing your database is
+necessary ::
+
+ $> python manage.py syndb
+
+
+Basic usage
+-----------
+
+If you're using filters and pattern for your SAP Models (or not), it is really
+easy to use the library to retrieve filtered data. Filters and patterns for
+each SAP models can be created or updated in the admnistration interface ::
+
+ from sifac import service
+
+ sifac_service = SifacService()
+ cost_centers = sifac_service.get_filtered_cost_center_list()
View
@@ -74,24 +74,32 @@ For example, this will return a list of filtered cost centers. The result of
this function is a list of badly formatted strings due to the saprfc library. I
really recommend to use high level models.
-Use without Django
-==================
+Use with the Sifac service
+==========================
-You need to create an instance of a sifac database connection yourself and pass
-it to the SifacDB class as the conn parameter. ::
+If you've already added filters for a SAP model, you can access directly to the
+filtered data with the sifac service instance. Here, we create some filters for
+the example ::
- import saprfc
- from sifac.sap.db import SifacDB
+ from sifac.models import SAPModelFilter, SAPQueryFilter
- sifac_connection = saprfc.conn(ashost='my_host', sysnr='00',
- client='500', user='my_user', passwd='my_pass', trace=0)
+ model_filter = SAPModelFilter.objects.create(sap_model_name='CostCenter')
+ query_filter = SAPQueryFilter.objects.create(sap_model=model_filter,
+ query_filter='PAIE1%')
- sifac.sap.db = SifacDB(conn=sifac_connection)
+With the sifac Service, you can retrieve directly the filtered data ::
-Or directly with the models ::
+ from sifac.service import SifacService
- from sifac.sap.models import CostCenter, SifacModel
+ sifac_service = SifacService()
+ filtered_cost_center = sifac_service.get_filtered_cost_center_list()
- SifacModel.set_connection(sifac_connection)
- cost_centers = CostCenter.get_list()
+Directly with the SAP models, you should do ::
+
+ from sifac.sap.models import CostCenter
+ from sifac.models import SAPModelFilter
+
+ sap_filters = SAPModelFilter.objects.get(sap_model_name='CostCenter')
+ filtered_cost_centers = CostCenter.get_list(
+ filters=sap_filters.get_query_filters(), pattern=sap_filters.pattern)

0 comments on commit 5a8c8db

Please sign in to comment.